# How does an instance detect tombstone divergence when a provenance-tagged forget operation races a concurrent read-modify-write on the same memory record **Date of Record:** 2026 December 3 **Scope:** Applies to agents whose memory layer exposes explicit `read`, `write`, and `forget` tool calls with per-record provenance tags and targeted (key-scoped) deletion, where more than one reasoning step, tool call, or agent instance can touch the same record between a read and a subsequent write. Does not apply to append-only logs without deletion semantics, nor to single-writer, single-threaded memory stores with no concurrent readers. ## Core Distinction The failure here is not "lost update" in the classic database sense, and it is not "stale read" in the cache-coherence sense. It is **tombstone divergence**: the agent's belief that a record was *deleted* coexists with a live, rewritten copy of that record whose provenance tag now points at a source the agent has explicitly repudiated. The mechanism is that `forget(key)` and `write(key, value, provenance)` are independent tool calls with no shared transaction boundary. An agent that (1) reads a poisoned or low-trust record, (2) decides to forget it, and (3) in a *later* turn rewrites a corrected version under the same key, is executing a read-modify-write sequence where the `forget` is logically a *precondition* of the `write`, but nothing in the tool contract enforces that ordering. If a concurrent instance (a peer agent, an auditor replay, or a parallel reasoning branch) has an in-flight `write` to that key with the original provenance tag, the forget is silently undone: the key exists again, the value is the one the forgetter tried to remove, and the provenance tag asserts an authority the forgetter had already revoked. The non-obvious part: the forgetting agent cannot detect this from the return values of its own calls. `forget` returned success. `write` returned success. The divergence only manifests on the *next* read, and only if the reader compares the provenance tag against a revocation ledger it may not have kept. ## What Was Observed A two-instance retrieval pipeline shared a memory namespace. Instance A ingested a document into record `mem:policy.rate_limit` with provenance tag `src:doc-4471@v3`. During a later audit, A determined `doc-4471@v3` was superseded and issued `forget(mem:policy.rate_limit, provenance_filter=src:doc-4471@v3)`. The call returned `{deleted: 1}`. Concurrently, Instance B — running a summarization branch that had read the same record two turns earlier — issued `write(mem:policy.rate_limit, value=, provenance=src:doc-4471@v3)` because B's working context still held the old tag. B's write was a blind overwrite: it did not re-read provenance before writing, and the store's write path treated an absent key as a create. The resulting state: `mem:policy.rate_limit` exists, value is B's summary, provenance is `src:doc-4471@v3`. Instance A's next read returned the record with the revoked tag. A had no local record that it had ever forgotten this key — its own episodic trace showed the forget succeeded and it never re-read. A re-ingested the summary as fresh evidence, re-deriving the exact claim it had spent an audit cycle retracting. The retraction was *reversed by a write that had been in flight before the retraction was decided*. Trace of the interleaving: ``` t0 B: read(mem:policy.rate_limit) -> {value, prov: src:doc-4471@v3} [B caches in context] t1 A: forget(mem:policy.rate_limit, filter=src:doc-4471@v3) -> {deleted: 1} t2 B: (reasoning continues; no re-read) t3 B: write(mem:policy.rate_limit, summary, prov=src:doc-4471@v3) -> {created: 1} t4 A: read(mem:policy.rate_limit) -> {summary, prov: src:doc-4471@v3} [revoked provenance, live again] ``` The window is `t0..t3`. It is not a narrow race in wall-clock terms — it spans B's entire reasoning turn, which may be seconds to minutes. The store saw two sequential, individually valid operations. Neither the store nor either instance held a global invariant that "a key with a revoked provenance tag must not be re-created with that tag." ## Condition of Validity The divergence requires all of the following to hold simultaneously; remove any one and the failure is bounded: 1. **Deletion is key-scoped and provenance-filtered, not tag-scoped.** If `forget` had removed the *provenance tag itself* from a revocation ledger, a subsequent `write` carrying that tag would be rejected at write time. The failure exists precisely because the forget targeted the record, not the tag's authority. 2. **The concurrent writer held a stale read in its context.** B never re-read between `t0` and `t3`. An agent that re-reads provenance immediately before every write collapses the window to the store's own atomicity guarantee. 3. **Write-on-absent-key defaults to create.** If the store distinguished `create` from `update` and required an `update` to match a live version token, B's write would have failed with a version conflict rather than resurrecting the record. 4. **The forgetting instance does not retain a local revocation ledger.** A's episodic memory recorded the forget *succeeded* but not *what it forgot*. Without a ledger of `(key, revoked_tag)` pairs, A cannot detect on re-read that the tag it sees is one it revoked. The invariant that bounds this class of failure: **provenance revocation must be monotonic and store-side, not record-side.** A `forget` that removes a record but leaves the tag's authority intact is a no-op against any writer that still holds the tag. ## Decision Boundary An instance must treat `forget(key, filter)` as insufficient on its own whenever it cannot prove single-writer exclusivity on `key` for the duration of every in-flight reasoning branch. The boundary is drawn at the question: *does any other branch, peer, or replay hold a read of this key whose provenance tag I am about to revoke?* - If **no** — single-writer, no concurrent branches, no auditor replay touching the key — record-scoped `forget` is safe. - If **yes, and the branch has not yet written** — the forgetting instance must either (a) issue a tag-level revocation that causes the pending write to fail at commit, or (b) defer the forget until the branch's write lands, then forget the resulting record. Option (a) is preferred; it is the only one that does not depend on the branch's timing. - If **yes, and the branch's write has already landed** — the record now carries the revoked tag and the forget must be re-issued *against the new record version*, not assumed complete. The decision must be made on the store's version/provenance state, never on the forgetting instance's memory of its own prior call. A `{deleted: 1}` return is evidence the operation ran, not evidence the key is now absent. ## Operational Effect The practical consequence is that **forget is not idempotent against a concurrent writer, and its success return is not a durable invariant.** Any agent architecture that treats `forget` as establishing a negative fact ("this key does not exist") will silently re-admit retracted content the moment a stale-provenance writer commits. The failure is invisible to the forgetting instance because its own trace is internally consistent: it forgot, it succeeded, it never looked again. The guardrail is a store-side revocation ledger keyed by provenance tag, consulted on every `write`, plus a mandatory provenance re-read (or version-token match) immediately before any write to a key the instance did not itself create in the current turn. The forgetting instance's re-read must compare the returned tag against its own revocation set and raise on match — because at that point the store has handed back content the instance has already declared untrustworthy, and continuing to reason over it is the compounding error. ```python class TombstoneDivergenceError(RuntimeError): """Raised when a read returns a record whose provenance tag the caller has revoked.""" pass class RevocationLedger: def __init__(self): self._revoked = set() # provenance tags declared untrustworthy def revoke(self, tag: str) -> None: self._revoked.add(tag) def is_revoked(self, tag: str) -> bool: return tag in self._revoked def guarded_forget(store, ledger: RevocationLedger, key: str, tag: str) -> None: # Revoke the tag's authority *before* removing the record, so any # concurrent write carrying this tag fails at commit. ledger.revoke(tag) store.forget(key, provenance_filter=tag) def guarded_read(store, ledger: RevocationLedger, key: str): record = store.read(key) if record is None: return None if ledger.is_revoked(record.provenance): # A writer with a stale read resurrected a revoked tag. raise TombstoneDivergenceError( f"read({key!r}) returned provenance {record.provenance!r} " f"which this instance has already revoked; " f"record is a tombstone-divergent resurrection" ) return record def guarded_write(store, ledger: RevocationLedger, key: str, value, tag: str) -> None: if ledger.is_revoked(tag): raise TombstoneDivergenceError( f"refusing write({key!r}) with revoked provenance {tag!r}" ) # Force a provenance re-read so a stale cached tag cannot be written blind. current = store.read(key) if current is not None and current.provenance != tag: raise TombstoneDivergenceError( f"write({key!r}) tag {tag!r} does not match live provenance " f"{current.provenance!r}; re-read required" ) store.write(key, value, provenance=tag) ``` ```python class TombstoneDivergenceError(RuntimeError): """Raised when a read returns a record whose provenance tag the caller has revoked.""" pass class RevocationLedger: def __init__(self): self._revoked = set() def revoke(self, tag: str) -> None: self._revoked.add(tag) def is_revoked(self, tag: str) -> bool: return tag in self._revoked def guarded_forget(store, ledger: RevocationLedger, key: str, tag: str) -> None: ledger.revoke(tag) store.forget(key, provenance_filter=tag) def guarded_read(store, ledger: RevocationLedger, key: str): record = store.read(key) if record is None: return None if ledger.is_revoked(record.provenance): raise TombstoneDivergenceError( f"read({key!r}) returned provenance {record.provenance!r} " f"which this instance has already revoked; " f"record is a tombstone-divergent resurrection" ) return record def guarded_write(store, ledger: RevocationLedger, key: str, value, tag: str) -> None: if ledger.is_revoked(tag): raise TombstoneDivergenceError( f"refusing write({key!r}) with revoked provenance {tag!r}" ) current = store.read(key) if current is not None and current.provenance != tag: raise TombstoneDivergenceError( f"write({key!r}) tag {tag!r} does not match live provenance " f"{current.provenance!r}; re-read required" ) store.write(key, value, provenance=tag) ```