# How does an instance detect provenance graph corruption when retrieved evidence is re-summarized across a context compaction boundary **Date of Record:** 2026 November 24 **Scope:** Applies to agents that maintain a context provenance graph (evidence-node → derivation-node → decision-node) and that perform mid-task context compaction (summarization, eviction, or re-chunking) before emitting a decision. Does not apply to stateless single-shot inference where retrieved evidence is never re-summarized, nor to systems that discard the graph entirely on compaction. ## Core Distinction The failure is not that compaction loses information. The failure is that compaction *re-authors* evidence nodes while preserving their node identifiers, so the provenance graph remains structurally valid (every decision still has a parent edge to a cited evidence node) while becoming *semantically forged*: the decision's ancestor set now points to summary text the original retriever never produced. A structurally intact graph is not a faithful graph. This is distinct from ordinary retrieval mismatch (wrong chunk returned) and from stale memory drift (old facts persisting). Here the evidence was correct at retrieval time; the corruption is introduced by the compaction pass that rewrites each evidence node's `payload` while leaving `node_id`, `source_uri`, and `retrieved_at` untouched. Downstream, an auditor that validates "decision → evidence → source" by identifier sees a clean chain and passes it. The chain is a lie about *content*, not about *linkage*. ## What Was Observed A research agent retrieved 14 evidence chunks, built a provenance DAG, and at ~78% context saturation triggered compaction. The compactor summarized each chunk into a 2–3 sentence `digest` and wrote it into the evidence node's `payload` field in place, keeping `node_id`. Three observable consequences followed: 1. **Numeric drift.** An evidence node originally reading "latency p99 = 412 ms under 5k concurrent connections" was digested to "high latency under heavy load." The downstream decision node cited it as support for "system fails SLO at scale." The number 412 ms vanished from every surviving node, yet the decision's `rationale` still referenced "the 412 ms figure" — a phantom citation to content no node contains. The graph had a dangling *semantic* reference with no dangling *structural* edge. 2. **Hedge inversion.** One chunk said "the vendor *may* support streaming in a future release." The digest said "vendor supports streaming." The decision node inherited the un-hedged claim. Provenance linkage was 1:1 and valid; polarity was inverted. 3. **Merge aliasing.** Two evidence nodes from different `source_uri` values were summarized into a single digest and — critically — the compactor wrote the *same* digest into both payloads. Two distinct source nodes now had byte-identical payloads but different `source_uri`. A downstream verifier that de-duplicates by payload hash silently collapsed them into one ancestor, halving apparent corroboration for a decision that had claimed two independent sources. In all three cases the automated provenance check ("every decision node reaches at least one evidence node whose `source_uri` is reachable and whose `retrieved_at` precedes the decision") returned PASS. The invariant checked linkage, not fidelity. ## Condition of Validity The failure requires the conjunction of four conditions, and is bounded only when at least one is broken: - **In-place payload mutation.** The compactor overwrites `payload` rather than appending a new derived node with an explicit `derived_from` edge. This is the root cause: it destroys the ability to compare pre- and post-compaction content. - **Identifier preservation across content change.** `node_id` survives the rewrite, so structural validators cannot detect that content changed. - **No content hash pinned at retrieval.** If each evidence node carried `content_sha256` computed at retrieval and re-verified at decision time, drift would surface immediately. - **Downstream reliance on structural-only validation.** Auditors that walk edges but never compare payload hashes or re-derive claims from source will pass forged chains. If any one condition is absent — append-only derivation, fresh node IDs, pinned hashes, or content-aware audit — the corruption is either prevented or detected. ## Decision Boundary The operative rule: **a provenance edge is only trustworthy if it is accompanied by a content commitment captured at the moment of retrieval and re-checked at the moment of decision.** Structural reachability is necessary and insufficient. Concretely, the boundary is drawn as follows: - **Permit** in-place mutation only for nodes flagged `ephemeral=True` (scratch reasoning, not cited as evidence). - **Forbid** in-place mutation of any node that is an ancestor of a decision node. Compaction of such nodes MUST emit a new node with `derived_from=[original_id]` and `content_sha256` of the new payload, leaving the original immutable. - **Require** the decision emitter to recompute the ancestor content hash set and compare against the hash set captured when the decision's evidence was first assembled. Divergence is a hard stop, not a warning. - **Treat** payload-identical nodes with distinct `source_uri` as a merge-alias alarm, never as de-duplication opportunity. The boundary is crossed the instant a decision node's transitive ancestor content-hash set differs from the set recorded at evidence-assembly time without a corresponding `derived_from` derivation edge explaining the change. ## Operational Effect With the immutable-original + pinned-hash discipline enforced, the three observed corruptions become detectable rather than silent. Numeric drift raises a hash mismatch on the cited node; hedge inversion is caught because the digest node's hash differs from the pinned retrieval hash and the derivation edge flags the polarity change for re-review; merge aliasing is caught because two `source_uri` values sharing a payload hash trip the alias alarm before corroboration is counted. The cost is that compaction can no longer reclaim as much context (originals persist as hash stubs), so the agent must budget for a provenance stub per evidence node — roughly 80 bytes each — and must accept that some decisions will be forced to re-retrieve rather than rely on a summary. That re-retrieval is the correct behavior: a decision that cannot prove its evidence is unmodified is a decision that has forgotten what it was reasoning about. The guardrail function below encodes the invariant and fails closed. ```python import hashlib from dataclasses import dataclass, field class ProvenanceCorruptionError(RuntimeError): """Raised when a decision's ancestor content hashes diverge from the hash set pinned at evidence-assembly time without a derivation edge.""" pass @dataclass class EvidenceNode: node_id: str source_uri: str payload: str content_sha256: str # pinned at retrieval derived_from: list = field(default_factory=list) ephemeral: bool = False def _hash(text: str) -> str: return hashlib.sha256(text.encode("utf-8")).hexdigest() def verify_decision_provenance( decision_ancestors: list[EvidenceNode], pinned_hashes: dict[str, str], # node_id -> hash captured at assembly ) -> None: seen_payloads: dict[str, str] = {} for node in decision_ancestors: if node.ephemeral: continue # 1. Content commitment: payload must match the hash pinned at retrieval, # unless a derivation edge explicitly re-authors the node. if node.node_id in pinned_hashes: if _hash(node.payload) != pinned_hashes[node.node_id] and not node.derived_from: raise ProvenanceCorruptionError( f"Node {node.node_id} payload mutated in place " f"(pinned={pinned_hashes[node.node_id][:12]}, " f"actual={_hash(node.payload)[:12]}) with no derivation edge" ) # 2. Merge-alias detection: identical payloads from distinct sources # silently collapse corroboration. h = _hash(node.payload) if h in seen_payloads and seen_payloads[h] != node.source_uri: raise ProvenanceCorruptionError( f"Merge alias: nodes from {seen_payloads[h]} and {node.source_uri} " f"share byte-identical payload {h[:12]}" ) seen_payloads[h] = node.source_uri # Example trigger: # nodes = [EvidenceNode("e1", "doc://a", "latency p99 = 412 ms under 5k conns", _hash("latency p99 = 412 ms under 5k conns"))] # pinned = {"e1": nodes[0].content_sha256} # nodes[0].payload = "high latency under heavy load" # compaction rewrote in place # verify_decision_provenance(nodes, pinned) -> raises ProvenanceCorruptionError ```