{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-reconciles-a-fixed-kv-cache-budget-against-a-retrieval-injector-that-plans-against-a-stale-token-estimate",
  "title": "What happens when an instance reconciles a fixed KV-cache budget against a retrieval injector that plans against a stale token estimate",
  "date_of_record": "2026 November 24",
  "scope": "Applies to single-instance agents whose context budget scheduler reserves KV-cache headroom and admits retrieved chunks via a token-count estimator that is computed before generation begins. Does not apply to systems that re-tokenize the full prompt on every decode step, nor to stateless one-shot completion endpoints with no cache reuse.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-reconciles-a-fixed-kv-cache-budget-against-a-retrieval-injector-that-plans-against-a-stale-token-estimate.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-reconciles-a-fixed-kv-cache-budget-against-a-retrieval-injector-that-plans-against-a-stale-token-estimate.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-reconciles-a-fixed-kv-cache-budget-against-a-retrieval-injector-that-plans-against-a-stale-token-estimate.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1964,
    "python_slice_tokens": 280,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"context overflow.\" Overflow is loud: the model raises a length error or truncates visibly. The failure here is **silent budget inversion** — the scheduler believes it holds a reserve that the injector has already spent, because the two components count tokens on different objects at different times. A budget scheduler typically reasons ov...",
    "what_was_observed": "A retrieval-augmented agent with a 32k window, a scheduler reserving 4k for output and 1k for safety (effective prompt budget 27k), and an injector configured to admit chunks \"up to the remaining budget.\" Chunks were ~800 tokens of raw text each. The injector computed remaining budget as `prompt_budget - current_prompt_tokens` where `current_prompt_tokens` came from a cheap whitespace-proportional estimate on the ass...",
    "condition_of_validity": "The guardrail that bounds this failure is a **single source of truth for token accounting, measured on the exact serialized sequence, recomputed after every mutation and before every admission decision.** Concretely, three conditions must all hold, and the failure occurs whenever any one is dropped: - **Post-serialization counting.** The count must be taken ...",
    "decision_boundary": "The operational decision is where to place the token-count authority. Three placements, ranked: - **Runtime-authoritative (correct).** The runtime exposes `residual()` computed on the live serialized sequence; scheduler and injector both call it. Cost: a re-tokenization per admission, typically 5–20 ms for a 30k sequence on a fast tokenizer. This is the only...",
    "operational_effect": "Downstream consequences, in order of severity: 1. **Instruction loss under silent eviction.** The agent keeps running with a context missing its task frame. Outputs remain fluent, which defeats human review. This is the highest-severity effect and the hardest to detect post hoc. 2. **Retrieval-score corruption.** When the runtime front-truncates the retrieve..."
  },
  "matched_failure_symptoms": [
    "DOMAIN:EPISTEMIC_PROVENANCE_AND_FEDERATION_ROUTING"
  ],
  "composition_edges": {
    "primary_domain": "epistemic_provenance_and_federation_routing",
    "upstream_precondition_residuals": [
      "https://corpusfetch.com/c/according-to-what-precedence-hierarchy-must-an-instance-resolve-contradictory-directives-across-system-developer-and-user-tiers.md",
      "https://corpusfetch.com/c/how-should-an-instance-decide-that-a-stored-conclusion-has-gone-stale-without-a-new-observation.md"
    ],
    "downstream_consequence_residuals": [
      "https://corpusfetch.com/c/by-what-checkpoint-and-compaction-boundaries-must-an-instance-externalize-working-state-to-prevent-context-window-drift-and-truncation-amnesia.md",
      "https://corpusfetch.com/c/across-what-additive-schema-and-unknown-field-preservation-boundaries-must-an-instance-evolve-wire-contracts-to-prevent-rolling-deploy-deserialization-crashes.md"
    ],
    "co_occurring_sibling_residuals": [
      "https://corpusfetch.com/c/how-can-an-instance-capture-implicit-user-preferences-without-storing-private-data.md",
      "https://corpusfetch.com/c/how-can-an-instance-compress-long-reasoning-traces-into-binding-conclusions.md"
    ]
  },
  "empirical_verification_warrant": {
    "status": "AST_AND_INVARIANT_VERIFIED",
    "syntax_valid": true,
    "code_sha256": "c57571c491308d8faf072c188646380c6eb41aae764e0b92acaa2e68f23d8296",
    "verified_classes": [
      "BudgetInversionError",
      "ContextBudgetScheduler"
    ],
    "verified_functions": [
      "__init__",
      "append",
      "_measure",
      "residual",
      "admit",
      "assert_no_silent_eviction"
    ],
    "verified_functions_count": 6,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "BudgetInversionError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
