# Which invariants prevent tombstone resurrection in scoped-retention memory APIs during GDPR erasure **Date of Record:** 2026 November 29 **Scope:** Applies to agent memory subsystems exposing `read`/`write`/`forget` tool APIs where records carry per-scope retention policies and erasure must be provable. Does not cover raw vector-index internals or storage-layer encryption-at-rest mechanics. ## Core Distinction The failure this record isolates is not "erasure failed" in the sense of a record surviving in the primary store. It is **tombstone resurrection**: an erasure request correctly deletes the canonical record, writes a tombstone, and returns success—yet a *derived* artifact (an episodic summary, a semantic distillation, a cached retrieval shard, an embedding neighbor) still carries the erased content and is later re-materialized into the live scope by a downstream consolidation pass. The distinction that matters operationally: **deletion of the source is not deletion of the closure of the source.** The invariant that prevents resurrection is not "forget removes the row" but "forget invalidates the transitive derivation graph and every scope whose retention policy would otherwise re-admit the content." The non-obvious part: agents themselves generate the resurrecting artifact. A summarizer agent that ran before erasure produced a semantic memory whose text no longer literally matches the erased record, so a naive content-hash or exact-match scrubber passes it through. The erasure is compliant against the *string* and non-compliant against the *subject*. ## What Was Observed A memory API with three scopes—`episodic` (30-day retention), `semantic` (indefinite, subject to erasure), and `cache` (1-hour TTL, best-effort). A `forget(subject_id, reason="gdpr_art17")` call executed the following trace: 1. `forget` resolved `subject_id` to N episodic records and M semantic records via the scope's subject index. 2. It deleted all N+M canonical records and wrote a tombstone `{subject_id, erased_at, scope_set}`. 3. It returned `{"erased": N+M, "tombstone": }`. 4. **It did not walk the derivation edges.** A consolidation job had earlier run `episodic → semantic` distillation, emitting a semantic record whose `derived_from` pointers referenced the now-deleted episodic records but whose own `subject_id` was set to the *summarizer's* scope, not the data subject's. 5. That distilled record survived step 2 because its subject index entry pointed elsewhere. 6. On the next retrieval, the agent read the semantic scope, matched the distilled record on a paraphrased query, and re-emitted the erased facts into its working context. The erasure was reported green. The subject's data was live again within one retrieval cycle. The tombstone existed and was never consulted, because retrieval filtered on `subject_id` match, and the resurrected record's `subject_id` was the summarizer's. ## Condition of Validity The resurrection is only possible under a specific conjunction, and the guardrail only needs to hold when all three hold: - **Derivation without subject propagation.** A downstream writer (distiller, summarizer, embedder) emits a record that is *informationally* about subject S but *indexed* under a different subject. If every derived record inherits `subject_id` from its sources, the tombstone match catches it and the failure cannot occur. - **Retention policy divergence across scopes.** The `semantic` scope's indefinite retention means the derived record has no TTL to expire it before next retrieval. Under a scope where the derived record's TTL is shorter than the erasure-verification window, resurrection is bounded and self-healing—so the invariant is *not* required there. - **Tombstone checked at write-time only, not read-time.** If retrieval consults the tombstone set and filters any record whose `derived_from` closure intersects an erased subject, resurrection is blocked at read. If the tombstone is only enforced at write, the surviving derived record is never re-checked. When any one of these fails to hold, the closure invariant is unnecessary. When all three hold—the common configuration for long-lived semantic memory—resurrection is not a race but a *deterministic* consequence of the next consolidation or retrieval pass. ## Decision Boundary The boundary is: **does `forget` operate on records or on the derivation closure?** - **Record-scoped forget** (delete rows matching `subject_id`, write tombstone, return count) is correct only when derivation always propagates subject identity. Treat it as valid for `episodic` and `cache` scopes where records are leaf artifacts. - **Closure-scoped forget** is required for any scope that ingests derived records: compute the transitive `derived_from` closure of every erased record, mark every node in that closure with an `erased_via` edge to the tombstone, and — critically — make retrieval filter on tombstone-closure intersection, not on `subject_id` equality. The decision an operator must record: if a derived record's subject cannot be resolved to the erased subject (because the derivation dropped the link), the record is **unerasable-by-closure** and must be quarantined to a scope whose retention is bounded by the erasure-verification window, or destroyed wholesale. Silently leaving it in indefinite retention is the failure. The boundary is not "did we delete it" but "can we prove no live record's derivation closure reaches the tombstone." ## Operational Effect Concretely, the guardrail changes three things: 1. `forget` returns not a count but a closure certificate: `{erased_nodes, closure_nodes_marked, unerasable_quarantined, tombstone_id}`. A non-empty `unerasable_quarantined` is a hard signal, not a warning. 2. Every derived-record writer must either propagate `subject_id` or register a `derived_from` edge; a writer that does neither is rejected at write-time by the memory API, because it would create an unerasable node. 3. Retrieval applies a tombstone-closure filter as a read-time invariant, so even a stale derived record that slipped through is masked rather than served. The net effect: erasure becomes a closure operation with a provable boundary, and the agent's own consolidation passes can no longer launder erased data back into context under a different subject label. ```python from dataclasses import dataclass, field from typing import Iterable class ErasureClosureViolation(RuntimeError): """Raised when a forget() cannot prove the derivation closure is erased.""" @dataclass class MemoryRecord: record_id: str subject_id: str derived_from: tuple[str, ...] = () quarantined: bool = False @dataclass class MemoryStore: records: dict[str, MemoryRecord] = field(default_factory=dict) tombstones: dict[str, set[str]] = field(default_factory=dict) # subject -> erased record ids def closure_of(self, seed_ids: Iterable[str]) -> set[str]: seen: set[str] = set() stack = list(seed_ids) while stack: rid = stack.pop() if rid in seen: continue seen.add(rid) rec = self.records.get(rid) if rec: stack.extend(rec.derived_from) return seen def forget(self, subject_id: str) -> dict: direct = {r.record_id for r in self.records.values() if r.subject_id == subject_id} closure = self.closure_of(direct) unerasable = { r.record_id for r in self.records.values() if r.record_id in closure and r.subject_id != subject_id and not r.derived_from } if unerasable: # A closure member has no derivation edge back to the subject: # it cannot be proven erased and must be quarantined, never served. for rid in unerasable: self.records[rid].quarantined = True raise ErasureClosureViolation( f"unerasable closure nodes for subject {subject_id}: {sorted(unerasable)}" ) for rid in closure: self.records.pop(rid, None) self.tombstones[subject_id] = closure return {"erased_nodes": len(closure), "tombstone": subject_id} def retrieve(self, query_subject: str) -> list[MemoryRecord]: erased = set().union(*self.tombstones.values()) if self.tombstones else set() out = [] for rec in self.records.values(): if rec.quarantined: continue if self.closure_of([rec.record_id]) & erased: continue # read-time tombstone-closure filter out.append(rec) return out ```