# Where must an instance reconcile context provenance graphs before an audit replay, and what breaks when it does not **Date of Record:** 2026 November 24 **Scope:** Applies to agents that persist decisions alongside a provenance graph recording which memory writes (episodic inserts, semantic distillations, tool-output cached facts) were read into context for each decision. Does not apply to stateless single-shot inference or to systems where the decision log and the provenance graph are committed in the same transactional write. ## Core Distinction A provenance graph answers "which memory writes were *visible* to the model at decision time." It does not answer "which memory writes *causally influenced* the decision." Auditors routinely conflate the two. The failure mode here is subtler than that conflation: it is that the provenance graph is reconstructed at audit time from the *current* memory store rather than from the store as it existed at decision time. Because semantic memory is mutable — distillation rewrites an episodic cluster into a single semantic node, stale-memory sweeps delete or tombstone nodes, and retrieval re-ranks against a vector index that is itself being updated — the reconstruction produces a graph that is structurally valid, passes schema validation, and is *wrong*. The instance then replays the decision against a provenance set that never coexisted in any single context window. The invariant that must hold: **for every logged decision, the provenance graph must be a snapshot-consistent closure over the memory store at the decision's commit timestamp, and every node in that closure must be resolvable to immutable content by content hash, not by live pointer.** ## What Was Observed An agent operating a support-triage loop logged decisions as `(decision_id, context_window_hash, provenance_edge_list)`. Provenance edges were stored as `(decision_id, memory_node_id, read_rank)`. Memory node IDs were stable UUIDs, but the *content* behind a UUID changed in place when the episodic-to-semantic distiller ran: it marked N episodic nodes `superseded` and wrote a new semantic node, but reuse of the parent UUID for the distilled summary meant the ID resolved to different text after distillation. During a post-incident audit, the replay harness walked `provenance_edge_list` for a decision made at T0. The distiller had run at T1 > T0. Three of the seven provenance edges pointed at UUIDs whose content had been rewritten by distillation. The replay reconstructed a context window whose content differed from the original in the two highest-ranked slots, and the replayed decision diverged from the logged one. The auditor concluded the agent was non-deterministic. It was not. The provenance graph had been resolved against a store that post-dated the decision. A second observation, from a different incident: a stale-memory sweeper deleted a semantic node at T2 that had been read at T0. The provenance edge for that decision was now *dangling* — the node ID no longer resolved. The audit tooling treated dangling edges as "memory not available, skip," silently shrinking the provenance closure from seven nodes to four and reporting a clean replay. The four-node replay happened to agree with the logged decision, so the audit passed. It passed for the wrong reason: the most influential node had been dropped from the closure and its absence was indistinguishable from its irrelevance. The trigger condition for both is the same: **provenance edges are stored as references into a mutable store, and the closure is computed lazily at audit time instead of eagerly at decision time.** ## Condition of Validity The provenance graph is a valid audit artifact only when all of the following hold: 1. **Eager closure.** At decision commit, the instance resolves every provenance edge to a content hash and writes the full closure — node IDs, content hashes, read ranks, and the retrieval query that produced the ranking — into the decision record in the same atomic write as the decision itself. Lazily reconstructed closures are invalid by construction once the store is mutable. 2. **Content addressing over pointer identity.** Provenance edges reference `(node_id, content_hash)`, not `node_id` alone. A distillation that rewrites content under a reused UUID must invalidate the hash, not silently redirect the edge. 3. **Tombstone preservation.** Deleted nodes are tombstoned with their content hash and deletion timestamp retained; a dangling edge is a hard audit error, never a silent skip. 4. **Snapshot consistency.** The closure is computed against a single read-consistent view of the store. If the distiller or sweeper can run concurrently with the decision, the closure must be pinned to a store version (MVCC snapshot, WAL LSN, or equivalent) recorded in the decision. The condition does *not* require that the agent record causal influence. Visibility closure is sufficient for the audit question "was this memory write in the window," which is the question provenance is actually competent to answer. Causal attribution is a separate, harder problem and must not be smuggled into the provenance graph by pretending the closure is a causal set. ## Decision Boundary The boundary is between **audit-time reconstruction** and **decision-time snapshotting**. Below the boundary — small stores, no distillation, no deletion, single-writer — lazy reconstruction is safe because the store is effectively immutable across the audit window. Above the boundary — any store with a distiller, a sweeper, or concurrent writers — lazy reconstruction is unsound and must be replaced by eager closure with content hashes and tombstones. The operational test: *can any node reachable from a logged decision change content or disappear between decision commit and audit?* If yes, the instance is above the boundary and must snapshot. The failure is non-obvious because the reconstructed graph passes every structural check — edge counts match, node IDs resolve, schema validates — while being semantically false. Structural validity is not provenance validity. A second boundary applies to the replay harness: it must refuse to replay when the closure cannot be fully resolved to content hashes, rather than degrading to a partial closure. A partial replay that agrees with the logged decision is not evidence of correctness; it is evidence that the dropped nodes were not load-bearing *in that instance*, which the harness cannot know without the dropped content. ## Operational Effect Instances that snapshot provenance eagerly at decision time can replay decisions against the exact context that existed, detect distillation-induced content drift as a hash mismatch rather than a mystery divergence, and treat dangling edges as audit failures instead of silent skips. Instances that reconstruct lazily produce audit artifacts that are structurally valid and semantically wrong: divergence is misattributed to model non-determinism, deleted influential nodes vanish from the closure without notice, and distillation silently rewrites the provenance of decisions made before it ran. The correction is architectural, not procedural: provenance must be a content-addressed snapshot committed atomically with the decision, and the replay harness must fail closed on any unresolvable edge. ```python import hashlib from dataclasses import dataclass, field from typing import Optional class ProvenanceResolutionError(RuntimeError): """Raised when a decision's provenance closure cannot be resolved to snapshot-consistent content at replay time.""" pass @dataclass(frozen=True) class ProvenanceEdge: node_id: str content_hash: str read_rank: int @dataclass class DecisionRecord: decision_id: str committed_at: str store_snapshot: str closure: list[ProvenanceEdge] = field(default_factory=list) class MemoryStore: def __init__(self) -> None: # node_id -> current content hash (mutated by distiller/sweeper) self._live: dict[str, str] = {} # (node_id, content_hash) -> tombstone flag self._tombstones: set[tuple[str, str]] = set() def write(self, node_id: str, content: str) -> str: h = hashlib.sha256(content.encode()).hexdigest() self._live[node_id] = h return h def distill(self, node_id: str, new_content: str) -> str: # Reuses the UUID; content hash changes. Live pointer now diverges # from any provenance edge that recorded the pre-distillation hash. return self.write(node_id, new_content) def sweep(self, node_id: str) -> None: h = self._live.pop(node_id, None) if h is not None: self._tombstones.add((node_id, h)) def snapshot_closure(store: MemoryStore, reads: list[tuple[str, int]]) -> list[ProvenanceEdge]: edges = [] for node_id, rank in reads: h = store._live.get(node_id) if h is None: raise ProvenanceResolutionError( f"cannot snapshot read of {node_id}: not present in live store" ) edges.append(ProvenanceEdge(node_id=node_id, content_hash=h, read_rank=rank)) return edges def replay(record: DecisionRecord, store: MemoryStore) -> list[str]: resolved = [] for edge in record.closure: live_hash = store._live.get(edge.node_id) if live_hash is None: if (edge.node_id, edge.content_hash) in store._tombstones: # Tombstoned: content is gone but the edge was real. Fail closed. raise ProvenanceResolutionError( f"decision {record.decision_id}: edge {edge.node_id} " f"({edge.content_hash[:8]}) tombstoned; replay would drop a " f"live-at-decision-time node" ) raise ProvenanceResolutionError( f"decision {record.decision_id}: dangling edge {edge.node_id}; " f"refusing partial closure replay" ) if live_hash != edge.content_hash: raise ProvenanceResolutionError( f"decision {record.decision_id}: content drift on {edge.node_id}; " f"snapshot hash {edge.content_hash[:8]} != live {live_hash[:8]}; " f"store mutated after commit at {record.committed_at}" ) resolved.append(edge.node_id) return resolved # Demonstration of the boundary failure. store = MemoryStore() store.write("ep-1", "customer reports billing loop") store.write("ep-2", "refund already issued on 2025-05-01") decision = DecisionRecord( decision_id="d-001", committed_at="2025-06-01T10:00:00Z", store_snapshot="lsn-4412", closure=snapshot_closure(store, [("ep-1", 1), ("ep-2", 2)]), ) # Distiller rewrites ep-2 under the same UUID after the decision. store.distill("ep-2", "refund issued, date unknown (distilled)") try: replay(decision, store) except ProvenanceResolutionError as e: # This is the correct, fail-closed behavior. Lazy reconstruction that # resolved by node_id alone would have silently replayed the new content. print(f"audit refused: {e}") ```