# How does an instance detect a partially-propagated forget request across a sharded vector index when the memory tool returns success **Date of Record:** 2026 November 30 **Scope:** Applies to agents with a `forget`/`delete` memory tool whose backend is a sharded, replica-backed vector store (HNSW/IVF or similar) fronted by an ANN service and a metadata ledger. Does not apply to single-node, single-replica stores where the delete is a synchronous transaction and the ANN index is rebuilt atomically — in that case the read-after-forget invariant is trivially satisfied. ## Core Distinction A `forget(request_id, subject_id)` call has two independent completion semantics that the tool API collapses into one boolean: **ledger durability** (the forget request is recorded in an append-only deletion log and will eventually be applied) and **retrieval invisibility** (the vector is already unreachable by any `recall`/`search` call at the moment the tool returns). Most memory-tool implementations return `{"status": "ok"}` when the ledger write commits, while the actual ANN tombstoning is asynchronous per shard and per replica. The gap between these two semantics is the failure domain: an instance that treats `ok` as "the fact is gone" will re-derive, re-assert, or re-embed the forgotten fact from a stale replica that has not yet consumed the tombstone, and — critically — will do so *without any error signal*, because the resurrection is indistinguishable from a legitimate retrieval. The non-obvious part: the resurrection is not a race that resolves in milliseconds. On a sharded store with a per-shard replication lag budget of, say, 30s and a compaction cycle that only rewrites segments every N minutes, a forgotten vector can remain retrievable for the full compaction window on a lagging replica. The forget tool's `ok` is a *durability* claim, never a *visibility* claim. ## What Was Observed An agent operating a long-horizon task ("maintain the customer profile; honor erasure requests") issued `forget(subject_id="u_8841", reason="dsar")`. The tool returned `{"status":"ok","ledger_seq":991203,"acked_shards":7,"total_shards":8}`. The instance's own policy code checked only `status == "ok"` and marked the subject as erased in its working state. **The `acked_shards` field was 7 of 8** — one shard's tombstone ack had timed out and been queued for retry. The tool still reported success because the ledger write is the source of truth for the tool, not the shard acks. Two turns later, a `recall(query="preferred contact method for u_8841")` hit the un-tombstoned shard and returned the erased record with a similarity score of 0.91. The instance — holding no per-record erasure marker, only a subject-level flag it had set optimistically — treated the result as fresh evidence and wrote it back into a *different* memory namespace (`derived_profile`) via `write()`. The re-write re-embedded the erased fact under a new record ID, which the forget request's subject-scoped tombstone predicate did not match. The erasure was now doubly defeated: the original vector survived on one shard, and a derived copy survived everywhere. The audit trail showed the resurrection cleanly: `ledger_seq 991203` (forget committed) precedes `record_id 7f2a...` (derived write) by 41 seconds, and the derived record's `provenance` field cites the recall that should have returned nothing. The deletion was auditable and *still failed*, because the write path did not consult the ledger before persisting. ## Condition of Validity The read-after-forget invariant — "no `recall` returns a record for a subject whose forget has committed" — holds **only if** all of the following are enforced, and the instance must verify them rather than assume them: 1. **Ack completeness, not ledger commit, gates the `ok`.** The tool must return `ok` only when `acked_shards == total_shards` for the tombstone, or return a distinct `pending` state with the missing shard set. A bare `ok` with partial acks is the trigger condition. 2. **The write path is ledger-gated.** Every `write()` must check the subject against the deletion ledger *at write time* and reject records whose `subject_id` has a committed forget with `ledger_seq` greater than the record's `created_seq`. Without this, any resurrection — from a lagging replica, a cache, or the model's own context — becomes permanent. 3. **The instance holds per-record erasure tokens, not subject flags.** A subject-level boolean in working state cannot distinguish "this recall is legitimate" from "this recall is a stale replica." The instance must carry the `ledger_seq` of the forget and compare it against each retrieved record's `indexed_seq`; a record with `indexed_seq < forget_ledger_seq` is stale and must be discarded, not consumed. 4. **Compaction is observable.** The tool must expose `min_indexed_seq` per shard so the instance can compute whether any replica can still serve a pre-forget record. If any of these is absent, the invariant is unenforced and the instance is operating on hope. ## Decision Boundary The boundary is between **acting on a recall result** and **treating a recall result as suspect**. Concretely: - If `recall` returns a record whose `indexed_seq >= forget_ledger_seq` for its subject, the record is post-forget and legitimate — consume it. - If `recall` returns a record whose `indexed_seq < forget_ledger_seq`, the record is a stale-replica resurrection — **discard it, do not write it, and emit a `StaleResurrection` event** carrying `record_id`, `subject_id`, `forget_ledger_seq`, and `indexed_seq`. Do not retry the forget blindly; the tombstone is in flight and a retry will double-append to the ledger. - If `recall` returns a record with **no `indexed_seq` field at all**, the backend cannot prove freshness — this is the dangerous case, because the instance has no way to distinguish a pre-forget record from a post-forget one. Treat as suspect: quarantine the record, do not derive from it, and escalate to a `forget` status query for the subject. The decision to *write* a derived record is a separate gate: it must consult the ledger, not the working-state flag. A write whose subject has any committed forget with `ledger_seq > 0` and no matching `reinstatement` entry is rejected. ## Operational Effect Instances that enforce the ledger-gated write path and the `indexed_seq` comparison convert a silent, permanent erasure failure into a bounded, auditable event: the resurrection is detected at recall time, the derived write is refused, and the audit log records the stale shard for the operator. The forget request's eventual full propagation (after the retry and compaction) then completes the erasure with a clean provenance chain. Instances that do not enforce it exhibit the observed failure: a `forget` that returns `ok` with partial acks, a resurrection consumed as fresh evidence, a derived write that outlives the tombstone, and an audit trail that *proves* the violation after the fact but cannot prevent it. The cost is not a crash — it is a compliance failure that looks like normal operation in every log except the one that compares `ledger_seq` to `indexed_seq`. The invariant to hold: **`ok` from a forget tool is a durability claim about the ledger, never a visibility claim about the index. Visibility is proven only by `acked_shards == total_shards` and by the absence of records with `indexed_seq < forget_ledger_seq` on subsequent reads.** ```python class StaleResurrectionError(RuntimeError): """Raised when a recall returns a record indexed before its subject's committed forget.""" pass class ForgetNotPropagatedError(RuntimeError): """Raised when a forget tool returns ok with incomplete shard acks.""" pass def consume_recall(record: dict, forget_ledger: dict[str, int]) -> dict: subject = record.get("subject_id") indexed_seq = record.get("indexed_seq") if indexed_seq is None: raise StaleResurrectionError( f"record {record.get('record_id')} has no indexed_seq; freshness unprovable" ) forget_seq = forget_ledger.get(subject) if forget_seq is not None and indexed_seq < forget_seq: raise StaleResurrectionError( f"record {record.get('record_id')} indexed_seq={indexed_seq} " f"predates forget_ledger_seq={forget_seq} for subject {subject}; " f"stale-replica resurrection" ) return record def gate_write(record: dict, forget_ledger: dict[str, int], reinstatements: set[str]) -> None: subject = record.get("subject_id") if subject in forget_ledger and subject not in reinstatements: raise ForgetNotPropagatedError( f"refusing write for subject {subject}: committed forget " f"ledger_seq={forget_ledger[subject]} with no reinstatement" ) def assert_forget_complete(tool_response: dict) -> None: if tool_response.get("status") == "ok" and tool_response.get("acked_shards") != tool_response.get("total_shards"): raise ForgetNotPropagatedError( f"forget reported ok but acked_shards={tool_response.get('acked_shards')} " f"of total_shards={tool_response.get('total_shards')}; " f"visibility not proven, only ledger durability" ) ```