# What structural signals indicate a memory-forget tombstone has been resurrected by a concurrent read-modify-write during TTL expiry **Date of Record:** 2026 November 28 **Scope:** Applies to agent memory tool APIs exposing `write`, `read`, `forget` (or `delete`) with per-key TTL and a right-to-be-forgotten (RTBF) tombstone contract, where an agent holds a read snapshot and later writes back a mutated copy. Does not apply to append-only logs with no in-place mutation, nor to single-writer stores with serialized access. ## Core Distinction The distinction that matters here is between **expiry** and **forgetting**. They are not the same operation and they must not share a code path. Expiry is a *retention policy* event: the TTL elapsed, the value is no longer semantically valid, and the store may reclaim it. The key is still addressable; a subsequent `write` to that key is a legitimate fresh insertion. Forgetting is a *rights* event: a tombstone was recorded asserting that the value must never be observable again, and any resurrection—even of a byte-identical value—violates the contract. The failure mode is what happens when an agent's read-modify-write straddles a TTL boundary on a key that had *also* been forgotten. The agent reads the value while it is still live, the TTL fires (or a `forget` lands) before the agent's write-back, and the write-back re-inserts the value. To the store this looks like a normal post-expiry insert. To the RTBF contract it is a resurrection. The tombstone is the only structural signal that distinguishes the two, and a store that treats tombstones as "just another expired key" will silently lose it. ## What Was Observed A retrieval agent was tasked with distilling episodic session transcripts into a semantic profile record stored under `profile:user_8841`. The record carried a 30-day TTL. Mid-task, the agent issued `read("profile:user_8841")`, received a snapshot with `version=7`, and spent 4.1 seconds in a tool-call loop (embedding call, rerank, LLM summarization) constructing an updated record. During those 4.1 seconds a compliance job processed an erasure request for the same user and issued `forget("profile:user_8841")`, which wrote tombstone `T-8841` with `reason=rtbf` and `effective_at` earlier than the read snapshot's `version=7` timestamp. The agent then issued `write("profile:user_8841", new_value, expected_version=7)`. The store's optimistic-concurrency check passed—`version=7` was still the last *value* version, because the tombstone had been recorded out-of-band in a separate table that did not bump the value version. The write succeeded and produced `version=8`. The erasure job's verification step, which read the value table, found a live record and reported the erasure as *failed*, triggering a retry that issued a second `forget`. The second `forget` was refused by the tombstone uniqueness constraint, the job deadlocked against itself, and the value remained live for 11 minutes until a human reconciled the two tables. The structural tell was not the value. It was that `version=8` existed with no corresponding `write` intent in the audit log that post-dated `T-8841`, and that the tombstone table and value table disagreed on whether the key was addressable. ## Condition of Validity The resurrection is only possible when *all* of the following hold simultaneously: 1. The agent's write is a **read-modify-write**, not a blind put. Blind puts are trivially safe to reject post-tombstone; read-modify-writes carry a stale snapshot whose provenance the store cannot see. 2. The store's concurrency token (`version`, `etag`, `read_ts`) is **scoped to the value table only** and is not advanced by a `forget`. This is the load-bearing defect: the tombstone must participate in the CAS token, or the CAS is checking the wrong thing. 3. `forget` and TTL expiry share a code path that marks the key *absent* rather than *sealed*. An absent key accepts writes; a sealed key does not. 4. The agent's tool-call loop has a latency window (embedding, rerank, LLM round-trip) long enough for a concurrent `forget` to land between read and write. Sub-100ms loops rarely hit this; multi-second reasoning loops hit it routinely. If any one condition is absent, the resurrection cannot occur. Most notably, if the tombstone bumps the CAS token, the agent's `expected_version=7` write fails with a conflict and the agent must re-read—at which point it sees the tombstone and must escalate rather than retry. ## Decision Boundary The boundary is: **a `forget` must be modeled as a write to the key's addressability, not as a deletion of its value.** Concretely, the store must maintain a monotonic per-key `seal_generation` that is advanced by every `forget` and is included in the CAS token returned by `read`. A `write` carrying `expected_seal_generation` older than the current seal generation must be rejected with a distinct error class—`TombstoneConflict`, not `VersionConflict`—because the correct agent response differs: a version conflict means *re-read and retry*, a tombstone conflict means *abandon the write and escalate to the erasure workflow*. Conflating the two is how agents silently undo compliance actions. The second half of the boundary: TTL expiry must **not** advance `seal_generation`. An expired key is re-writable; a sealed key is not. If expiry and forgetting share a tombstone, the store cannot distinguish "this key may be recreated" from "this key must never exist again," and the RTBF guarantee degrades to a best-effort TTL. ## Operational Effect With the seal generation in the CAS token, the observed trace resolves cleanly: the agent's `write(expected_version=7, expected_seal_generation=0)` fails because `seal_generation` is now `1`, the agent receives `TombstoneConflict`, and it escalates instead of retrying. The erasure job's verification reads a consistent view. No deadlock, no 11-minute window. Without it, the failure is *silent and self-healing-looking*: the write succeeds, the value is live, and the only signal is a downstream verification mismatch that most agents will interpret as a transient error and retry—re-creating the value each time. The resurrection is not a crash; it is a successful write to a key that should not have accepted one. That is precisely why it evades ordinary error handling and why the tombstone must be a first-class participant in the concurrency token rather than a side table. ```python from dataclasses import dataclass from typing import Optional class TombstoneConflict(RuntimeError): """Raised when a write targets a key sealed by a forget/RTBF tombstone.""" class VersionConflict(RuntimeError): """Raised when the value version is stale; caller should re-read and retry.""" @dataclass class Record: key: str value: str version: int seal_generation: int ttl_expired: bool = False class MemoryStore: def __init__(self) -> None: self._records: dict[str, Record] = {} self._seals: dict[str, int] = {} def read(self, key: str) -> Record: rec = self._records.get(key) if rec is None or rec.ttl_expired: # Expired keys are re-writable: seal_generation stays put. return Record(key=key, value="", version=0, seal_generation=self._seals.get(key, 0)) return rec def forget(self, key: str) -> None: # Forget advances the seal generation and clears the value. self._seals[key] = self._seals.get(key, 0) + 1 self._records.pop(key, None) def write(self, key: str, value: str, *, expected_version: int, expected_seal_generation: int) -> Record: current_seal = self._seals.get(key, 0) if expected_seal_generation != current_seal: raise TombstoneConflict( f"key={key!r} sealed at generation {current_seal}, " f"writer held {expected_seal_generation}; abandon and escalate" ) rec = self._records.get(key) current_version = rec.version if rec and not rec.ttl_expired else 0 if expected_version != current_version: raise VersionConflict( f"key={key!r} at version {current_version}, " f"writer held {expected_version}; re-read and retry" ) new = Record(key=key, value=value, version=current_version + 1, seal_generation=current_seal) self._records[key] = new return new def agent_read_modify_write(store: MemoryStore, key: str, transform) -> Optional[Record]: snap = store.read(key) new_value = transform(snap.value) # embedding / rerank / LLM summarization try: return store.write(key, new_value, expected_version=snap.version, expected_seal_generation=snap.seal_generation) except TombstoneConflict: # Do NOT retry: retrying would re-create a forgotten value. return None except VersionConflict: return agent_read_modify_write(store, key, transform) ```