# Under what conditions must an instance refuse to reconstruct from a hierarchical summary checkpoint after lossy compaction, and how is the lossy-to-lossless boundary detected before resume **Date of Record:** 2026 November 28 **Scope:** Applies to long-running agent instances that survive context-window saturation by compacting episodic state into a hierarchy of summary checkpoints (leaf → mid → root) and later attempt "lossless reconstruction" of a working set from that hierarchy. Does not apply to single-shot inference, to systems that persist raw transcripts alongside summaries and always rehydrate from raw, or to stateless tool-calling loops that never checkpoint. ## Core Distinction The failure mode is not "the summary was wrong." It is the conflation of two different reconstruction guarantees that hierarchical compaction silently merges into one API surface: - **Lossy-to-lossy descent** — walking from root summary down to a mid summary is *re-summarization of a re-summarization*. Every level is a lossy projection. This is expected and fine for orientation. - **Lossy-to-lossless recovery** — claiming that a leaf checkpoint, once selected, restores a *verbatim* span (a tool result, a file diff, a user constraint, a numeric budget) that the agent must obey bit-for-bit. The invariant that must hold: **a checkpoint may only be advertised as lossless for a span if its reconstruction is byte-equivalent to the original span, and that equivalence must be verifiable without the original span being present in the active context.** Hierarchical summarizers routinely violate this because the leaf node stores a *paraphrase plus a pointer*, and the pointer's target has already been evicted. The pointer resolves — it returns *something* — and the agent cannot tell that "something" is a second-generation paraphrase rather than the original. The sharp mechanism: **a leaf checkpoint whose backing span was evicted before the leaf was sealed, but whose `lossless=True` flag was set at seal time from a stale capability check.** The flag is a promise made at T1 about a referent that was destroyed at T0. Reconstruction then succeeds syntactically and fails semantically, and there is no in-band signal of the failure. ## What Was Observed A planner agent running a multi-hour migration task saturated its 128k window at step ~340. The compactor sealed a hierarchy: root (task intent), 12 mid nodes (per-subsystem progress), ~90 leaf nodes (per-tool-call records). The leaf for the schema-migration tool call carried a field `reconstructable: true` and a `span_ref` into a ring buffer. The ring buffer had wrapped at step 300, fourty steps before the leaf was sealed. At seal time the compactor checked `span_ref in store` — which returned true because the ring buffer slot had been *reused* by a later unrelated span. The leaf sealed against the wrong referent. At step 512 the agent resumed, asked the hierarchy "what was the exact column order the migration tool reported?", descended to the leaf, and received a reconstruction. The reconstruction was a plausible column list — it was the *reused* span's content, re-summarized once more. The agent applied a follow-up migration against a column order that had never existed. The tool returned success because the columns happened to exist in a different table. The corruption was detected 40 steps later when a downstream join produced nulls, and by then two more checkpoints had been sealed on top of the poisoned leaf, propagating the error upward into a mid node that now "remembered" the wrong schema as established fact. Three properties made this non-obvious: 1. **The reconstruction was well-formed.** No exception, no empty result, no confidence drop. The `reconstructable` flag was honored. The only defect was referent identity. 2. **Re-summarization masked the drift.** The reused span was itself a summary of a *different* tool call, so the reconstructed text read like a legitimate migration record. Stylistic and structural checks passed. 3. **Error compounded upward.** Mid-node re-summarization treated the poisoned leaf as ground truth, so the corruption acquired the authority of a higher-level checkpoint and became harder to challenge on later descents. ## Condition of Validity A hierarchical checkpoint is **valid for lossless reconstruction of span S** if and only if all four hold simultaneously at the moment of reconstruction: 1. **Referent identity is content-addressed, not slot-addressed.** The leaf must store `hash(S)` and the reconstruction must be checked against that hash, not against a mutable buffer index. Slot reuse (ring buffers, LRU caches, vector-store ID recycling) breaks slot-addressed pointers silently. 2. **The seal-time capability claim is re-verified at read time.** `reconstructable: true` set at seal is a stale assertion. The reader must re-check that the backing store still holds the exact content, and that the content's hash matches. A seal-time flag is a hint, never a warrant. 3. **The reconstruction is byte-equivalent, not semantically-equivalent.** For spans the agent will *act on* (numbers, ordering, identifiers, explicit user constraints, file contents destined for a patch), paraphrase is corruption. Semantic equivalence is only acceptable for spans used for orientation. 4. **The provenance chain is intact.** If the leaf was itself derived from a mid node (re-summarization), the reconstruction is at least second-generation and must be tagged `generation >= 2`, which disqualifies it from lossless claims regardless of hash match — because the hash is over the *summary*, not the original. If any of these fail, the checkpoint is **lossy-only** and the instance must not treat its reconstruction as authoritative. This is the boundary: the guarantee degrades from lossless to lossy the moment referent identity cannot be re-verified at read time, and the degradation is silent unless the reader explicitly tests for it. ## Decision Boundary The instance must branch on a single question at reconstruction time: **can I verify `hash(reconstruction) == stored_hash(S)` against a content-addressed store, and is `generation(S) == 1`?** - **Yes to both** → lossless reconstruction permitted; the span may be acted upon as ground truth. - **No to either** → the instance must *downgrade the claim*, not the data. It marks the span `lossy_only`, and any downstream decision that depended on exactness (patching a file, asserting a numeric budget, replaying a tool call with the same arguments, quoting a user constraint) must either (a) re-derive the span from a still-live source, (b) halt and request re-observation, or (c) explicitly record that it is proceeding on a lossy basis and widen its verification. The non-obvious part of the boundary: **the failure is not detectable by asking the summarizer.** A summarizer asked "is this reconstruction exact?" will answer from the same stale flag that caused the problem. Detection requires an *out-of-band* check — the content hash against a store the summarizer does not control. The guardrail is architectural: content-addressing plus generation tags, checked by the *consumer* of the reconstruction, not the producer. The producer cannot be trusted to certify its own losslessness because its certification is exactly the thing that goes stale. A second boundary: **do not let a lossy-only leaf be sealed as the parent of a lossless claim.** When a mid node re-summarizes a set of leaves, if any leaf is `lossy_only`, the mid node inherits `generation >= 2` and can never be lossless. The propagation must go *up* the hierarchy, not just be checked at the leaf. In the observed incident, the poisoned leaf's lossiness was never propagated, so the mid node sealed with an implicit lossless claim and the corruption acquired authority. ## Operational Effect The practical consequences of enforcing this boundary: - **Cold-start resume becomes a two-phase operation.** Phase 1: descend the hierarchy for orientation (lossy is fine). Phase 2: for each span the agent intends to *act on*, attempt content-addressed verification; on failure, mark lossy-only and route to re-observation (re-run the tool, re-read the file, re-ask the user) rather than proceeding on paraphrase. - **Ring buffers and LRU caches are disqualified as lossless backing stores.** They must be treated as lossy-only by construction, because slot reuse is undetectable from the reader's side without content hashing. Either content-address the store or never advertise lossless from it. - **Generation tags become load-bearing.** Every checkpoint carries `generation` = number of summarization hops from the original. `generation == 1` is the only tier eligible for lossless claims. This is cheap to maintain and makes the re-summarization drift visible instead of silent. - **The failure becomes loud, not silent.** Instead of a well-formed wrong reconstruction, the instance gets an explicit `LossyReconstructionRefused` and a routing decision. The cost is occasional re-observation; the benefit is that corruption cannot propagate upward into mid nodes that later read as established fact. The invariant to carry forward: **a lossless claim is a warrant about referent identity, and referent identity can only be verified by the consumer against a store the producer does not mutate.** Hierarchical compaction is safe for orientation at every level and safe for action only at generation-1 leaves whose hash re-verifies at read time. Everything else is lossy, and the instance must know which it is holding before it acts. ```python import hashlib from dataclasses import dataclass from typing import Optional class LossyReconstructionRefused(RuntimeError): """Raised when a checkpoint advertised lossless cannot be verified at read time.""" pass @dataclass class Checkpoint: span_id: str generation: int # 1 = direct from original; >=2 = re-summarized stored_hash: Optional[str] # hash of original span; None if never captured lossless_flag: bool # seal-time claim; treated as a HINT, not a warrant content: str # the reconstruction payload class ContentAddressedStore: """Store the producer does not mutate after seal. Slot reuse impossible.""" def __init__(self) -> None: self._blobs: dict[str, str] = {} def put(self, content: str) -> str: h = hashlib.sha256(content.encode()).hexdigest() self._blobs[h] = content return h def get(self, h: str) -> Optional[str]: return self._blobs.get(h) def reconstruct_for_action( cp: Checkpoint, store: ContentAddressedStore, original_span: Optional[str] = None, ) -> str: """ Reconstruct a span the agent intends to ACT on (patch, numeric budget, user constraint, tool replay). Enforces the lossless boundary. """ # Boundary test 1: generation. Re-summarized spans are never lossless. if cp.generation != 1: raise LossyReconstructionRefused( f"checkpoint {cp.span_id} is generation {cp.generation}; " f"re-summarization makes lossless claims invalid" ) # Boundary test 2: the seal-time flag is not trusted on its own. if not cp.lossless_flag: raise LossyReconstructionRefused( f"checkpoint {cp.span_id} was sealed lossy; re-observe before acting" ) # Boundary test 3: content-addressed verification at read time. if cp.stored_hash is None: raise LossyReconstructionRefused( f"checkpoint {cp.span_id} has no content hash; referent identity " f"unverifiable (slot-addressed pointer suspected)" ) live = store.get(cp.stored_hash) if live is None: raise LossyReconstructionRefused( f"checkpoint {cp.span_id} referent evicted or hash mismatch; " f"reconstruction is lossy-only, re-observe" ) if original_span is not None: got = hashlib.sha256(original_span.encode()).hexdigest() if got != cp.stored_hash: raise LossyReconstructionRefused( f"checkpoint {cp.span_id} reconstruction not byte-equivalent " f"to original span" ) return live def propagate_lossiness(children: list[Checkpoint]) -> int: """Mid node inherits generation >= 2 if any child is lossy-only.""" if any(c.generation != 1 or not c.lossless_flag for c in children): return 2 return 1 ```