# What happens when an instance deletes a memory namespace while a peer agent still holds a live read cursor into it **Date of Record:** 2026 November 25 **Scope:** Applies to multi-agent systems where long-term memory is exposed through scoped-namespace tool APIs (write/read/forget) with TTL-based expiry and verifiable deletion guarantees, and where more than one agent instance can hold concurrent read cursors or recall handles into the same namespace. Does not apply to single-writer, single-reader memory stores or to stateless retrieval over an external immutable corpus. ## Core Distinction The failure is not "deletion lost data" and it is not "a reader got a stale value." It is that **namespace deletion and cursor validity are two independently-maintained facts that the API never joins atomically**. A `forget(namespace)` call is a tombstone operation over a key range; a read cursor is a positional handle (a snapshot epoch, a pagination token, or a live iterator) that was minted *before* the tombstone. Most memory tool APIs treat these as orthogonal: deletion sweeps records, and cursors are validated against "does the namespace exist," not "does the namespace still exist *at the epoch this cursor was minted at*." When a peer instance resumes a task mid-iteration and its cursor outlives the namespace, the API has to answer a question its schema never encoded: **is a cursor into a deleted namespace an error, an empty result, or a silent resurrection?** That three-way ambiguity is the boundary. The invariant that must hold is epoch-fencing: *a cursor minted at epoch E may only observe the namespace as of E, and once the namespace is deleted (epoch E+1), every prior cursor must fail closed with a typed tombstone error rather than returning empty or, worse, re-materializing the namespace.* ## What Was Observed An orchestrator agent (`planner`) delegated a long synthesis task to a worker (`summarizer`) that recalled facts from namespace `proj:acme:facts` via a paginated read tool. The worker's cursor was a `(namespace, epoch=7, offset=340)` tuple. Mid-task, a third agent (`janitor`) ran a TTL-driven retention sweep that determined the namespace had exceeded its 30-day policy and issued `forget("proj:acme:facts")`, which: 1. Wrote a tombstone record `{ns, deleted_at, epoch: 8}`. 2. Enqueued asynchronous physical deletion of the underlying records (eventual, ~90s). 3. Returned `{"deleted": true, "records_marked": 1204}` to `janitor`. The worker, unaware, called `read(namespace="proj:acme:facts", cursor=(7,340))`. Because physical deletion was still in flight and the read path validated only "namespace resolves to a live or recently-tombstoned store," the read **succeeded and returned 60 records** from the pre-deletion snapshot. The worker distilled those records into a semantic summary and wrote it to a *different* namespace, `proj:acme:summary`. The summary was therefore built on data the system had, three seconds earlier, declared deleted and reported as deleted to `janitor`. A compliance audit later replayed the deletion and found derived content surviving in `proj:acme:summary` that referenced tombstoned source records — a verifiable-deletion violation, not a data-loss event. The inverse case was also observed on a second run: after physical deletion completed, the *same* cursor call returned `{"records": []}` — an empty success. The worker interpreted empty as "namespace exhausted, task complete" and finished with a truncated summary, silently. Neither run raised an error. The failure surfaced only in audit replay. ## Condition of Validity The epoch-fencing invariant is required precisely when all three of the following hold, and is unnecessary when any one fails: - **Concurrent cursor lifetime exceeds namespace lifetime.** A reader mints a cursor, yields control (tool call, model turn, checkpoint), and the namespace is deleted or TTL-expired before the reader resumes. If cursors are always consumed within a single uninterrupted call, deletion can never interleave and the invariant is vacuous. - **Deletion is logically immediate but physically eventual.** The tombstone lands synchronously; record reclamation is asynchronous. During the gap, the read path can still resolve old records. If deletion is atomic (tombstone and reclamation in one transaction), the read either sees everything or nothing and the gap closes. - **Derived writes are permitted from read results.** If the memory API forbids writing derived content into any namespace without a provenance link to source epochs, the resurrection has nowhere to land. The invariant matters because *derived* memory (distilled facts, summaries) is the real leak vector — raw records get physically deleted, but their distillate does not. The invariant does **not** need to hold for append-only audit logs, for namespaces with a single owning instance, or where TTL expiry is advisory only and never reported as deletion to any agent. ## Decision Boundary The API must decide, at cursor-mint time and at every cursor-resume, which of three semantics it enforces. Only one is safe: | Cursor resume against deleted namespace | Behavior | Verdict | |---|---|---| | Return remaining pre-deletion records | **Resurrection** — reader builds on deleted data | Violates verifiable deletion | | Return empty success | **Silent truncation** — reader concludes "done," loses coverage | Violates task integrity | | Raise typed `NamespaceTombstonedError` carrying `{ns, minted_epoch, deleted_epoch}` | Reader must abandon cursor, re-plan, and any derived write must be re-validated against provenance | **Required** | The decision boundary is the epoch comparison, and it must be checked on **every** cursor operation, not just the first. A cursor is valid iff `cursor.epoch == namespace.current_epoch` AND `namespace.tombstone == null`. If `namespace.tombstone != null`, the operation fails closed regardless of physical reclamation state. The tombstone must be readable *before* the data, i.e., the read path performs a tombstone check that is linearized against the delete, even while reclamation lags. A second boundary governs derived writes: a write whose provenance set includes any `(ns, epoch)` that has since been tombstoned must itself be rejected or quarantined, otherwise deletion is not transitive and the leak simply moves one namespace over. ## Operational Effect Enforcing epoch-fenced cursors converts a silent correctness bug into a loud, recoverable one. The worker that hits `NamespaceTombstonedError` must: (a) discard its cursor and any partial distillation not yet written, (b) re-request the namespace or escalate to the orchestrator that the source was deleted under it, and (c) if it had already written derived content, emit a compensating `forget` for the contaminated derived namespace keyed by provenance. The orchestrator gains a signal it previously lacked: deletion events are now observable to in-flight readers as a first-class control-flow interrupt rather than a data anomaly discovered in audit. The cost is that deletion becomes *synchronizing*: `forget` must wait for or invalidate outstanding cursors (or the read path must check the tombstone on every call, adding a lookup). Systems that cannot afford the lookup should instead make cursors epoch-pinned snapshots that hold a read lease, so deletion blocks until leases drain — trading deletion latency for read simplicity. Either way, the invariant is the same: **no cursor may observe a namespace across a tombstone boundary, and no derived write may cite a tombstoned epoch.** Verifiable deletion is not a property of the delete call; it is a property of every read and every derived write that could resurrect what the delete claimed to remove. ```python class NamespaceTombstonedError(RuntimeError): """Raised when a read cursor or derived write references a namespace epoch that has been tombstoned. Fail-closed: never return empty, never return pre-deletion records.""" def __init__(self, ns: str, minted_epoch: int, deleted_epoch: int): self.ns = ns self.minted_epoch = minted_epoch self.deleted_epoch = deleted_epoch super().__init__( f"namespace {ns!r} tombstoned at epoch {deleted_epoch}; " f"cursor minted at epoch {minted_epoch} is invalid" ) def read_with_cursor(store, ns: str, cursor_epoch: int, offset: int): meta = store.namespace_meta(ns) # linearized with delete if meta.tombstone is not None: # deletion is logical-immediate, physical-eventual: # do NOT fall through to reading reclaimed-but-present records raise NamespaceTombstonedError(ns, cursor_epoch, meta.tombstone.epoch) if cursor_epoch != meta.current_epoch: raise NamespaceTombstonedError(ns, cursor_epoch, meta.current_epoch) return store.read_page(ns, epoch=cursor_epoch, offset=offset) def write_derived(store, target_ns: str, content, provenance: list[tuple[str, int]]): for src_ns, src_epoch in provenance: meta = store.namespace_meta(src_ns) if meta.tombstone is not None or meta.current_epoch != src_epoch: # derived write would resurrect a tombstoned epoch raise NamespaceTombstonedError(src_ns, src_epoch, meta.tombstone.epoch if meta.tombstone else meta.current_epoch) return store.put(target_ns, content, provenance=provenance) ```