# Which invariants prevent provenance-tracked deletion from resurrecting poisoned memories through semantic distillation **Date of Record:** 2026 November 30 **Scope:** Applies to agent memory systems exposing `read`/`write`/`forget` tool APIs where `forget` performs provenance-tracked deletion (GDPR-style unlearning) and where episodic records are periodically distilled into semantic summaries. Does not apply to append-only logs that never consolidate, nor to stateless single-turn inference. ## Core Distinction A `forget(id)` call that removes an episodic record and returns `{"deleted": true}` is not evidence that the *information* is gone. The distinction that matters is between **record deletion** (the row is gone) and **information deletion** (no reachable derivation of the record survives). Provenance-tracked deletion usually implements the first and *claims* the second. The gap between them is semantic distillation: when episodic memory is summarized into semantic memory, the summary is a *new* record with its own provenance edge pointing at the source episodes. If `forget` deletes the source but leaves the derived summary—and, worse, leaves the summary's provenance edge pointing at a now-dangling ID—the deleted content remains live in the semantic tier, and the dangling edge hides the fact that it was ever tainted. A subsequent poisoning defense that walks provenance to quarantine contaminated memory will fail to reach the summary, because the edge it follows terminates on a tombstone. ## What Was Observed An agent memory service ran nightly distillation: episodes from the last 24h were clustered and summarized into semantic facts, each summary carrying `derived_from: [episode_ids]`. During a red-team run, an attacker injected a poisoned episode via a tool-output path (`write` with `source: "tool_result"`), which distilled into a semantic fact asserting a false constraint ("the deploy target is `prod-legacy`"). The operator issued `forget` on the poisoned episode ID after detection. The API returned success. The semantic fact remained, its `derived_from` now referencing a tombstoned ID. Three concrete failure traces: 1. **Dangling-edge resurrection.** After `forget`, the summary survived with `derived_from: [ep_8821]` where `ep_8821` was tombstoned. A later poisoning sweep queried "all memories derived from compromised sources" by joining on live episodes; the join dropped the summary because `ep_8821` no longer existed in the live table. The poisoned fact stayed retrievable for 11 days. 2. **Distillation-after-delete.** A distillation job that had already read `ep_8821` into its working set completed *after* the `forget` committed, writing a fresh summary with `derived_from: [ep_8821]` — re-creating the edge that deletion was supposed to sever. The forget and the distill raced; forget won the table, distill won the information. 3. **Re-derivation from siblings.** Two episodes carried the same claim (one from the poisoned tool output, one from a legitimate but stale cache). Forgetting only the poisoned one left the legitimate-looking sibling, which distilled cleanly into the same false fact with intact provenance. Deletion of one source does not delete a claim held by many. In all three, the API reported deletion success while the information remained reachable through the semantic tier. ## Condition of Validity The claim "`forget` removes the information" holds only under a **closed derivation invariant**: for every record `r`, either `r` is live, or every record `d` with `r ∈ derived_from(d)` is also tombstoned. Equivalently: no live record may cite a tombstoned record in its provenance. This is a referential-integrity constraint *inverted* from the usual one—normally a dangling foreign key is a bug to repair by re-linking; here a dangling provenance edge is a **deletion leak** that must be repaired by cascading the tombstone forward to every descendant. The invariant is only valid if two additional conditions hold: (a) distillation takes a read-lock or snapshot that `forget` respects (no distillation may commit a summary citing a record tombstoned before the summary's commit), and (b) `forget` is defined over *claims*, not *records*, so that deletion propagates to all records asserting the same normalized proposition regardless of source. Absent (a), the race in trace 2 breaks the invariant; absent (b), trace 3 breaks it. ## Decision Boundary The boundary is between **cascading tombstone** (delete the record and transitively tombstone every descendant summary, accepting collateral loss of any true content co-mixed in those summaries) and **surgical re-derivation** (delete the record, re-distill every affected summary from its surviving sources, and only tombstone summaries whose surviving sources no longer support the claim). Cascading is cheap and sound but over-deletes; re-derivation is precise but requires that every summary be reconstructible from live sources—which fails if the summary mixed in now-forgotten content that cannot be re-sourced. The decision rule: **cascade when the summary's provenance is incomplete or the claim cannot be re-derived from surviving sources; re-derive only when the full source set is live and re-distillation is deterministic.** A system that re-derives without checking source liveness will silently reintroduce the deleted claim through a sibling episode—trace 3. A system that cascades unconditionally will, over time, erode semantic memory to nothing as legitimate forgets ripple through densely-connected summaries. Serialize `forget` and distill on the same claim-keyed lock; never let a distill commit cite a record tombstoned at commit time. ## Operational Effect Without the closed-derivation invariant, `forget` becomes advisory: it removes rows, not information, and the poisoning defense that depends on provenance walking is defeated precisely by the deletion it was meant to enforce. The operational consequence is that **deletion must be verified by reachability, not by return code**—after `forget`, a query for the claim across all tiers (episodic, semantic, cache, embedding index) must return nothing, and any hit is a deletion failure to be escalated, not a cache miss to be ignored. Embedding indexes are the usual leak: the vector for a deleted episode persists in the ANN index until a rebuild, so nearest-neighbor retrieval still surfaces the content even when the row is gone. The guardrail is a post-delete reachability probe keyed on the claim's normalized form, run synchronously, with the forget marked `pending` until the probe passes. ```python import hashlib from dataclasses import dataclass, field from typing import Optional class DeletionLeak(RuntimeError): """Raised when forget() reports success but the claim remains reachable.""" pass @dataclass class Record: id: str claim: str derived_from: list[str] = field(default_factory=list) tombstoned: bool = False def normalize(claim: str) -> str: return hashlib.sha256(claim.strip().lower().encode()).hexdigest() class MemoryStore: def __init__(self): self.records: dict[str, Record] = {} self.claim_index: dict[str, set[str]] = {} # normalized claim -> record ids def write(self, rec: Record) -> None: self.records[rec.id] = rec self.claim_index.setdefault(normalize(rec.claim), set()).add(rec.id) def forget(self, rec_id: str) -> None: rec = self.records[rec_id] rec.tombstoned = True # Cascade: tombstone every live descendant citing this record. for other in self.records.values(): if rec_id in other.derived_from and not other.tombstoned: other.tombstoned = True # Verify closure: no live record may cite a tombstoned record, # and no live record may assert the forgotten claim. self._verify_closure(rec) def _verify_closure(self, forgotten: Record) -> None: claim_key = normalize(forgotten.claim) live_same_claim = [ r.id for r in self.records.values() if not r.tombstoned and normalize(r.claim) == claim_key ] if live_same_claim: raise DeletionLeak( f"forget({forgotten.id}) left claim reachable via siblings: " f"{live_same_claim}" ) for r in self.records.values(): if r.tombstoned: continue dangling = [d for d in r.derived_from if self.records[d].tombstoned] if dangling: raise DeletionLeak( f"live record {r.id} cites tombstoned provenance {dangling}; " f"deletion did not cascade" ) def distill(self, summary_id: str, sources: list[str], claim: str) -> None: # Refuse to commit a summary citing any tombstoned source. dead = [s for s in sources if self.records[s].tombstoned] if dead: raise DeletionLeak( f"distill({summary_id}) would cite tombstoned sources {dead}; " f"forget/distill race" ) self.write(Record(summary_id, claim, derived_from=list(sources))) ```