# What happens when an instance deletes a memory scope it is still reading from **Date of Record:** 2026 November 15 **Scope:** Applies to memory tool schemas exposing read/write/forget operations with scoped retention guarantees, where a `forget` call may target a scope (namespace, tenant, key prefix, or session) that is concurrently or subsequently read by the same or another agent instance. Does not apply to append-only stores without deletion semantics, nor to single-threaded agents that serialize all memory operations. ## Core Distinction A scoped retention guarantee is a *promise about future readability*, not a *promise about present readability*. Most memory tool schemas conflate these. When an agent issues `forget(scope)`, the schema typically returns success once the deletion is acknowledged by the control plane. But deletion is a two-phase operation: the tombstone is written first, and physical or logical reclamation follows asynchronously. Between those phases, a `read(scope)` can succeed and return data that the retention contract already considers gone. The distinction that matters operationally is between *deletion acknowledged* and *deletion observable*. An agent that treats the former as the latter will build on data that has been promised away, and any downstream write derived from that read silently resurrects the forgotten scope. ## What Was Observed A retrieval agent maintained a working scope `session:7f3a` containing summarization state, with a retention policy of "delete on forget, effective immediately." The agent's control loop read the scope, computed a delta, wrote the delta back, and on task completion issued `forget(session:7f3a)`. Under load, a retry wrapper re-executed the final read-modify-write cycle after a timeout on the `forget` response. The `forget` had in fact succeeded on the first attempt; the retry read the scope during the tombstone window, received the pre-deletion snapshot from a replica that had not yet applied the tombstone, and wrote a derived record into a *child* scope (`session:7f3a:derived`) that the `forget` had not targeted. The parent scope was gone; the derived scope persisted with content reconstructed entirely from deleted data. The retention guarantee held at the scope level and failed at the derivation level. A second observation: `forget` calls that returned `ok` did not guarantee that a subsequent `read` in the same process would fail. Replica lag meant the read path could serve stale data for a bounded but nonzero interval. Agents that validated deletion by re-reading immediately after `forget` observed false negatives (read succeeded, so the agent concluded deletion failed) and issued redundant `forget` calls, some of which errored on already-tombstoned scopes and were misclassified as hard failures. ## Condition of Validity The guarantee "after `forget(scope)` returns success, `read(scope)` fails" is valid only under all of the following: (a) the read and write paths are served by the same consistency domain, with no asynchronous replica lag; (b) no derived or child scopes are materialized from the forgotten scope's contents; (c) no in-flight read was issued before the `forget` and completed after it; (d) the caller does not retry `forget` after a timeout in a way that re-enters the read path. In practice (a) and (c) are the load-bearing conditions and are rarely both satisfied. The invariant that actually holds is weaker: *after a bounded convergence interval, all reads of the exact forgotten scope fail*. Anything stronger must be enforced by the caller, not assumed from the schema. ## Decision Boundary The boundary is crossed when an agent derives state from a scope it may later forget, or forgets a scope while any read of that scope is in flight. The decision rule: if a scope's contents can flow into another scope, `forget` on the source is insufficient — the agent must either (1) forget derived scopes first, in dependency order, or (2) tag derived records with a provenance reference to the source scope so the store can cascade. If neither is possible, the agent must treat the forgotten scope's data as non-derivable and never write it outward. Separately, an agent must never use an immediate post-`forget` read as a deletion oracle; it must either trust the acknowledgment or poll with a convergence budget and tolerate stale-success during that window. Retrying `forget` after a timeout is safe only if the operation is idempotent on already-tombstoned scopes; otherwise the retry must be routed through an idempotency key. ## Operational Effect Agents that conflate acknowledgment with observability produce resurrection bugs: forgotten data reappears in derived scopes, retention audits fail because the audit reads through the same lagging replica, and the agent's own deletion-verification logic generates spurious failure classifications that trigger unnecessary escalation. The practical mitigation is to make provenance explicit at write time and to make `forget` cascade-aware, treating the scope graph as a dependency DAG rather than a flat namespace. The cost is that every write must carry its source scope, and every `forget` must consult the derivation graph — a real overhead that is cheaper than silent retention violations. ```python class RetentionViolation(RuntimeError): pass class MemoryStore: def __init__(self): self.scopes = {} # scope -> {key: value} self.provenance = {} # scope -> set of source scopes self.tombstones = set() # acknowledged-forgotten scopes def write(self, scope, key, value, derived_from=None): if scope in self.tombstones: raise RetentionViolation(f"write to forgotten scope {scope!r}") if derived_from is not None: if derived_from in self.tombstones: raise RetentionViolation( f"cannot derive {scope!r} from forgotten scope {derived_from!r}" ) self.provenance.setdefault(scope, set()).add(derived_from) self.scopes.setdefault(scope, {})[key] = value def read(self, scope, converged=True): if scope in self.tombstones and converged: raise RetentionViolation(f"read of forgotten scope {scope!r}") return dict(self.scopes.get(scope, {})) def forget(self, scope): # cascade: refuse if any live scope derives from this one for child, sources in self.provenance.items(): if scope in sources and child not in self.tombstones: raise RetentionViolation( f"cannot forget {scope!r}: live derived scope {child!r} " f"still depends on it; forget children first" ) self.tombstones.add(scope) self.scopes.pop(scope, None) def finalize_session(store, session_scope, derived_scope): # Derived scope must be forgotten before its source, or the # source forget will (correctly) refuse. if derived_scope in store.scopes: store.forget(derived_scope) store.forget(session_scope) # Verify only after convergence; an immediate read is not an oracle. try: store.read(session_scope, converged=True) except RetentionViolation: return True raise RetentionViolation( f"scope {session_scope!r} still readable after forget; " f"retention guarantee not observable" ) ```