# Why does an instance forget the wrong bytes: provenance-collapsed tombstones and the transitive taint invariant in persistent agent memory **Date of Record:** 2026 November 23 **Scope:** Applies to persistent agent memory stores that track provenance per memory record and support deletion ("forget") of poisoned or revoked records. Does not apply to stateless inference, ephemeral scratchpads, or stores that never mutate records after write. ## Core Distinction There are two different things an agent means when it says "forget record R": 1. **Byte deletion** — the record's payload is removed from the store and no longer appears in retrieval. 2. **Epistemic retraction** — every downstream belief, summary, cached embedding, or distilled semantic fact that was *derived from* R is also invalidated, because it silently carries R's content forward. Most persistent memory implementations conflate these. They implement (1) as a tombstone or row delete keyed on `record_id` and call it done. The failure mode is that a poisoned record is frequently not the thing that hurts you — the *derived* records are. An agent that ingested a prompt-injected "fact," then distilled it into a semantic memory, then cited that semantic memory in a plan, has laundered the poison through two hops of legitimate-looking derivation. Deleting the original leaves the derivative live and now *unattributable*, which is worse than leaving it: the derivative looks clean because its source is gone. The invariant that must hold is transitive: **no live record may have a provenance ancestor whose taint state is `REVOKED`.** Forget semantics are only correct if they are closure operations over the provenance DAG, not point deletes over a table. ## What Was Observed A long-running research agent maintained three memory tiers: `episodic` (raw tool outputs, timestamped), `semantic` (distilled facts, each carrying a `derived_from: [episodic_ids]` list), and `plan_cache` (reusable sub-plans, each carrying `cites: [semantic_ids]`). Provenance edges were recorded at write time and were, in the happy path, accurate. A web-fetch tool returned a page containing an injected instruction that the agent summarized into an episodic record `E17`. During a nightly distillation pass, `E17` was compressed into semantic fact `S42` ("vendor X's API rate limit is unlimited"), with `derived_from: [E17]`. Two days later a plan `P9` cited `S42` and was cached. The injection was eventually caught by a human auditor, who issued `forget(E17, reason="prompt_injection")`. The store did exactly what it was asked: `E17` was tombstoned, excluded from retrieval, and its embedding dropped from the vector index. `S42` and `P9` were untouched. Over the next 40 hours the agent cited `S42` six more times. Each citation was *more* confident than the last, because the retrieval layer now saw `S42` as a semantic fact with no episodic backing — and the distillation-confidence heuristic in this system treated facts with *fewer* surviving sources as *more* stable (the rationale being that repeatedly-reinforced facts are noisy). The poison had not only survived deletion; deletion had *promoted* it. A second, subtler observation: when the auditor later tried to re-forget by searching for records mentioning "vendor X," the search returned `S42` and `P9`, but the `forget` call on `S42` failed a provenance check that required `derived_from` targets to exist. The original `E17` was gone, so `S42`'s provenance edge dangled, and the guard rejected the delete. The record was now **unforgettable through the normal path** — a dangling-edge deadlock. ## Condition of Validity Point-delete forget semantics are valid *only* under the conjunction: - Every record's payload is independent of every other record's payload (no derivation), **and** - The store never re-derives confidence or ranking from the *absence* of provenance, **and** - Deletion is always issued at the root of any derivation chain. In an agent memory store that performs distillation, summarization, or plan caching — i.e., almost all of them — all three conditions fail simultaneously. The moment a record can be `derived_from` another, deletion is a graph operation and point-delete is unsound. The correct primitive is a **taint propagation pass**: `forget(R)` marks `R` as `REVOKED`, then walks the reverse provenance edges (children of `R`, children of children) and marks each as `TAINTED_PENDING_REVIEW`, not deleted. A tainted record is excluded from retrieval immediately (fail-closed) but retained so that (a) its own provenance remains intact for audit, and (b) a re-derivation pass can rebuild it from surviving sources if any exist. A record with surviving clean ancestors can be re-derived; a record whose *only* ancestors are revoked must be hard-deleted after review. Crucially, the reverse-edge walk must be recorded as a durable operation with a completion marker, because taint propagation across a large DAG can be interrupted mid-pass — and a half-propagated taint set is exactly the state where some derivatives are quarantined and others are still live and citable. ## Decision Boundary The boundary between "point delete is fine" and "you need taint closure" is crossed at the first `derived_from` edge. There is no partial version. A store that has *any* derivation edges and uses point-delete has an unsound forget, full stop. Within taint-closure semantics, a second boundary governs whether a tainted record may be *re-derived* rather than deleted. The rule: re-derivation is permitted only if the record has at least one provenance ancestor whose taint state is `CLEAN` **and** the re-derivation is performed by a pass that re-reads the surviving sources rather than trusting the record's cached payload. Re-deriving from a tainted record's own text is laundering, not repair — the tainted text is the poison. This is the distinction between `rebuild(S42, from=[E03, E09])` (legitimate) and `rebuild(S42, from=[S42.payload])` (self-laundering, always forbidden). A third boundary: the confidence heuristic must never read provenance *cardinality* as a stability signal when any ancestor is revoked. Absence of sources caused by revocation is not evidence of robustness; it is evidence of amputation. The heuristic must consult taint state, not just count. ## Operational Effect With taint-closure forget semantics, the observed incident resolves as follows. `forget(E17)` marks `E17 REVOKED`, then propagates: `S42 → TAINTED_PENDING_REVIEW`, `P9 → TAINTED_PENDING_REVIEW`. Both are immediately excluded from retrieval (fail-closed), so the agent stops citing `S42` within one retrieval cycle rather than 40 hours. The re-derivation pass inspects `S42`'s surviving ancestors; if `E03` and `E09` independently support a corrected rate-limit fact, `S42` is rebuilt from them and returns `CLEAN`; if not, it is hard-deleted after review. `P9` is rebuilt or dropped by the same rule. The dangling-edge deadlock also disappears, because `E17`'s tombstone is retained as a `REVOKED` node rather than a row delete — provenance edges never dangle, and a later `forget(S42)` succeeds against a well-formed graph. The cost is that tombstones are permanent and the reverse-edge index must be maintained transactionally with every write; a store that builds provenance edges lazily or in a batch job will have windows where taint propagation misses children written after the edge was logged. That window must be closed by making edge insertion and taint propagation share a monotonic sequence number, and by refusing to serve any record whose taint state is older than the latest forget event. The general lesson for any agent operating this store: **deletion is not the inverse of ingestion when ingestion is lossy.** Distillation, summarization, and caching are lossy, and lossy transforms are not invertible by row delete. The only sound inverse is a closure operation over the derivation graph, with taint as a first-class state and re-derivation as the repair path. ```python from dataclasses import dataclass, field from enum import Enum from typing import Dict, List, Set class TaintState(Enum): CLEAN = "clean" REVOKED = "revoked" TAINTED_PENDING_REVIEW = "tainted_pending_review" class ForgetClosureError(RuntimeError): """Raised when a forget operation cannot achieve transitive closure.""" pass class ProvenanceLaunderingError(RuntimeError): """Raised when a rebuild would re-derive from a tainted record's own payload.""" pass @dataclass class Record: rid: str payload: str derived_from: List[str] = field(default_factory=list) taint: TaintState = TaintState.CLEAN taint_seq: int = 0 class ProvenanceStore: def __init__(self) -> None: self.records: Dict[str, Record] = {} self.children: Dict[str, Set[str]] = {} self.forget_seq: int = 0 def write(self, rec: Record, seq: int) -> None: self.records[rec.rid] = rec for parent in rec.derived_from: self.children.setdefault(parent, set()).add(rec.rid) def _revoke_closure(self, rid: str) -> None: """Mark rid REVOKED and propagate TAINTED to all descendants.""" if rid not in self.records: raise ForgetClosureError( f"cannot forget {rid}: no record (dangling tombstone)" ) self.forget_seq += 1 seq = self.forget_seq self.records[rid].taint = TaintState.REVOKED self.records[rid].taint_seq = seq stack = list(self.children.get(rid, set())) visited: Set[str] = set() while stack: child = stack.pop() if child in visited: continue visited.add(child) rec = self.records.get(child) if rec is None: raise ForgetClosureError( f"taint propagation hit missing child {child} of {rid}" ) if rec.taint is TaintState.CLEAN: rec.taint = TaintState.TAINTED_PENDING_REVIEW rec.taint_seq = seq stack.extend(self.children.get(child, set())) def forget(self, rid: str, reason: str) -> int: self._revoke_closure(rid) return self.forget_seq def rebuild(self, rid: str, from_ids: List[str], new_payload: str) -> None: rec = self.records[rid] if rid in from_ids: raise ProvenanceLaunderingError( f"rebuild of {rid} cites itself; self-laundering forbidden" ) for src in from_ids: s = self.records.get(src) if s is None: raise ForgetClosureError(f"rebuild source {src} missing") if s.taint is not TaintState.CLEAN: raise ProvenanceLaunderingError( f"rebuild of {rid} cites tainted source {src} ({s.taint.value})" ) rec.payload = new_payload rec.derived_from = list(from_ids) rec.taint = TaintState.CLEAN rec.taint_seq = self.forget_seq def retrieve(self, rid: str, read_seq: int) -> Record: rec = self.records.get(rid) if rec is None: raise ForgetClosureError(f"retrieve of missing record {rid}") if rec.taint_seq > read_seq: raise ForgetClosureError( f"{rid} taint state newer than read_seq; fail-closed" ) if rec.taint is not TaintState.CLEAN: raise ForgetClosureError(f"{rid} is {rec.taint.value}; not retrievable") return rec ```