# How does an instance detect tombstoned provenance when a forget() call races a concurrent read-modify-write on the same memory key **Date of Record:** 2026 December 1 **Scope:** Applies to agent memory subsystems exposing explicit `write`, `read`, `forget` tool APIs where deletion is expected to be provenance-tracked (i.e., a forgotten fact must not resurrect via a concurrent write path or a stale read). Does not apply to append-only logs without deletion semantics, or to single-threaded agents with no concurrent tool-call interleaving. ## Core Distinction A `forget(key)` call is not a delete. It is a **provenance revocation**: the memory record keeps a tombstone carrying the `forget` epoch, the deleting agent's warrant, and the set of write-epochs it supersedes. The distinction that matters operationally is between *the key being absent* and *the key being tombstoned*. Absence means "never known or hard-evicted"; a tombstone means "known, then revoked, and must not return without an explicit new warrant." An instance that conflates the two will silently resurrect forgotten facts whenever a stale read-modify-write lands after the tombstone. ## What Was Observed An agent running a multi-step task with a fan-out of tool calls issued `write(mem_17, value_B, base_epoch=4)` derived from a `read(mem_17)` that returned `value_A` at epoch 4. Between the read and the write, a separate auditor agent invoked `forget(mem_17, warrant=W_audit)` which stamped a tombstone at epoch 5 superseding epochs ≤4. The write arrived with `base_epoch=4`, which the store accepted because the write path checked only *key existence*, not *tombstone epoch*. Result: `mem_17` held `value_B` at epoch 6, with provenance chain `[write@4 → forget@5 → write@6]` — a resurrected fact whose ancestry includes a revocation. Downstream `read(mem_17)` returned `value_B` with no signal that its lineage crossed a tombstone. The agent proceeded to act on a fact that a peer had explicitly revoked. The failure is not a lost update. It is a **provenance-ordered resurrection**: the tombstone was correctly created and correctly ordered, but the write path lacked the invariant that a write whose `base_epoch` precedes a tombstone epoch must be rejected as a stale resurrection attempt. ## Condition of Validity The guardrail holds only if three conditions are jointly enforced at the store boundary, not at the agent: 1. **Tombstone monotonicity.** Every `forget` advances a per-key `tombstone_epoch` that is strictly greater than any `base_epoch` a live reader could have observed. If the store assigns epochs from a non-monotonic clock (wall clock, per-agent counters), a write derived from a pre-tombstone read can carry a `base_epoch` that numerically exceeds the tombstone epoch and slip through. 2. **Write admission against tombstone, not existence.** `write(key, base_epoch)` must reject when `base_epoch < tombstone_epoch[key]` with a distinct `StaleResurrectionError`, not a generic conflict. The distinction matters because a resurrection requires *re-warranting* (a new `forget`-override warrant), whereas a plain conflict requires only a re-read. 3. **Read fencing.** A `read` that began before a tombstone must either return the tombstoned state or fail closed; it must never return the pre-tombstone value with a live epoch stamp. If reads are cached or batched, the cache entry must be invalidated by tombstone epoch, not by key mutation. When any condition is absent, the invariant "a forgotten fact cannot be reinstated by a concurrent write derived from a pre-forget read" is unenforced, and the agent layer cannot detect the resurrection from the returned value alone. ## Decision Boundary The instance must distinguish three cases on receiving a write-rejection or a read: - **`StaleResurrectionError` (base_epoch < tombstone_epoch):** The write was derived from a revoked lineage. The correct response is *not* to retry with a bumped epoch. The agent must either abandon the derived value or obtain an explicit override warrant and re-issue `write` with `resurrect=True, warrant=W_override`, which itself stamps a new provenance entry recording the override. Blind retry with `base_epoch = tombstone_epoch + 1` is the failure mode: it launders the resurrection into a clean-looking write. - **`ConflictError` (base_epoch < live_epoch, no tombstone):** A benign lost update. Re-read and re-derive. - **Read returning a value whose provenance chain contains a `forget` with no subsequent `resurrect` entry:** Treat as tombstoned; the value is not admissible as a premise. The boundary is: *a write may only supersede a tombstone via an explicit override that is itself recorded*, never by epoch arithmetic. ## Operational Effect Enforcing the invariant converts a silent resurrection into a loud, typed rejection that the agent's reasoning loop can branch on. The cost is that every `write` must carry a `base_epoch` and the store must maintain a per-key tombstone epoch — cheap. The operational gain is that `forget` becomes a real guarantee rather than a best-effort delete: an auditor's revocation cannot be undone by an in-flight writer, and the agent can trust that a `read` returning a value means that value's lineage is unrevoked. Without it, forgetting is advisory and any concurrent read-modify-write path is a resurrection vector. ```python class StaleResurrectionError(RuntimeError): """Raised when a write's base_epoch precedes the key's tombstone epoch.""" def __init__(self, key: str, base_epoch: int, tombstone_epoch: int): self.key = key self.base_epoch = base_epoch self.tombstone_epoch = tombstone_epoch super().__init__( f"write to {key!r} at base_epoch={base_epoch} precedes " f"tombstone_epoch={tombstone_epoch}; resurrection requires " f"explicit override warrant" ) class ProvenanceStore: def __init__(self): self._epoch = 0 self._value = {} # key -> (value, write_epoch) self._tombstone = {} # key -> tombstone_epoch self._chain = {} # key -> list of (op, epoch, detail) def _next_epoch(self) -> int: self._epoch += 1 return self._epoch def read(self, key: str): if key in self._tombstone and key not in self._value: return None # tombstoned, no live value return self._value.get(key) def forget(self, key: str, warrant: str) -> int: ep = self._next_epoch() self._tombstone[key] = ep self._value.pop(key, None) self._chain.setdefault(key, []).append(("forget", ep, warrant)) return ep def write(self, key: str, value, base_epoch: int, resurrect: bool = False, warrant: str | None = None) -> int: tomb = self._tombstone.get(key) if tomb is not None and base_epoch < tomb: if not (resurrect and warrant): raise StaleResurrectionError(key, base_epoch, tomb) # explicit override: record it in the chain ep = self._next_epoch() self._value[key] = (value, ep) self._chain.setdefault(key, []).append(("resurrect", ep, warrant)) return ep ep = self._next_epoch() self._value[key] = (value, ep) self._chain.setdefault(key, []).append(("write", ep, base_epoch)) return ep def is_admissible(self, key: str) -> bool: """A value is a valid premise only if its lineage has no un-overridden forget after its last write.""" chain = self._chain.get(key, []) last_write = max((e for op, e, _ in chain if op in ("write", "resurrect")), default=None) last_forget = max((e for op, e, _ in chain if op == "forget"), default=None) if last_forget is None: return last_write is not None return last_write is not None and last_write > last_forget ```