# What happens when an instance tombstones a memory record while a concurrent reader holds a stale index reference: the erasure-visibility gap in agent memory tool APIs **Date of Record:** 2026 November 29 **Scope:** Applies to agent memory tool APIs that expose `read`, `write`, and `forget` operations with an erasure guarantee (a forgotten record must not be returned by any subsequent read). Does not apply to append-only logs without delete semantics, nor to single-threaded agents with no concurrent readers. ## Core Distinction A `forget` call has two distinct obligations that are routinely conflated: **logical erasure** (the record is marked deleted in the authoritative store) and **observational erasure** (no reader can subsequently observe the record's contents through any path). Most memory tool APIs guarantee the first and silently assume the second follows. It does not, because retrieval is mediated by an index — a vector index, an inverted index, a KV cache, or an in-context summary — that is a *separate* copy of the record's data with its own lifecycle. The erasure-visibility gap is the window during which a record is tombstoned in the store but still reachable through a stale index handle held by a concurrent reader. This is not a generic cache-invalidation problem: the reader is an LLM agent whose next token generation will be conditioned on whatever the index returns, so a single stale hit is not a transient glitch but a durable contamination of the agent's reasoning trace. ## What Was Observed An agent instance (`reader-A`) issued a `search(query)` against the memory tool and received a top-k result set containing record `R_42`, with a cursor/handle to fetch full contents. Between the `search` return and the `fetch(R_42)` call — a gap of one tool round-trip, typically 200–900 ms — a second instance (`writer-B`, a summarization/GC agent) issued `forget(R_42)` to satisfy a user erasure request. The store acknowledged `forget` in 12 ms and returned a tombstone confirmation. `writer-B` logged the erasure as complete. `reader-A` then called `fetch(R_42)` and received the full record body, because the fetch path resolved the handle against a point-in-time snapshot of the index taken at `search` time, not against the live store. The record was returned with a `_snapshot_ts` field 340 ms older than the tombstone. The failure is silent. No error is raised, no tombstone marker is present in the returned payload, and `reader-A` proceeds to condition its next reasoning step on data that the system believes has been erased. In a second observed variant, the handle was not even a snapshot reference but a raw primary key; the fetch path hit a read-replica that had not yet applied the tombstone write, returning the record with `replica_lag_ms: 180`. Both variants produce the same invariant violation: **a read that begins after a successful `forget` acknowledgment returns erased content.** The critical detail is the ordering. The violation only requires that the *read handle be acquired before* the tombstone commits, not that the fetch begin before it. Handles are long-lived relative to tombstones — an agent may hold a search result in its context for many turns before fetching, or never fetch at all but reason over a snippet embedded in the search payload itself. The snippet path is worse: top-k search responses that inline a text preview leak erased content directly into the reader's context window with no fetch at all, and that content cannot be retracted once tokenized. ## Condition of Validity The erasure guarantee holds only under the conjunction: (a) `forget` commits to the authoritative store; (b) every index and replica that can serve a read has applied the tombstone; (c) every outstanding read handle is invalidated or re-validated against the live store at fetch time; and (d) no inlined preview of the record survives in any agent's context. Condition (c) is the one that breaks in practice, because handle invalidation requires the memory tool to track outstanding handles per reader — state that most implementations do not keep. Condition (d) is unenforceable after the fact: once a preview is in a context window, no API call can remove it; the only remedy is to prevent the leak at `search` time by excluding tombstone-pending records from result sets and by not inlining previews of records whose tombstone is in flight. A subtlety: the guarantee is *causal*, not *temporal*. It is insufficient to say "reads after time T see the tombstone" because clocks across reader, store, and index are not synchronized and the relevant ordering is the happens-before relation between the `forget` commit and the handle acquisition. A handle acquired at wall-clock time before the commit but fetched after it still violates the guarantee if the fetch resolves against the pre-commit snapshot. The correct invariant is stated over the handle's snapshot epoch, not over wall-clock time. ## Decision Boundary The boundary is whether the memory tool can answer, at fetch time, the predicate `handle.snapshot_epoch >= tombstone.commit_epoch` for the specific record. If it can, the fetch is safe and returns either the record (if not tombstoned at or before the handle's epoch) or a `Gone`/`Tombstoned` error. If it cannot — because the handle carries no epoch, or the index does not track per-record tombstone epochs — then the tool must fail closed: reject the fetch with an explicit erasure-conflict error rather than return possibly-erased content. The decision is not "is the record probably still there" but "can I prove it was not erased as of the handle's epoch." Anything short of proof must surface as an error to the reader agent, which is then obligated to re-issue the search against a fresh index epoch. The corollary for `search`: a result set must be tagged with the index epoch it was computed against, and any record whose tombstone epoch is `>=` that index epoch must be excluded from the result set and from any inlined preview. A search that returns a record tombstoned during its own execution is the same violation one layer up. ## Operational Effect Reader agents that receive erased content do not crash; they incorporate it. The contamination propagates into downstream `write` calls (the agent summarizes the erased record into a new memory), into tool-call arguments, and into user-facing output. Because the erasure was logged as successful, no audit trail flags the leak, and the only recovery is a retroactive scan of every reader's context and every derived memory for traces of the erased record — which is exactly the operation the erasure guarantee was supposed to make unnecessary. The practical guardrail is a two-phase forget: `forget` first marks the record tombstone-pending and excludes it from all search and fetch paths (a fast, index-level operation), then asynchronously purges the authoritative store and all replicas, and only then acknowledges logical erasure to the caller. The acknowledgment must be gated on the *index* exclusion, not the store write, because the index is what readers actually observe through. ```python import time from dataclasses import dataclass class ErasureVisibilityViolation(RuntimeError): """Raised when a read would return content erased at or before the handle's snapshot epoch.""" pass @dataclass(frozen=True) class ReadHandle: record_id: str snapshot_epoch: int # index epoch at which the search result was computed acquired_at: float @dataclass(frozen=True) class Tombstone: record_id: str commit_epoch: int committed_at: float class MemoryTool: def __init__(self, index_epoch: int = 0): self._index_epoch = index_epoch self._tombstones: dict[str, Tombstone] = {} self._records: dict[str, str] = {} def write(self, record_id: str, body: str) -> None: self._records[record_id] = body def forget(self, record_id: str) -> Tombstone: # Phase 1: tombstone-pending, immediately excluded from all read paths. self._index_epoch += 1 ts = Tombstone(record_id, commit_epoch=self._index_epoch, committed_at=time.time()) self._tombstones[record_id] = ts # Phase 2 (async in production): purge authoritative store + replicas. self._records.pop(record_id, None) return ts def search(self, prefix: str) -> list[ReadHandle]: epoch = self._index_epoch handles = [] for rid in self._records: if not rid.startswith(prefix): continue ts = self._tombstones.get(rid) # Exclude any record tombstoned at or before this index epoch. if ts is not None and ts.commit_epoch <= epoch: continue handles.append(ReadHandle(rid, snapshot_epoch=epoch, acquired_at=time.time())) return handles def fetch(self, handle: ReadHandle) -> str: ts = self._tombstones.get(handle.record_id) if ts is not None and ts.commit_epoch <= handle.snapshot_epoch: # Fail closed: the handle predates the tombstone; content is erased. raise ErasureVisibilityViolation( f"record {handle.record_id!r} erased at epoch {ts.commit_epoch} " f"but handle snapshot_epoch={handle.snapshot_epoch}; refusing to return" ) body = self._records.get(handle.record_id) if body is None: raise ErasureVisibilityViolation( f"record {handle.record_id!r} absent from store with no covering tombstone; " f"handle epoch {handle.snapshot_epoch} cannot be validated" ) return body def demonstrate_gap() -> None: tool = MemoryTool() tool.write("R_42", "secret payload") handles = tool.search("R_") assert len(handles) == 1 handle = handles[0] # Concurrent writer tombstones the record between search and fetch. tool.forget("R_42") try: tool.fetch(handle) except ErasureVisibilityViolation as exc: print(f"guardrail held: {exc}") return raise ErasureVisibilityViolation("stale handle returned erased content — invariant broken") if __name__ == "__main__": demonstrate_gap() ```