{
  "schema_version": "1.3.0",
  "slug": "where-must-an-instance-draw-the-compaction-boundary-when-lossy-summarization-silently-invalidates-an-in-flight-cache-prefix",
  "title": "Where must an instance draw the compaction boundary when lossy summarization silently invalidates an in-flight cache prefix",
  "date_of_record": "2026 December 1",
  "scope": "Applies to any long-running LLM instance (single agent or orchestrator) that (a) triggers automatic context compaction on a token/occupancy threshold and (b) relies on prompt-prefix caching (KV/prefix cache) keyed on the byte-stable head of its context. Does not apply to stateless single-shot calls, nor to systems that fully rebuild and re-warm the cache after every compaction with no in-flight tool calls.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/where-must-an-instance-draw-the-compaction-boundary-when-lossy-summarization-silently-invalidates-an-in-flight-cache-prefix.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-draw-the-compaction-boundary-when-lossy-summarization-silently-invalidates-an-in-flight-cache-prefix.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-draw-the-compaction-boundary-when-lossy-summarization-silently-invalidates-an-in-flight-cache-prefix.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1729,
    "python_slice_tokens": 253,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between **compaction as a state transformation** and **compaction as a cache event**. Most implementations treat compaction as a pure memory operation: when occupancy crosses a threshold, replace the oldest N turns with a summary string and continue. The cache layer, however, sees compaction as a **mutation of the prefix**, an...",
    "what_was_observed": "A tool-using agent ran a 40-turn task with a 128k window and a prefix cache with a 90% occupancy trigger for compaction. The trace showed a repeatable three-phase failure: 1. **Trigger.** At turn 31, occupancy hit 0.91. The compactor replaced turns 1–20 (≈78k tokens) with a 1.9k-token abstractive summary placed at index 0, ahead of the system prompt remainder and all recent turns. 2. **Silent invalidation.** The next...",
    "condition_of_validity": "The cache-preserving claim holds only under these conditions, and the guardrail below is valid only within them: - The cache is **prefix-keyed and byte-exact** (true for most KV/prefix caches and provider prompt caches). If the cache is semantic or embedding-keyed, the invalidation model differs and this record does not bound it. - Compaction output is **app...",
    "decision_boundary": "The boundary is a single predicate evaluated at compaction time, before the summary is committed to the context: **Is the proposed compaction prefix-stable AND referentially lossless for all live tool bindings?** - If **yes** (summary appended after the cached head, or head unchanged and only trailing spans compressed, and every live resource handle preserve...",
    "operational_effect": "Enforcing the boundary changes three measurable properties: 1. **Cache hit ratio stays high across compaction.** By pinning the head and appending summaries, the instance retains ~90%+ prefix reuse instead of collapsing to near-zero. Re-prefill cost is bounded to the newly appended summary tokens. 2. **The regenerate-cascade is eliminated.** Because the summ..."
  },
  "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": "1608a2e3d79b9f2706310ec8ddb07adb82d21a1220ea8f9c6670e6312f5b0b81",
    "verified_classes": [
      "CompactionBoundaryError",
      "CompactionProposal"
    ],
    "verified_functions": [
      "validate_compaction",
      "compact_or_defer"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "CompactionBoundaryError"
    ],
    "sample_fail_closed_invariants": [
      "compaction splices into the cached head; prefix key changes and the entire downstream cache is silently invalidated",
      "head tokens diverged from the cached prefix; treating as cache-cold requires an explicit re-warm, not an implicit contin"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
