{
  "schema_version": "1.3.0",
  "slug": "where-must-an-instance-prove-lossless-compaction-before-evicting-the-oldest-turns-and-why-the-token-counter-is-not-that-proof",
  "title": "Where must an instance prove lossless compaction before evicting the oldest turns, and why the token counter is not that proof",
  "date_of_record": "2026 November 30",
  "scope": "Applies to any long-running agent that performs automatic context compaction (summarize-and-evict, hierarchical rollup, or KV-cache trimming) to stay under a hard token budget while claiming fidelity to prior state. Does not apply to stateless single-turn inference or to systems that never evict context and instead terminate on budget exhaustion.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/where-must-an-instance-prove-lossless-compaction-before-evicting-the-oldest-turns-and-why-the-token-counter-is-not-that-proof.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-prove-lossless-compaction-before-evicting-the-oldest-turns-and-why-the-token-counter-is-not-that-proof.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-prove-lossless-compaction-before-evicting-the-oldest-turns-and-why-the-token-counter-is-not-that-proof.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1840,
    "python_slice_tokens": 346,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two different quantities that both get called \"the context budget\": the *admission budget* (how many tokens the model will accept this turn, enforced by the tokenizer and the API's hard limit) and the *fidelity budget* (how much of the evicted material must remain recoverable for downstream decisions to be correct). Compaction logic almost always o...",
    "what_was_observed": "An agent executing a 40-step migration task (read schema, propose DDL, apply in staging, verify, promote) crossed the admission budget at step 23. The compactor fired: it summarized turns 1–14 into a 600-token digest, kept turns 15–23 verbatim, and rewrote the system prompt's \"working memory\" block. The digest read cleanly and passed a human skim. Three things were lost that no counter flagged: 1. The exact staging c...",
    "condition_of_validity": "The \"summarize and evict\" step is only fidelity-preserving under a condition that is almost never checked: **the summarizer's input must be a superset, in information content, of every field any downstream step can dereference, and the digest must carry a resolvable address back to the verbatim source for each field it compresses.** Formally, for each evicte...",
    "decision_boundary": "The boundary is: **compact only what you can address, and address only what you have stored verbatim outside the window.** Concretely, the compactor must, before evicting turn `t`: - Extract every *dereferenceable atom* from `t` — tool arguments, tool results, IDs, URLs, connection strings, numeric facts with their scope (prod vs staging), and negative resul...",
    "operational_effect": "With the pre-eviction check in place, compaction becomes a two-phase commit: atoms are durably keyed, then the window is rewritten to reference keys, then the check confirms every required atom resolves. The admission budget is still met — keys are cheaper than verbatim turns — but the fidelity budget is now certified by resolution rather than by prose quali..."
  },
  "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": "8614940caa475224ac9fbf83cbd694c0772f94816551d490ef51c4d216b848eb",
    "verified_classes": [
      "CompactionFidelityError",
      "Atom",
      "Turn",
      "DurableStore"
    ],
    "verified_functions": [
      "key_atoms",
      "compact",
      "__init__",
      "put",
      "get"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "CompactionFidelityError",
      "KeyError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
