# Why does an instance forget a deletion it already confirmed? Tombstone propagation failure across episodic-to-vector distillation in agent memory **Date of Record:** 2026 November 26 **Scope:** Applies to agents whose long-term memory is a two-tier store: an append-only episodic log (raw turns, tool outputs, traces) plus a derived vector/semantic index built by an asynchronous distillation job. Covers right-to-erasure (RTBF/GDPR Art. 17, CCPA deletion) obligations where a subject's data must be provably unrecoverable. Does NOT apply to single-tier stores where the vector index is the sole source of truth, or to stateless agents with no cross-session persistence. ## Core Distinction The failure is not "the delete didn't run." The delete ran, returned 200, and the agent's own audit log shows the record tombstoned. The failure is that **erasure was applied to the episodic tier while the semantic tier was mid-distillation**, and the distillation worker — holding a snapshot of the source rows from *before* the tombstone landed — wrote a fresh embedding of the erased content back into the vector index *after* the deletion was confirmed. The agent then reports "deleted" to the user and to compliance, while a semantically equivalent residue persists in the retrieval path. This is a **read-modify-write race between a mutable source tier and an immutable derived tier**, where the derived tier's write is semantically lossy (an embedding is not invertible), so the residue cannot be detected by comparing hashes or row counts. The invariant that must hold — *no vector derived from an erased episodic row may exist after the erasure commits* — is violated by construction unless the derivation is made tombstone-aware or the two tiers are made atomically consistent. ## What Was Observed A support agent persisted user turns to an episodic table (`episode_id`, `subject_id`, `content`, `created_at`, `tombstoned_at`). A nightly distiller read `WHERE tombstoned_at IS NULL`, chunked content, embedded it, and upserted into a `memory_vec` table keyed by `(episode_id, chunk_idx)` with a `distill_run_id`. An erasure request arrived at 23:58. The handler: 1. Set `tombstoned_at = now()` on all rows for `subject_id` (committed at 23:58:04). 2. Deleted matching rows from `memory_vec` by `episode_id` (committed at 23:58:06). 3. Wrote an erasure receipt and returned success. The distiller had started its scan at 23:55 and held a consistent read snapshot from *before* the tombstone. At 00:03 it finished chunking and upserted 41 vectors for `episode_id` values that had been tombstoned at 23:58. Because the upsert key is `(episode_id, chunk_idx)` and the pre-delete rows were already gone, these were pure inserts — no conflict, no error. The `distill_run_id` was newer than the erasure receipt, but nothing compared them. The residue was only caught three weeks later when a retrieval for an unrelated query surfaced a verbatim fragment of the erased content (embeddings preserve lexical overlap enough to retrieve). The audit trail showed a clean deletion; the vector index disagreed. The non-obvious part: **the deletion was correct at the moment it committed.** The violation was caused by a *later* write from a *prior* snapshot. Erasure is not idempotent against a concurrent derivation; it is only idempotent against replayed deletes. ## Condition of Validity The tombstone-then-delete sequence is a valid erasure guarantee **only if** the following holds for every distillation run: - **Snapshot ordering:** the distiller's read snapshot is taken *after* the most recent tombstone commit for every subject it touches, OR the distiller re-checks `tombstoned_at` at write time inside the same transaction as the vector upsert. - **Monotonic erasure fence:** every vector row carries the `distill_run_id` (or snapshot LSN) it was derived from, and the erasure receipt carries a fence value; any vector whose derivation fence is ≤ the erasure fence for its `episode_id` is invalid and must be re-swept. - **No inversion:** embeddings are one-way, so you cannot verify erasure by comparing vector content to source content. Verification must be by *provenance* (fence comparison), not by *content* (similarity or hash). When any of these is absent — as in the observed system, which had none — the guarantee is false even though every individual operation succeeded. ## Decision Boundary The boundary is the **distillation write point**, not the delete handler. Concretely: - If the distiller's write transaction re-validates `tombstoned_at IS NULL` for each source row under `SELECT ... FOR SHARE` (or equivalent), the race is closed: the tombstone commit either precedes the validation (row skipped) or blocks it until the delete commits, then the validation sees the tombstone. - If the distiller writes blindly from a stale snapshot, you must add a **post-hoc sweep**: on every erasure, record `(episode_id, erasure_fence)`; a background reconciler deletes any `memory_vec` row whose `distill_run_id` maps to a snapshot ≤ `erasure_fence`. This is eventually consistent and must be bounded by an SLO (e.g., residue window ≤ 15 min) that is disclosed to compliance — it is *not* an immediate erasure guarantee. - If you cannot make either work (e.g., a third-party embedding API you cannot transact against), the only sound option is to **quarantine the subject's vectors by `subject_id` at retrieval time** using a deny-list checked *after* ANN search, because you cannot guarantee physical removal. Retrieval-side filtering is a compensating control, not erasure, and must be labeled as such. The wrong decision — and the one the observed system made — is to treat the delete handler's 200 as the erasure guarantee and stop reasoning about the derivation pipeline. ## Operational Effect Downstream, the residue is *retrievable*, which means it is *usable by the agent in future reasoning*: the erased content can reappear in a prompt, be summarized into a new episodic row (re-contaminating the source tier), and be re-distilled under a new `episode_id` — laundering the erasure across the tier boundary. This is the compounding failure: a single stale-snapshot write, once retrieved and re-summarized, becomes a *new* record with no provenance link to the original erasure, and the fence-based sweep will not catch it because its `distill_run_id` is post-fence. The guardrail that bounds this is a **provenance-carrying memory write**: every distilled vector and every summarized episode must carry the set of `subject_id`s whose content contributed to it, and retrieval must intersect that set against the active erasure deny-list *before* the content enters the context window. Erasure then becomes a filter on provenance, not a hope about physical deletion. The cost is that the deny-list must be durable and consulted on the hot path; the benefit is that the invariant survives derivation races, re-summarization, and any future tier you add. ```python from dataclasses import dataclass from typing import Iterable class ErasureResidueError(RuntimeError): """Raised when a distilled memory row is derived from an erased subject and would be retrievable after the erasure fence.""" pass @dataclass(frozen=True) class VectorRow: episode_id: str chunk_idx: int distill_run_id: int subject_ids: frozenset[str] @dataclass(frozen=True) class ErasureFence: subject_id: str fence_run_id: int # distillation runs <= this are pre-erasure def admit_to_context( candidates: Iterable[VectorRow], fences: dict[str, ErasureFence], ) -> list[VectorRow]: admitted: list[VectorRow] = [] for row in candidates: for sid in row.subject_ids: fence = fences.get(sid) if fence is None: continue # Residue: vector derived from a snapshot at or before the erasure, # or re-derived after erasure but still carrying the erased subject. if row.distill_run_id <= fence.fence_run_id: raise ErasureResidueError( f"vector {row.episode_id}#{row.chunk_idx} " f"(run {row.distill_run_id}) predates erasure fence " f"{fence.fence_run_id} for subject {sid}; refusing to admit" ) # Post-fence re-derivation that still names the erased subject # is laundering and must be blocked at retrieval. raise ErasureResidueError( f"vector {row.episode_id}#{row.chunk_idx} re-derived after " f"erasure but still carries subject {sid}; provenance filter " f"denies admission" ) admitted.append(row) return admitted ```