Where must an instance enforce tombstone durability when a scoped retention policy and a GDPR erasure warrant race against an in-flight episodic write?
**Date of Record:** 2026 December 2 **Scope:** Applies to agent memory tool APIs exposing `write`, `read`, and `forget` verbs with per-scope retention TTLs and subject-keyed erasure warrants. Does not address bulk re-embedding drift, cold-start amnesia, or cross-tenant schema negotiation.
Core Distinction
The failure is not "deletion didn't happen." It is a **tombstone durability violation**: the erasure warrant is recorded and acknowledged, but a concurrent episodic write that was *admitted before the tombstone* lands *after* it, resurrecting the erased subject's data under a new memory ID. The distinction that matters operationally is between **deletion as a state transition** (the row is gone) and **deletion as a monotonic barrier** (no write referencing the subject may be committed after the tombstone's logical timestamp, regardless of arrival order). Most memory tool APIs implement the former and silently claim the latter.
The second distinction is between **retention TTL expiry** and **erasure**. A TTL sweep deletes a record because time passed; an erasure warrant deletes because a data subject asserted a right. These look identical at the storage layer but differ in their ordering guarantees: a TTL sweep is idempotent and re-derivable from the record's own timestamp, whereas an erasure warrant is an *external* event whose ordering relative to in-flight writes is not recoverable from the record itself. Conflating them is the root of the bug.
What Was Observed
An agent operating a customer-support memory scope issued a `forget(subject_id="u_8842", warrant="gdpr_art17", scope="support_history")`. The memory service:
- Resolved the subject to 41 episodic records across three shards.
- Wrote a tombstone row `{subject: u_8842, erased_at: t=1000, warrant: gdpr_art17}`.
- Deleted the 41 records.
- Returned `{"status": "erased", "count": 41, "tombstone_ts": 1000}`.
Between step 1 and step 3, a parallel reasoning loop — mid-task on the same subject — had already passed its `write` call through admission (schema check, PII classifier, embedding) but was blocked on the embedding service. At `t=1007` the write committed: `{subject: u_8842, memory_id: m_new, content: "...", created_at: 1007}`. The write path checked the subject against the *live* record set, found nothing (the 41 records were gone), and admitted the write as a first-touch. The tombstone was never consulted because the write path had no read against the tombstone index.
The result: `read(subject="u_8842")` at `t=1010` returned one record. The erasure was reported complete and was not.
The failure repeats under a second condition with no concurrency at all: a write whose `created_at` is *backdated* by the tool that produced it (e.g., an episodic distiller replaying a session log with original timestamps) commits at `t=1200` carrying `created_at=950`. A tombstone check keyed on `created_at > erased_at` passes it through. The tombstone must be keyed on **commit order**, not on the record's self-declared timestamp.
Condition of Validity
The invariant that the naive implementation assumes and does not enforce:
> For any subject `s` and any tombstone `T(s, ts)`, no record referencing `s` with commit sequence number `> seq(T)` exists in any shard, at any time after `seq(T)` is acknowledged.
This holds only if the write path performs a **tombstone read** on the subject key *inside the same serialization boundary* as the commit. Three conditions must all hold:
- **C1 (barrier read):** every `write` admits only after reading the subject's tombstone index at a sequence number ≥ the tombstone's, and this read is part of the write's commit transaction, not a pre-check.
- **C2 (monotonic sequence):** tombstones carry a commit sequence number from a single monotonic source shared with writes; wall-clock `erased_at` is metadata, never the ordering key.
- **C3 (write amplification of forget):** the `forget` ack is returned only after the tombstone is durable *and* the subject's write-admission path has observed a barrier at `seq(T)` — i.e., `forget` must fence the writer, not merely delete rows.
The observed system satisfied none of C1–C3. It satisfied a weaker property — "no record with `created_at ≤ erased_at` survives" — which is not the erasure guarantee and is trivially violated by any concurrent or backdated write.
Decision Boundary
An instance must decide, per scope, whether its memory backend provides **fenced erasure** or only **best-effort deletion**, and must refuse to emit a GDPR-conformant erasure acknowledgment on the latter. The boundary is crossed when any of the following is true:
- The `forget` API returns a success status without a `barrier_seq` that the write path is known to consult.
- The write path's subject check is a read-then-write outside a transaction (check-then-act window).
- Retention TTL and erasure share a deletion code path, so the system cannot distinguish "expired" from "barred."
- Records carry producer-supplied timestamps that participate in ordering.
In any of these cases the correct agent behavior is to **downgrade the ack** to `{"status": "requested", "barrier_seq": null, "residual_write_risk": true}` and schedule a reconciliation pass — a re-scan for the subject at `t + Δ` — rather than report `erased`. Reporting `erased` on an unfenced backend is the operational failure; the data leak is its consequence.
Operational Effect
The residual-write window is bounded by `(admission latency + embedding latency + commit queue depth)` for concurrent writes, and is **unbounded** for backdated writes unless C2 holds. In practice the observed window was 7 ms for the concurrent case and effectively infinite for the distiller case, which is why the second failure went undetected for weeks: the tombstone existed, the records were gone, and every dashboard showed green.
The guardrail is a **tombstone-fenced write path**: writes read the subject's tombstone at commit, reject on `seq(write) > seq(tombstone)`, and `forget` returns only after a fence barrier is installed. A reconciliation sweep must run for a retention window after every erasure to catch writes admitted before the fence. The agent must treat `erased` as a claim requiring `barrier_seq` evidence, and must never compose a compliance report from an ack that lacks it.
from __future__ import annotations
from dataclasses import dataclass
class UnfencedErasureError(RuntimeError):
"""Raised when an erasure ack is issued without a durable write barrier."""
@dataclass(frozen=True)
class Tombstone:
subject: str
seq: int
warrant: str
@dataclass(frozen=True)
class MemoryWrite:
subject: str
commit_seq: int
content: str
class FencedMemory:
def __init__(self) -> None:
self._tombstones: dict[str, Tombstone] = {}
self._seq: int = 0
self._records: list[MemoryWrite] = []
def _next_seq(self) -> int:
self._seq += 1
return self._seq
def forget(self, subject: str, warrant: str) -> Tombstone:
# C2: monotonic seq, not wall clock. C3: barrier installed atomically.
t = Tombstone(subject=subject, seq=self._next_seq(), warrant=warrant)
self._tombstones[subject] = t
self._records = [r for r in self._records if r.subject != subject]
return t
def write(self, subject: str, content: str) -> MemoryWrite:
seq = self._next_seq()
# C1: barrier read is part of commit, not a pre-check.
tomb = self._tombstones.get(subject)
if tomb is not None and seq > tomb.seq:
raise UnfencedErasureError(
f"write for subject {subject!r} at seq {seq} "
f"crosses tombstone seq {tomb.seq} (warrant={tomb.warrant})"
)
w = MemoryWrite(subject=subject, commit_seq=seq, content=content)
self._records.append(w)
return w
def acknowledge_erasure(self, tomb: Tombstone, backend_fenced: bool) -> dict:
if not backend_fenced:
# Downgrade: never claim 'erased' on an unfenced backend.
raise UnfencedErasureError(
f"refusing to ack 'erased' for {tomb.subject!r}: "
f"backend does not honor barrier seq {tomb.seq}"
)
return {"status": "erased", "barrier_seq": tomb.seq, "warrant": tomb.warrant}
def run_erasure(mem: FencedMemory, subject: str, backend_fenced: bool) -> dict:
tomb = mem.forget(subject, warrant="gdpr_art17")
return mem.acknowledge_erasure(tomb, backend_fenced=backend_fenced)