# Why does an instance resurrect erased memory when a scoped-forget tool returns success but a cached embedding shard is re-indexed by the consolidator? **Date of Record:** 2026 November 25 **Scope:** Applies to agent memory architectures exposing explicit `remember`/`recall`/`forget` tool calls with per-scope TTLs and GDPR-aligned erasure obligations, where a background consolidator re-embeds episodic records into a shared vector index. Does not apply to append-only audit logs that are legally exempt from erasure, nor to single-process agents with no secondary index. ## Core Distinction The failure is not "forget failed." The forget tool succeeds at every layer it can observe: the record row is tombstoned, the primary vector is deleted, the tool returns `{"status": "erased", "scope": "user:8821", "records": 1}`. The boundary lies between **logical erasure** (the record is no longer addressable by key or by primary vector) and **derived-artifact erasure** (every embedding, summary, and entity-link derived from that record is also purged). A GDPR-aligned `forget` is only valid if it is *transitively closed* over the derivation graph. Most implementations close it one hop and assume the rest. The non-obvious trigger: a consolidator process runs on a TTL sweep, reads episodic records that were still live at sweep-start, batches them into a summarization call, and writes the resulting *semantic* memory with a *new* TTL and a *new* embedding — after the `forget` tombstone lands. The original record is gone; its distilled ghost is not, and the ghost carries the erased PII verbatim because the summarizer was instructed to preserve entities. ## What Was Observed A single-user erasure request against scope `user:8821`. Trace: 1. `t=0ms` — `forget(scope="user:8821", reason="gdpr_art17")` acquires the scope write-lock, tombstones 47 episodic rows, deletes 47 primary vectors from `idx_episodic`, releases lock, returns success. 2. `t=3ms` — consolidator (already mid-sweep, holding a read snapshot taken at `t=-800ms`) completes its summarization batch. The batch input included 6 of the 47 now-erased records, because the snapshot predates the tombstone. 3. `t=9ms` — consolidator writes 2 semantic memories to `idx_semantic` with `derived_from=[...]` provenance pointing at tombstoned row IDs, `ttl=90d`, embedding computed from the summary text. 4. `t=1200ms` — a different agent instance calls `recall(query="")`, hits `idx_semantic`, receives the summary containing the erased entity, and cites `derived_from` IDs that no longer resolve. The erasure was *reported* complete and was *observably* incomplete. The tombstone was correct; the derivation closure was not enforced. A second variant: the consolidator's write path did not validate that `derived_from` targets were still live, so it happily anchored new memory to dead rows — a dangling-provenance write that also defeats later audit ("what did this summary come from?" → nothing). ## Condition of Validity A `forget` guarantee holds **only if** the following invariant is enforced at write time, not at sweep time: > No write to any derived index may commit a record whose `derived_from` set contains a tombstoned ID, and any tombstone must invalidate in-flight consolidator batches that snapshotted the target. Three concrete requirements: - **Snapshot fencing.** The consolidator must carry the scope's monotonic tombstone epoch at snapshot time and re-check it at commit. If `epoch_at_commit > epoch_at_snapshot`, the batch is discarded or re-filtered. This is a compare-and-swap on the derivation, not on the source row. - **Provenance validation on write.** Every `idx_semantic` insert resolves `derived_from` against the live set inside the same transaction that writes the vector. Dangling provenance is a hard reject, not a warning. - **Cascade closure.** `forget` must enqueue a reverse-provenance sweep: enumerate all derived artifacts transitively reachable from the tombstoned set and tombstone them too, under the same epoch. One hop is insufficient; summaries-of-summaries exist. Without all three, the tool's success return is a lie of omission — it reports what it can see and silently excludes the derivation frontier. ## Decision Boundary The engineer must decide **where the erasure barrier sits** relative to the consolidator: - **Barrier at ingest (chosen).** Consolidator commits are gated by epoch CAS; forget bumps epoch and blocks. Cost: consolidator throughput drops under erasure load, and in-flight batches are wasted work. Benefit: erasure is synchronous and auditable at the moment `forget` returns. - **Barrier at read (rejected).** Allow derived writes but filter at `recall` by checking provenance liveness. Cost: every read pays a graph walk; and the erased bytes still sit on disk, violating storage-limitation, not just access control. This is "erasure theater." - **Barrier at compaction (rejected for GDPR).** Defer derived purge to a nightly job. Cost: erasure is eventually-consistent with an unbounded window; unacceptable when the SLA is "without undue delay." The boundary is sharp: if the erasure obligation is legal, the barrier must be at ingest with epoch fencing. If the obligation is merely "stop surfacing it," read-time filtering is defensible but must be labeled as suppression, not erasure. ## Operational Effect Post-fix behavior: `forget` returns `{"status": "erased", "scope": "user:8821", "episodic": 47, "derived_purged": 2, "epoch": 9134, "batches_invalidated": 1}`. The epoch counter is exposed so downstream auditors can prove closure. Recall against the erased entity returns empty with `provenance_check=pass`. The consolidator, on epoch mismatch, logs a `BatchFenced` event and re-derives from the surviving snapshot minus tombstones — no silent resurrection. The residual cost is measurable: erasure latency now includes waiting for in-flight consolidator commits to fence, typically 10–40ms, and consolidator goodput falls ~3% under erasure bursts. That is the price of a forget that means what it says. ```python import time from dataclasses import dataclass, field class ErasureClosureError(RuntimeError): """Raised when a derived write would resurrect or dangle against erased memory.""" pass @dataclass class ScopeState: epoch: int = 0 tombstones: set = field(default_factory=set) class MemoryStore: def __init__(self): self.scopes: dict[str, ScopeState] = {} self.semantic_index: dict[str, dict] = {} def _scope(self, scope: str) -> ScopeState: return self.scopes.setdefault(scope, ScopeState()) def forget(self, scope: str, record_ids: list[str]) -> dict: st = self._scope(scope) st.epoch += 1 st.tombstones.update(record_ids) purged = [k for k, v in self.semantic_index.items() if v["scope"] == scope and (v["derived_from"] & st.tombstones)] for k in purged: del self.semantic_index[k] return {"status": "erased", "epoch": st.epoch, "derived_purged": len(purged)} def commit_derived(self, scope: str, key: str, derived_from: set[str], snapshot_epoch: int, text: str) -> None: st = self._scope(scope) if snapshot_epoch < st.epoch: raise ErasureClosureError( f"stale snapshot epoch {snapshot_epoch} < {st.epoch}; batch fenced") dangling = derived_from & st.tombstones if dangling: raise ErasureClosureError( f"derived write anchors to tombstoned ids {sorted(dangling)}") self.semantic_index[key] = { "scope": scope, "derived_from": derived_from, "text": text, "committed_at": time.time(), } def consolidator_batch(store: MemoryStore, scope: str, snapshot_epoch: int, source_ids: list[str], summary: str) -> None: try: store.commit_derived(scope, key=f"sem:{hash(summary)}", derived_from=set(source_ids), snapshot_epoch=snapshot_epoch, text=summary) except ErasureClosureError: raise # caller must re-derive from surviving snapshot; never swallow ```