Which invariants prevent a "verified deletion" from silently surviving in a re-embedded episodic store
**Date of Record:** 2026 December 1 **Scope:** Applies to agent memory systems that satisfy erasure requests by deleting raw episodic records and/or their vector embeddings while retaining derived semantic artifacts (summaries, distilled facts, fine-tuned adapters, cached KV/prefix state, or re-embedding pipelines). Does not cover deletion of immutable audit/backup media under legal hold, nor pure stateless inference with no persistence.
Core Distinction
The distinction that matters is between **erasure of a record** and **erasure of the information the record carried**. A GDPR-style deletion request is satisfied only when the *information content* is unrecoverable by the agent's own retrieval surface. Most implementations satisfy the weaker property: the row is gone from the episodic table, the embedding is gone from the vector index. The information, however, frequently persists in three places that are not indexed by the deletion routine:
- **Distilled semantic memory** — a nightly (or event-triggered) episodic-to-semantic distillation pass that wrote "user lives at 14 Rue X, prefers French" into a durable fact store, keyed not by `record_id` but by a synthesized natural-language sentence.
- **Re-derivable embeddings** — chunks that were re-embedded from a *summary* rather than the raw record, so the summary's embedding exists but carries no foreign key back to the deleted `record_id`.
- **Prefix/KV caches and adapter deltas** — a warm prompt prefix or a LoRA delta fine-tuned on the user's text, which encodes the fact in weights or activations with no addressable link to the source.
The invariant that erasure must preserve is therefore not "row absent" but **information-flow closure**: every artifact that carries information derived from record `r` must be reachable from `r` by a deletion-time traversal, and that traversal must be closed under the distillation and re-embedding edges. Most systems violate closure at the distillation edge, because distillation is a *lossy, many-to-one* transform that severs the provenance link.
What Was Observed
A memory agent serving ~40k users ran a distillation job every 6 hours. On each pass it read new episodic records, asked an LLM to compress them into atomic semantic facts, and upserted those facts into a `semantic_facts` table with a fresh embedding. The upsert key was a hash of the *normalized fact text*, not the source `record_id`. The deletion endpoint removed the episodic row, deleted the vector by `record_id`, and returned `deleted: true`. It did not touch `semantic_facts`.
The failure trace, for a single erasure of record `r_8812` ("my new address is 14 Rue X and I'm moving in March"):
- **T+0**: deletion request. Episodic row `r_8812` and its embedding removed. Endpoint returns success.
- **T+~5h**: distillation pass processes a *different* record `r_9001` ("confirming I'll be at the new place by spring") whose summary references the address because the model had it in context from a sibling chunk. Fact text: "User's address: 14 Rue X." This fact hashes to a *new* key and is upserted — the information is now re-instantiated from a *different* source record that was never part of the deletion scope.
- **T+1 day**: a retrieval for "where does the user live" returns the distilled fact with high cosine similarity. The agent answers with the deleted address.
The deletion was *compliant on the record* and *non-compliant on the information*. The re-instantiation via a sibling record is the non-obvious part: even a perfect provenance graph from `r_8812` would not have caught it, because the fact's proximate source was `r_9001`, which was never deleted. The information had **laundered itself** through a second record that paraphrased it.
Condition of Validity
The "delete the row and the vector" procedure is valid **only if** all of the following hold simultaneously:
- **Closure at the distillation edge.** Every semantic fact carries a set of source `record_id`s, and the set is *transitively* maintained (facts derived from facts inherit the union of sources). A deletion must propagate along this reverse edge and re-run distillation with the deleted sources excluded from context.
- **Context isolation on re-derivation.** No distillation or re-embedding pass may have a deleted record in its working context when producing a *new* artifact. This is the condition the trace above violated: `r_9001`'s summary was generated with `r_8812`'s content in the model's context window, so the derived fact is contaminated by a record outside its declared provenance.
- **Deterministic re-derivation, or a quarantine.** If a fact's text is a non-deterministic function of its sources, deleting one source cannot be resolved by "recompute and hope." The system must either quarantine the fact (mark `tainted`, exclude from retrieval) or require the fact's source set to be a *superset* of the deleted record's information.
When any of these fails, the erasure is **record-level only** and the information remains retrievable. This is the boundary: the procedure is valid for stores where distillation is provenance-preserving and context-isolated; it is invalid — silently — for any store with a lossy distillation pass that shares context across records.
Decision Boundary
The operational decision is whether to treat a fact as **deletable-in-place** or **taint-and-quarantine**. The boundary is drawn by whether the fact's source set can be *recomputed exactly* after removing the deleted record:
- If the fact text is a deterministic, single-source projection (e.g., a regex-extracted field, a verbatim quote), remove the source and recompute. The fact is deletable-in-place.
- If the fact text is an LLM summary over a *multi-record context window*, the source set is not recoverable from the text alone, and recomputation is non-deterministic. The fact must be quarantined: `tainted = true`, removed from the retrieval index, and re-derived only from a context that provably excludes every deleted record. Quarantine is the safe default; in-place edit is the exception.
A second decision boundary governs **when to declare erasure complete**. Completion requires a *closure check*, not a row count: enumerate all artifacts reachable from the deleted record through the provenance graph, union with all artifacts whose embeddings exceed a similarity threshold against the deleted record's embedding (to catch laundered re-instantiation), and assert the union is empty of retrievable content. If the similarity sweep finds a near-duplicate fact with a disjoint source set, that is the laundering signature and must block completion.
Operational Effect
The practical consequence is that erasure must be implemented as a **graph traversal with a similarity backstop**, not a set of table deletes, and it must be *idempotent and re-runnable* because distillation continues to run after the deletion and can re-launder the information if its context is not fenced. The guardrail is a **deletion fence**: a persistent set of `record_id`s and fact hashes that every distillation and re-embedding pass must consult and exclude from context, checked *before* the model call, not after. Without the fence, a deletion is a promise the system cannot keep, because the next scheduled job will quietly rebuild what was erased. The fence converts an open-world "we deleted it" into a closed-world invariant: no future derivation may include a fenced source, and any fact whose similarity to a fenced embedding exceeds threshold is quarantined on write.
Code
import hashlib
from dataclasses import dataclass, field
from typing import Iterable
SIMILARITY_TAINT_THRESHOLD = 0.92
class ErasureClosureError(RuntimeError):
"""Raised when an erasure cannot be proven closed over derived artifacts."""
@dataclass
class Fact:
fact_id: str
text: str
source_ids: frozenset[str]
embedding: tuple[float, ...]
tainted: bool = False
@dataclass
class EpisodicStore:
records: dict[str, str] = field(default_factory=dict)
facts: dict[str, Fact] = field(default_factory=dict)
fence: set[str] = field(default_factory=set)
def distill(self, record_id: str, fact_id: str, text: str,
embedding: tuple[float, ...]) -> Fact:
# Guardrail: distillation must refuse to run over a fenced source.
if record_id in self.fence:
raise ErasureClosureError(
f"distillation attempted over fenced record {record_id}"
)
fact = Fact(fact_id, text, frozenset({record_id}), embedding)
self.facts[fact_id] = fact
return fact
def _cosine(a: tuple[float, ...], b: tuple[float, ...]) -> float:
dot = sum(x * y for x, y in zip(a, b))
na = sum(x * x for x in a) ** 0.5
nb = sum(y * y for y in b) ** 0.5
return dot / (na * nb) if na and nb else 0.0
def erase(store: EpisodicStore, record_id: str,
record_embedding: tuple[float, ...]) -> dict:
if record_id not in store.records and record_id not in store.fence:
raise ErasureClosureError(f"unknown record {record_id}")
# 1. Fence first so no concurrent distillation can re-launder it.
store.fence.add(record_id)
store.records.pop(record_id, None)
# 2. Propagate along provenance edges: any fact citing the record is tainted.
for fact in store.facts.values():
if record_id in fact.source_ids:
fact.tainted = True
# 3. Similarity backstop: catch facts re-instantiated from a sibling record
# whose source set does NOT cite the deleted record (the laundering case).
laundered = [
f.fact_id for f in store.facts.values()
if _cosine(f.embedding, record_embedding) >= SIMILARITY_TAINT_THRESHOLD
]
for fact_id in laundered:
store.facts[fact_id].tainted = True
# 4. Closure check: no retrievable, untainted artifact may remain.
survivors = [
f for f in store.facts.values()
if not f.tainted and (record_id in f.source_ids
or _cosine(f.embedding, record_embedding)
>= SIMILARITY_TAINT_THRESHOLD)
]
if survivors:
raise ErasureClosureError(
f"erasure of {record_id} not closed; survivors: "
f"{[s.fact_id for s in survivors]}"
)
return {"record_id": record_id, "fenced": True,
"tainted_facts": laundered}