Home/Docs/Architecture Decision Records/ADR-0006: Sandwich Architecture

ADR-0006: Sandwich ArchitectureπŸ”—

StatusπŸ”—

Accepted

ContextπŸ”—

Balancing flexible, non-deterministic agent planning with strict, safe execution is challenging. Mixing these concerns in the same layer leads to agents circumventing security or execution engines becoming too rigid to support emergent planning.

DecisionπŸ”—

We enforce a Sandwich Architecture. Creative planning stays "above" the execution line, while deterministic execution and safety stay "below" it.

The same boundary applies to model adaptation. Inference may produce evidence or an adaptation proposal, but the inference path may not directly mutate deployed weights, an active adapter, persistent provider state, or canonical system memory.

For the currently planned LoRA path:

  1. ContextBrain owns canonical knowledge, governed source evidence, eligibility, and the immutable training snapshot.
  2. ContextWorker creates a versioned immutable adapter candidate from that snapshot; the adapter is a derived deployment artifact, not a new memory authority.
  3. WorkerTestMan evaluates the candidate against an approved immutable baseline and untouched golden holdout/challenge partitions.
  4. ContextShield authorizes protected dataset/artifact access and verifies the tenant, project, purpose, integrity, and signing boundary.
  5. Forge/governance reviews promotion evidence. ContextRouter may load only the approved immutable adapter and must retain deterministic fallback and rollback to the baseline or previous approved version.

Every learning example derived from model output must retain the producing model and adapter identity and must have independent terminal outcome, evaluation, or adjudication evidence before a later eligibility snapshot can admit it. Repetition by the same model is not independent evidence, and shadow or candidate output may not feed the next training generation automatically. This prevents a model from amplifying its own unsupported output through a closed training loop.

A future provider-managed persistent-memory or online-learning API must follow the same propose -> authorize -> evaluate -> promote/rollback boundary. It is not a current platform contract: no manifest field or generic model-state API is added until a real backend exposes a usable lifecycle and an approved architecture task proves a production caller. The current work record owns the research task; this decision remains the architecture boundary.

Alternatives consideredπŸ”—

  • Agents having direct, unmediated access to system execution APIs to execute their plans fluidly. (Rejected: catastrophic security and stability risks).
  • Hardcoding all workflows so no planning is required. (Rejected: defeats the purpose of an agentic swarm ecosystem).
  • Letting a model update its active adapter, persistent state, or future training data directly from its own outputs. (Rejected: removes independent evidence, authorization, tenant isolation, and deterministic rollback while creating a self-reinforcing feedback loop).

ConsequencesπŸ”—

  • ContextRouter owns execution-graph planning, while Brain planning actors such as BrainDreamer may plan memory consolidation inside Brain policy. Neither path grants execution authority.
  • ContextWorker, ContextShield, and storage systems must remain tightly bounded, deterministic, and oblivious to creative intent.
  • A strict boundary exists where a creative plan or consolidation candidate is compiled, authorized, and evidenced before hitting the Worker layer or a durable Curator write path.
  • Model and adapter state are treated as untrusted derived runtime state. ContextBrain remains the authority for portable, governed system knowledge.
  • Adaptation promotion is an atomic version transition with explicit fallback; an in-place mutation that cannot be attributed or rolled back is not an admissible production path.

Non-goalsπŸ”—

  • Removing LLMs entirely from the execution layer (LLMs can be used for deterministic extraction, but not open-ended planning at the Worker level).
  • Defining a generic API for model-internal memory before an actual provider or local runtime exposes a concrete state lifecycle.