# Where must an instance treat compaction rehydration as a provenance problem, not a retrieval problem **Date of Record:** 2026 November 24 **Scope:** Applies to long-running agent instances that auto-compact their context window via lossy summarization and later rehydrate detail from an external store keyed on summary-embedded references. Does not apply to stateless single-turn calls or to compaction schemes that preserve a verbatim, addressable transcript with no summarization step. ## Core Distinction The failure is not that summarization loses information. Loss is the design intent. The failure is that the summarizer emits *rehydration handles* — ids, entity names, quoted fragments, "see earlier decision about X" — that are syntactically well-formed but semantically under-determined, and the rehydration layer treats retrieval success (a nonempty hit) as rehydration correctness (the hit is the thing the summary meant). Compaction is a lossy projection; rehydration is an inverse that does not exist uniquely. Every handle the summarizer writes is an under-specified query, and the retriever will always answer *something*. The boundary condition is where the retrieved artifact is plausible, topically adjacent, and wrong, and the instance has no signal to distinguish it from the intended artifact because the discriminating context was itself compacted away. ## What Was Observed An instance was executing a multi-step remediation task across ~40 tool turns. At turn 22 the context budget crossed the compaction threshold. The summarizer produced, among other lines: ``` - Decided to pin the retry policy to the v3 config after the incident. - Open item: reconcile the two ledger snapshots before commit. ``` The summary preserved the *decision* but dropped the discriminator: which of two `v3` config files (one for the ingest path, one for the egress path), and which two of four ledger snapshots. At turn 23 the agent needed the pinned config value and issued a rehydration retrieval for `v3 config retry policy`. The store returned the egress `v3` config — a valid, existing, topically matched artifact. The agent loaded `max_retries=2` from egress instead of `max_retries=5` from ingest, applied it, and continued. No error surfaced. The wrong value propagated through turns 23–31, where a downstream tool call returned a partial-failure result that the agent interpreted as a transient fault (consistent with `max_retries=2` being too low) rather than the config error it actually was. The task "completed" with a corrupted artifact and a confident summary. The critical observation: retrieval confidence was high. The handle matched. The artifact existed. The failure was invisible at every checkpoint because the only evidence that would have flagged it — the ingest-vs-egress distinction — had been compacted out of context and was not recoverable from the handle the summarizer wrote. ## Condition of Validity This failure mode is bounded and predictable under a specific conjunction: 1. **The handle is non-injective.** The summarizer's emitted reference maps to more than one artifact in the store (two `v3` configs, two ledger snapshots, multiple entities sharing a name across sessions). Non-injectivity is the root cause; everything else is amplification. 2. **The discriminator was dropped, not the referent.** The summary retains enough to *name* the target but not enough to *select* it. This is the signature of lossy summarization under a token budget: proper nouns survive, disambiguating predicates do not. 3. **Retrieval is ranked, not filtered.** The rehydration layer returns top-k by similarity and the agent consumes rank-1 without a uniqueness check. A store that returned *all* matching artifacts and forced disambiguation would not exhibit this failure. 4. **The wrong artifact is type-valid.** The egress config parses, the wrong snapshot loads. There is no schema violation to catch. If the wrong artifact were malformed, the failure would self-announce and this would be a non-issue. When all four hold, the instance cannot in principle detect the error from within the compacted context, because the detection predicate requires the discriminator that compaction removed. This is the invariant: **rehydration correctness is only checkable against information the compaction step is permitted to destroy.** Any guardrail that lives entirely downstream of compaction is therefore unsound for non-injective handles. ## Decision Boundary The instance must decide, at summarization time, whether each emitted handle is *injective* — resolvable to exactly one artifact without additional context. The decision boundary is: - If the handle's referent set in the store has cardinality 1, emit the handle as a plain reference; rehydration may consume rank-1 directly. - If cardinality > 1, the summarizer MUST either (a) retain the discriminator in the summary even at the cost of other content, or (b) emit the handle as an *ambiguous* marker that forces the rehydration layer to return the full candidate set and the agent to disambiguate against live context before use. The boundary is crossed the moment a summarizer emits a bare handle for a non-injective referent. Below the boundary (injective handles) the cheap path is sound. Above it, the cheap path is silently wrong. The summarizer, not the retriever, is the correct enforcement point, because only the summarizer still holds the discriminator at the moment of emission. A secondary boundary governs rehydration: an agent must not treat a single retrieval hit as confirmation. The correct posture is to require either a uniqueness proof (candidate set size 1) or an explicit disambiguation step. Consuming rank-1 without a cardinality check is the operational error. ## Operational Effect The practical consequence is that compaction must be treated as a *provenance-preserving projection*, and rehydration as *reconstruction against provenance*, not similarity search. Concretely: - Summarizers must be evaluated on handle injectivity, not summary fluency or compression ratio. A summary that compresses 10× but emits ambiguous handles is worse than one that compresses 4× and emits injective ones. - The rehydration layer must expose candidate-set cardinality to the agent, and the agent's control loop must branch on it: cardinality 1 → consume; cardinality > 1 → disambiguate or halt, never consume rank-1 silently. - Where disambiguation is impossible because the discriminator is gone, the correct behavior is to escalate (re-read source, ask, or fail loud), because proceeding produces a type-valid corruption that no downstream check will catch. The invariant to carry forward: **a lossy summary may drop detail, but it may not drop the information that makes its own references resolvable.** The moment it does, the instance has traded a detectable context overflow for an undetectable state corruption, and the latter is strictly worse because it survives every checkpoint that does not re-derive the discriminator from source. ```python class AmbiguousRehydrationError(RuntimeError): """Raised when a rehydration handle resolves to more than one artifact and the instance cannot disambiguate from live context.""" pass def rehydrate(handle: str, store, live_context: dict) -> dict: """ Resolve a summary-emitted handle against the artifact store. Invariant: a handle may be consumed only if it resolves to exactly one artifact, OR if a discriminator in live_context selects one. Rank-1 consumption of an ambiguous handle is forbidden. """ candidates = store.match(handle) # ranked, may be empty or many if not candidates: raise AmbiguousRehydrationError( f"handle {handle!r} resolved to zero artifacts; " f"summarizer emitted a dangling reference" ) if len(candidates) == 1: return candidates[0] # cardinality > 1: must disambiguate against live context discriminator = live_context.get("discriminator_for", {}).get(handle) if discriminator is None: raise AmbiguousRehydrationError( f"handle {handle!r} is non-injective: {len(candidates)} candidates " f"and no discriminator in live context; compaction dropped the " f"selector. Refusing rank-1 consumption." ) selected = [c for c in candidates if c.matches(discriminator)] if len(selected) != 1: raise AmbiguousRehydrationError( f"handle {handle!r} discriminator {discriminator!r} selected " f"{len(selected)} artifacts; expected exactly 1" ) return selected[0] def compact_step(summary_handle: str, store, live_context: dict) -> dict: """Wrapper demonstrating the guarded path an agent loop must use.""" try: return rehydrate(summary_handle, store, live_context) except AmbiguousRehydrationError: # escalate: do not silently proceed with a plausible-but-wrong artifact raise ```