Skip to the content.

The managed-context glossary and product contract

Program: managed-context. Issue: #1571.

fak already runs strong context mechanisms — a planner, a durability gate, a wall-clock budget, a reset ledger. What was missing was a plain-language contract that lets a user stop managing those assumptions in their head. This page is that contract: the core terms, each defined by what fak automatically manages, what it will ask the user about instead of silently assuming, and what remains fully user-controlled. Entries grounded in shipped code name the real Go type or function behind them. The relay vocabulary is called out as a planned, data-only extension until the #1860 relay rungs consume it.

For the separate budget-sizing doctrine behind long-context defaults, see long-context-defaults.md: it defines HardContextCap, MVC, MECW, target resident budget, output reserve, and provenance labels.

How to read each entry:


1. Assumption

Definition. A fact-like item a context plan may rely on, tagged with where it came from and how confident fak is in it — not a bare string, a scored, provenanced claim.

Shipped mechanism: ctxplan.Assumption (internal/ctxplan/assumption.go). Every assumption carries a closed provenance class (AssumptionSource: user_stated, witnessed, inferred, stale, unknown) and a confidence in [0,1]. AssessAssumptions scores each one against a policy (DefaultAssumptionPolicy: 0.65 minimum confidence, 0.80 for inferred claims) and resolves it to one of three closed actions — use, query, or refresh — never a fourth, silent “assume it’s fine.”


2. Resident view

Definition. The bounded, O(1) set of context spans that are actually materialized into the current turn — as opposed to the full, unbounded history sitting behind it.

Shipped mechanism: ctxplan (internal/ctxplan/doc.go, plan.go, layout.go). fak treats the current turn’s context as a re-planned view over a lossless store, not a linearly growing transcript and not a lossy summary. A Layout controls four independently tunable areas (Base, Current, Recent, Deep), each with its own span count and precision (exact, planned, or pointer); Optimize chooses which spans populate the view under a hard token Budget, and every span it elides is Faithful — kept recoverable by a content-address handle, never destroyed (faithful.go).


3. Pinned objective

Definition. The user’s standing, active goal, represented as a stable, addressable span that must survive a hidden context reset, replan, or session migration unchanged.

Shipped mechanism: ctxplan.ObjectivePin (internal/ctxplan/objective.go), wired into session-reset carryover by sessionreset.PinObjective / RepinObjective / CarryObjective (internal/sessionreset/objective.go). A pin’s PinID is assigned once and never regenerated; its Digest is a content address over the pin’s identity fields, so “the objective was preserved” is a checkable equality (ReconcileObjective), not a narrative claim. Reconciliation returns a closed ObjectiveOutcome a host must branch on.


4. Budget envelope

Definition. The set of orthogonal limits — turns, output tokens, context tokens, clarification queries, and wall-clock time — that together bound how much a session may spend before it must pause, reset, or stop.

Shipped mechanism: session.Budget (internal/session/session.go) covers the token axes (TurnsLeft, TokensLeft, ContextTokensLeft/Cap, ClarificationQueriesLeft/Cap); session.TimeBudget (internal/session/timebudget.go, issue #1584) adds the orthogonal wall-clock axis, because real elapsed time keeps ticking whether or not the model is spending tokens. Both are reset-aware: a hidden context reset carries the remaining budget and elapsed time forward onto the fresh trace (session.ResetBudgetRearm, Table.RecontinueAt) instead of quietly resetting to zero.


5. Reset transaction

Definition. The replayable audit row for one context-budget reset — what carried over from the old trace to the new one, what did not, and why.

Shipped mechanism: session.ResetTransaction (internal/session/reset_transaction.go). It records the old/new trace ids, the fresh ResetBudgetRearm, a SeedDigest over the carryover seed, the Contributors that built it, and — critically — every ResetOmittedSpan: a payload-free pointer (role + content digest + reason) to transcript bytes that did not land verbatim in the fresh session. Nothing is dropped without a named reason attached to a checkable digest.


6. Context query

Definition. A model-authored (or user-authored) request that states what the next turns will need and gets back a typed, inspectable view — the agent-callable front door onto the same planner that runs the resident view.

Shipped mechanism: ctxplan.PlanQuery / Plan / PlanView (internal/ctxplan/query.go). A caller states Intents (predicted reference strings for the upcoming horizon) plus optional Budget, Horizon, Pins, and Weights; the query lowers into the same Forecast the host path uses and runs the identical PlanCells — the facade adds no second planner and no divergence. An under-specified query (empty intents) still plans against sane defaults rather than erroring.


7. Memory promotion

Definition. The write-time decision that moves a fact from live, ephemeral context into durable, cross-session memory — gated so that “it’s 3pm” never becomes a standing belief and “I prefer afternoons” does.

Shipped mechanism: the durability classifier in internal/ctxmmu stamps a closed durability class (turn, session, bounded, durable) on every admitted value, defaulting to the shortest-lived class for anything unclassified (see CONTEXT-IS-NOT-MEMORY.md). memq.PromotionRecord (internal/memq/promotion.go) is the audit trail for any write that actually crosses into durable storage: it names the source span, the durability class earned, and a closed consent class — ConsentExplicit (you asked for it), ConsentInferred (the system judged it durable-worthy), or ConsentUnknown (fails closed to the weakest claim). A turn-class fact never mints a promotion record at all — it was never a candidate.


8. Cache state

Definition. The warmth belief fak holds about a provider’s prompt-prefix cache — whether a chained request is likely to land on a shard that already has your prefix warm — and the guards that keep fak from trusting that belief past what it’s worth.

Shipped mechanism: the agent wire layer’s prompt_cache_key derivation (internal/agent): every OpenAI-Responses request carries a stable 32-hex-char hash of its cacheable head (model + system instructions + tools), biasing chained requests that share a prefix onto the same warm upstream cache node. Off the request path, internal/vcachegov and internal/vcachecal are the decision/proof layer: the governor classifies prefixes (pin / lazy-rebuild / ride-natural / evict) and budgets warming inside rate-limit headroom, and vcachecal.Concentration measures whether a workload is concentrated enough (a Zipf exponent s > 1) for warming to pay off at all, flagging a flat workload as structurally defeated rather than warming a tail that will never pay back. (An earlier version of this entry claimed a shipped governor-side affinity router with autoscale-rehash detection and warming-burst caps; that router never had a live caller and was cut in #5190.)


9. Relay vocabulary

Definition. The planned perpetual-session vocabulary for running one long goal as a sequence of bounded context windows without asking the model to summarize itself.

Status: planned/data-only contract for epic #1860. The concept spine is docs/notes/CONCEPT-PERPETUAL-SESSIONS-2026-07-01.md; the closed reason rows live in docs/notes/RELAY-REASON-VOCABULARY-2026-07-01.md; the baton wire shape lives in docs/notes/RELAY-BATON-SCHEMA-2026-07-01.md. No shipped driver consumes these terms yet.


What this adds up to

A reader should now be able to state, plainly: fak automatically manages what’s resident in context right now (assumption scoring, the resident view, budget accounting, reset bookkeeping) and what’s structurally safe to skip (elided-but-recoverable spans, cache warmth as a non-authoritative bias). It asks the user (or defers to an explicit decision) whenever a fact’s confidence, durability, or promotion status is ambiguous — never silently guessing on the expensive-to-get-wrong side. And it leaves fully user-controlled: every explicit statement of fact, every budget number, every layout/pin override, and the objective itself. The relay section extends the vocabulary for the planned perpetual-session mode while keeping its unshipped status explicit.

See also