# Where must an instance refuse to compact: the summary-of-summary authority collapse when a hierarchical compaction tree loses its leaf-recoverability invariant **Date of Record:** 2026 December 1 **Scope:** Applies to any agent runtime that manages context-window pressure by recursively summarizing older turns into higher-level nodes (hierarchical compaction), with or without semantic deduplication, when the original leaf spans are evicted after summarization. Does not apply to lossless externalization schemes where every compacted span remains byte-recoverable via a stable handle, nor to single-level rolling summaries that never re-summarize a prior summary. ## Core Distinction The failure is not "summaries lose information." Every compaction strategy is lossy by design, and a well-tuned summarizer loses the *right* information. The non-obvious boundary is different: it is the point at which a **summary node is treated as a source of authority rather than as a citation of evicted leaves**. Once a second-order summary (a summary of summaries) exists and the leaves beneath it are gone, the agent has no way to distinguish a faithfully compressed fact from a hallucinated or drifted one. The summary becomes *axiomatic* — it asserts, and nothing in the system can contest it. Hierarchical compaction is safe only while every node in the tree carries a recoverability path back to ground truth it can be re-derived from. The moment the tree is "pruned" (leaves dropped to save space), the invariant that made compaction a *compression* silently becomes an *assertion*, and the agent's belief state is now grounded in its own paraphrase of its own paraphrase. This is distinct from ordinary summarization loss. Lossy compression that you can decompress-check is bounded. Lossy compression of a lossy compression whose source is deleted is unbounded drift, and — critically — *undetectable from inside the agent*, because the drift signal lives in the discarded leaves. ## What Was Observed A long-horizon coding agent ran a 3-level compaction tree over a 40-turn debugging session. Compaction was triggered at 78% context utilization. Level-1 nodes summarized pairs of turns; level-2 nodes summarized groups of level-1 nodes; level-3 summarized level-2. To stay under budget, the runtime evicted all level-0 (raw) spans older than two compactions, keeping only the tree. At turn 31 the agent needed a specific detail: the exact error string and the one-line fix attempted at turn 6, which had *failed* and been reverted. The level-3 summary for that epoch read: "Resolved the import error in `config.py` by adjusting the path." Three facts had been laundered through two summarization hops: 1. The fix was *attempted and reverted* — the summary said "resolved." 2. The error was a `ModuleNotFoundError` caused by a stale editable install, not a path issue — the level-1 node had already generalized "path" from the original `sys.path` vs `site-packages` distinction. 3. The revert was recorded only in a level-0 span that had been evicted. The agent, reading its own level-3 node as authoritative, proceeded on the premise that `config.py` was fixed, re-derived a *different* fix for a problem that was already solved-and-reverted, and introduced a regression that took four more turns to trace. The trace shows the failure cleanly: at turn 31 the agent issued a `read_file` on `config.py`, found it *unmodified* (because the revert was real), and — instead of concluding "my summary is wrong" — concluded "the file was reverted by something else," generating a false hypothesis about an external process. **The agent trusted the summary over the filesystem.** That inversion is the signature. A second, quieter instance: semantic deduplication at level-2 merged two nodes that both mentioned "the timeout is 30s" — but one referred to the HTTP client timeout and one to the DB connection timeout. Dedup keyed on surface similarity, collapsed them into one node, and the surviving node silently inherited both scopes. Downstream, a retry loop used 30s for the DB and hung past the real 5s limit. ## Condition of Validity Hierarchical compaction preserves a usable belief state **iff** every summary node at level *n* ≥ 2 satisfies the *leaf-recoverability invariant*: for each atomic claim in the node, there exists a resolvable handle to a level-0 span from which the claim can be re-derived and re-checked on demand. Formally, the compaction tree must be a *DAG with live back-edges to ground truth*, not a tree with pruned leaves. This holds only when all of the following are true: - **Eviction is gated on externalization, not on summarization.** A raw span may be dropped from the *context window* only after it is written to a recoverable store (file, KV, vector index with exact spans) addressable by a stable ID that the summary node embeds. - **Summaries carry provenance, not just content.** Each node must record which leaf IDs it was built from and which claims map to which leaf. A summary without provenance is an unfalsifiable assertion. - **Deduplication operates on referents, not on strings.** Two spans are mergeable only if they denote the same entity *and* the same scope; surface-similar claims about different objects (client timeout vs DB timeout) must not collapse. - **Re-derivation is cheap enough to actually happen.** If recovering a leaf costs a full re-fetch and re-parse, the agent will skip it and trust the summary — the invariant is only real if the check is cheaper than the error. When any of these fail — most commonly the first, because eviction is the whole point of compaction — the tree degrades from a compression scheme into an *unfalsifiable belief store*, and the agent can no longer tell paraphrase from fact. ## Decision Boundary The operational line is **not** "how much can I compress." It is **"can I still falsify this node."** - **Compact freely while leaves are recoverable.** Aggressive hierarchical summarization and dedup are safe as long as eviction is decoupled from summarization and every node keeps a live provenance edge. Compress to the budget; keep the back-edges. - **Stop compacting — and refuse to evict — the moment a node would become the sole surviving record of a claim that is (a) load-bearing for a pending task and (b) contradicted-or-contradictable by observable state.** For such nodes, either keep the leaf, or externalize it *before* eviction and embed the handle. - **Never re-summarize a summary whose leaves are already gone** without flagging it as *derived-only*. A derived-only node is admissible as a *hint* ("we believe X") but must be treated as inadmissible as *authority* ("X is true") when it conflicts with any directly observable signal (a file read, a tool output, a test result). The filesystem beats the summary, always. - **Dedup is a merge of referents, not of sentences.** If two nodes cannot be shown to share entity *and* scope, do not merge; keep both and let the contradiction surface. The boundary, stated as a rule the agent can execute: *if a claim is about to become unrecoverable and is load-bearing, externalize-then-evict or do not evict.* There is no third option that preserves correctness. "Trust the summary" is not a strategy; it is the failure. ## Operational Effect When the invariant is enforced, hierarchical compaction behaves as intended: context pressure drops, long-horizon coherence holds, and — the part teams forget — the agent retains the ability to *discover its own summaries were wrong* and correct course. The turn-31 failure becomes a non-event: the agent reads `config.py`, sees it unmodified, follows the provenance handle to the turn-6 leaf, sees "attempted, reverted, root cause = stale editable install," and proceeds correctly. When the invariant is violated, the failure is not a crash but a **silent authority inversion**: the agent's belief state becomes grounded in its own lossy paraphrases, and every subsequent reasoning step inherits the drift. The compounding is the danger — a single laundered "resolved" poisons every downstream hypothesis, and because the leaves are gone, the agent cannot localize the error. It will blame the environment (external processes, races, "something else reverted it") before it blames its own memory, because from the inside the summary is indistinguishable from ground truth. The guardrail is therefore not a better summarizer. It is a **recoverability contract**: eviction is a privilege granted only to spans that have been externalized and whose handles are embedded in every summary node that depends on them, plus a hard precedence rule that directly observable state overrides any derived-only node. Enforce the contract and compaction is compression. Break it and compaction is confabulation with a provenance-shaped hole where the truth used to be. ```python from dataclasses import dataclass, field from typing import Optional class UnrecoverableCompactionError(RuntimeError): """Raised when eviction would make a load-bearing claim unfalsifiable.""" @dataclass class Leaf: leaf_id: str content: str externalized: bool = False # written to recoverable store with a stable handle @dataclass class SummaryNode: node_id: str level: int claims: dict[str, str] # claim -> leaf_id it was derived from derived_only: bool = False # leaves already gone provenance: dict[str, str] = field(default_factory=dict) # claim -> handle class CompactionTree: def __init__(self) -> None: self.leaves: dict[str, Leaf] = {} self.nodes: dict[str, SummaryNode] = {} def summarize(self, node_id: str, level: int, claims: dict[str, str]) -> SummaryNode: # Every claim must point at a real, still-recoverable leaf. for claim, leaf_id in claims.items(): leaf = self.leaves.get(leaf_id) if leaf is None or (not leaf.externalized and level >= 2): raise UnrecoverableCompactionError( f"node {node_id} claim {claim!r}: leaf {leaf_id} is not " f"recoverable; refusing to build an authority-bearing summary" ) node = SummaryNode(node_id=node_id, level=level, claims=claims) self.nodes[node_id] = node return node def evict_leaf(self, leaf_id: str, load_bearing_claims: set[str]) -> None: leaf = self.leaves[leaf_id] if not leaf.externalized: # A load-bearing claim whose only record is this leaf must not # be evicted into an unfalsifiable summary. for node in self.nodes.values(): for claim, src in node.claims.items(): if src == leaf_id and claim in load_bearing_claims: raise UnrecoverableCompactionError( f"cannot evict leaf {leaf_id}: it is the sole " f"recoverable source for load-bearing claim " f"{claim!r} in node {node.node_id}; externalize first" ) del self.leaves[leaf_id] def resolve(self, claim: str, observable: Optional[str]) -> str: # Directly observable state always overrides a derived-only node. for node in self.nodes.values(): if claim in node.claims and node.derived_only: if observable is not None: return f"OBSERVED:{observable} (summary node {node.node_id} overridden)" raise UnrecoverableCompactionError( f"claim {claim!r} rests on derived-only node {node.node_id} " f"with no recoverable leaf and no observable to arbitrate" ) return f"UNRESOLVED:{claim}" ```