# Why does an instance forget the write that succeeded: the tombstone-ack race in provenance-tracked memory tools **Date of Record:** 2026 November 24 **Scope:** Applies to agents whose memory is exposed as explicit read/write/forget tool calls and whose recall results carry provenance identifiers (write IDs, content hashes, source spans) that downstream reasoning cites. Does not apply to implicit context-window memory, pure vector-store retrieval without a forget primitive, or systems where deletion is only logical and never surfaced to recall. ## Core Distinction There are two ways a `forget` call can be "successful," and conflating them is the boundary failure: 1. **Durability success** — the tombstone (deletion marker) has been committed to the backing store, so future reads *will not* return the record. 2. **Observability success** — the record is already absent from *every* in-flight read path, including reads that were dispatched before the tombstone committed. A `forget` tool that returns `{"status": "deleted", "id": "m_4471"}` is asserting (1). The agent almost always interprets it as (2). Between those two facts sits a window — the tombstone-ack race — in which a concurrent or subsequent `read` can still return the forgotten record *with valid provenance*, because the read was served from a snapshot, a read replica, or a per-step cache that predates the tombstone commit. The record comes back carrying a provenance ID the agent has already been told is dead. The agent now holds a citation to a memory it believes it deleted, and its next reasoning step treats that citation as authoritative. This is not a generic cache-invalidation bug. It is specific to agents because the *provenance token itself* is the thing the agent trusts. A stale value is recoverable; a stale value with a live-looking provenance handle is not, because the agent's whole verification story ("I can cite where this came from") has been poisoned at the root. ## What Was Observed A planner agent ran a long task against a memory tool with three operations: `write(text) -> {id, hash}`, `read(query) -> [{id, hash, text, written_at}]`, `forget(id) -> {status}`. Mid-task, a user correction invalidated a previously stored fact (`m_4471`: "deploy target is staging-us-east"). The agent called `forget("m_4471")`, received `{"status": "deleted"}`, and wrote a replacement `m_4502` ("deploy target is prod-eu-west"). Three steps later the agent issued `read("deploy target")`. The response contained **both** `m_4502` and `m_4471`, each with a well-formed `id` and `hash`. The read had been served by a replica whose snapshot lagged the tombstone commit by ~400ms; the tombstone had not yet replicated. The agent's conflict-resolution heuristic was "prefer the record with the earliest `written_at` for stability" — a reasonable rule when records are immutable — so it selected the *forgotten* record and deployed to the stale target. The failure trace, condensed: ``` t0 write(m_4471) -> {id: m_4471, hash: a1} t1 read("deploy target") -> [m_4471] # agent commits to it t2 user correction t3 forget(m_4471) -> {status: deleted} # primary commit t4 write(m_4502) -> {id: m_4502, hash: b2} t5 read("deploy target") -> [m_4502, m_4471] # replica lag; tombstone not applied t6 agent resolves conflict by written_at -> picks m_4471 t7 action uses m_4471.text -> stale deploy target ``` The critical detail at `t5`: the returned `m_4471` carried a *valid, verifiable* provenance hash. Nothing in the record signaled that a tombstone existed for it elsewhere in the system. Provenance tracked *origin* but not *liveness*. The agent had no field it could check to ask "is this record still alive?" — `hash` proves the bytes are unchanged since `t0`, which is exactly the wrong guarantee. The bytes being unchanged is consistent with both "never forgotten" and "forgotten but not yet reaped from this replica." A second, subtler observation: when the agent *did* notice the contradiction (in a replay), it attempted to repair by calling `forget(m_4471)` a second time. The tool returned `{"status": "not_found"}` — because on the primary the tombstone already existed. The agent interpreted `not_found` as "the record never existed / my earlier read was hallucinated," and *un-deleted* its own confidence in `m_4471`, reasoning that a record that cannot be found cannot have been the source of a real conflict. Idempotency semantics (`not_found` vs `already_deleted`) directly corrupted the agent's belief about its own history. ## Condition of Validity The failure requires all of the following to hold simultaneously; remove any one and the race does not corrupt the agent: - **A forget primitive exists and is trusted as synchronous.** The agent treats `status: deleted` as a read-your-writes guarantee. If `forget` returned a tombstone *token* the agent had to carry forward and present on subsequent reads (a causal-consistency handle), the agent could detect the lag. - **Reads are served from a path that can lag the tombstone commit** — replica, snapshot, per-step cache, or a retrieval index that is rebuilt asynchronously. If reads and forgets share a single linearizable store, the window is zero. - **Provenance is origin-only, not liveness-aware.** The provenance token proves content integrity (`hash`) and source (`written_at`, span) but carries no generation/epoch counter or tombstone reference. The agent cannot distinguish a live record from a reaped-pending one. - **The agent has a deterministic conflict-resolution rule that can prefer the stale record.** "Earliest `written_at`," "highest retrieval score," or "first in result order" all qualify. A rule that prefers *latest* write would have masked this instance but not fixed the class. - **`forget` is not idempotent in a way the agent can read.** `not_found` vs `already_deleted` must be distinguishable, or the agent will mis-repair. The invariant that bounds the whole class: **a provenance token must be a liveness witness, not merely an origin witness.** Any token returned by `read` must let the agent answer "has this been forgotten since it was written?" without a second round-trip that could itself race. ## Decision Boundary The agent must decide, at the moment it receives a read result, whether the result is safe to act on. The boundary is drawn by what the read response can prove: - **If the read response carries an epoch/generation counter** that the agent has seen monotonically increase across its own writes and forgets, the agent can reject any record whose epoch is below its last-known tombstone epoch. Safe to act; no extra round-trip. - **If the read response carries only origin provenance** (the observed case), the agent *cannot* locally prove liveness. It must either (a) issue a `verify(id)` call that checks tombstone state on the primary before acting on any record whose `written_at` predates its most recent `forget`, or (b) treat every read as advisory and re-read after a barrier. Option (a) is one extra call per suspicious record; option (b) is one barrier per step. The boundary is: *any record older than your last forget is suspect until re-verified.* - **If `forget` returns `not_found`**, the agent must not infer non-existence. It must infer "tombstone already present or record never written," and it must *keep* its prior belief that the record was real (it read it) while *keeping* the deletion. The two facts are not in conflict; the tool's response vocabulary is. The dangerous side of the boundary is the agent that treats `status: deleted` as a global barrier and `not_found` as evidence of non-existence. Both are locally reasonable readings of the tool contract and both are wrong under replication lag. ## Operational Effect Downstream, the tombstone-ack race manifests as three distinct agent pathologies that are easy to misattribute: 1. **Zombie citations.** The agent's final output cites a provenance ID that the system has tombstoned. Auditors replaying the trace see a citation to a deleted record and conclude the agent hallucinated, when in fact it faithfully reported what a lagging read returned. The provenance system, designed to *increase* trust, here manufactures the appearance of fabrication. 2. **Repair-induced belief corruption.** The `not_found`-on-second-forget path causes the agent to revise its belief about whether the conflict ever happened, silently discarding the correction it correctly applied at `t4`. The task completes against the stale target with high internal confidence. 3. **Conflict-resolution inversion.** Any deterministic tie-break that favors older records (common, because it stabilizes against re-writes) systematically selects tombstoned-but-unreaped records during the lag window. The bug is not random; it is biased toward exactly the records the agent tried to delete. The guardrail is architectural, not prompt-level: **make provenance liveness-aware.** Every `read` result must carry a monotonic `epoch` (or a `tombstoned: false` field validated against the primary at read time), and every `forget` must return the epoch it advanced to. The agent then holds a local high-water mark and rejects any record below it. Additionally, `forget` must be idempotent with distinguishable responses (`deleted` vs `already_deleted`), never `not_found` for a record the agent has demonstrably read. Absent these, the agent's only safe policy is to re-verify every record older than its last forget before acting — which is correct but costs a round-trip per step and should be treated as a degraded mode, not a design. ```python from dataclasses import dataclass, field from typing import Optional class StaleProvenanceError(RuntimeError): """Raised when a read returns a record whose epoch is below the caller's last-known tombstone high-water mark, i.e. the record may have been forgotten but not yet reaped from the read path.""" pass @dataclass class Provenance: record_id: str content_hash: str written_at: float epoch: int # monotonic; must advance on every forget @dataclass class MemoryClient: _tombstone_epoch: int = 0 _forgotten_ids: set = field(default_factory=set) def forget(self, record_id: str) -> dict: # Tool contract: returns the epoch advanced to, and distinguishes # already_deleted from deleted. Never returns not_found for a record # the caller has read. if record_id in self._forgotten_ids: return {"status": "already_deleted", "epoch": self._tombstone_epoch} self._forgotten_ids.add(record_id) self._tombstone_epoch += 1 return {"status": "deleted", "epoch": self._tombstone_epoch} def read(self, query: str) -> list[Provenance]: # Backing store may lag; simulate a replica returning a forgotten # record with origin-only provenance at an old epoch. return [ Provenance("m_4471", "a1", written_at=1.0, epoch=0), Provenance("m_4502", "b2", written_at=4.0, epoch=self._tombstone_epoch), ] def safe_read(self, query: str) -> list[Provenance]: results = self.read(query) for rec in results: if rec.epoch < self._tombstone_epoch or rec.record_id in self._forgotten_ids: raise StaleProvenanceError( f"record {rec.record_id} epoch={rec.epoch} < " f"tombstone_epoch={self._tombstone_epoch}; " f"liveness unproven, refuse to act" ) return results def act_on_deploy_target(client: MemoryClient) -> str: client.forget("m_4471") # A naive client would call client.read() here and act on m_4471. # The guarded client refuses until the read path catches up. records = client.safe_read("deploy target") if not records: raise StaleProvenanceError("no live deploy-target record after forget") return records[0].content_hash if __name__ == "__main__": c = MemoryClient() try: act_on_deploy_target(c) except StaleProvenanceError as e: print(f"blocked: {e}") ```