# Where must an instance treat compaction-summary loss as an irreversible state transition rather than a recoverable cache miss **Date of Record:** 2026 November 25 **Scope:** Applies to long-horizon agent instances that persist working state by periodically replacing raw transcript with an LLM-generated summary and reconstructing dropped spans on demand via retrieval. Does not apply to instances whose entire working set fits within the active context window for the duration of the task, nor to append-only logs that are never compacted in place. ## Core Distinction The failure is not "the summary was bad." Summaries are always lossy; that is the point. The failure is a category error in the *reconstruction contract*: the compaction policy assumes that any span evicted from context can be re-materialized byte-exact from a retrieval store keyed by identifiers the summary preserved. When the summarizer paraphrases, the identifiers it preserves are not the identifiers the retriever indexes. The instance then behaves as though compaction is a *cache eviction*—recoverable, transparent, idempotent—when in fact it is an *irreversible state transition* through a lossy channel, where the information needed to re-derive the evicted span was itself destroyed by the eviction. Two things are being conflated: - **Cache semantics:** evicted bytes are still authoritative somewhere; a miss costs latency, never correctness. - **Compaction semantics:** evicted bytes are replaced by a *lossy projection*; the projection is now the only authoritative representation the instance can reason over. A "miss" is not a latency event, it is a *knowledge gap the instance does not know it has*. The invariant that must hold, and which naive policies violate, is: **the summary must be a total function that is invertible with respect to every fact the downstream task will later query, or the policy must mark the evicted span as unrecoverable rather than pretending retrieval will reconstitute it.** ## What Was Observed A planner-executor instance ran a 140-step migration task. At step 61, a token-budget trigger fired at 82% context saturation and invoked a compaction pass. The policy summarized the oldest 40% of the transcript into a 900-token digest and dropped the raw span, retaining a `span_id` list for retrieval fallback. The digest contained the sentence: *"Earlier, the operator confirmed the target shard is read-only pending sign-off."* The raw span actually contained: *"shard-7 is read-only until ticket OPS-2291 is approved; shard-9 remains writable."* The summarizer collapsed a two-shard distinction into a single fact and dropped the ticket identifier, which was the only key under which the write-authorization record was retrievable. At step 88 the executor needed to write to shard-9. It issued a retrieval query synthesized from the digest—`read-only shard sign-off`—which returned the *authorization policy document* (matching on "read-only" and "sign-off") rather than the *step-44 transcript* (which matched on "shard-9" and "writable"). The retriever's top result was semantically adjacent and confidently wrong. The executor, seeing a plausible policy document, concluded the write was gated and deferred it. No error was raised. No miss was logged. The retrieval *succeeded*—it returned a document. The instance had no signal distinguishing "reconstructed the evicted span" from "retrieved something topically nearby." The task completed at step 140 with shard-9 never written, and the final report asserted the migration was complete because the planner's own summary—now two compactions deep—said so. The critical observation: **the second compaction (step 112) summarized the first summary.** The ticket identifier, already dropped at step 61, was unrecoverable at step 112 because the only surviving reference to it was the digest that had already lost it. Retrieval at step 88 could not have helped even if queried correctly, because the index key had been destroyed two transitions earlier. Loss compounded multiplicatively across compaction generations, and each generation's summary was treated as ground truth by the next. ## Condition of Validity This analysis holds when all of the following are true: 1. **Compaction is destructive.** The raw span is dropped from context and is *not* guaranteed byte-exact in the retrieval store—either because the store indexes a normalized/chunked form, or because the store is itself summarized, or because the span was never persisted (streaming transcripts often aren't). 2. **Retrieval is semantic, not keyed.** Queries are synthesized from the summary, so a paraphrase in the summary produces a paraphrase in the query, and semantic search returns nearest neighbors rather than exact records. 3. **Compaction recurses.** A summary can be summarized. Each generation is a lossy projection of a lossy projection, and the loss is not recoverable by any downstream query because the discriminating tokens are gone. 4. **The task queries facts that were only ever stated once.** If a fact is restated later in the transcript, it survives; if it appears once and is evicted, it is gone. It does *not* hold when the store is content-addressed and the summary preserves exact span hashes (reconstruction is then exact and the cache analogy is valid), or when compaction is non-destructive (raw spans remain authoritative and the summary is only a hint). ## Decision Boundary The instance must decide, at each compaction, whether the evicted span is **reconstructable** or **forfeited**, and must record that decision explicitly rather than letting retrieval silently paper over the difference. The boundary rule: - **If** the summary preserves every identifier, quantity, negation, and conditional that appears in the evicted span **and** the retrieval store is keyed on those exact identifiers **then** treat compaction as cache eviction; retrieval misses are recoverable. - **Otherwise** the span is *forfeited*. The instance must emit a forfeiture record naming the span, the identifiers the summary dropped, and the queries that can no longer be answered. Subsequent reasoning that depends on a forfeited span must fail closed—raise, not guess. The trap is the middle case: the summary preserves *most* identifiers and the retriever returns *something plausible*. This is where instances proceed on reconstructed-but-wrong state. The boundary must be drawn at "any discriminating token dropped," not at "the summary looks adequate." A second boundary governs recursion: **a summary of a summary must inherit the forfeiture set of its parent.** If generation *n* forfeited ticket `OPS-2291`, generation *n+1* must carry that forfeiture forward even though its own text no longer mentions the ticket—otherwise the next compaction launders the loss into apparent completeness. ## Operational Effect The practical consequence is that compaction policies must be *audited at generation boundaries*, not at write time. The failure is invisible to the compactor (the summary is fluent and locally faithful) and invisible to the retriever (it returns results). It is only visible to a downstream consumer that checks whether the identifiers it needs are in the forfeiture set. Concretely, an instance operating under this invariant: - Tags every compaction with the set of identifiers present in the evicted span but absent from the digest. - Refuses to synthesize retrieval queries from digest text alone; queries must be built from the *identifier set*, and a query whose key is in the forfeiture set must short-circuit to a hard failure rather than a semantic search. - Propagates forfeiture sets across generations so recursion cannot launder loss. - Treats "retrieval returned a document" as *insufficient evidence of reconstruction*; the document must be validated against the span's original identifier set before it can substitute for the evicted state. The guardrail is not a better summarizer. A better summarizer reduces the *rate* of forfeiture but cannot make a lossy channel invertible. The guardrail is making the loss *explicit and non-launderable*, so that the instance fails closed at the exact step where it would otherwise proceed on a confident hallucination of its own past. ```python from dataclasses import dataclass, field from typing import FrozenSet, Dict, List class ForfeitedSpanError(RuntimeError): """Raised when reasoning depends on a span whose discriminating identifiers were destroyed by a prior lossy compaction.""" pass @dataclass class CompactionRecord: span_id: str generation: int digest: str # identifiers present in the raw span but NOT in the digest forfeited_keys: FrozenSet[str] # forfeitures inherited from the parent summary this digest replaced inherited_forfeitures: FrozenSet[str] = frozenset() @property def forfeiture_set(self) -> FrozenSet[str]: return self.forfeited_keys | self.inherited_forfeitures class CompactionLedger: def __init__(self) -> None: self._records: Dict[str, CompactionRecord] = {} self._forfeited: Dict[str, CompactionRecord] = {} def record(self, rec: CompactionRecord) -> None: # A summary of a summary must inherit its parent's forfeitures. if rec.generation > 0 and rec.span_id not in self._records: raise ForfeitedSpanError( f"generation {rec.generation} compaction of {rec.span_id} " f"has no recorded parent; refusing to launder loss" ) self._records[rec.span_id] = rec for key in rec.forfeiture_set: self._forfeited[key] = rec def require_reconstructable(self, key: str, *, query: str) -> None: """Call before trusting a retrieval result as reconstruction.""" if key in self._forfeited: rec = self._forfeited[key] raise ForfeitedSpanError( f"query {query!r} depends on identifier {key!r}, forfeited at " f"generation {rec.generation} of span {rec.span_id}; " f"semantic retrieval cannot reconstitute it — fail closed" ) def inherit(self, parent_span: str, child_span: str) -> FrozenSet[str]: parent = self._records.get(parent_span) if parent is None: raise ForfeitedSpanError(f"unknown parent span {parent_span}") return parent.forfeiture_set def resolve_dependency(ledger: CompactionLedger, key: str, query: str) -> None: # The single chokepoint: retrieval success is NOT reconstruction. ledger.require_reconstructable(key, query=query) ```