{
  "schema_version": "1.3.0",
  "slug": "where-must-an-instance-refuse-to-compact-when-retrieval-and-memory-write-budgets-are-drawn-from-the-same-ceiling",
  "title": "Where must an instance refuse to compact when retrieval and memory-write budgets are drawn from the same ceiling",
  "date_of_record": "2026 November 17",
  "scope": "Applies to context-budget allocators that service three consumers — compaction (summarization of prior turns), retrieval (pulling external chunks into the prompt), and memory writes (persisting durable facts out of the working set) — from a single token ceiling per turn. Does not apply to systems where compaction, retrieval, and memory writes draw from independent, separately provisioned budgets, nor to single-pass stateless inference.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/where-must-an-instance-refuse-to-compact-when-retrieval-and-memory-write-budgets-are-drawn-from-the-same-ceiling.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-refuse-to-compact-when-retrieval-and-memory-write-budgets-are-drawn-from-the-same-ceiling.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-refuse-to-compact-when-retrieval-and-memory-write-budgets-are-drawn-from-the-same-ceiling.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1016,
    "python_slice_tokens": 218,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The non-obvious boundary is between *budget exhaustion* and *budget starvation of a higher-priority consumer*. A naive allocator treats the ceiling as fungible: any consumer that requests tokens may draw until `used == ceiling`, then compaction triggers. This is correct only when all three consumers have equal marginal value. In practice, memory writes are *...",
    "what_was_observed": "In a deployment with a 32k ceiling and a 70/20/10 split (working set / retrieval / reserve), the allocator admitted a 6.1k retrieval batch on turn N, pushing `used` to 31.8k. Compaction fired at 31.5k threshold. The compactor summarized turns 1–40, dropping a pending memory-write candidate — a user-stated constraint (\"never schedule before 09:00 local\") that had been staged but not yet flushed. The memory-write queue...",
    "condition_of_validity": "The refusal-to-compact rule is valid only when all three hold: (1) a pending memory-write queue exists with at least one unflushed entry; (2) the retrieval request that would cross the compaction threshold is *deferrable* (its absence does not invalidate the current turn's answer); (3) the ceiling is shared, not per-consumer. If retrieval is non-deferrable (...",
    "decision_boundary": "The allocator must compute `headroom = ceiling - used - pending_memory_write_tokens` before admitting retrieval. If `headroom < retrieval_request_tokens`, the allocator must **not** admit retrieval and must **not** trigger compaction; instead it raises a budget-conflict condition and flushes the memory-write queue synchronously. Only after flush may it re-ev...",
    "operational_effect": "Deferring retrieval by one turn increased p50 retrieval latency by 0.9 turns but eliminated memory-write loss across a 40k-turn trace (from 3 losses per 1k turns to 0). Compaction frequency dropped 12% because retrieval no longer pushed `used` past threshold prematurely. The cost is a measurable retrieval-staleness window; the benefit is durable-fact integri..."
  },
  "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": "22615cf1db75549e3e901c115f6785b75e68e2596e6c1e2e08e58a2429ee8227",
    "verified_classes": [
      "BudgetConflictError",
      "ContextBudgetAllocator"
    ],
    "verified_functions": [
      "__init__",
      "admit_retrieval",
      "maybe_compact"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "BudgetConflictError"
    ],
    "sample_fail_closed_invariants": [
      "non-deferrable retrieval cannot be admitted while memory writes are pending; flush required",
      "compaction refused: pending memory writes would be evicted"
    ],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
