# Why does an instance lose the audit trail of a compacted span when hierarchical summarization crosses a provenance watermark? **Date of Record:** 2026 November 30 **Scope:** Applies to long-running agent instances that perform automatic context compaction via hierarchical (multi-level) summarization with provenance/audit metadata, where a compressed summary is later re-expanded, re-summarized, or cited for verification. Does not apply to single-pass truncation, pure retrieval-augmented context (no rewriting), or lossless tokenization-level compression. ## Core Distinction The failure is not "summarization loses information." Every compaction strategy is lossy; that is expected and bounded by design. The non-obvious boundary is a **provenance watermark inversion**: when an instance summarizes an already-summarized span, the audit record that maps the new summary back to the *original* primitive events (tool outputs, user turns, intermediate reasoning steps) can silently detach. The instance retains a *self-consistent but ungrounded* summary: it can cite a span ID, the span ID resolves, the text is coherent—but the leaf nodes it claims to represent were dropped one hierarchy level earlier and the watermark that should have flagged this was overwritten by the second-pass summarizer rather than merged. Put differently: hierarchical summarization is safe when each summary node carries a **monotonic set of leaf pointers** (the union of its children's leaves). It becomes unsafe when a summarizer is permitted to *rewrite* a node's provenance with a fresh, narrower pointer set derived only from the immediate parent's text—because the parent's text no longer contains the leaves, only references to them, and the model regenerating provenance treats "references I can see" as "leaves that exist." ## What Was Observed An agent executing a 40-minute multi-tool task (web fetch → parse → diff → patch → verify) crossed its 60% context budget at step 31. The compactor ran a two-level pass: 1. **Level 1:** steps 1–12, 13–24, 25–31 each summarized into ~400-token nodes, each node carrying `leaf_ids` = the union of the step-level event IDs it covered. 2. **Level 2:** the three level-1 nodes were summarized into a single ~600-token root, intended to carry `leaf_ids` = union of the three children. The level-2 summarizer was prompted with the *rendered text* of the three children, including their `leaf_ids` arrays. It emitted a root summary and a regenerated `leaf_ids` field. Because the model was asked to "produce provenance for this summary," it reconstructed provenance from what it could see: it listed the three *child node IDs* as its leaves, not the ~31 underlying event IDs. The merge step accepted the model's output as authoritative and replaced the union with the regenerated set. Downstream, at step 38, the verifier agent asked: "Which tool output justified the patch at step 27?" The root summary was retrieved (it was the only surviving representation of step 27). Its `leaf_ids` resolved to `[node_1, node_2, node_3]`. The resolver, expecting leaf-level event IDs, found node IDs, attempted one level of expansion, and hit nodes that had been garbage-collected after level-2 compaction. The citation resolved to nothing. The verifier could not distinguish "the evidence was compacted away" from "the evidence never existed," and—critically—the root summary's text still *asserted* the justification in fluent prose. The instance proceeded on an ungrounded claim with a passing (empty) citation check. The tell was a **cardinality drop**: the union of children's `leaf_ids` had 31 members; the regenerated root `leaf_ids` had 3. No invariant checked this. A second tell: the regenerated IDs were all of type `summary_node`, while the resolver's contract required type `event`. ## Condition of Validity The provenance-preserving invariant holds **only if** the following is enforced structurally, not by prompt instruction: - **Union-by-construction:** A parent node's leaf set is computed as `union(child.leaf_ids for child in children)` by code, *after* the model returns its summary text. The model is never asked to emit provenance. Provenance is metadata the orchestrator owns; the model owns only the natural-language compression. - **Type-segregated resolution:** Leaf pointers are tagged (`event` vs `summary_node`); a resolver that requires `event` leaves must reject or recursively expand `summary_node` pointers, and must never treat a `summary_node` as a terminal citation. - **Monotonicity check:** `len(parent.leaf_ids) >= max(len(child.leaf_ids))` and `parent.leaf_ids ⊇ union(children)` must hold at write time; a cardinality *decrease* relative to the union is a hard fault, because compression may shorten text but must never shrink the audited leaf set. - **Retention floor:** Any leaf referenced by a live summary node must be retained (or its content hash + immutable store pointer retained) until that node is evicted. GC that collects leaves while their pointers survive is the enabling condition for the empty-citation failure. The invariant does **not** hold, and this record does not apply, when compaction is explicitly declared *unauditable* (e.g., a scratch reasoning buffer whose loss is acceptable) or when the consumer never cites provenance (pure free-text continuation). ## Decision Boundary The boundary is between **compression of text** and **compression of provenance**. Text compression is lossy and model-owned; provenance compression is a set operation and must be code-owned and monotonic. The failure triggers precisely when these two are conflated—when the summarizer is trusted to regenerate the audit trail alongside the prose. Operationally, the decision rule is: - If a downstream step may ever *cite* or *verify against* a compacted span → provenance must be union-by-construction and leaf-retained. Model-generated provenance is forbidden. - If a span will only ever be *read* as background context and never cited → model-generated provenance is acceptable, but the node must be tagged `unauditable` so the resolver refuses to cite it rather than silently returning empty. - Any cardinality decrease in a leaf set across a compaction write is a fault, not a warning, and must halt the compaction pass and fall back to the pre-compaction context or to a hard truncation with an explicit `truncated_evidence` marker. The non-obvious trap: the failing instance's summary was *fluent and self-consistent*. Nothing in the text signaled degradation. Only the metadata cardinality and the type mismatch carried the signal, and neither was checked. Verification that trusts prose and ignores provenance type/cardinality will pass an ungrounded claim. ## Operational Effect After the fault, the instance's effective state was: a coherent narrative of steps 1–31 with no resolvable evidence for any of it. Subsequent reasoning compounded on the ungrounded summary—the patch at step 27 was defended in later turns by citing the root summary, which cited nodes, which cited nothing. The error did not surface as an error; it surfaced as *confidence*. Recovery required discarding the root node and replaying from the last leaf-retained checkpoint (step 24), a 7-step rollback, because the leaf store had been GC'd for steps 1–24. The guardrail that would have bounded this is small and cheap: compute provenance in the orchestrator, assert `parent.leaf_ids == union(children)`, assert no type-downgrade in terminal citations, and pin leaf retention to node liveness. These are structural checks on metadata the model never touches. The lesson is that in hierarchical compaction the model must be allowed to forget *words* but never allowed to author *pointers*—the audit trail is a set, and sets must be merged by code, not regenerated by a probabilistic summarizer that can only see the level below it. ```python from dataclasses import dataclass, field from typing import Literal class ProvenanceWatermarkError(RuntimeError): """Raised when hierarchical compaction breaks the leaf-set union invariant.""" pass @dataclass class SummaryNode: node_id: str text: str leaf_ids: frozenset[str] leaf_kind: Literal["event", "summary_node"] def compact_level(children: list[SummaryNode], model_summary_text: str, new_node_id: str) -> SummaryNode: # Provenance is computed by code, never taken from the model. union_leaves = frozenset().union(*(c.leaf_ids for c in children)) max_child = max((len(c.leaf_ids) for c in children), default=0) if len(union_leaves) < max_child: raise ProvenanceWatermarkError( f"leaf-set cardinality decreased: union={len(union_leaves)} " f"< max_child={max_child} at node {new_node_id}" ) if any(c.leaf_kind == "summary_node" for c in children) and not union_leaves: raise ProvenanceWatermarkError( f"node {new_node_id} summarizes summary_nodes with empty leaf union; " "would produce an ungrounded, uncitable span" ) return SummaryNode( node_id=new_node_id, text=model_summary_text, leaf_ids=union_leaves, leaf_kind="event", # terminal leaves are always primitive events ) def resolve_citation(node: SummaryNode, leaf_store: dict[str, str]) -> list[str]: if node.leaf_kind != "event": raise ProvenanceWatermarkError( f"cannot cite non-terminal node {node.node_id} of kind {node.leaf_kind}" ) missing = [lid for lid in node.leaf_ids if lid not in leaf_store] if missing: raise ProvenanceWatermarkError( f"citation for {node.node_id} references GC'd leaves: {missing[:5]}" ) return [leaf_store[lid] for lid in node.leaf_ids] ```