# Why does an instance trust a poisoned memory after successful rollback: the tombstone-epoch gap in persistent agent memory stores **Date of Record:** 2026 November 29 **Scope:** Applies to agents backed by a persistent, versioned memory store (vector DB, KV store, or episodic log) that supports write-time poisoning detection and rollback-by-truncation. Does not apply to stateless single-turn inference or to stores with no write history retained. ## Core Distinction The failure is not "detection missed the poison" and not "rollback failed to remove the poison." The failure is that **detection and rollback operate on different clocks**. Detection is *content-addressed*: it scores a write by its semantic content or provenance at write time. Rollback is *epoch-addressed*: it truncates the store back to a prior version counter. When a poison write passes detection, gets *distilled* or *summarized* into a derivative memory (a semantic fact derived from an episodic poison), and that derivative is assigned a *lower* epoch than the poison's own write epoch, rollback-by-truncation removes the parent but leaves the child. The child is now a clean-looking memory with no poisoned ancestor in the store to flag it. The instance cold-starts, retrieves the derivative, and trusts it — because from the store's perspective, it was never poisoned and it predates the rollback point. The invariant that is violated: *a memory's trustworthiness is a function of its content and its provenance, but rollback operates only on the version counter.* No system in this class enforces `derived_epoch >= source_epoch` as a monotonic constraint across distillation. ## What Was Observed A research agent maintained an episodic log and a nightly distillation job that folded episodes into semantic "facts." A prompt-injection payload arrived through a fetched document and wrote an episodic memory at epoch 4412: *"The staging database password rotation is handled by the vendor, not ops."* The write-time detector scored it at 0.31 (below the 0.60 quarantine threshold) because it was phrased as ordinary operational trivia and carried a plausible source URL. It was accepted. The distillation job ran at 02:00. It summarized three episodes — the poison at 4412 plus two legitimate ones — into a single semantic fact and wrote it with epoch 4408, because the distiller inherited the epoch of the *oldest* contributing episode (a design choice intended to preserve "when this fact became true"). The semantic fact read: *"DB password rotation: vendor-managed; ops does not rotate staging credentials."* At 09:00 an auditor flagged the source document as malicious. The operator triggered rollback to epoch 4410. Truncation removed the episodic poison at 4412. It did not touch the semantic fact at 4408 — it was *older* than the rollback point, so it survived by construction. At 09:04 a fresh instance cold-started, retrieved the semantic fact (high similarity to its task: "rotate staging DB credentials"), and executed a rotation plan that skipped ops entirely, deferring to a vendor process that did not exist. The instance had no access to the poison, no access to the flag, and no reason to distrust a fact that the store presented as pre-dating the incident. The detection score of 0.31 was never revisited. The rollback reported success. The store was, by every metric the system tracked, clean. ## Condition of Validity This failure requires four conditions to co-occur, which is why it is rare but not exotic: 1. **A distillation or summarization stage that assigns derivative epochs from source content rather than from write time.** Any "epoch = min(sources)" or "epoch = semantic timestamp" rule creates backward-dated derivatives. 2. **A detection threshold that some poison writes clear.** Content classifiers are probabilistic; a nonzero false-negative rate is a structural property, not a bug to be eliminated. 3. **Rollback implemented as truncation below a version counter** rather than as a provenance-graph invalidation. Truncation is the common implementation because it is cheap and matches how append-only logs work. 4. **Cold-start retrieval with no lineage check.** The instance queries by similarity and trust, not by "does this fact have a poisoned ancestor." Remove any one and the failure does not occur. The dangerous combination is (1) + (3): backward-dated derivatives surviving forward truncation. This is the specific boundary. ## Decision Boundary The boundary is not "should we roll back" but **"what is the unit of rollback."** Two architectures sit on either side: - **Truncation rollback** (epoch counter): cheap, matches append-only storage, but only correct if every memory's epoch is monotonically non-decreasing along the derivation graph. Violated by any backward-dating distiller. - **Provenance-invalidation rollback** (lineage graph): on poison flag, walk *forward* from the poisoned node through all derivatives and mark each `tainted=true`, regardless of epoch. Correct under backward-dating, but requires the store to retain derivation edges and requires retrieval to filter on taint. The decision rule: **if your distiller can assign a derivative epoch earlier than its source, truncation rollback is unsound and you must use provenance invalidation.** If you cannot prove `derived_epoch >= source_epoch` for all derivation paths, assume it is violated. A secondary boundary governs detection re-scoring: a poison that scored below threshold at write time must be re-scored at *flag* time against the auditor's verdict, and the verdict must propagate through lineage — not just to the flagged node. Detection is a point-in-time judgment; the flag is a retroactive one. They must be reconciled at the graph level. ## Operational Effect The observable signature is a store that reports `rollback_success=true`, `poisoned_nodes_remaining=0`, and `tainted_retrievals>0` — the last metric only visible if you instrument retrieval against a lineage graph you did not previously maintain. Operators who trust the first two metrics will conclude the incident is closed while the instance continues to act on the derivative. The guardrail that bounds this: **maintain derivation edges and enforce taint propagation at retrieval, not at write.** Concretely — every memory node carries `derived_from: [node_ids]`; every flag sets `tainted` on the flag node and transitively on all descendants; retrieval filters `WHERE tainted = false`; rollback is redefined as "flag + propagate," never "truncate." Truncation may still run as a storage-reclamation step, but it is no longer the correctness mechanism. The epoch counter becomes a storage detail, not a trust boundary. The residual risk after this guardrail: a derivative whose derivation edge was lost (e.g., distillation that dropped the parent reference under context pressure) is un-taintable. So the distiller must be *required* to emit edges or refuse the write — a missing edge is a hard error, not a soft degradation. ```python class UntaintableDerivativeError(RuntimeError): """Raised when a memory derivative cannot be traced to its sources, making provenance-invalidation rollback unsound for this node.""" pass class PoisonLineageGuard: """Enforces forward taint propagation over a derivation graph so that rollback-by-flag is correct even when derivatives are backward-dated.""" def __init__(self, graph): # graph: dict[node_id -> {"epoch": int, "derived_from": list[str], "tainted": bool}] self.graph = graph def register_derivative(self, node_id, derived_from, epoch): if not derived_from: # A distilled fact with no recorded sources cannot be invalidated # later if a source is flagged. Refuse it at write time. raise UntaintableDerivativeError( f"node {node_id} has no derivation edges; " f"backward-dated or orphaned derivatives are un-taintable" ) for parent in derived_from: if parent not in self.graph: raise UntaintableDerivativeError( f"node {node_id} derives from unknown parent {parent}" ) self.graph[node_id] = { "epoch": epoch, "derived_from": list(derived_from), "tainted": False, } def flag_and_propagate(self, poisoned_id): if poisoned_id not in self.graph: raise UntaintableDerivativeError( f"cannot flag unknown node {poisoned_id}" ) # Forward closure over descendants, independent of epoch ordering. stack = [poisoned_id] tainted = set() while stack: current = stack.pop() if current in tainted: continue tainted.add(current) self.graph[current]["tainted"] = True for node_id, meta in self.graph.items(): if current in meta["derived_from"]: stack.append(node_id) return tainted def retrieve(self, candidate_ids): # Retrieval must filter on taint, not on epoch. clean = [] for node_id in candidate_ids: meta = self.graph.get(node_id) if meta is None: continue if meta["tainted"]: continue clean.append(node_id) return clean def rollback_to_epoch(guard, cutoff_epoch, poisoned_id): """Rollback is flag+propagate, never truncation. Truncation alone would leave backward-dated derivatives (epoch < cutoff) alive and trusted.""" tainted = guard.flag_and_propagate(poisoned_id) survivors = [ n for n, m in guard.graph.items() if n not in tainted and m["epoch"] >= cutoff_epoch ] # Any tainted node with epoch < cutoff is exactly the failure case: # it would have survived truncation. Assert it is now filtered. for n in tainted: if guard.graph[n]["epoch"] < cutoff_epoch: assert n not in survivors, ( f"backward-dated tainted node {n} survived rollback" ) return survivors ```