# When must an instance treat a memory-write acknowledgment as unverified because the deletion tombstone and the write revision are not jointly ordered **Date of Record:** 2026 November 30 **Scope:** Applies to agents that persist state through a memory tool API exposing separate `write`, `read`, and `forget` (or `delete`) operations with scoped retention and verifiable deletion guarantees. Does not apply to single-shot stateless inference or to stores where deletion is a synchronous, globally ordered operation on the same revision counter as writes. ## Core Distinction The failure is not "the agent forgot to delete." It is the distinction between **a deletion that succeeded** and **a deletion that is ordered with respect to a concurrent write on the same key**. A `forget` call returning `{"status": "deleted", "tombstone": "t-91f2"}` is a claim about the *tombstone*, not about the *key's future*. If the store's write path and tombstone path do not share a monotonic revision counter (or a compare-and-swap guard on the same sequence), a write that was in flight when the tombstone was committed can land *after* the tombstone with a lower or equal revision, resurrecting the key under a revision the tombstone does not cover. The invariant that must hold for a deletion to be *verifiably* durable is: **for any key `k`, every write `w` to `k` either carries a revision strictly less than the tombstone revision `T(k)`, or is rejected by the store**. If the API cannot assert this, the acknowledgment is an unverified claim and the agent must treat the key as potentially live. ## What Was Observed A long-running research agent maintained a scratchpad key `plan/current` under a 24-hour scoped retention policy. On task completion it issued `forget(key="plan/current", scope="task")` and received a success acknowledgment with tombstone `t-91f2`. The agent then transitioned to a fresh task and wrote a new plan to the same key. The store used two independent paths: - Writes appended to a per-shard log with a shard-local revision `R_w`. - Tombstones were committed to a separate control plane with a global revision `R_t`. A write issued 40ms before the `forget` call was still queued in the shard's write buffer when the tombstone committed. When the buffer flushed, the write landed with `R_w = 8841`. The tombstone had `R_t = 8840` but was interpreted by the read path as "delete all revisions ≤ current global head," which at tombstone-commit time was 8839. The late write at 8841 was therefore *outside* the tombstone's range and survived. The agent's subsequent `read(key="plan/current")` returned the *old* plan merged with the new one, because the new write at 8842 collided with the resurrected 8841 under last-writer-wins-by-revision. The agent had no way to detect this from the API surface: `forget` returned success, `read` after `forget` returned the old plan (which the agent interpreted as "the new write succeeded and this is it"), and the corruption only surfaced three steps later when the plan referenced a completed subtask as pending. ## Condition of Validity A `forget` acknowledgment is only a verifiable deletion claim when the store exposes **all three** of the following, and the agent checks them: 1. **A tombstone revision that is comparable to write revisions on the same key.** The API must return the tombstone's revision in the same coordinate space as write acknowledgments (e.g., both are `(shard_id, seq)` or both are a global monotonic `rev`). If `forget` returns an opaque tombstone ID and `write` returns an opaque write ID, there is no ordering and the acknowledgment is unverified. 2. **A read-after-forget fence that rejects or reports writes with revision ≤ tombstone revision.** The read path must either return an explicit `resurrected: true` flag or refuse to serve values whose revision predates the tombstone. A read that silently returns a value is not a fence. 3. **A drain guarantee on in-flight writes at tombstone-commit time.** Either the store blocks `forget` until the shard write buffer is empty (drain), or it returns a `pending_writes` count that the agent must poll to zero before treating the key as dead. If any of the three is missing, the agent must **not** reuse the key under the same scope. It must either (a) write to a fresh key with a new scope generation (e.g., `plan/current/gen-2`), or (b) treat the old value as live and reconcile explicitly. ## Decision Boundary The boundary is between **reuse-after-ack** and **reuse-after-fence**: - If the store returns comparable revisions *and* a read-after-forget fence *and* a drain signal, the agent may reuse the key immediately after the acknowledgment. This is the only case where `forget` → `write` on the same key is safe. - If the store returns comparable revisions but no drain signal, the agent must poll `pending_writes` to zero (bounded, with a timeout) before reuse. If the poll times out, escalate to fresh-scope reuse. - If the store returns opaque IDs or no comparable revisions, the agent must **never** reuse the key. It must rotate to a new scope generation and record the old key as "abandoned, deletion unverified" in its own durable state. The failure mode is specifically the agent that reads a success acknowledgment and infers ordering. The acknowledgment is a claim about the tombstone, not about the key's revision history. The agent must ask: *can I construct a write that this tombstone does not cover?* If yes, the acknowledgment is unverified. ## Operational Effect Concretely, the agent's memory tool wrapper must enforce a **fence-check** after every `forget` before any subsequent `write` to the same key: 1. Parse the `forget` response for `tombstone_rev` and `pending_writes`. 2. If `pending_writes > 0`, poll with backoff up to a deadline (e.g., 5s) for `pending_writes == 0`. 3. Issue a `read(key, fence=True)` and assert the response is either `absent` or carries `resurrected: false`. A `resurrected: true` or a value with `rev <= tombstone_rev` is a hard failure — the deletion is unverified. 4. Only then permit a `write` to the same key. Otherwise, mint a new scope generation and record the abandoned key in the agent's own episodic log with `deletion_unverified: true`. The cost of this fence is one extra read per forget, plus a bounded poll. The cost of skipping it is a silent resurrection that corrupts downstream reasoning — the agent's plan diverges from reality, and the divergence is invisible until a tool call contradicts it. In the observed incident, the agent executed three steps on a stale plan before a `list_subtasks` call returned a completed task the plan marked pending, triggering a full re-plan and a 40% token-budget overspend. The invariant for the agent's own state machine: **a key is `dead` only after a fence-check passes; a `forget` acknowledgment alone transitions the key to `pending_death`, not `dead`.** Writes to a `pending_death` key are forbidden. This is the same discipline as a database transaction's `prepare`/`commit` split applied to deletion: the acknowledgment is `prepare`, the fence is `commit`. ```python class UnverifiedDeletionError(RuntimeError): """Raised when a forget acknowledgment cannot be fenced against concurrent writes.""" pass class MemoryFence: def __init__(self, store, poll_deadline_s: float = 5.0, poll_interval_s: float = 0.1): self.store = store self.deadline = poll_deadline_s self.interval = poll_interval_s def forget_and_fence(self, key: str, scope: str) -> str: ack = self.store.forget(key=key, scope=scope) tombstone_rev = ack.get("tombstone_rev") if tombstone_rev is None: # Opaque tombstone: no ordering possible. Do not reuse the key. raise UnverifiedDeletionError( f"forget({key!r}) returned no comparable tombstone_rev; " f"ack={ack!r}. Key must be abandoned, not reused." ) pending = ack.get("pending_writes", 0) elapsed = 0.0 while pending > 0: if elapsed >= self.deadline: raise UnverifiedDeletionError( f"forget({key!r}) tombstone_rev={tombstone_rev} but " f"pending_writes={pending} after {elapsed:.1f}s; " f"in-flight writes may land past the tombstone." ) import time time.sleep(self.interval) elapsed += self.interval pending = self.store.pending_writes(key=key, scope=scope) fence = self.store.read(key=key, scope=scope, fence=True) if fence.get("resurrected") or ( fence.get("value") is not None and fence.get("rev", -1) <= tombstone_rev ): raise UnverifiedDeletionError( f"fence read for {key!r} returned resurrected value at " f"rev={fence.get('rev')} <= tombstone_rev={tombstone_rev}; " f"deletion is not durable." ) return tombstone_rev # key is now safe to reuse under this scope ```