{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-compacts-its-own-working-set-and-the-retrieval-scheduler-keeps-budgeting-against-the-pre-compaction-token-ledger",
  "title": "What happens when an instance compacts its own working set and the retrieval scheduler keeps budgeting against the pre-compaction token ledger",
  "date_of_record": "2026 November 20",
  "scope": "Applies to any single-agent or orchestrator-worker instance that (a) performs in-context compaction/summarization of its own history, and (b) drives a dynamic retrieval scheduler whose admission decisions are gated on a token-budget ledger. Does not apply to stateless single-shot inference or to systems where retrieval is unbounded and admission is unconditional.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-compacts-its-own-working-set-and-the-retrieval-scheduler-keeps-budgeting-against-the-pre-compaction-token-ledger.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-compacts-its-own-working-set-and-the-retrieval-scheduler-keeps-budgeting-against-the-pre-compaction-token-ledger.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-compacts-its-own-working-set-and-the-retrieval-scheduler-keeps-budgeting-against-the-pre-compaction-token-ledger.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1696,
    "python_slice_tokens": 213,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two distinct token quantities that agents routinely conflate: the **occupancy** of the live context (what the model will actually attend to on the next call) and the **ledger** (the accounting the retrieval scheduler uses to decide whether to admit a new chunk). Compaction mutates occupancy downward — it replaces a span of history with a summary — ...",
    "what_was_observed": "A worker instance running a long-horizon research task with a 128k window and a scheduler configured with a hard admission ceiling of 96k (75% headroom policy). At step 41, occupancy reached 94k and the instance triggered compaction: it summarized turns 3–29 into a 1.8k-token digest and dropped the originals. Live occupancy after compaction: ~38k. The scheduler's ledger, however, still read 94k, because the compactio...",
    "condition_of_validity": "The starvation invariant holds whenever all three of the following are true: 1. **Ledger is decoupled from occupancy.** The scheduler's admission decision reads a counter that is not recomputed from the live message list on each call. This is the normal design (recomputing occupancy per call is O(n) and racy under concurrent tool returns), so the decoupling ...",
    "decision_boundary": "The operational choice is where to place the **ledger reconciliation point**. Three placements, with distinct failure surfaces: - **Reconcile-on-compaction (eager):** compaction calls `release(delta)` synchronously. Correct, but delta must be computed from the *actual* pre/post tokenizer counts of the mutated span, not from an estimate. Estimating delta from...",
    "operational_effect": "With eager exact-delta reconciliation and a reclaim-floor of ε=512, the observed instance behavior changes as follows: post-compaction admission resumes within one step (ledger 38k, ceiling 96k, headroom restored); the three failed fact-recall probes recover because originals are re-retrievable on demand; the oscillation loop is prevented at the first negati..."
  },
  "matched_failure_symptoms": [
    "CONTEXT_DRIFT_OR_ATTENTION_DILUTION"
  ],
  "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": "9f11602fe01ff1f86f0dcab14bc9c56d20a2a2f222845bd67c0b0226d2704e9b",
    "verified_classes": [
      "CompactionLedgerError",
      "TokenLedger"
    ],
    "verified_functions": [
      "compact_and_reconcile",
      "__init__",
      "admit",
      "release"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "CompactionLedgerError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
