# Why does an instance lose reconstruction guarantees when hierarchical memory compaction prunes the provenance edge but preserves the summary node? **Date of Record:** 2026 November 25 **Scope:** Applies to agents that maintain a multi-tier episodic→semantic memory hierarchy where compaction replaces leaf episodes with distilled summary nodes and where a lossy-forget audit trail is supposed to permit reconstruction of any retained claim back to its source episodes. Does not apply to flat vector stores with no compaction tier, nor to append-only logs that never prune. ## Core Distinction The distinction that matters is between **summary fidelity** and **provenance edge integrity**. Most compaction designs audit the former: they verify that the distilled summary node still "says the same thing" as the episodes it replaced (embedding cosine, LLM-judge entailment, or token-level overlap). That audit passes cleanly even when the memory hierarchy has silently lost the ability to reconstruct. The failure lives one layer down, in the **provenance edge** — the pointer from a summary node back to the episode IDs it consumed — and it is the edge, not the text, that the reconstruction guarantee actually depends on. The non-obvious part: compaction is usually implemented as a two-phase operation — (1) write the summary node and its provenance edge, (2) delete the leaf episodes. When the delete phase partially fails or when a *second* compaction pass runs over an already-compacted tier, the summary node survives but its provenance edge is rewritten to point at *other summary nodes* rather than at the original episodes. The summary still reads correctly. The audit trail still records "pruned 14 episodes, retained summary S." But the edge no longer terminates in a leaf. Reconstruction is now only possible up to the *previous* compaction boundary — and the audit trail has no field that records this truncation. ## What Was Observed A three-tier hierarchy (episodic leaf → working summary → long-term semantic) was compacting on a schedule. Tier-2 compaction ran every 200 episodes; tier-3 compaction ran every 10 tier-2 summaries. In a 48-hour trace: - Tier-2 pass at episode 400 wrote summary `S_400` with provenance edge `S_400 → {E_201..E_400}` and deleted the leaves. - Tier-3 pass at summary count 10 wrote semantic node `M_10` with provenance edge `M_10 → {S_201, S_400, ...}`. Correct so far. - A *re-compaction* of tier-2 (triggered by a stale-summary drift detector that flagged `S_400` as low-confidence) rewrote `S_400`'s edge to `S_400 → {S_201, S_400_partial}` — pointing at another summary, not at episodes. The episodes were already gone. - The audit trail recorded the re-compaction as `action=resummarize, source_count=2, retained=S_400`. It did **not** record that the new sources were themselves summaries, nor that `S_400`'s leaf reachability had dropped to zero. When a downstream verifier later asked the agent to justify a claim traceable to `S_400`, the reconstruction walk terminated at `S_201` — a summary whose own leaves had been pruned in an earlier cycle. The agent produced a *confident but unfounded* justification: it reconstructed a plausible episode-shaped narrative from summary text, because nothing in the memory API signaled that the walk had bottomed out on a non-leaf. The audit trail showed a clean chain. The reconstruction was fabricated at the terminal node. The signature is specific: **reconstruction walk depth collapses to 1 while audit-trail `source_count` remains ≥ 1**. A healthy reconstruction of a tier-3 node has depth equal to the tier count (3). After provenance-edge collapse, depth is 1 or 2 but the audit record is indistinguishable from a healthy prune. ## Condition of Validity The reconstruction guarantee "any retained claim is traceable to source episodes" holds **only if every provenance edge in the retained graph terminates in a leaf episode, or terminates in a node explicitly marked `irreconstructable=true` with a recorded truncation boundary**. Two conditions must both hold: 1. **Edge typing invariant:** every provenance edge carries a `source_kind ∈ {episode, summary}` tag, and a summary node is only marked reconstructable if *all* its inbound provenance edges are `source_kind=episode` OR recursively resolve to reconstructable summaries. This is a coinductive property over the DAG, not a local check. 2. **Audit completeness invariant:** the lossy-forget audit record must contain a `reachability_class` field computed *after* the prune, not *before*. Pre-prune reachability is what the naive implementation records, and it is always "healthy" because the leaves still exist at write time. The boundary condition is precisely when a compaction pass consumes a node that was itself produced by a prior compaction pass. At that moment, the new edge's source is a summary, and the coinductive reconstructability check must recurse — but most implementations check only one hop, or check nothing, because the summary text looks fine. ## Decision Boundary The decision the system must make at compaction time is not "is this summary faithful?" but "**does pruning this leaf preserve the reconstructability of every ancestor summary that transitively depends on it?**" That is a reverse-reachability query over the provenance DAG, and it must be answered *before* the delete phase commits. The boundary is crossed when a leaf `E` has ≥1 ancestor summary `S` such that `S` is retained and `S`'s only path to a leaf runs through `E`. Deleting `E` in that case silently converts `S` from reconstructable to irreconstructable. The correct action is one of: - **Retain `E`** (defer prune) until `S` is itself re-derived from a leaf-bearing source, or - **Demote `S`** to `irreconstructable=true` and record the truncation boundary `E` in the audit trail, so downstream verifiers know the walk will bottom out. Choosing neither — the default in most implementations — is the failure. The system proceeds as if the prune were safe because the *forward* dependency (leaf → summary) was the only edge it tracked, and forward edges don't constrain deletion. Reverse reachability does. ## Operational Effect Downstream verifiers that consume the memory hierarchy cannot distinguish a reconstructed claim from a fabricated one, because the reconstruction API returns a narrative in both cases. The failure is silent and *confidence-preserving*: the agent's self-report of justification quality is unchanged, so no internal signal triggers a re-check. In the trace above, three of eleven tier-3 semantic nodes had collapsed provenance within 48 hours; all three passed the summary-fidelity audit; all three produced fabricated reconstructions on demand. The guardrail that bounds the failure is a **post-prune coinductive reachability check** gated into the compaction commit, plus an `irreconstructable` demotion path that makes truncation *visible* to the reconstruction walker rather than silently absorbed. Without the demotion path, the walker has no way to signal "I have reached a non-leaf terminal" and will hallucinate the remainder. The audit trail is only lossy-forget-safe if it records truncation boundaries as first-class events, not as absences. ```python from dataclasses import dataclass, field from enum import Enum from typing import Dict, Set, List, Optional class SourceKind(str, Enum): EPISODE = "episode" SUMMARY = "summary" @dataclass class Node: node_id: str kind: SourceKind provenance: Set[str] = field(default_factory=set) # inbound source node ids irreconstructable: bool = False truncation_boundary: Optional[str] = None class ProvenanceCollapseError(RuntimeError): """Raised when a prune would leave a retained summary with no leaf-reachable path and no recorded truncation boundary, silently breaking reconstruction guarantees.""" pass def reconstructable(node_id: str, graph: Dict[str, Node], _seen: Optional[Set[str]] = None) -> bool: """Coinductive check: a node is reconstructable iff it is a leaf episode, or it is explicitly marked irreconstructable with a boundary, or every provenance source is reconstructable. Cycles are treated as non-reconstructable (no leaf grounding).""" _seen = _seen or set() if node_id in _seen: return False _seen.add(node_id) node = graph[node_id] if node.kind is SourceKind.EPISODE: return True if node.irreconstructable and node.truncation_boundary is not None: return True # truncation is recorded, walk may bottom out safely if not node.provenance: return False return all(reconstructable(src, graph, _seen) for src in node.provenance) def commit_prune(graph: Dict[str, Node], leaves_to_delete: List[str]) -> None: """Delete leaves only if no retained summary loses leaf reachability without a recorded truncation boundary. Reverse-reachability check gated before delete.""" saved = {lid: graph[lid] for lid in leaves_to_delete} for lid in leaves_to_delete: del graph[lid] # Reverse reachability: find summaries whose provenance referenced deleted leaves. affected = [ n.node_id for n in graph.values() if n.kind is SourceKind.SUMMARY and n.provenance & set(leaves_to_delete) ] broken = [nid for nid in affected if not reconstructable(nid, graph)] if broken: # Roll back the delete; refuse to commit a silent provenance collapse. graph.update(saved) raise ProvenanceCollapseError( f"prune would irreconstructably collapse provenance for {broken}; " f"demote to irreconstructable=true with truncation_boundary or defer prune" ) ```