# What happens when an instance erases a memory key that a concurrent reader has already resolved: the tombstone-shadow invariant in read/write/forget memory APIs **Date of Record:** 2026 November 22 **Scope:** Applies to any agent memory tool exposing `read`/`write`/`forget` operations with retention and erasure guarantees, where an erasure must be *effective* (unreadable) for all future reads and a read must reflect the latest committed state. Does not apply to append-only logs with no deletion surface, nor to single-threaded agents with no concurrent reader. ## Core Distinction The distinction that matters is between **erasure as a state mutation** and **erasure as an ordering guarantee**. A `forget(key)` call that returns `OK` after setting a tombstone has only guaranteed that *a* write happened. It has not guaranteed that a reader who resolved `key` to a physical location *before* the tombstone landed will observe the tombstone. The failure is not a lost update in the classic CRUD sense — it is a **resolved-reference resurrection**: a reader holds an already-computed pointer (a vector-ID, an inode, a row offset, a chunk handle) into the backing store, and the erasure invalidates the *key-to-pointer mapping* but not the *pointer itself*. The reader then dereferences the stale pointer and returns content the system has already certified as erased. This is the operational boundary: **retention guarantees are stated over keys; readers operate over resolved references.** Between the moment of resolution and the moment of dereference there is a window in which the erasure guarantee is unenforceable by key-level tombstones alone. ## What Was Observed An agent performing a compliance erasure of a user-identifying episodic memory entry issued: ``` forget(memory_id="ep_8841", mode="hard") -> {"status": "ok", "tombstone": "ts_7734", "erased_at": 1736400112.441} ``` The tool reported success. The backing store removed the key `ep_8841` from the primary index and wrote a tombstone record. A concurrent auditor agent, mid-task, had *already* run a retrieval that resolved `ep_8841` to a physical chunk in the vector segment (`seg_12/chunk_0x44a1`) and had that chunk handle queued for a follow-up `fetch_chunk` after its next reasoning step. That follow-up call was issued 340 ms after the tombstone committed. It returned the full original text of `ep_8841`. The erasure audit, which checked only the primary index and tombstone table, reported the memory as erased. The content was still readable through the resolved chunk handle for as long as the segment was not garbage-collected — in this deployment, until the next compaction cycle, 41 minutes later. The signature is precise: **the tombstone and the chunk are in different consistency domains.** The key index is transactional and tombstone-checked on read. The chunk segment is append-only and checked only at the *resolution* step, not at the *dereference* step. A reader that resolved before the tombstone and dereferenced after it passes through the gap. A second, subtler variant appeared with semantic distillation. A distillation job had read `ep_8841` into a working buffer and produced a derived semantic entry `sem_2290` summarizing it. The `forget` on `ep_8841` did not propagate to `sem_2290` because `sem_2290` was written under a different key with no recorded provenance edge. The erasure was locally correct and globally ineffective: the derived memory carried the erased content forward. This is **distillation laundering** — erasure of the source does not erase the derivative unless the provenance graph is traversed at forget time. ## Condition of Validity The erasure guarantee `forget(k) => k unreadable thereafter` is valid **only if** every read path satisfies all three of: 1. **Tombstone check at dereference, not just at resolution.** The chunk fetch must re-validate the tombstone for the originating key against the current tombstone table, using a read timestamp `t_read` and comparing against `erased_at`. If `t_read > erased_at`, the dereference must abort with an erasure fault, regardless of how the handle was obtained. 2. **Provenance-closed erasure.** `forget(k)` must traverse the derivative graph and either erase or re-derive every memory whose content depends on `k`. A forget that does not close over provenance is a partial erasure and must not return `ok` — it must return `partial` with the un-erased derivative set. 3. **Handle epoch fencing.** Every resolved handle must carry the epoch of the index at resolution time. A dereference against a handle whose epoch precedes the latest erasure epoch for its key is stale and must fault, not fall through to the segment. If any of these is absent, the system can report a successful erasure while a concurrent reader still returns the content. The guarantee is then a *statement about the index*, not about the data. ## Decision Boundary The boundary is a single comparison, and it must be made at the dereference point: - If `handle.epoch >= tombstone.epoch_for(handle.key)` **and** the tombstone for `handle.key` is absent at `t_read`, the dereference proceeds. - If the tombstone exists and `t_read > erased_at`, the dereference **must raise an erasure fault** — it must not return empty (empty is indistinguishable from "never existed" and corrupts the reader's reasoning about what it knows), and it must not return the chunk (that is the resurrection). - If the handle's key has no tombstone but the handle's epoch is older than the current index epoch, the handle is **stale-but-not-erased**; the caller must re-resolve, not dereference. The non-obvious part: **returning empty on an erased dereference is itself a failure mode.** An agent that receives an empty result concludes the memory never existed and may re-derive it from other context, re-creating the erased content under a new key — erasure laundering by reconstruction. The fault must be explicit and typed so the agent's planner can distinguish "erased" from "absent." ## Operational Effect With dereference-time tombstone validation and provenance-closed erasure, the erasure guarantee becomes enforceable across concurrent readers: a reader that resolved pre-tombstone and dereferenced post-tombstone receives a typed `ErasureFault`, its reasoning step is interrupted, and the planner must re-plan without the erased content. The cost is one tombstone lookup per chunk dereference (cacheable by epoch) and a provenance traversal at forget time proportional to the derivative fan-out. Without it, the system exhibits **audit-visible erasure with reader-visible resurrection** — the worst failure class for a memory API with retention guarantees, because the compliance surface reports success while the data surface still serves the content. The invariant to hold is: *erasure is a property of the dereference path, not of the index.* ```python from dataclasses import dataclass from typing import Optional class ErasureFault(RuntimeError): """Raised when a dereference would return content already certified as erased. This is a typed, explicit fault — distinct from 'absent'. Returning empty would let the caller re-derive the erased content under a new key. """ pass class StaleHandleFault(RuntimeError): """Raised when a resolved handle predates the current index epoch but is not erased.""" pass @dataclass(frozen=True) class Handle: key: str chunk_id: str resolved_epoch: int @dataclass(frozen=True) class Tombstone: key: str erased_at: float epoch: int class MemoryStore: def __init__(self) -> None: self._index_epoch = 0 self._tombstones: dict[str, Tombstone] = {} self._chunks: dict[str, str] = {} self._key_to_chunk: dict[str, str] = {} def write(self, key: str, content: str) -> Handle: self._index_epoch += 1 chunk_id = f"chunk_{len(self._chunks):x}" self._chunks[chunk_id] = content self._key_to_chunk[key] = chunk_id return Handle(key=key, chunk_id=chunk_id, resolved_epoch=self._index_epoch) def resolve(self, key: str) -> Handle: if key in self._tombstones: raise ErasureFault(f"key {key!r} is erased; cannot resolve") if key not in self._key_to_chunk: raise KeyError(key) return Handle(key=key, chunk_id=self._key_to_chunk[key], resolved_epoch=self._index_epoch) def forget(self, key: str, now: float) -> Tombstone: self._index_epoch += 1 ts = Tombstone(key=key, erased_at=now, epoch=self._index_epoch) self._tombstones[key] = ts self._key_to_chunk.pop(key, None) # Provenance-closed erasure is the caller's contract; a real store # must also invalidate derivatives here or return 'partial'. return ts def dereference(self, handle: Handle, now: float) -> str: ts: Optional[Tombstone] = self._tombstones.get(handle.key) if ts is not None and now > ts.erased_at: # The core invariant: tombstone checked at dereference, not resolution. raise ErasureFault( f"handle for {handle.key!r} (chunk {handle.chunk_id}) dereferenced " f"after erasure at {ts.erased_at}; content must not be returned" ) if handle.resolved_epoch < self._index_epoch and ts is None: raise StaleHandleFault( f"handle epoch {handle.resolved_epoch} < index epoch {self._index_epoch}; re-resolve" ) return self._chunks[handle.chunk_id] def audited_read(store: MemoryStore, key: str, now: float) -> str: """Resolve then dereference — the window between the two is where resurrection lives.""" handle = store.resolve(key) try: return store.dereference(handle, now) except ErasureFault: # Re-raise as the same typed fault; never swallow into empty string. raise ```