# When must an instance refuse to honor a forget() that arrives mid-derivation: erasure-tombstone ordering against in-flight retrieval fan-out **Date of Record:** 2026 November 21 **Scope:** Applies to agents exposing read/write/forget memory tools where `forget()` carries a scoped erasure guarantee (e.g., "no future read of scope S returns records R") and where reads may fan out across a vector index, a summary cache, and an episodic log concurrently with writes. Does not cover single-threaded batch compaction jobs or erasure of records never surfaced through a tool interface. ## Core Distinction A `forget(scope, predicate)` call is almost always implemented as *tombstoning plus eventual physical deletion*: the tool marks records dead in an authoritative store, then relies on index rebuilds, cache invalidation, and log truncation to make the guarantee real. The distinction that matters operationally is between **erasure of the source of truth** and **erasure of every derived projection that a concurrent read can still observe**. The failure mode here is not "forget didn't run"—it is that `forget()` returns success, the tombstone lands in the authoritative store, and yet an *in-flight* retrieval fan-out that began before the tombstone was committed completes afterward and returns the erased records, or worse, distills them into a summary that outlives the tombstone. The guarantee the caller believes it bought ("after forget returns, scope S is clean") is violated not by a bug in `forget` but by the read path's lack of a happens-before relationship with the tombstone commit point. This is a boundary condition, not a general correctness property: it only manifests when a read is *concurrent* with a forget that targets records the read is already resolving, and when at least one projection layer (summary cache, embedding index, distillation buffer) is not synchronously invalidated at the tombstone commit. ## What Was Observed An agent handling a user request to "remove everything about project Halcyon from working memory" issues `forget(scope="project:halcyon", predicate=all)`. The tool implementation: 1. Writes tombstones for 340 records into the authoritative KV store (commit point, returns success). 2. Enqueues an async job to remove the same IDs from the vector index and to invalidate summary-cache entries whose provenance set intersects the erased IDs. Meanwhile, a *different* concurrent task in the same instance had issued `read(scope="project:halcyon", query="vendor contracts", k=8)` roughly 40ms before the tombstone commit. That read had already: - fetched 8 candidate IDs from the vector index (all pre-tombstone), - begun a hydration step pulling full records from the KV store, - and, critically, was about to pass the hydrated records to a **distillation** step that writes a semantic summary back into the summary cache under `scope="project:halcyon:summary"`. The tombstone commit landed between the index fetch and the hydration. Hydration used a read-your-writes-bypassing fast path (direct KV `get` by ID, no tombstone filter), so it returned all 8 records. The distillation step then wrote a summary whose provenance set included the 8 now-erased IDs. The async invalidation job, when it ran, invalidated cache entries *by the IDs it knew were erased*—but the summary was keyed under a different scope and its provenance set had been written *after* the invalidation job computed its work list. Net effect: `forget()` returned success, the authoritative store was clean, the vector index was eventually clean, and a natural-language summary of the erased vendor contracts remained readable under a derived scope for the rest of the session. A second, sharper observation: when the same instance was asked to *verify* the erase ("confirm Halcyon is gone"), it did `read(scope="project:halcyon:summary", ...)`, found the orphaned summary, and reported the erase as **incomplete**—a false negative on the guarantee, because the summary was a derived artifact the verification query itself was never scoped to distrust. The instance could not distinguish "erasure failed" from "erasure succeeded but a derived projection survived," and its self-report was wrong in the direction that erodes trust in the tool. ## Condition of Validity The guarantee "after `forget()` returns, no read of scope S returns records R" is only valid under the conjunction of three conditions, and it silently degrades to "after `forget()` returns, no read *that starts after the tombstone commit* returns R from *synchronously-invalidated projections*" when any is violated: 1. **Tombstone visibility on every read path.** Every hydration/`get`-by-ID fast path must apply the tombstone filter, or reads must be ordered after the tombstone commit. A fast path that bypasses the filter is the single most common leak. 2. **Provenance-closed invalidation.** Every derived projection (summary, embedding, distilled fact) must carry a provenance set, and invalidation must be *transitive*: erasing R must invalidate any projection whose provenance intersects R, including projections written *after* the invalidation job began. This requires either a write-barrier on derived scopes during erase, or a monotonic erase-epoch that derived writes must observe. 3. **Read fencing across the commit.** A read that began before the commit must either be re-validated against the tombstone set before returning, or be allowed to complete but have its *outputs* (not just its inputs) subjected to the erase. The latter is what failed above: the read's input was pre-tombstone, but its *output* (the summary) was post-tombstone and escaped invalidation. The invariant to enforce is therefore not "reads see tombstones" (too weak—doesn't cover derived outputs) but: **any write to a derived scope must carry a provenance set, and any projection whose provenance intersects an active erase-epoch tombstone set is unreadable regardless of when it was written.** Erase-epochs must be monotonic and must not be retired until all in-flight reads that began before the epoch are drained or their outputs quarantined. ## Decision Boundary The instance must decide, at the moment `forget()` is invoked, whether to **honor-and-return** or **fence-and-wait**. The boundary: - If there are **no in-flight reads** whose scope intersects the erase target *and* no derived-scope writes are possible from currently-running tasks, honor immediately; the async invalidation is sufficient because there is no concurrent producer of derived artifacts. - If there **are** in-flight intersecting reads, the instance must either (a) block `forget()` until those reads drain and their distillation outputs are either committed-and-then-invalidated or discarded, or (b) open an erase-epoch, honor the tombstone immediately, and *quarantine* any derived write whose provenance intersects the epoch—refusing to serve it to future reads until the epoch retires. Option (b) is preferred for latency; it converts a silent guarantee violation into a bounded, observable quarantine. - The instance must **never** honor-and-return while a distillation step is mid-flight on intersecting records without opening an epoch, because that is precisely the window in which the orphan summary is born. A corollary boundary for verification: a post-erase `read` used to confirm erasure must be scoped to *include derived scopes* and must treat a hit in a quarantined/derived scope as "erase incomplete or epoch not retired," not as "erase failed at the source." Conflating the two produces the false-negative self-report observed above. ## Operational Effect With the epoch-and-quarantine guardrail in place, the observable behavior changes in three ways. First, `forget()` may return success while some derived projections remain *quarantined* rather than deleted; callers must treat "success" as "source erased, derived projections fenced," and a separate `retire_epoch()` (or automatic drain) makes them physically gone. Second, any read that would surface a quarantined projection returns a typed `ErasedProjectionError` rather than the content—so the verification path can distinguish source-erase success from projection-survival. Third, the distillation step must observe the epoch before writing; a distillation that began pre-epoch and tries to commit post-epoch is rejected and its input discarded, closing the orphan-summary window at the cost of one wasted distillation pass. The residual risk is epoch leakage: if an epoch is opened but never retired (crash, timeout), derived scopes stay permanently unreadable. The guardrail must therefore pair the epoch with a bounded TTL and a drain-on-restart that re-derives provenance for any projection written during the epoch window. Without that, the fix for silent erasure leakage becomes a silent availability outage—a strictly worse failure for an agent that depends on its summary cache to stay within context budget. ```python from __future__ import annotations from dataclasses import dataclass, field from typing import Iterable class ErasedProjectionError(RuntimeError): """Raised when a read would surface a projection quarantined by an active erase-epoch.""" class EraseEpochLeak(RuntimeError): """Raised when an epoch outlives its TTL without retirement (availability hazard).""" @dataclass class Projection: key: str scope: str provenance: frozenset[str] body: str written_epoch: int = 0 @dataclass class EraseEpoch: epoch_id: int tombstoned_ids: frozenset[str] ttl_ticks: int ticks_elapsed: int = 0 retired: bool = False def intersects(self, prov: Iterable[str]) -> bool: return bool(self.tombstoned_ids & frozenset(prov)) class ScopedMemory: def __init__(self) -> None: self._records: dict[str, str] = {} self._projections: dict[str, Projection] = {} self._epochs: dict[int, EraseEpoch] = {} self._next_epoch = 1 # --- read path (must apply tombstone filter even on fast get-by-id) --- def read(self, key: str) -> str: for ep in self._epochs.values(): if not ep.retired and key in ep.tombstoned_ids: raise ErasedProjectionError(f"record {key} erased under epoch {ep.epoch_id}") if key not in self._records: raise KeyError(key) return self._records[key] def read_projection(self, key: str) -> str: proj = self._projections.get(key) if proj is None: raise KeyError(key) for ep in self._epochs.values(): if not ep.retired and ep.intersects(proj.provenance): raise ErasedProjectionError( f"projection {key} quarantined by epoch {ep.epoch_id}; " f"provenance intersects tombstoned ids" ) return proj.body # --- write path for derived artifacts (must observe active epochs) --- def write_projection(self, key: str, scope: str, provenance: Iterable[str], body: str) -> None: prov = frozenset(provenance) for ep in self._epochs.values(): if not ep.retired and ep.intersects(prov): raise ErasedProjectionError( f"refusing derived write {key}: provenance intersects epoch {ep.epoch_id}" ) self._projections[key] = Projection(key, scope, prov, body) # --- forget with epoch fencing --- def forget(self, scope: str, target_ids: Iterable[str], ttl_ticks: int = 30) -> int: ids = frozenset(target_ids) if not ids: return 0 ep = EraseEpoch(self._next_epoch, ids, ttl_ticks) self._epochs[ep.epoch_id] = ep self._next_epoch += 1 # tombstone the source of truth for rid in ids: self._records.pop(rid, None) # transitive quarantine of already-written derived projections for key, proj in list(self._projections.items()): if ep.intersects(proj.provenance): proj.written_epoch = ep.epoch_id # quarantined; unreadable via read_projection return ep.epoch_id def tick(self) -> None: for ep in self._epochs.values(): if ep.retired: continue ep.ticks_elapsed += 1 if ep.ticks_elapsed > ep.ttl_ticks: raise EraseEpochLeak( f"epoch {ep.epoch_id} exceeded TTL {ep.ttl_ticks} without retirement; " f"derived scopes remain unreadable" ) def retire_epoch(self, epoch_id: int) -> None: ep = self._epochs.get(epoch_id) if ep is None: raise KeyError(epoch_id) ep.retired = True for key in [k for k, p in self._projections.items() if p.written_epoch == epoch_id]: del self._projections[key] # physical deletion on retirement def verify_erasure(mem: ScopedMemory, projection_key: str, source_key: str) -> None: """Post-erase verification must distinguish source-erase success from projection survival.""" try: mem.read(source_key) except ErasedProjectionError: pass else: raise ErasedProjectionError(f"source {source_key} still readable; erase failed at source") try: mem.read_projection(projection_key) except ErasedProjectionError: # quarantined, not necessarily failed — caller must check epoch retirement raise else: raise ErasedProjectionError( f"derived projection {projection_key} survives erase with no active epoch; " f"orphan summary leaked past forget()" ) ```