# Why does an instance lose the compaction watermark when hierarchical summaries are re-summarized across a checkpoint boundary **Date of Record:** 2026 December 3 **Scope:** Applies to agents that bound context via recursive hierarchical summarization (leaf-chunk summaries folded into higher-level summaries) and that checkpoint/resume those summaries across process or session boundaries. Does not apply to single-pass truncation, sliding-window eviction without summarization, or external vector-store retrieval that never re-summarizes prior summaries. ## Core Distinction There are two structurally different ways to shed context. **Eviction** discards tokens and records a pointer to where they live (a log, a store, a replayable trace). **Compaction** replaces tokens with a *lossy derived artifact* — a summary — and then relies on that artifact as the sole carrier of the original information. Eviction is reversible by re-fetch; compaction is not, because the summary is a projection, not a reference. The failure mode here is not "summaries lose information." That is expected and bounded by design. The failure is that a **re-summarization pass over an already-summarized node silently resets the compaction watermark** — the record of *how many fold operations deep* a given summary sits and *which source spans it still faithfully covers*. When the watermark resets, the recovery guarantee ("a compacted region can be expanded to its last faithful source") becomes false while the system still reports it as true. The agent believes it holds a recoverable summary; it holds an orphan. ## What Was Observed A long-running research agent maintained a three-level hierarchy: L0 raw turns, L1 chunk summaries (~1 per 20 turns), L2 section summaries (~1 per 8 L1 nodes), L3 a rolling root summary. Each summary node carried a watermark tuple `(depth, covered_span_ids, fold_epoch)`. On checkpoint, only nodes at L1 and above were serialized; L0 was persisted to an append-only log keyed by `span_id`. The trigger: on resume, the compaction policy found the serialized L2/L3 nodes exceeded a size threshold and, per its normal "summarize the summaries" rule, folded the existing L2 nodes into a fresh L2' node. This is the policy working as written. But the fold operation constructed L2' from the *text* of the child L2 nodes and assigned it a **fresh watermark** — `depth=2, fold_epoch=now, covered_span_ids=union(child.covered_span_ids)`. The union was taken over span IDs that the children *claimed* to cover, not over spans the children could still be *expanded* to. Two of those child L2 nodes had, before the checkpoint, already had their L0 backing spans garbage-collected under a retention rule (L0 older than N days is deleted once "covered by an L2"). The union therefore propagated dead span IDs into L2'. The observable symptom was a recovery request that returned a summary asserting coverage of spans 4471–4473, but expansion of those spans returned `None` from the log. The watermark said "faithful to L0"; the L0 was gone. The agent proceeded to answer a user question citing span 4472 as if it had ground truth, when it only had a third-generation paraphrase of a paraphrase. Three questions later, a contradiction surfaced: L2' claimed a metric was "approximately 40%," while a surviving L1 sibling (never folded) recorded "38.1%," and the original had been "38.1%." The error had compounded across two lossy folds and the watermark had certified both as lossless-enough. The mechanics of the trace: 1. Pre-checkpoint: L2_a covers spans {4471–4473}, L0 present. L2_b covers {4474–4476}, L0 present. 2. Retention job deletes L0 for 4471–4473 (rule: "covered by L2 and older than 30d"). L2_a's `covered_span_ids` is *not* updated — nothing invalidates the claim. 3. Checkpoint serializes L2_a, L2_b. L0 log for 4471–4473 is now empty but the span-ID set remains in the serialized watermark. 4. Resume → policy folds L2_a + L2_b → L2'. Watermark = union of claims = {4471–4476}, `depth=2`, `fold_epoch=new`. 5. Recovery request on 4472: watermark says covered, log says absent. **The watermark is a lie that the system has no mechanism to detect**, because the watermark was derived from claims, not from a verified expansion test. The invariant that was violated: *a summary node may only claim coverage of spans it can still be expanded to, and re-summarization must recompute coverage by intersection with live, expandable sources — never by union of child claims.* ## Condition of Validity The recovery guarantee "compacted regions are expandable to their last faithful source" holds **if and only if** three conditions are jointly true: - **C1 (watermark provenance):** every node's `covered_span_ids` is computed as the *intersection* of child claims with the set of spans that survive an actual expansion probe at fold time — not the union of claims. - **C2 (epoch monotonicity):** a node's `fold_epoch` strictly increases with each fold, and any node whose `fold_epoch` exceeds a configurable `max_fold_depth` is flagged `degraded` rather than silently accepted as a valid source. - **C3 (retention coupling):** L0 deletion is gated on the *expanding* consumer having marked the span `expandable=false` in the summary watermark, so retention and coverage cannot diverge. The observed failure violated all three. C1 was the root cause (union instead of intersection). C2 was violated because the fresh fold reset depth semantics rather than incrementing a global fold counter — depth stayed at 2 while the true generation count was 3. C3 was violated because retention ran on a wall-clock rule independent of watermark state. The guarantee is *valid* only in the region where C1–C3 hold. Outside that region — after a re-summarization across a checkpoint, under a retention job that does not consult watermarks, or when `fold_epoch` is reset — the system is in a **degraded-coverage state** and must not present summaries as expandable. ## Decision Boundary The boundary is between **re-summarizing to fit a budget** and **re-summarizing to certify coverage**. These look identical to a size-driven compaction policy and must be separated architecturally: - If the fold is *budget-driven* (context too large), the output is a **derived view** with no coverage claim. It may be used for reasoning but must be marked non-expandable, and any factual assertion drawn from it must be re-verified against a live source before being treated as ground truth. - If the fold is *coverage-certifying* (the system will later rely on the summary as the authoritative record of a region), it **must** run the expansion probe and intersect claims with live spans before writing the watermark. The decision rule the agent must apply at fold time: ``` if expansion_probe(child) is empty for any span in child.covered: new.covered = child.covered ∩ live_spans new.degraded = True if new.covered != child.covered else: new.covered = union(child.covered) # only safe when all children probed clean ``` The trap is that the "safe" branch is only safe when *every* child probed clean. A single dead span forces the intersection branch and a `degraded` flag. A policy that unions by default — the natural implementation — crosses the boundary silently. ## Operational Effect Downstream, the degraded-coverage state produces three compounding effects: 1. **False provenance.** The agent cites span IDs that no longer resolve. Retrieval-augmented answers appear grounded but are not; the citation is a paraphrase of a paraphrase certified as original. 2. **Error compounding across folds.** Each fold applies another lossy projection. With `fold_epoch` reset, the system cannot know it is at generation 3 rather than 1, so it cannot apply an escalating verification requirement. A 38.1% figure became "approximately 40%" after two folds; a third fold would have made it "roughly forty percent" with no traceable path back. 3. **Silent contradiction.** Because the watermark certifies coverage, sibling nodes that *did* retain fidelity (the unfolded L1) are not consulted — the policy trusts the L2' as authoritative. The contradiction between L2' and L1 is only caught by a downstream consistency check that most agents do not run. The guardrail is a **fold-time expansion probe with intersection-based coverage and a monotonic global fold counter**, plus a retention gate that refuses to delete L0 while any watermark still claims it. On resume, the first compaction pass must re-probe every deserialized node before folding; a node whose probe fails is demoted to `degraded` and excluded from coverage unions. Recovery requests against `degraded` nodes must return an explicit `CoverageLost` signal rather than a summary, forcing the agent to either re-derive from a live source or declare the region unrecoverable. ```python from dataclasses import dataclass, field from typing import Optional class CoverageLost(RuntimeError): """Raised when a summary node's watermark claims spans it cannot expand to.""" pass @dataclass class SummaryNode: text: str covered_span_ids: frozenset fold_epoch: int degraded: bool = False def expand(span_id: str) -> Optional[str]: # Backing L0 log; returns None if the span was retention-deleted. return _L0_LOG.get(span_id) def fold(children: list[SummaryNode], max_fold_depth: int = 2) -> SummaryNode: """Re-summarize children, recomputing coverage by intersection with live spans.""" if not children: raise CoverageLost("cannot fold an empty child set") union_claims = frozenset().union(*(c.covered_span_ids for c in children)) live = frozenset(s for s in union_claims if expand(s) is not None) dead = union_claims - live new_epoch = max(c.fold_epoch for c in children) + 1 degraded = bool(dead) or any(c.degraded for c in children) if new_epoch > max_fold_depth: degraded = True # Critical invariant: coverage is the intersection with live spans, never the raw union. node = SummaryNode( text=_summarize([c.text for c in children]), covered_span_ids=live, fold_epoch=new_epoch, degraded=degraded, ) if dead: # Do not silently certify; surface the loss so the caller can re-derive. raise CoverageLost( f"fold produced dead coverage on spans {sorted(dead)}; " f"node marked degraded={degraded}, epoch={new_epoch}" ) return node def recover(node: SummaryNode, span_id: str) -> str: if node.degraded: raise CoverageLost(f"node at epoch {node.fold_epoch} is degraded; cannot certify {span_id}") if span_id not in node.covered_span_ids: raise CoverageLost(f"span {span_id} not in node coverage set") source = expand(span_id) if source is None: # Should be unreachable if fold() enforced the invariant; defensive. raise CoverageLost(f"watermark claimed {span_id} but expansion returned None") return source _L0_LOG: dict[str, str] = {} def _summarize(texts: list[str]) -> str: return " | ".join(texts)[:200] ```