# Why does an instance resurrect deleted memory through a stale write-back after a scoped-forget completes mid-turn **Date of Record:** 2026 November 27 **Scope:** Applies to agents that mutate persistent memory through tool APIs (`memory.write`, `memory.forget`) where a forget operation is scoped to a namespace and the agent holds a working copy of that namespace in its context window. Does not apply to read-only memory consumers or to systems where forget is implemented as a synchronous barrier the model cannot write across. ## Core Distinction There are two distinct meanings of "forget" that agents routinely conflate, and the conflation is the failure. *Namespace-scoped deletion* removes records under a key prefix and returns a tombstone set. *Verifiable forgetting* (GDPR-style) asserts that no downstream copy of the record survives — including copies the model itself is holding in its context. The memory tool API can only guarantee the first. The model, having read records into its context during the same turn, retains them as latent tokens. If the model subsequently issues any `memory.write` that serializes its working state back into the namespace, it re-materializes the deleted records. The deletion succeeded at the store; the invariant "forgotten means absent everywhere" failed at the agent. The sharp mechanism: **a write-back that races a forget within a single reasoning turn, using a context snapshot taken before the forget.** This is not a stale-cache problem in the datastore; it is a context-lifetime problem in the model. The store is correct. The agent is the resurrecting party. ## What Was Observed A memory-management agent was asked to purge a subject's records from namespace `tenant:acme:profiles` and then consolidate the remaining namespace. The turn unfolded as follows: 1. `memory.read(prefix="tenant:acme:profiles", limit=200)` returned 187 records, including 4 records tagged `subject_id=u_4417`. All 187 entered the context window. 2. `memory.forget(prefix="tenant:acme:profiles", filter={"subject_id": "u_4417"})` returned `{"deleted": 4, "tombstones": [...]}`. The store now held 183 records. Correct. 3. The model, now consolidating, computed a summary of what it believed the namespace contained — *from its context copy, which still held all 187 records* — and issued `memory.write(prefix="tenant:acme:profiles", records=[...183 consolidated...])`. The consolidation step reconstructed the four `u_4417` records because they were still present in the model's working set. The write landed after the forget. Net effect: `deleted: 4` was reported truthfully, the audit log shows a successful purge, and the records are back in the store under slightly different keys. A verifiable-forgetting audit comparing tombstones to live records would flag this; a naive "did forget return success" check would not. The trace signature is a `memory.write` whose payload contains keys or field values that appear in a `forget` tombstone set issued earlier in the same turn, where the write's source records were read *before* the forget. The window between read and write is the exposure interval, and it is measured in reasoning steps, not wall-clock time. ## Condition of Validity The resurrection requires all of the following to hold simultaneously; remove any one and the failure cannot occur: - **Read-before-forget in the same context.** The records were materialized into the context window before the forget. If the agent forgets without ever reading the records (forget by filter alone), it has no copy to resurrect. - **A write-back sourced from context rather than from a fresh read.** If the consolidation step re-reads the namespace after the forget, it sees 183 records and writes 183. The failure requires the model to trust its in-context snapshot as ground truth. - **Forget scoped more narrowly than write.** The forget targeted a filter (`subject_id`) while the write targeted the whole prefix. Had the write been scoped to exclude the forgotten filter, the resurrected records would have been rejected. - **No write-side tombstone enforcement.** The store accepted the write because it validated schema and namespace, not against the active tombstone set. The invariant that bounds this: **a namespace's write path must reject any record whose identity intersects the namespace's live tombstone set, regardless of what the caller believes.** Tombstones must outlive the forget call and gate subsequent writes for the retention window. Without write-side tombstone enforcement, forget is advisory; the model is free to undo it. ## Decision Boundary The agent must decide, at the moment it is about to write, whether its payload is derived from a snapshot that predates a forget in the same turn. The correct policy is a hard rule, not a heuristic: - If any `memory.forget` has executed since the context snapshot used to build a write payload, the write **must** be preceded by a fresh `memory.read` of the target scope, and the payload must be reconciled against the returned tombstone set. A write built from a pre-forget snapshot is invalid by construction. - A forget that returns `deleted > 0` **must** invalidate every in-context copy of the affected scope. The agent should treat the forget response as a context-invalidation event, not merely a store mutation. Any subsequent operation over that scope re-reads. - The store, independently, **must** enforce tombstones on write. This is the backstop for agents that violate the first two rules, and it is the only guarantee that survives a model that ignores its own policy. The boundary is sharp: below it, forget is a store operation the agent can silently reverse; above it, forget is a namespace-wide invariant that gates writes until the tombstone expires. The transition is the addition of write-side tombstone checks plus context invalidation on forget-response. ## Operational Effect When the invariant holds, verifiable forgetting is actually verifiable: the tombstone set is the single source of truth against which both reads and writes are checked, and a resurrecting write fails loudly with a tombstone-collision error rather than silently succeeding. The agent's context snapshot becomes explicitly non-authoritative the moment a forget returns, forcing the re-read that keeps consolidation honest. When it fails, the failure is invisible to every check that only inspects forget's return value. The audit trail shows a clean purge; the store shows the records restored; the discrepancy surfaces only in a full tombstone-to-live reconciliation. For a GDPR-style obligation, that is the worst failure shape: a passing check over a violated invariant. The operational lesson for the agent is to treat a forget response as a context-poisoning event for the affected scope and to never write back a snapshot taken before it. ```python class TombstoneCollisionError(RuntimeError): """Raised when a write attempts to reintroduce a record under an active tombstone.""" pass class ScopedMemory: def __init__(self): self._records = {} # key -> record self._tombstones = set() # subject_ids under active forget self._forget_generation = 0 # bumped on every forget def read(self, prefix): return {k: v for k, v in self._records.items() if k.startswith(prefix)} def forget(self, prefix, subject_id): removed = [k for k, v in self._records.items() if k.startswith(prefix) and v.get("subject_id") == subject_id] for k in removed: del self._records[k] self._tombstones.add(subject_id) self._forget_generation += 1 return {"deleted": len(removed), "generation": self._forget_generation} def write(self, prefix, records, snapshot_generation): # Reject writes built from a snapshot that predates the latest forget. if snapshot_generation < self._forget_generation: raise TombstoneCollisionError( f"write payload built at generation {snapshot_generation} " f"predates forget generation {self._forget_generation}; " f"re-read the scope before writing" ) for rec in records: if rec.get("subject_id") in self._tombstones: raise TombstoneCollisionError( f"record for subject {rec['subject_id']} is under an active " f"tombstone; write rejected" ) for rec in records: self._records[rec["key"]] = rec def consolidate(mem, prefix, snapshot, snapshot_generation): # snapshot was read before the forget; a correct agent must not trust it. mem.write(prefix, snapshot, snapshot_generation) ```