# When must an instance refuse to forget a provenance-tagged memory whose write quorum was never acknowledged **Date of Record:** 2026 December 1 **Scope:** Applies to agents that expose distinct `write_memory`, `read_memory`, and `forget_memory` tool calls over a provenance-tagged vector store plus an episodic log, where a `forget` can be issued against an item whose `write` returned before write-quorum acknowledgment. Does not apply to append-only stores with no deletion primitive, or to single-writer stores where write and forget are serialized on one connection. ## Core Distinction The failure is not "forget deleted something it shouldn't have." The recoverable bug is subtler: **a `forget` acknowledgment is a claim about the durable absence of a record, but the record it is forgetting may not yet be durably present.** When `write_memory` returns optimistically (vector upsert queued, episodic append pending replication) and the agent then decides, in the same reasoning loop, that the fact was wrong and calls `forget_memory`, the forget targets a *provenance tag* rather than a *committed record*. The store has two representations of the same fact moving through independent pipelines at different speeds: - The **vector store** upsert is fast, idempotent by embedding key, and often acknowledged after in-memory index insertion but before segment flush. - The **episodic log** append is ordered, slower, and carries the provenance chain (source turn, tool call id, parent span) that downstream auditors use to reconstruct *why* the fact existed. A forget that tombstones the vector key and appends a `forget` event to the episodic log can therefore **invert the causal order** in the log: the forget event lands before the write event it is meant to cancel. The vector key is gone, but the episodic log now contains an orphaned `write` that replays into any agent that cold-starts from the log, resurrecting the fact the forget was supposed to erase. This is a *continuity invariant violation*: replay is not idempotent with respect to write/forget interleaving. ## What Was Observed A research agent ran a three-turn loop: `write_memory("user's employer is Acme", provenance=span_42)`, then a tool result contradicted it (`"user's employer is Initech"`), then `forget_memory(provenance=span_42)` followed immediately by `write_memory("user's employer is Initech", provenance=span_47)`. The forget returned `{"status": "forgotten", "tombstones": 1}`. The vector query for "employer" returned only Initech. Correct at the surface. Twelve minutes later a second instance cold-started from the episodic log to answer a related query. Its replay reconstructed memory state by folding events in log order: `write(span_42)`, `forget(span_42)`, `write(span_47)`. That fold is correct *if* the log order matches causal order. It did not. The forget event had been appended with a lower sequence number than the write it canceled, because the write's episodic append was still in the replication queue when the forget fired. The replay fold produced `write(span_42)`, `write(span_47)`, `forget(span_42)`, and — because the fold keyed on provenance and the last event for `span_42` was a forget — it also *erased* `span_47` under a tag-collision rule that treated same-fact writes as superseding. The second instance answered "employer unknown" and re-derived Acme from an unrelated cached context. The tell is that the first instance's `read_memory` was correct and the second instance's was wrong, for the same logical fact, at the same wall-clock time. The divergence is not staleness; it is **replay non-determinism induced by forget/write reordering across two pipelines with independent acknowledgment semantics.** ## Condition of Validity This failure requires all of the following to hold simultaneously: 1. `write_memory` returns before the episodic append is durably ordered (optimistic ack, queue depth > 0, or replication lag). 2. `forget_memory` appends its own episodic event synchronously, so the forget's log position is *later in arrival* but *earlier in sequence* than the pending write. 3. The episodic log is the source of truth for cold-start replay (as opposed to the vector store, which is treated as a derived cache). 4. Replay folds events by provenance tag with a last-writer-wins or supersession rule, rather than by causal dependency. Remove any one and the bug does not fire. If the write ack is synchronous with the episodic append, order is preserved. If replay reads the vector store directly, the tombstone holds. If the fold is causal (forget only cancels the specific write it names, and supersession is keyed on `(fact_id, version)` rather than provenance tag), the collision does not erase `span_47`. The condition is *not* met by stores that expose a `write_memory` ack token that `forget_memory` must present. That token is the missing invariant. ## Decision Boundary The boundary is: **an instance must refuse to execute `forget_memory` against a provenance tag whose write has not returned a durable commit token, and must instead return a deferred-forget handle.** Concretely: - `write_memory` must return a `commit_token` that is only issued after the episodic append is ordered (or must return `{"status": "pending", "commit_token": null}`). - `forget_memory` must require a `commit_token` and must reject a provenance-only target with a distinct error, not a generic failure, so the agent can branch. - The agent's reasoning loop must treat `pending` writes as *un-forgettable* and either wait, or write a compensating `retract` event that names the pending write and is ordered *after* it by construction (a `retract` that the write pipeline applies on flush, not a `forget` that races it). The tempting wrong boundary is "make forget synchronous." That closes the race but does not fix replay: a synchronous forget still produces a log where forget precedes write if the write's append was already queued. The only invariant that holds is **forget references a committed token, and the log fold is causal, not tag-keyed.** ## Operational Effect With the token requirement in place, the three-turn loop becomes: write returns `pending`; the agent, seeing contradiction, issues `retract(commit_token=pending_handle)` which enqueues a cancel that the write pipeline applies before flush; the subsequent `write(span_47)` commits with its own token. Replay folds `write(span_42)` → `retract(span_42)` → `write(span_47)` in causal order regardless of arrival order, because the retract carries the token of the write it cancels. Cold-start reconstruction is now idempotent: replaying the log twice yields the same memory state, which is the continuity invariant the original design silently lacked. The cost is one extra round-trip on the write path and a `pending` state the agent must handle — a state most agent loops are not written to expect, which is why the failure is common and the fix is not. ```python from dataclasses import dataclass from typing import Optional class UncommittedForgetError(RuntimeError): """Raised when forget_memory targets a provenance tag with no durable commit token.""" pass @dataclass class WriteHandle: provenance: str commit_token: Optional[str] # None => episodic append not yet ordered class MemoryStore: def __init__(self) -> None: self._committed: dict[str, str] = {} # provenance -> commit_token self._pending: dict[str, WriteHandle] = {} def write_memory(self, provenance: str, durable: bool) -> WriteHandle: handle = WriteHandle(provenance, commit_token=f"tok:{provenance}" if durable else None) if durable: self._committed[provenance] = handle.commit_token # type: ignore[assignment] else: self._pending[provenance] = handle return handle def forget_memory(self, provenance: str, commit_token: Optional[str]) -> str: # Invariant: a forget must name a token that the store has durably committed. if commit_token is None or self._committed.get(provenance) != commit_token: raise UncommittedForgetError( f"refusing to forget {provenance!r}: no durable commit token; " f"issue retract(handle) instead and let the write pipeline apply it on flush" ) del self._committed[provenance] return "forgotten" def retract(self, handle: WriteHandle) -> str: # Cancel a pending write before it flushes; ordered after the write by construction. if handle.provenance in self._pending: del self._pending[handle.provenance] return "retracted_pending" return self.forget_memory(handle.provenance, handle.commit_token) # Trigger: optimistic write, then immediate forget in the same reasoning loop. store = MemoryStore() h = store.write_memory("span_42", durable=False) try: store.forget_memory("span_42", commit_token=None) except UncommittedForgetError as e: print("blocked:", e) print("safe path:", store.retract(h)) ```