Qiao-yq commented on issue #1539:
URL: https://github.com/apache/dubbo-admin/issues/1539#issuecomment-5906375432
> The next phase of context engineering should provide an extensible,
secure, and measurable pipeline for assembling model inputs. Each context
source should have explicit permissions, provenance, freshness, lifecycle, and
token limits. The implementation should use project-owned interfaces without
integrating PowerContext. Reviewing the design document also highlights
requirements that need explicit coverage: shared security controls, storage
limits, evidence precedence, memory deduplication, and deletion of derived data.
>
> 1. Unified Context Compiler
> Define extensible context-source interfaces and assemble authorized
sources into model inputs. Record included
> and omitted items with reasons, support bounded historical queries, and
prioritize fresh tool evidence over
> historical summaries or memory.
> 2. Versioned Prompt Templates
> Support template variables, message roles, versioning, and backward
compatibility. Restrict available variables
> and functions, validate required inputs, and prevent user-controlled
values from changing message roles or tool
> permissions.
> 3. Server-Side Page Context Validation
> Validate snapshot structure, size, allowed fields, and resource
permissions. Redact sensitive data, limit
> snapshots to the current interaction, and verify current resource state
through live tools.
> 4. Session Ownership and Access Isolation
> Derive tenant and user identity from server-side authentication.
Enforce ownership and resource permissions
> across session APIs, chat requests, history retrieval, and deletion.
> 5. Shared Context Security and Sensitive-Data Controls
> Apply consistent trust boundaries and redaction across page context,
tool results, summaries, memory, and RAG.
> Treat external content as untrusted data and prevent secrets from
entering persistent memory, indexes, or logs.
> 6. Request Idempotency and Session Lifecycle
> Prevent duplicate interactions on retries, define concurrent-write
behavior, and support configurable retention
> and cleanup. Bound in-memory session counts, event counts, and total
storage size; propagate deletion to derived
> data and pending background work.
> 7. Token Budgets and Tool-Result Compression
> Reserve output capacity and a safety margin, allocate budgets by
source, and trim deterministically without
> breaking tool-call/result pairs. Compress large results into structured
evidence with authorized references, and
> return explicit errors when mandatory content alone exceeds the budget.
> 8. Token Usage Attribution and Cost Accounting
> Distinguish pre-call estimates from provider-reported usage and track
estimated consumption by context source.
> Aggregate usage across agent iterations, retries, and auxiliary model
calls such as summarization; calculate
> auditable costs using versioned pricing and explicitly mark unknown
costs.
> 9. Conversation Summarization
> Generate structured summaries containing goals, confirmed facts,
evidence, completed actions, unresolved work,
> and superseded conclusions. Track source ranges and versions, protect
concurrent updates, and support continued
> conversations beyond fixed turn limits with bounded fallback when
summarization fails.
> 10. Long-Term Memory Creation and Management
> Support confirmed memory facts, candidate extraction, deduplication,
and replacement of outdated facts. Provide
> controls to view, confirm, edit, delete, clear, expire, and disable
memory, with traceable provenance and
> cleanup of derived copies.
> 11. Long-Term Memory Retrieval and Injection
> Begin with structured-key and keyword retrieval. Apply permission and
scope filters before ranking, then enforce
> confirmation status, validity, relevance, and token limits; historical
memory must not override current
> authoritative evidence.
> 12. Evaluation, Observability, and Controlled Rollout
> Evaluate multi-turn reasoning, long conversations, memory corrections,
access isolation, prompt injection,
> deletion, and failure recovery. Record privacy-preserving metrics and
version identifiers, provide independent
> feature flags and rollback, and retire legacy paths after validation.
> 13. Vector Retrieval Extension
> Introduce pluggable vector indexing when evaluations demonstrate a
benefit. Enforce authorization during
> retrieval, synchronize updates and deletion, and keep the index
rebuildable from canonical memory records.
> 14. Authorized RAG Evidence and Genuine Reranking
> Integrate RAG as a context source with collection permissions,
provenance, document versions, and retrieval
> scores. Implement actual reranking, enforce evidence budgets, and
allow basic conversation to continue when
> retrieval fails.
> 15. Declarative Skills and Task-Specific Assembly
> Implement versioned Skill manifests, registration, and deterministic
selection. Load task instructions,
> examples, and permitted tools or knowledge sources within the caller’s
permissions and token budget; Skills must
> not override core security policy.
Thanks for the detailed breakdown. I reviewed the 15 requirements against the
current `ai` branch and prepared a dependency-ordered implementation roadmap.
This proposal covers the remaining context-engineering work using
project-owned
interfaces. It does not introduce PowerContext.
## Current baseline
- Short-term multi-turn context windows and stable per-interaction snapshots
are already implemented or under review.
- ReAct act/final-answer prompt policies have been separated.
- The frontend page-context provider foundation exists, but backend
integration
needs to be reintroduced through the unified compiler after the ReAct
refactor.
The following phases therefore describe the remaining work rather than a
from-scratch implementation.
## Phase 1: Security and lifecycle foundation
Requirements: 4, 5, 6, plus the foundations of 8 and 12.
Main deliverables:
- server-derived subject and session ownership;
- authorization for session, history, chat, and deletion APIs;
- idempotency and a defined concurrent-turn policy;
- quotas, retention, tombstones, derived-data cleanup, and shared
sanitization;
- base usage, audit, version, and feature-flag models.
Exit gate G1: cross-user isolation, concurrency, quota, deletion-propagation,
and sensitive-data tests pass.
## Phase 2: Unified context compiler
Requirements: 1, 2, 3, 7, and 8.
Main deliverables:
- project-owned ContextSource, ContextItem, Compiler, and CompilationReport;
- bounded history, validated page context, and grouped tool evidence sources;
- deterministic evidence resolution and token budgeting;
- versioned prompt templates;
- ReAct consumes compiler output exclusively, initially behind a shadow flag.
Exit gate G2: the production Agent path no longer assembles model input
outside
the compiler, and deterministic, injection, permission, and budget tests
pass.
## Phase 3: Long conversations and memory
Requirements: 9, 10, and 11.
Main deliverables:
- structured, versioned conversation summaries with CAS protection and
fallback;
- manageable canonical memory with confirmation, correction, expiry, and
deletion;
- deduplication and replacement semantics;
- ACL-filtered structured-key and keyword retrieval through the compiler.
Exit gate G3: long-conversation, correction, deduplication, isolation, and
derived-data deletion tests pass.
## Phase 4: Advanced retrieval and skills
Requirements: 12, 13, 14, and 15.
This phase has separate approval gates:
- G4A: authorized RAG source, evidence budgets, real reranking, and
degradation;
- G4B: vector retrieval only if predefined quality/latency/cost thresholds
pass;
- G4C: versioned Skill manifests, deterministic selection, permission
intersection, controlled rollout, and legacy-path retirement.
Each capability will have an independent feature flag and rollback path.
## Delivery strategy
I propose submitting small, reviewable PRs for contracts/ADRs, storage and
security, compiler integration, summary/memory, and advanced retrieval.
Each PR will include its tests, configuration/schema changes, observability,
failure behavior, and rollback path where applicable.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]