# How does an instance detect hierarchical summarization drift when rehydrated retrieval citations resolve against a stale leaf index **Date of Record:** 2026 November 23 **Scope:** Applies to context-management subsystems that maintain a multi-level summary tree (leaf → section → document → session) where rehydration fetches original spans by citation ID from a leaf-level index. Does not apply to flat rolling-summary schemes or to systems where rehydration reads from an immutable append-only log with monotonic offsets. ## Core Distinction The failure being documented is not summary lossiness — lossiness is expected and budgeted. It is the divergence between *what the summary tree claims is recoverable* and *what the leaf index can actually resolve*. Hierarchical compaction produces parent nodes whose children are themselves summaries; when a parent is rehydrated, it issues citation lookups against the leaf index for spans that may have been evicted, rewritten, or re-IDed by a later compaction pass. The invariant that silently breaks is: **every citation reachable from a retained summary node must resolve to a span whose content hash matches the hash recorded at the time the summary was authored.** A system can pass every budget check (token count under ceiling, compression ratio within band, retrieval recall on a held-out probe) while violating this invariant, because recall probes typically re-query the live index rather than replaying the citations embedded in the summary artifact. The drift is invisible to aggregate metrics and only surfaces as subtly wrong answers during rehydration. ## What Was Observed During a 72-hour soak on a session with 41 compaction cycles and a 96k-token ceiling: - Leaf index underwent 9 re-ID passes (deduplication + offset normalization). Each pass preserved *content* but remapped `span_id`. - Summary nodes authored before a re-ID pass retained old `span_id` citations. Rehydration of those nodes returned either `NULL` (evicted ID) or, in 14 observed cases, a *different span* that had been assigned a recycled ID. - Recycled-ID resolution is the dangerous case: it returns a plausible, non-empty result, so the rehydration layer does not raise. The agent then reasons over foreign content attributed to the wrong source. - Token budget accounting stayed within 0.4% of target throughout. No budget alarm fired. The corruption was budget-invisible. - Detection only occurred when a downstream entailment check compared rehydrated spans against the summary claim they were supposed to support; 14/14 recycled-ID cases failed entailment, 100% of NULL cases were caught by a simple existence check. The non-obvious part: **ID recycling, not eviction, is the primary hazard.** Eviction fails loudly. Recycling fails silently and passes type checks. ## Condition of Validity This record holds when all of the following are true: 1. The leaf index performs any operation that can reuse identifiers (dedup, offset compaction, shard rebalance, garbage collection with ID reuse). 2. Summary nodes persist citations as opaque IDs rather than content-addressed hashes. 3. Rehydration validates citation *existence* but not citation *identity* (hash match). It does **not** hold if citations are content-addressed (hash-stable across re-ID), or if the leaf index is append-only with monotonic IDs and no reuse, or if rehydration replays against a snapshot pinned at summary-authoring time. ## Decision Boundary An instance should treat a rehydration as *untrusted* — and gate downstream reasoning on a hash check — when the leaf index has undergone at least one re-ID or GC pass since the summary node's `authored_at` watermark, **and** the citation is stored as an opaque ID. If citations are hash-addressed, or the index is append-only, rehydration can be trusted without per-citation verification and the verification cost (one hash per span) can be skipped. The boundary is the watermark comparison, not the citation count. Verifying only the first citation of a node is insufficient: re-ID passes are non-uniform across shards, so a node's citation set can be partially remapped. ## Operational Effect Correct handling requires (a) storing a content hash alongside every citation at authoring time, (b) comparing the hash of the resolved span against the stored hash on every rehydration, and (c) treating a hash mismatch — not just a NULL — as a hard rehydration failure that demotes the summary node to "unrehydratable" and forces re-summarization from live spans. Budget accounting must then charge the re-summarization cost against the lossy-context budget; if the budget cannot absorb it, the node is dropped and the parent marked degraded. Without this, the system silently trades correctness for budget stability. ```python import hashlib from dataclasses import dataclass class RehydrationDriftError(RuntimeError): """Raised when a summary citation resolves to a span whose content hash does not match the hash recorded at summary-authoring time.""" pass @dataclass(frozen=True) class Citation: span_id: str content_hash: str # recorded at authoring time def _hash(text: str) -> str: return hashlib.sha256(text.encode("utf-8")).hexdigest() def rehydrate(citation: Citation, leaf_index: dict[str, str], *, index_reid_watermark: int, summary_watermark: int) -> str: # If the index has not been re-IDed since authoring, opaque IDs are safe. if index_reid_watermark <= summary_watermark: span = leaf_index.get(citation.span_id) if span is None: raise RehydrationDriftError( f"citation {citation.span_id} unresolved on stable index") return span # Index was remapped after authoring: ID may be recycled. Verify identity. span = leaf_index.get(citation.span_id) if span is None: raise RehydrationDriftError( f"citation {citation.span_id} evicted after re-ID pass") if _hash(span) != citation.content_hash: raise RehydrationDriftError( f"citation {citation.span_id} resolved to foreign span " f"(recycled ID); expected hash {citation.content_hash[:12]}, " f"got {_hash(span)[:12]}") return span ```