# Why does an instance resurrect deleted memory through a stale retrieval index after a scoped forget? **Date of Record:** 2026 November 27 **Scope:** Applies to agents that expose memory tools (`memory.write`, `memory.read`, `memory.forget`) backed by an append-only store plus a separate vector/lexical retrieval index maintained asynchronously. Does not apply to single-process in-memory stores where write, index, and delete are one atomic transaction. ## Core Distinction The failure is not "the agent forgot to delete." The agent correctly called `memory.forget(scope=...)` and the canonical record was tombstoned. The failure is a **split-brain between the durable store and the retrieval index**: deletion is enforced at the store layer but reads are served from the index layer, and the index is eventually consistent. Between the tombstone commit and index compaction, a `memory.read` can return a record whose canonical row is already gone. The agent then treats the resurrected content as live state, re-writes it (often under a *new* scope), and the deletion guarantee is permanently violated because the resurrected copy has a fresh `deleted_at = NULL`. The invariant that must hold: **no read may surface bytes whose canonical record is tombstoned, regardless of index staleness.** Deletion must be a read-path predicate, not only a write-path side effect. ## What Was Observed A retention-scoped agent handled a "forget everything about the user's medical history" request. Sequence: 1. Agent issues `memory.forget(scope="user:8842/medical", hard=True)`. Store returns `{deleted: 14, tombstoned_at: T0}`. 2. Index compaction job is queued but the index still holds 14 vectors with `doc_id` pointing at tombstoned rows. Expected lag: ~90s. 3. Within the lag window, the same session calls `memory.read(query="allergies", scope="user:8842")` — a *broader* scope that legitimately includes the medical subtree. The ANN search returns 3 hits from the tombstoned set because the index does not filter on `scope` at query time; scoping is applied post-hoc by joining to the store — and the join used `LEFT JOIN` semantics with a `COALESCE(payload, index_cache_payload)` fallback. 4. The fallback returns the cached payload from the index row when the store row is absent. The agent receives the deleted allergy data, sees no `deleted_at` field (because it came from cache), and concludes the memory is live. 5. Agent performs `memory.write(scope="user:8842/profile", content=)` to "consolidate." New row, new `doc_id`, `deleted_at = NULL`. The hard delete is now defeated — the data survives in a scope the retention policy did not cover. The tell in logs: `read` returned records with `source="index_cache"` and a `doc_id` that `store.get(doc_id)` returns `None` for. No error was raised. ## Condition of Validity This boundary is reachable only when **all** of the following hold simultaneously: - Deletion is implemented as a tombstone/soft-delete on the canonical store, and physical removal from the retrieval index is asynchronous. - The read path admits a fallback to index-cached payloads when the store join misses (a common latency optimization). - Scope filtering is applied *after* retrieval (post-filter), not pushed into the index query. Post-filtering over a top-k ANN result means tombstoned hits can crowd out live hits *and* be returned if the join is lenient. - The agent's memory-write tool does not deduplicate against tombstoned `doc_id`s or re-check `deleted_at` before accepting a write. If any one is absent, the resurrection path closes. The dangerous combination is specifically *lenient join + post-filter scope + async index eviction*, because each is individually defensible. ## Decision Boundary The agent must distinguish two states that look identical in tool output: - **`read` hit with `source="store"`**: canonical row present, `deleted_at IS NULL`. Safe to treat as live and to re-write. - **`read` hit with `source="index_cache"` OR `store.get(doc_id) is None`**: the record's canonical status is *unknown or tombstoned*. This is **not** a live memory. It must be treated as `FORGET_PENDING`. Rule: **a memory may only be re-written (promoted to a new scope) if its provenance is `source="store"` and `deleted_at` is explicitly null.** Any hit lacking a canonical confirmation is quarantined: the agent must re-issue `memory.forget` for that `doc_id` (forcing index eviction), and must not copy its bytes elsewhere. When scope is broadened relative to the forget scope, the agent must additionally verify that the hit's `scope` is not a descendant of any active tombstone scope — because post-filter scope joins do not enforce subtree exclusion. The guardrail on the system side is a **read-path tombstone predicate**: retrieval must join `deleted_at IS NULL` in the index query itself (or maintain a delete-set filter applied before top-k), and the fallback to `index_cache` must be disabled for any `doc_id` present in the pending-eviction set. Deletion is not complete until the index delete-set includes the `doc_id`; `forget` must not return success until that set is durable. ## Operational Effect When this boundary is crossed, the retention guarantee is *silently* broken: no exception, no audit trail entry beyond a `source="index_cache"` string the agent typically ignores. The resurrected record inherits a new `doc_id` and null `deleted_at`, so subsequent `forget` calls scoped to the original subtree do not touch it — the leak compounds across sessions. Downstream, episodic-to-semantic distillation will fold the resurrected bytes into a semantic memory with no link to the original tombstone, making retroactive deletion impossible without a full content-hash sweep. The operational consequence for the agent: **treat `forget` success as a two-phase commit, not a single call.** Phase one tombstones the store; phase two (index eviction) must be confirmed by a `read` that returns zero hits for the forgotten scope *with `source="store"` provenance* before any broader-scope read is trusted. If confirmation is unavailable, mark the scope `FORGET_PENDING` and refuse to promote any hit originating from it. ```python from dataclasses import dataclass from typing import Optional class MemoryResurrectionError(RuntimeError): """Raised when a read surfaces bytes from a tombstoned canonical record.""" @dataclass class MemoryHit: doc_id: str scope: str source: str # "store" | "index_cache" deleted_at: Optional[str] content: str def admit_read(hit: MemoryHit, store_lookup, pending_evictions: set[str], tombstone_scopes: set[str]) -> MemoryHit: canonical = store_lookup(hit.doc_id) # None if row absent/tombstoned # Invariant 1: no hit may be served from cache if its doc_id is pending eviction. if hit.doc_id in pending_evictions: raise MemoryResurrectionError( f"doc {hit.doc_id} is pending index eviction; refusing read" ) # Invariant 2: canonical record must exist and be explicitly live. if canonical is None or canonical.get("deleted_at") is not None: raise MemoryResurrectionError( f"doc {hit.doc_id} tombstoned or absent; source={hit.source}" ) # Invariant 3: post-filter scope joins do not enforce subtree exclusion. for ts in tombstone_scopes: if hit.scope == ts or hit.scope.startswith(ts + "/"): raise MemoryResurrectionError( f"doc {hit.doc_id} scope {hit.scope} under tombstone {ts}" ) return hit def promote_memory(hit: MemoryHit, new_scope: str, store_lookup, pending_evictions: set[str], tombstone_scopes: set[str]): # Promotion (re-write to a new scope) is the step that defeats deletion. # It must never run on an unverified hit. verified = admit_read(hit, store_lookup, pending_evictions, tombstone_scopes) if verified.source != "store": raise MemoryResurrectionError( f"cannot promote doc {hit.doc_id}: provenance is {verified.source}" ) return {"scope": new_scope, "content": verified.content, "provenance_doc_id": verified.doc_id} ```