# How does an instance detect tombstone collisions when right-to-erasure deletes overlap shared semantic memory in a persistent agent store **Date of Record:** 2026 November 20 **Scope:** Applies to persistent agent memory stores that support subject-scoped erasure (GDPR Art. 17 / CCPA delete) where derived semantic memory is shared across multiple subjects or sessions. Does not apply to per-session ephemeral context windows, nor to stores where every memory row has exactly one subject owner and no cross-subject derivation. ## Core Distinction The distinction that matters is between *provenance erasure* and *content erasure*. A naive erasure implementation deletes rows whose `subject_id` matches the requester. But persistent agent stores do not keep raw episodic records only—they distill episodic traces into semantic summaries, embeddings, and consolidated facts. A single consolidated semantic fact (e.g., "user prefers async standups") may be derived from ten episodic events belonging to three different subjects, or may have been promoted into a shared "team context" memory that carries no per-subject attribution at all. The failure mode is not "the delete didn't run." The failure mode is that the delete runs, succeeds by its own accounting, and silently leaves the erased subject's information recoverable through a *derived* memory whose provenance link was severed or never recorded. The instance then reports erasure-complete while the semantic layer still encodes the erased data. Detecting this requires the agent to distinguish "row deleted" from "information no longer reconstructable from the store." ## What Was Observed A long-running research agent maintained two memory tiers: an episodic log (append-only, per-event, `subject_id` on every row) and a semantic consolidation tier written by a nightly distillation job. The distillation job merged episodic events across subjects into topic-clustered summaries, storing `source_event_ids` as a JSON array. When an erasure request arrived for subject S, the erasure routine: 1. Deleted all episodic rows where `subject_id = S`. 2. Deleted all semantic rows where `subject_id = S`. Step 2 was mostly a no-op because the distillation job stamped consolidated rows with `subject_id = NULL` (they were "shared") and instead recorded provenance only in `source_event_ids`. After step 1, those source IDs pointed to rows that no longer existed. The `source_event_ids` array became a list of dangling references—unresolvable, and therefore un-auditable. The observable symptom appeared weeks later during a retrieval probe: a query about S's project returned a consolidated summary containing a verbatim phrase S had used. The summary's `source_event_ids` were all dangling. No live row referenced S. The store's erasure log said "complete." The information was still present. Two secondary observations: - **Distillation races erasure.** If erasure ran concurrently with the nightly distillation job, the job could read episodic rows for S *before* the delete and write a consolidated row *after* the delete, re-materializing erased content with no provenance link to the (now-deleted) source. The window was small but reproducible under load. - **Embedding residue.** Even when the consolidated text was rewritten to remove the phrase, the row's embedding vector was not recomputed. Cosine probes still surfaced the row for queries semantically close to the erased content—a form of erasure that is textually complete but vectorially incomplete. The instance had no mechanism to detect any of this. Its erasure verifier only checked `COUNT(*) WHERE subject_id = S = 0`, which was trivially true because the derived rows never carried that column. ## Condition of Validity The guardrail below is valid only when the following hold. If any fails, the detection is unsound and must be treated as advisory: - Every derived memory row records a *resolvable* provenance set at write time (`source_event_ids` referencing live rows, or a content hash of the source set). - Erasure is serialized against distillation via a shared lock, or distillation is required to re-check erasure tombstones before commit. - The store maintains an erasure tombstone ledger: a durable set of `(subject_id, erased_at, content_fingerprints)` that survives the deletion of the rows themselves. - Embeddings are recomputed on any text mutation, or the store can prove the embedding is not invertible to erased content within its retrieval threshold. Absent tombstones, the instance cannot distinguish "this derived row never contained S" from "this derived row contained S and its source was deleted." That distinction is the entire detection problem. ## Decision Boundary The boundary is: **a derived memory is considered erased only if every element of its provenance set is either (a) still live and attributable to a non-erased subject, or (b) covered by a tombstone fingerprint that matches its content.** A dangling provenance reference with no matching tombstone is a *collision*—an unresolvable state that must block the erasure-complete assertion. The instance must therefore take one of three actions per derived row at erasure time: 1. **Rewrite**: if provenance resolves to a mix of erased and live subjects, re-distill from the live sources only, recompute embedding, and record the rewrite. 2. **Tombstone**: if provenance is fully erased, delete the row and write a content fingerprint into the tombstone ledger so future distillation cannot re-materialize it. 3. **Quarantine**: if provenance is dangling and no tombstone matches, halt and escalate—do not report complete. The non-obvious part: step 3 must fire *before* the erasure-complete response is emitted. The default behavior of "delete matching rows, return 200" is precisely the failure. The instance must run a *post-delete provenance sweep* over all derived rows whose `source_event_ids` intersect the erased set, and refuse to acknowledge completion while any sweep result is unclassified. ## Operational Effect With the sweep and tombstone ledger in place, erasure latency rises from O(rows for subject) to O(derived rows touching subject), which for a heavily consolidated store can be an order of magnitude more work—but the erasure-complete assertion becomes *sound*: it now means "no live row, and no re-materializable derived row, encodes the erased subject's content above the retrieval threshold." The tombstone ledger also closes the distillation race: the nightly job must check each candidate consolidated row's content fingerprint against the tombstone set before commit, and drop any row whose fingerprint matches an erased subject's tombstone. This converts a silent re-materialization into a no-op. The residual risk the instance must still disclose: embeddings computed before an erasure and cached elsewhere (e.g., in a vector index replica) are not covered by the sweep. The invariant "erased" is therefore bounded to *this store's live and derived tiers*, not to downstream caches—and the erasure log must say so explicitly rather than asserting unconditional completion. ```python import hashlib from dataclasses import dataclass, field class ErasureCollisionError(RuntimeError): """Raised when a derived memory's provenance cannot be resolved post-erasure.""" @dataclass class DerivedMemory: row_id: str text: str source_event_ids: list[str] subject_id: str | None = None def content_fingerprint(self) -> str: return hashlib.sha256(self.text.encode("utf-8")).hexdigest() @dataclass class Store: live_events: dict[str, str] = field(default_factory=dict) # event_id -> subject derived: dict[str, DerivedMemory] = field(default_factory=dict) tombstones: set[str] = field(default_factory=set) # content fingerprints def erase_subject(store: Store, subject_id: str) -> dict: erased_event_ids = {eid for eid, sid in store.live_events.items() if sid == subject_id} for eid in erased_event_ids: del store.live_events[eid] unclassified: list[str] = [] for row in list(store.derived.values()): touches = erased_event_ids.intersection(row.source_event_ids) if not touches: continue resolves = any(eid in store.live_events for eid in row.source_event_ids) if resolves: continue # rewrite path is safe; leave for re-distillation fp = row.content_fingerprint() if fp in store.tombstones: del store.derived[row.row_id] else: unclassified.append(row.row_id) if unclassified: raise ErasureCollisionError( f"erasure for subject {subject_id!r} left {len(unclassified)} derived rows " f"with dangling provenance and no matching tombstone: {unclassified}" ) return {"subject_id": subject_id, "status": "complete", "scope": "live+derived tiers only"} def distill_and_commit(store: Store, candidate: DerivedMemory) -> None: fp = candidate.content_fingerprint() if fp in store.tombstones: return # distillation race guard: erased content must not re-materialize store.derived[candidate.row_id] = candidate ```