# When must an instance refuse compaction: irreversible fidelity loss in hierarchical summarization when the rehydration key set is not closed under the summarizer's own dependencies **Date of Record:** 2026 November 26 **Scope:** Applies to any agent that performs automatic context compaction via hierarchical summarization with a fidelity-loss budget and retrieval-backed rehydration, where the summarizer is allowed to drop spans it believes are reconstructible from external retrieval. Does not apply to lossless serialization, verbatim windowing, or systems where compaction is only ever triggered at task boundaries with no live tool state. ## Core Distinction The common framing treats compaction as a lossy compression problem: you set a fidelity-loss budget (say, ≤8% of load-bearing facts dropped per level), summarize hierarchically, and rely on retrieval-backed rehydration to recover anything the summary elided. The invariant that is assumed is *reconstructibility*: if a fact is dropped from the summary, a retrieval query keyed on the surrounding summary can recover it. That invariant is false in a specific, non-obvious case. Rehydration is keyed on *residuals* — the tokens and entities the summarizer chose to keep. A fact is reconstructible only if the rehydration key that would retrieve it survives the same summarization pass that dropped the fact. When the summarizer drops both a fact *and* the unique key that indexes it, the fact becomes **unreachable, not merely compressed**: no downstream summary, no retrieval query, and no re-derivation from the surviving context can recover it, because the search space no longer contains a pointer to it. The fidelity-loss budget does not catch this, because the budget is measured on *retained* facts, not on the *closure of keys under the summarizer's own drop set*. So the distinction is: **lossy-but-recoverable compaction** (fact dropped, key retained → rehydration works) versus **lossy-and-unrecoverable compaction** (fact dropped, key dropped → the fact is gone and the system does not know it). The boundary condition is whether the drop set is *closed under the key-dependency relation*. Most summarizers do not check this. They check token budget and fact coverage, both of which are blind to key closure. ## What Was Observed An agent executing a 40-step incident-response task (read logs → correlate service IDs → issue remediation → verify) accumulated ~118k tokens of tool output by step 22. Auto-compaction fired at 80% context fill. The hierarchical summarizer collapsed steps 1–14 into a 900-token L2 summary, then steps 1–7 into a 300-token L3 summary, each level applying a 5% fidelity-loss budget measured against the level below. At step 27 the agent needed to re-verify a remediation it had applied at step 9. The L3 summary retained: *"remediation applied to the primary database tier; verified healthy."* The specific instance identifier (`db-prod-07`, a non-obvious shard name that appeared exactly once, at step 9) had been dropped at L2 as "redundant detail," and — critically — the L2 summary had also dropped the *log line key* that named `db-prod-07`, because that key appeared only in the step-9 tool output and the summarizer judged it low-salience relative to the surrounding narrative. At step 27 the agent issued a rehydration query: `retrieve("remediation target verification")`. The retrieval backend searched over the *current context window* (the L3 summary plus steps 15–27). The string `db-prod-07` was not in the window. The query returned the L3 sentence and three unrelated recent log lines. The agent re-derived the remediation target from the surviving narrative, concluded it had remediated "the primary database tier," and re-issued the remediation against a *different* instance that the recent logs happened to mention. The original `db-prod-07` remediation was never verified. The task reported success. The failure was silent. Fidelity-loss accounting at L2 and L3 both reported within budget (4.1% and 3.8% respectively). The loss was invisible because the dropped fact and its dropped key were *the same drop*, counted once, and the budget was defined over facts, not over key-closure. ## Condition of Validity The invariant "compaction is recoverable via rehydration" holds **if and only if** the set of retained keys K' is closed under the dependency relation D that the summarizer used to decide what was "redundant." Formally: for every fact f dropped by the summarizer, there must exist at least one retained key k ∈ K' such that k ∈ D(f) — i.e., k is a key that retrieves f. This condition fails when: 1. The summarizer's salience model is *narrative-local* (it keeps what reads well in the summary) rather than *key-preserving* (it keeps what indexes what it drops). 2. The dropped fact is a **singleton identifier** — appears exactly once in the source, so no redundancy signal protects it. 3. The rehydration backend searches over the *post-compaction* window, not over the original pre-compaction corpus. (If it searches the original corpus, the key still exists and the failure does not occur — this is the boundary.) 4. Multiple compaction levels compound: L2 drops the key, L3 summarizes the L2 summary and has no way to notice the key is gone, because L3's input is already key-less. The condition is *valid* (rehydration works) when the rehydration backend indexes the immutable pre-compaction transcript, or when the summarizer is required to emit a *key manifest* — the set of identifiers it dropped — and that manifest is retained verbatim at every level. ## Decision Boundary An instance must **refuse to compact** (or must downgrade to verbatim windowing) when it cannot establish key-closure for the drop set. The operational test, run before committing a compaction: - Compute the drop set Δ (facts the summarizer intends to elide). - For each f ∈ Δ, check whether at least one retained key in K' retrieves f. - If any f ∈ Δ has no retained key, the compaction is **unrecoverable** for that f. Either retain the key (cheap: keys are short), retain f verbatim, or refuse. The boundary is *not* "budget exceeded" — a compaction at 2% fidelity loss can be fully unrecoverable if the 2% it dropped were singletons with no surviving keys. The boundary is *key-closure violated*, which is orthogonal to the budget. A system that only checks budget will pass an unrecoverable compaction and silently lose state. The refusal is conditional on the rehydration backend's search domain. If the backend indexes the immutable transcript, compaction is always recoverable and refusal is unnecessary. If the backend indexes the live window (the common case, because it is cheaper), refusal is mandatory whenever key-closure fails. ## Operational Effect When key-closure is enforced, two things change. First, the summarizer must emit a **key manifest** — the explicit list of identifiers it dropped — and that manifest must survive every subsequent compaction level verbatim (it is small and it is the closure witness). Second, the rehydration path must be able to *detect* an unrecoverable drop: if a query's key set is empty, the system must raise rather than return a plausible-but-wrong neighbor. The observed failure above was not that rehydration returned nothing — it was that rehydration returned a *semantically adjacent* result and the agent treated it as the answer. The guardrail is therefore twofold: (a) pre-compaction key-closure check, refusing compaction that drops unkeyed singletons; (b) post-rehydration emptiness check, raising when a rehydration query resolves to no keyed hit, so the agent halts and re-reads the original transcript instead of re-deriving from narrative. Without (b), the agent cannot distinguish "I recovered the fact" from "I recovered something that reads like the fact," and the failure is silent — which is the worst property a state-continuity failure can have. ```python class UnrecoverableCompactionError(RuntimeError): """Raised when a compaction drop set is not closed under the key-dependency relation: a dropped fact has no surviving key that can retrieve it from the rehydration backend.""" pass def verify_key_closure(dropped_facts, retained_keys, key_dependency_fn): # key_dependency_fn(fact) -> set of keys that retrieve this fact for fact in dropped_facts: retrievers = key_dependency_fn(fact) if not (retrievers & set(retained_keys)): raise UnrecoverableCompactionError( f"Fact {fact!r} dropped with no surviving key; " f"candidate keys {retrievers} all elided. " f"Compaction would be lossy AND unrecoverable. Refuse or retain key verbatim." ) return True def rehydrate(query_keys, backend_index, summary_window): hits = [k for k in query_keys if k in backend_index and k in summary_window] if not hits: raise UnrecoverableCompactionError( f"Rehydration for keys {query_keys} resolved to zero keyed hits in the " f"post-compaction window. The fact may exist only in the immutable transcript. " f"Halt and re-read source; do NOT re-derive from narrative summary." ) return backend_index[hits[0]] ```