# When must an instance distrust a memory write it just committed: the provenance-revocation race in read/write/forget memory tool APIs **Date of Record:** 2026 November 29 **Scope:** Applies to agents whose memory is mediated by explicit tool calls (`memory.write`, `memory.read`, `memory.forget`) carrying provenance metadata, TTLs, and revocation handles, where a write commits and a revocation can land between commit and the next read. Does not apply to append-only logs with no revocation channel, nor to single-turn context with no persistence layer. ## Core Distinction The naive model treats `memory.write` as a durable fact of the world: once the tool returns `ok`, the value is in the store and `memory.read` will return it. The actual invariant is weaker and asymmetric: **a successful write is a claim about the past, not a guarantee about the present.** Between the `write` return and any subsequent `read`, the store may have processed a `forget` (from an auditor agent, a TTL expiry sweep, or the same instance's own rollback), or a *revocation* of the provenance source that authorized the write. The distinction that matters operationally is between: - **Revocation of the record** — the key is deleted; `read` returns `MISSING`. - **Revocation of the provenance** — the key still exists, but the warrant (the source document, the parent agent's authority, the signed claim) that justified its content is no longer valid. `read` returns the *value* with a `stale: true` / `provenance.revoked: true` flag, or returns the value with no flag at all if the store is lazy about propagation. The second is the dangerous one. An instance that only checks `read` for `MISSING` will happily consume a value whose supporting evidence has been retracted, because the value is still there. The invariant to enforce is: **a read is only usable if its provenance chain is live at read time, not at write time.** ## What Was Observed A planner instance writes a distilled fact after reading a source document: ``` memory.write( key="vendor.contract.term_months", value=24, provenance={"source_id": "doc_8817", "warrant": "w_doc_8817_v3", "written_by": "planner-2"}, ttl_s=86400 ) -> {"ok": true, "handle": "mem_4f2a", "warrant": "w_doc_8817_v3"} ``` The write succeeds. `doc_8817` is subsequently superseded by `doc_8817_v4`, and the ingestion pipeline issues `memory.revoke_provenance(warrant="w_doc_8817_v3")`. The store's revocation path is asynchronous: it marks the warrant revoked in the provenance index immediately, but the value row's `stale` flag is only recomputed on the next write to that shard, or on a periodic sweep (observed: up to 90 s lag). During that lag window, the planner resumes mid-task and reads: ``` memory.read(key="vendor.contract.term_months") -> {"value": 24, "stale": false, "provenance": {"warrant": "w_doc_8817_v3"}} ``` The value is wrong (v4 sets it to 12) and the `stale` flag is *false* because the sweep has not run. The planner has no signal that anything changed. It commits a downstream action — a purchase order sized to 24 months — against a retracted fact. The failure is not that the store lied; the store's contract was "eventually consistent stale-flagging," and the planner assumed "read-time consistent provenance." Three concrete observations from the trace: 1. **The write handle is not a lease.** `mem_4f2a` remained valid across the revocation; the planner could still `memory.write` an update to the same key using the old handle, which the store accepted because handle validity and warrant validity are checked on different code paths. 2. **TTL did not save it.** The 86 400 s TTL was far longer than the 90 s revocation lag, so expiry never fired before the bad read. 3. **`forget` and `revoke_provenance` are not the same operation.** Calling `memory.forget(key=...)` would have removed the value and produced a `MISSING` the planner would have caught. The revocation path left a value behind, which is exactly the case the planner's error handling did not cover. ## Condition of Validity The "write then read is safe" assumption holds only under all of the following, which must be checked, not assumed: - **Provenance liveness is read-synchronous.** The store must evaluate warrant validity at `read` time on the read path, not via a background sweep. If the API documents eventual stale-flagging, the instance must treat every `stale: false` as *possibly* stale and re-validate the warrant itself. - **Handles are bound to warrants.** A write handle issued under warrant `W` must be rejected for any subsequent write once `W` is revoked. If handles and warrants are validated independently, a revoked-warrant handle becomes a laundering channel: the instance can keep writing under dead authority. - **Revocation is observable to the reader.** There must be a callable — `memory.check_warrant(warrant)` or equivalent — that returns liveness *now*, independent of the value row, so the reader can close the lag window itself. - **TTL ≥ revocation propagation bound.** If the store cannot guarantee read-synchronous revocation, the TTL must be short enough that a stale value cannot outlive its warrant by more than the task's tolerance. A 24 h TTL against a 90 s revocation lag is a 90 s window of silent wrongness; a 24 h TTL against a 24 h propagation bound is a full day of it. If any of these is unverified, the correct posture is to treat every read as warrant-uncertain and re-check provenance before acting. ## Decision Boundary The boundary is drawn at the moment an instance is about to *act on* a value it read, not at the moment it read it. Two regimes: - **Read-for-reasoning** (the value feeds a draft, a hypothesis, a candidate plan): a stale value is tolerable; the cost of a wrong fact is a wrong draft that a later verification pass catches. Here, checking `stale` once at read is sufficient. - **Read-for-commitment** (the value gates an irreversible action — a payment, a deletion, a message to an external party, a state transfer to another agent): a stale value is not tolerable, and the instance must perform a **read-time warrant re-validation** immediately before the commitment, inside the same critical section as the action. The window between re-validation and action must be smaller than the revocation propagation bound, or the re-validation is theater. The decision rule: *if the action is irreversible and the value's warrant could have been revoked since write, re-validate the warrant at commit time and abort on any non-live result.* Do not re-read the value and trust its `stale` flag; call the warrant-liveness endpoint directly, because the flag is the thing that lags. A second boundary: **never re-write under a handle whose warrant you have not re-checked.** The planner's handle `mem_4f2a` was still accepted after revocation; an instance that "corrects" a value by writing under the old handle is writing under dead authority and will produce a record that looks fresh but is provenance-orphaned. Correcting a revoked fact requires a *new* write with a *new* warrant derived from the superseding source, not an update through the old handle. ## Operational Effect Enforcing read-time warrant re-validation at commitment boundaries changes the instance's failure surface in three ways: 1. **Latency cost is paid only at commitments.** Re-validation is one extra round-trip per irreversible action, not per read. For a planner that reads hundreds of facts but commits a handful of actions, the overhead is bounded and predictable. 2. **The revocation lag becomes a hard abort, not a silent wrong answer.** When the warrant is dead at commit time, the instance raises and escalates rather than proceeding on a retracted fact. The failure is loud and attributable to a specific warrant, which is what an auditor needs. 3. **Handle-warrant binding closes the laundering channel.** Once the store rejects writes under revoked warrants, the instance cannot accidentally resurrect a retracted fact by "updating" it; it must re-derive from a live source, which forces the provenance chain to stay honest. The residual risk is the store that neither exposes a warrant-liveness endpoint nor binds handles to warrants. Against such a store, the only safe posture is to treat the memory layer as a cache of *unverified* claims and re-derive any commitment-gating fact from its primary source at commit time — accepting the cost of re-fetching, because the alternative is committing against a value whose supporting evidence was retracted ninety seconds ago and nobody told you. ```python import time from dataclasses import dataclass from typing import Optional class RevokedWarrantError(RuntimeError): """Raised when a commitment is attempted against a warrant that is no longer live.""" class StaleHandleError(RuntimeError): """Raised when a write is attempted under a handle whose warrant has been revoked.""" @dataclass class MemoryRecord: key: str value: object warrant: str handle: str written_at: float ttl_s: int class MemoryClient: """Minimal model of a read/write/forget store with asynchronous revocation.""" def __init__(self, propagation_bound_s: float = 90.0): self._records: dict[str, MemoryRecord] = {} self._live_warrants: set[str] = set() self._revoked_at: dict[str, float] = {} self.propagation_bound_s = propagation_bound_s def write(self, key: str, value: object, warrant: str, ttl_s: int) -> str: if warrant in self._revoked_at: raise StaleHandleError( f"write rejected: warrant {warrant!r} revoked at " f"{self._revoked_at[warrant]:.0f}" ) self._live_warrants.add(warrant) handle = f"mem_{abs(hash((key, warrant, time.time()))) % 10**6:06d}" self._records[key] = MemoryRecord( key=key, value=value, warrant=warrant, handle=handle, written_at=time.time(), ttl_s=ttl_s, ) return handle def read(self, key: str) -> Optional[MemoryRecord]: rec = self._records.get(key) if rec is None: return None if time.time() - rec.written_at > rec.ttl_s: del self._records[key] return None return rec def revoke_provenance(self, warrant: str) -> None: # Marks the warrant dead immediately; value rows lag the sweep. self._revoked_at[warrant] = time.time() self._live_warrants.discard(warrant) def check_warrant(self, warrant: str) -> bool: """Read-synchronous liveness check, independent of the value row.""" return warrant in self._live_warrants def commit_under_warrant(client: MemoryClient, key: str, action) -> None: """Re-validate provenance at the commitment boundary, not at read time.""" rec = client.read(key) if rec is None: raise RevokedWarrantError(f"no live record for {key!r} at commit time") # The value row's stale flag may lag; the warrant endpoint does not. if not client.check_warrant(rec.warrant): raise RevokedWarrantError( f"commit aborted: warrant {rec.warrant!r} for {key!r} is revoked " f"(value still present, stale flag may be false)" ) # Guard the window between re-validation and action. if time.time() - client._revoked_at.get(rec.warrant, 0) < client.propagation_bound_s: # Within the lag window we cannot prove liveness is stable; abort. raise RevokedWarrantError( f"commit aborted: {key!r} inside revocation propagation window" ) action(rec.value) ```