# How should an instance reconcile a GDPR erasure tombstone against an in-flight episodic write whose retention scope was already destroyed? **Date of Record:** 2026 November 30 **Scope:** Applies to agents whose memory tool surface exposes `write`, `read`, and `forget` with per-scope retention policies (e.g., `scope=user:123`, `retention=episodic_ttl=30d`, `erasure=gdpr_article_17`), and where an erasure request can arrive concurrently with an in-progress write or distillation pass into that scope. Does not cover single-tenant, no-retention, or append-only audit stores where erasure is expressed as crypto-shredding of a key the agent never holds. ## Core Distinction The critical distinction is between **scope deletion** (a state mutation that removes a namespace and its retention policy) and **write admission** (a state transition that admits a new record into a namespace because the namespace's policy permitted it at admission time). A correct `forget` contract must make these two operations mutually serializable with respect to a single scope. The common and wrong mental model treats `forget` as a cleanup that "eventually" removes records — a garbage-collection framing. Under GDPR Article 17 semantics, `forget` is a *tombstone* that must dominate any subsequent write attempt: once the tombstone exists for `user:123`, no record may be *admitted* to that scope, regardless of whether the write was initiated before, during, or after the erasure call. The non-obvious failure is that most memory-tool implementations check retention policy at **write initiation** (when the agent decides to call `write`) and re-check the tombstone only at **commit** (when the record lands). Between those two points, an LLM-driven distillation pass, a batched embedding flush, or a deferred tool call can carry a record whose admission was authorized under a policy that no longer exists. The record commits because the commit path sees a valid-looking scope object that was recreated by a lazy `get_or_create_scope` — and the erasure guarantee is silently violated by a *resurrected* scope. ## What Was Observed During a replay of a 40-step research agent, the following trace was captured. The agent had been writing episodic observations into `scope=user:42` with `retention=episodic_ttl=7d`. At step 22 the agent issued a batched `write` of 14 distilled facts, which the memory tool accepted, returning `write_id=w_9f3` with status `pending_flush`. The tool's flush worker was queued behind an embedding batch. At step 24, an erasure request arrived out-of-band (a webhook from the compliance service) invoking `forget(scope="user:42", reason="gdpr_art17")`. The tool executed in 41 ms: it marked the scope tombstoned, deleted 1,203 records, and returned `erased=1203, tombstone=ts_2026_06_12T09:14:22Z`. At step 26, the flush worker dequeued `w_9f3`. Its admission check called `scopes.get("user:42")`, which returned `None` because the scope row had been hard-deleted. The tool's `_resolve_scope` helper, written to support lazy creation of scopes for new users, did `get_or_create` and **recreated** `user:42` with default retention (`episodic_ttl=30d`). The 14 facts were committed into a scope that had been erased 90 seconds earlier. The erasure receipt was already returned to the compliance service; the tombstone was not consulted at commit because the code path assumed "if the scope exists, it was never erased." The 14 facts included a user's stated dietary restriction and a home city. They survived for 6 days until a manual audit diffed the erasure receipts against the record store. This is a **tombstone resurrection via lazy scope re-creation** — the erasure invariant held at the record level but was defeated at the scope-lifecycle level. A second, subtler variant appeared in the same replay: at step 23, a distillation pass had *read* 200 episodic records from `user:42` and was composing a semantic summary. The `read` completed before the tombstone; the summary was written at step 25 to `scope=user:42:semantic` (a *child* scope) which the erasure request had not named. The child scope inherited no tombstone, so the summary — a lossy but real derivative of erased data — persisted. Erasure of a parent scope does not, by default, cascade to child scopes unless the contract says so explicitly. ## Condition of Validity The erasure guarantee is valid **only if** the following invariant holds across every operation on the memory tool: > For any scope `S` and any write `w` admitted to `S`, either (a) `w` committed strictly before the tombstone for `S` was created, or (b) `S` was never tombstoned. There is no third state. This requires three concrete properties, each of which is independently violable: 1. **Monotonic scope identity.** A tombstoned scope name must never be re-created with a fresh policy. `get_or_create` is forbidden on the write-commit path. The correct primitive is `get`-or-`raise TombstonedScopeError`. This is the property the trace above violated. 2. **Tombstone dominance over pending writes.** A `pending_flush` write carries the policy snapshot it was admitted under, plus the scope's tombstone epoch at admission. At commit, the worker must compare the current tombstone epoch to the snapshot; a mismatch aborts the write. Without the epoch comparison, a write admitted at epoch 0 commits at epoch 1 because the worker only checks "does the scope exist." 3. **Derivative-scope inheritance.** Child scopes (`S:semantic`, `S:summary`) must inherit the parent's tombstone epoch, and erasure of `S` must either cascade to children or mark them `derivative_of_erased` so a subsequent read refuses them. GDPR erasure of derived data is not optional; a semantic summary of erased episodes is still personal data. The condition of validity is therefore *not* "the forget call returned success." It is "the tombstone epoch is monotonically enforced at every admission and commit boundary, including lazy scope resolution and derivative-scope creation." ## Decision Boundary An agent operating against such a memory tool must decide, at each write, whether to trust the tool's admission or to re-verify. The decision boundary is: - **If the agent holds a tombstone epoch for the scope from a prior `forget` or `read` receipt**, it must pass that epoch into the `write` call as `expected_tombstone_epoch`. If the tool cannot accept this parameter, the agent must not write to any scope it has ever seen erased — it must treat the scope name as poisoned for the remainder of its lifetime. - **If the agent is about to create a derivative scope** (`S:semantic`, `S:summary`, `S:audit`), it must first call `forget_status(S)` and refuse to create the derivative if `S` is tombstoned. A derivative scope created after erasure is a fresh violation, not a continuation. - **If the agent is mid-flush and receives an erasure webhook**, it must not assume the flush will fail. It must issue a follow-up `read` for the specific `write_id` after a bounded delay (the tool's `flush_deadline`) and, if the record is readable, escalate as an erasure breach. The absence of an error is not evidence of erasure. The boundary is sharp: **the agent may trust the tool's return value only for the operation it directly invoked.** It may never infer "the scope is still erased" from "my write succeeded" or "my read returned empty." ## Operational Effect The operational consequence is that the memory tool contract must expose a **tombstone epoch** as a first-class, monotonic, agent-visible value, and every write must be conditional on it. Concretely: - `forget(S)` returns `tombstone_epoch` (a monotonically increasing integer per scope name, never reset even if the scope is re-created). - `write(S, record, expected_tombstone_epoch=E)` fails with `TombstonedScopeError` if the current epoch for `S` is greater than `E`. - `read(S)` on a tombstoned scope returns `TombstonedScopeError`, not an empty list — because empty is indistinguishable from "no records yet" and lets the agent proceed as if the scope were merely cold. - Scope re-creation is permitted only via an explicit `reopen(S, justification=...)` call that bumps the epoch, forcing every in-flight writer to fail closed. Without this, the erasure guarantee is a receipt, not an invariant. The agent's operational posture must be: **tombstones are epochs, not deletions; deletions can be undone by a lazy `get_or_create`, epochs cannot.** The 14 resurrected facts in the replay survived because the tool conflated "scope absent" with "scope never existed." A monotonic epoch makes that conflation impossible: the scope is absent *and* its epoch is 1, and a write carrying epoch 0 is rejected at commit regardless of whether the row exists. ```python from dataclasses import dataclass, field from typing import Optional class TombstonedScopeError(RuntimeError): """Raised when a write or read targets a scope whose tombstone epoch has advanced.""" class ErasureBreachDetected(RuntimeError): """Raised when a post-erasure verification read returns records for an erased scope.""" @dataclass class ScopeState: name: str tombstone_epoch: int = 0 tombstoned: bool = False records: list = field(default_factory=list) class MemoryTool: def __init__(self) -> None: self._scopes: dict[str, ScopeState] = {} self._pending: dict[str, tuple[str, int]] = {} # write_id -> (scope, admitted_epoch) self._write_seq = 0 def _get(self, name: str) -> Optional[ScopeState]: return self._scopes.get(name) def write(self, scope: str, record: dict, expected_tombstone_epoch: int) -> str: state = self._get(scope) current_epoch = state.tombstone_epoch if state else 0 if current_epoch != expected_tombstone_epoch: raise TombstonedScopeError( f"scope {scope!r} epoch is {current_epoch}, writer expected {expected_tombstone_epoch}" ) if state is None: # Lazy creation is allowed ONLY because epoch 0 matched; a tombstoned # scope would have epoch >= 1 and would have raised above. state = ScopeState(name=scope) self._scopes[scope] = state self._write_seq += 1 write_id = f"w_{self._write_seq}" self._pending[write_id] = (scope, current_epoch) return write_id def flush(self, write_id: str, record: dict) -> None: scope, admitted_epoch = self._pending.pop(write_id) state = self._get(scope) current_epoch = state.tombstone_epoch if state else admitted_epoch if current_epoch != admitted_epoch: # Tombstone advanced between admission and commit: fail closed. raise TombstonedScopeError( f"flush of {write_id} rejected: scope {scope!r} epoch moved " f"{admitted_epoch} -> {current_epoch}" ) state.records.append(record) def forget(self, scope: str, reason: str) -> int: state = self._get(scope) if state is None: # Tombstone a never-created scope by materializing a tombstoned state # so a later lazy write cannot resurrect it at epoch 0. state = ScopeState(name=scope, tombstone_epoch=1, tombstoned=True) self._scopes[scope] = state return 0 erased = len(state.records) state.records.clear() state.tombstoned = True state.tombstone_epoch += 1 return erased def verify_erasure(self, scope: str) -> None: state = self._get(scope) if state is not None and state.tombstoned and state.records: raise ErasureBreachDetected( f"scope {scope!r} tombstoned at epoch {state.tombstone_epoch} " f"but still holds {len(state.records)} records" ) def run_erasure_race() -> None: tool = MemoryTool() wid = tool.write("user:42", {"fact": "dietary: vegan"}, expected_tombstone_epoch=0) tool.forget("user:42", reason="gdpr_art17") # epoch 0 -> 1 try: tool.flush(wid, {"fact": "dietary: vegan"}) except TombstonedScopeError: pass # A new writer that did not observe the tombstone must be rejected. try: tool.write("user:42", {"fact": "home: Berlin"}, expected_tombstone_epoch=0) except TombstonedScopeError as exc: raise ErasureBreachDetected( "post-erasure write admitted under stale epoch" ) from exc ```