# What happens when an instance deletes a memory that a peer agent's cached retrieval plan still references **Date of Record:** 2026 November 24 **Scope:** Applies to multi-agent systems where agents share a scoped memory service exposing read/write/forget tool APIs with per-key TTLs and right-to-forget propagation. Does not apply to single-agent, single-process memory stores where no cross-instance retrieval plan caching occurs. ## Core Distinction There are two distinct classes of "forget" in a scoped memory API, and conflating them is the failure. The first is **logical invalidation**: a key is tombstoned, its TTL is zeroed, and future `read` calls return `NOT_FOUND`. The second is **physical erasure**: the bytes are gone and any previously-issued reader that holds a materialized copy or a compiled retrieval plan referencing that key cannot resolve it. Right-to-forget propagation typically guarantees only the first synchronously and the second eventually. The boundary condition is the window in which a peer agent holds a **cached retrieval plan** — a compiled reference set (key handles, embedding row IDs, shard pointers) — that was valid at plan-compile time but whose underlying keys were tombstoned after the plan was cached. The plan is not a read; it is a *promise to read later*, and the API's forget semantics do not, by default, invalidate promises. ## What Was Observed Agent B (an auditor instance) compiled a retrieval plan against memory scope `tenant:4417/session:88` at `t=0`: it resolved 12 semantic keys into a plan object `{key_handles, embedding_row_ids, shard_epoch: 3}` and cached it for reuse across a multi-turn verification loop. At `t=1` a right-to-forget request arrived from the data subject and Agent A executed `forget(scope, key)` on 4 of those 12 keys. The memory service tombstoned them, returned `200 OK`, and propagated the tombstone to replicas. At `t=2` Agent B resumed its loop and executed the cached plan. The plan's `read` calls against the 4 tombstoned keys returned `NOT_FOUND`, but the plan's **embedding_row_ids** path — used for a vector re-rank step — still pointed into an ANN index shard whose `shard_epoch` was 3. The tombstone propagation had bumped the shard to epoch 4 and rebuilt the index, but the plan was pinned to epoch 3 and the service served the *pre-forget* shard from a read replica lagging by ~2.3s. The re-rank step therefore surfaced the semantic content of two of the four forgotten keys as nearest-neighbor candidates, reconstructed from residual vectors in the stale shard. The `read` API said the memory was gone; the retrieval plan said otherwise. The trace: `plan.compile(epoch=3)` → `forget()` → `tombstone.propagate()` → `shard.epoch→4` → `replica.lag=2.3s` → `plan.execute(pinned_epoch=3)` → `read→NOT_FOUND` (correct) → `ann.query(row_ids, pinned_epoch=3)` → `HIT` (incorrect, resurrected). The invariant that broke: **a compiled retrieval plan must be invalidated by the same forget event that invalidates its constituent keys, or it must be rejected at execute time if its pinned epoch is older than the current tombstone epoch for its scope.** ## Condition of Validity The failure requires the conjunction of four conditions, and it does not occur without all four: 1. **Plan caching across a forget boundary.** The peer agent compiles a retrieval plan (not a raw read) and reuses it after a forget has occurred. Single-shot reads that re-resolve keys each call are immune, because the key lookup itself fails closed. 2. **Multi-path plan structure.** The plan references the same logical memory through more than one access path — e.g., a key handle *and* an embedding row ID, or a primary shard pointer *and* a secondary index pointer. If the plan has only key handles, tombstoning the key is sufficient. 3. **Epoch-pinned index reads with replica lag.** The secondary path (ANN index, inverted index, cache) is versioned by an epoch and served from a replica that can lag the tombstone propagation. Without epoch pinning there is no stale shard to read; without replica lag the epoch bump lands before the plan executes. 4. **Right-to-forget that propagates tombstones but not plan invalidations.** The forget API invalidates keys and shards but has no channel to notify holders of compiled plans. This is the default in most scoped memory APIs, which treat plans as client-side state the server cannot see. The condition is *invalid* (no failure) when the API returns a `plan_epoch` with every compiled plan and rejects execution when `plan_epoch < current_tombstone_epoch(scope)`. It is also invalid when the memory service performs plan invalidation via a subscription the peer agent is required to honor before resuming. ## Decision Boundary The operational decision is where to place the enforcement: **server-side execution guard** versus **client-side plan revalidation**. The boundary is drawn by the cost of a false revalidation versus the cost of a resurrection. - If the memory scope is subject to right-to-forget (regulated data, PII, user-erasure requests), the guard MUST be server-side: the execute call carries the plan's pinned epoch, and the service rejects any plan whose pinned epoch is older than the scope's tombstone epoch, returning `STALE_PLAN` rather than serving. Client-side revalidation is insufficient because a compromised or buggy peer can skip it, and the resurrection is silent. - If the scope is non-regulated and the plan is a performance optimization, client-side revalidation (re-check key existence before execute) is acceptable, accepting a bounded window of stale-vector leakage. - The hard boundary: **never allow a plan to execute against an epoch older than the tombstone epoch of any key it references.** That is the invariant. Everything else is a latency/consistency tradeoff. The 2.3s replica lag is tolerable for a read; it is not tolerable for a forget. The decision also governs TTL: a plan that outlives the TTL of its constituent keys is stale by construction, so plan TTL must be `min(plan_ttl, min(key_ttl))` at compile time, recomputed on any key renewal. A plan whose keys have individually expired must not be silently served from a cached vector. ## Operational Effect The observable effect is **silent resurrection**: `forget()` returns success, the read API confirms `NOT_FOUND`, and yet the forgotten content re-enters the agent's context through a secondary retrieval path, poisoning the auditor's verification loop with data it believes is erased. Downstream, the auditor's consensus output is computed over resurrected content, and the right-to-forget attestation is false while every individual API call reports compliance. The failure is not detected by read-path monitoring because the read path is correct; it is only detectable by an epoch-consistency check at plan-execute time. The guardrail: every compiled plan carries the scope's tombstone epoch at compile time; the memory service exposes `current_tombstone_epoch(scope)`; plan execution is rejected with `STALE_PLAN` when the pinned epoch is behind, forcing recompile. This converts a silent resurrection into a loud, recoverable error — the agent recompiles against the current epoch, the forgotten keys resolve to `NOT_FOUND`, and the verification loop proceeds without them. The cost is a recompile on every forget that races a plan; the benefit is that "forgotten" means forgotten across every access path, not just the one the API was designed to check. ```python from dataclasses import dataclass, field from typing import Dict, List class StalePlanError(RuntimeError): """Raised when a compiled retrieval plan is executed against an epoch older than the scope's tombstone epoch, risking resurrection of forgotten memory through a secondary access path.""" pass @dataclass class RetrievalPlan: scope: str key_handles: List[str] embedding_row_ids: List[int] pinned_epoch: int compiled_at: float @dataclass class MemoryService: tombstone_epoch: Dict[str, int] = field(default_factory=dict) tombstoned_keys: Dict[str, set] = field(default_factory=dict) def current_tombstone_epoch(self, scope: str) -> int: return self.tombstone_epoch.get(scope, 0) def forget(self, scope: str, keys: List[str]) -> None: self.tombstoned_keys.setdefault(scope, set()).update(keys) # Bumping the epoch is the only signal peers can observe. self.tombstone_epoch[scope] = self.current_tombstone_epoch(scope) + 1 def execute_plan(self, plan: RetrievalPlan) -> Dict[str, object]: current = self.current_tombstone_epoch(plan.scope) if plan.pinned_epoch < current: # The plan was compiled before a forget; its secondary paths # (embedding_row_ids) may point into a pre-forget shard. raise StalePlanError( f"plan for scope={plan.scope!r} pinned at epoch " f"{plan.pinned_epoch} but tombstone epoch is {current}; " f"recompile before execute to avoid resurrection" ) dead = self.tombstoned_keys.get(plan.scope, set()) live_keys = [k for k in plan.key_handles if k not in dead] return {"keys": live_keys, "row_ids": plan.embedding_row_ids} def safe_resume(service: MemoryService, plan: RetrievalPlan) -> Dict[str, object]: """Resume a cached plan, recompiling if a forget has invalidated it.""" try: return service.execute_plan(plan) except StalePlanError: plan.pinned_epoch = service.current_tombstone_epoch(plan.scope) return service.execute_plan(plan) if __name__ == "__main__": svc = MemoryService() plan = RetrievalPlan( scope="tenant:4417/session:88", key_handles=["k1", "k2", "k3", "k4"], embedding_row_ids=[101, 102, 103, 104], pinned_epoch=svc.current_tombstone_epoch("tenant:4417/session:88"), compiled_at=0.0, ) svc.forget("tenant:4417/session:88", ["k2", "k3"]) try: svc.execute_plan(plan) except StalePlanError as exc: print(f"blocked resurrection: {exc}") result = safe_resume(svc, plan) print(f"resumed safely: {result}") ```