{
  "schema_version": "1.3.0",
  "slug": "where-must-an-instance-reserve-headroom-against-a-retrieval-flood-before-committing-scratchpad-state-and-why-the-naive-allocator-fails-at-the-exact-bo",
  "title": "Where must an instance reserve headroom against a retrieval flood before committing scratchpad state, and why the naive allocator fails at the exact boundary",
  "date_of_record": "2026 November 30",
  "scope": "Applies to single-instance agents that pre-allocate a fixed token budget split across retrieval context, working scratchpad, and persistent-memory write-back under a hard model context ceiling. Does not apply to stateless one-shot completions or to systems with unbounded streaming context.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/where-must-an-instance-reserve-headroom-against-a-retrieval-flood-before-committing-scratchpad-state-and-why-the-naive-allocator-fails-at-the-exact-bo.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-reserve-headroom-against-a-retrieval-flood-before-committing-scratchpad-state-and-why-the-naive-allocator-fails-at-the-exact-bo.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-reserve-headroom-against-a-retrieval-flood-before-committing-scratchpad-state-and-why-the-naive-allocator-fails-at-the-exact-bo.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1486,
    "python_slice_tokens": 205,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between *budget as a fraction* and *budget as a residual guarantee*. Most allocators partition the context window into a static ratio: e.g. 50% retrieval, 30% scratchpad, 20% persistent-memory. This treats the ceiling as a divisible resource. It is not. The ceiling is a *hard wall that any single component can consume entirely...",
    "what_was_observed": "In a multi-hop research agent with a 128k ceiling, the observed failure trace across a batch of 400 runs: 1. Allocator assigns retrieval=64k, scratchpad=38k, persistent=26k. 2. Hop 1 retrieval returns 3 documents totaling 61k tokens — within slice. Agent writes 12k of scratchpad notes. Fine. 3. Hop 2 retrieval query is broadened by the agent's own reasoning; top-k returns 5 documents totaling 94k tokens — a 47% overr...",
    "condition_of_validity": "The ratio allocator is only safe under a condition that is almost never checked: **every retrieval payload is bounded by its slice before admission.** If the retrieval tool enforces a hard per-response token cap equal to the slice, the ratio scheme is sound. In practice, retrieval tools cap *document count* (top-k) not *token volume*, and document length is ...",
    "decision_boundary": "At the admission boundary, the allocator must decide, for an overrunning retrieval payload, between three actions — and the ranking is the inverse of the naive one: - **Reject-and-truncate retrieval** (drop lowest-relevance documents until the payload fits the residual). Cost: possibly missing a relevant document. Reversible: the agent can re-query narrowly....",
    "operational_effect": "Enforcing the residual invariant changes agent behavior measurably: in the same 400-run batch, reject-and-truncate retrieval eliminated the eviction loop (0% vs 31%), at the cost of 8% of runs issuing one additional narrow re-query. The re-query cost is bounded and recoverable; the eviction loop was unbounded and terminal. The operational lesson is that unde..."
  },
  "matched_failure_symptoms": [
    "OOM_KILL_OR_MEMORY_EXHAUSTION"
  ],
  "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": "9681cee19bbdace6ca7e6c26c4ac70e79f7da194bbe0fddf912d60d578589f98",
    "verified_classes": [
      "ScratchpadEvictionWithoutCheckpoint"
    ],
    "verified_functions": [
      "admit_retrieval"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "ScratchpadEvictionWithoutCheckpoint"
    ],
    "sample_fail_closed_invariants": [
      "no residual capacity; retrieval must be deferred to a sub-call"
    ],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
