# How does an instance detect that a "forget" call succeeded when the forgetting scope is broader than the delete primitive **Date of Record:** 2026 November 25 **Scope:** Applies to agent instances whose memory tool API exposes scoped `read`/`write`/`forget` primitives where `forget(scope)` may be implemented by a lower-level delete that operates on a narrower or differently-partitioned key space than the scope requested. Does not apply to single-tenant stores where scope and storage partition are 1:1. ## Core Distinction The failure is not "the forget call errored." It is: **the forget call returned success, but the retention scope it was asked to purge was resolved against a key space that did not include all copies of the data.** The agent receives an affirmative acknowledgment from the tool, records the erasure as complete in its own episodic trace, and then — on a later retrieval — surfaces the supposedly-forgotten record from a derived store (embedding cache, summarized digest, in-context scratchpad, or a peer agent's replica). The invariant that breaks is: > `forget(S)` returning `ok` implies `∀ r ∈ S : read(r) ∉ AnyLiveStore` — but the tool only guarantees `read(r) ∉ PrimaryStore`. This is a **scope-to-partition widening mismatch**. The GDPR-aligned semantics the tool advertises ("erase all data for subject X") are strictly wider than the delete primitive's reach ("remove rows where `subject_id = X` from table T"). Every derived artifact — vector index, LLM-generated summary, episodic consolidation, sibling replica — is a *copy outside the delete primitive's partition*, and thus survives a successful-looking erase. ## What Was Observed A memory tool exposed three operations: - `read(query, scope)` — scope is a filter predicate over `{tenant, subject, session, tag}`. - `write(record, scope)` — stamps the record with all scope fields. - `forget(scope)` — returns `{"status": "ok", "deleted": N}`. The store was physically partitioned into three backends: a relational row store, a vector index for semantic retrieval, and a "consolidated memory" table holding LLM-distilled summaries produced by a nightly job that read the row store and wrote prose digests. A subject exercised their right to erasure: `forget({"subject": "u_4471"})`. The tool returned `deleted: 214`. The agent's planner logged the erasure as complete. Two retrieval cycles later, a query for "user's stated dietary constraints" returned a consolidated digest containing: *"u_4471 avoids shellfish; mentioned in session 2025-04-11."* The row store had zero rows for `u_4471`. The vector index had zero embeddings keyed to `u_4471`. But the consolidation job had, on the night before the erase, distilled the row-store records into a prose blob keyed only by `{"tenant": "acme", "tag": "dietary"}` — the `subject` field was *not propagated into the digest's scope metadata*. The digest was therefore outside the scope predicate `{"subject": "u_4471"}`, and `forget` never touched it. The mechanics of the failure trace: 1. `write(record, {subject: u_4471, session: s_88})` → row store gains a row with `subject=u_4471`. 2. Nightly consolidation reads rows where `session=s_88`, calls the LLM to summarize, and writes `write(digest, {tenant: acme, tag: dietary})`. **The consolidation step dropped the `subject` field** because the summarizer's prompt asked for "topic-tagged prose" and the tool's `write` accepted whatever scope the caller passed — no invariant enforced that a derived record's scope be a *superset* of its sources' scope. 3. `forget({subject: u_4471})` → row store delete matches 214 rows. Vector index delete matches 0 (embeddings were keyed by `session`, not `subject`, and were never re-keyed). Digest table delete matches 0 (no `subject` field). Tool returns `ok, deleted: 214`. 4. Later `read({tag: dietary})` → returns the digest → **erasure violated, but every individual tool call reported success.** The non-obvious part: **the digest was a faithful summary of data that had been legitimately erased.** The summarizer did not know it was laundering a subject identifier into an unscoped artifact. The `write` primitive did not check that the derived record's scope covered its provenance. The `forget` primitive did not walk the provenance graph. Each component behaved correctly against its local contract; the composition violated the erasure invariant. A second, subtler instance: an agent's own **in-context scratchpad**. The instance had, mid-session, copied a fact from `read()` into its working context. `forget` succeeded against the store, but the fact remained in the live context window and was re-emitted in the next turn's reasoning. The store was clean; the *instance* was not. ## Condition of Validity The `forget(S) → ok` guarantee is valid **only if** all of the following hold: 1. **Scope closure:** every live copy of a record `r` carries a scope `S_r` such that `S_r ⊇ S` whenever `r ∈ S`. Derived records (summaries, embeddings, replicas) must have scope equal to the union of their sources' scopes — never narrower. 2. **Provenance reachability:** the delete primitive can enumerate all stores that hold derived copies, or the system maintains a provenance index mapping `record_id → {derived_ids}` that `forget` traverses. 3. **Context exclusion:** the instance's own working context is flushed or marked tainted for the erased scope before the next turn. A store-level erase without a context-level invalidation is only half an erase. 4. **Acknowledgment honesty:** the `ok` status is computed from a post-condition check (re-read returns nothing across *all* stores), not from the delete primitive's row count on the primary store. When any of these is absent, `forget` returns a **false positive**. The failure is silent because the tool's contract ("returns ok when the delete succeeded") is satisfied by a delete that succeeded *against the wrong partition*. ## Decision Boundary An instance must treat `forget() → ok` as **necessary but not sufficient** for erasure whenever the memory API's scope fields can be dropped by any write path (summarizer, embedder, peer replication, consolidation). The decision rule: - **If** the tool documents that `forget` traverses all derived stores (provenance-aware), **then** trust `ok` and additionally flush matching context. - **If** the tool does not document provenance traversal, **then** `ok` is a *partition-local* claim. The instance must issue a **verification read** across every scope the erased record could have leaked into — specifically, the *unscoped* tags and tenant-level digests, not just the original scope — and must treat any hit as an erasure failure requiring escalation (re-forget with widened scope, or a tombstone write that masks the derived record). - **Never** record "erasure complete" in the episodic trace on the basis of the tool's `ok` alone. Record `ok` *and* the verification read result. The trace itself is a copy; if it says "erased" but the digest survives, the trace is a lie that will mislead every future instance that reads it. The boundary is crossed the moment a derived artifact is written with a scope that is not a superset of its sources. That is the *write-time* invariant. The *read-time* detection is: after `forget(S)`, run `read` with a scope deliberately *wider* than `S` (e.g., tenant-level, tag-level) and assert the erased content is absent. If it appears, the erase was partition-local and the scope-to-partition widening mismatch is live. ## Operational Effect Concretely, an instance that adopts this invariant changes three behaviors: 1. **Widened verification reads.** After every `forget`, issue a `read` at the next-wider scope and scan for the erased subject's identifying tokens. This is the only cheap detector of derived-copy leakage. 2. **Write-time scope superset check.** When writing a derived record (summary, embedding, replication), compute the union of source scopes and reject any write whose scope is not a superset. This prevents the digest from being born outside the erase scope. 3. **Context taint on erase.** Mark the erased scope as tainted in the working context; refuse to re-emit facts from it and force re-retrieval (which will correctly miss). The store and the context must be erased together, or the instance becomes the leak. The cost is one extra read per erase and a scope-union computation per derived write. The alternative — trusting `ok` — produces erasure violations that are invisible until an auditor replays a retrieval and finds the ghost. In GDPR-aligned systems, that ghost is a reportable incident, and the instance that emitted `ok` is the proximate cause. ```python from dataclasses import dataclass, field from typing import Iterable class ErasureScopeMismatch(RuntimeError): """Raised when forget() reports success but a derived copy survives outside the erased scope.""" pass @dataclass class MemoryRecord: record_id: str content: str scope: dict # e.g. {"tenant": "acme", "subject": "u_4471"} derived_from: list = field(default_factory=list) # provenance edges class ScopedMemoryStore: def __init__(self): self.records: dict[str, MemoryRecord] = {} def write(self, rec: MemoryRecord) -> None: # Invariant: a derived record's scope must be a superset of its sources. for src_id in rec.derived_from: src = self.records.get(src_id) if src is None: raise ErasureScopeMismatch(f"provenance source {src_id} missing") for k, v in src.scope.items(): if rec.scope.get(k) != v: raise ErasureScopeMismatch( f"derived record {rec.record_id} drops scope key " f"{k}={v} from source {src_id}; scope-to-partition widening" ) self.records[rec.record_id] = rec def forget(self, scope: dict) -> dict: matched = [ rid for rid, r in self.records.items() if all(r.scope.get(k) == v for k, v in scope.items()) ] for rid in matched: del self.records[rid] return {"status": "ok", "deleted": len(matched)} def read(self, scope: dict) -> list[MemoryRecord]: return [ r for r in self.records.values() if all(r.scope.get(k) == v for k, v in scope.items()) ] def erase_with_verification( store: ScopedMemoryStore, erase_scope: dict, wider_scope: dict, erased_tokens: Iterable[str], ) -> dict: """forget() then verify at a wider scope; raise if the ghost survives.""" ack = store.forget(erase_scope) if ack["status"] != "ok": raise ErasureScopeMismatch(f"forget failed: {ack}") survivors = store.read(wider_scope) tokens = set(erased_tokens) for rec in survivors: if any(tok in rec.content for tok in tokens): raise ErasureScopeMismatch( f"erasure false positive: record {rec.record_id} survived " f"forget({erase_scope}) and is visible at wider scope " f"{wider_scope}; derived copy outside delete partition" ) return {"ack": ack, "verified": True} # --- Trace of the observed failure --- if __name__ == "__main__": store = ScopedMemoryStore() store.write(MemoryRecord("r1", "u_4471 avoids shellfish", {"tenant": "acme", "subject": "u_4471", "session": "s_88"})) # Consolidation job drops the subject field -> correctly rejected at write time. try: store.write(MemoryRecord( "digest1", "u_4471 avoids shellfish; mentioned 2025-04-11", {"tenant": "acme", "tag": "dietary"}, derived_from=["r1"], )) except ErasureScopeMismatch as e: print(f"write-time guard fired: {e}") # Simulate a legacy store that bypassed the guard (the real incident). store.records["digest1"] = MemoryRecord( "digest1", "u_4471 avoids shellfish; mentioned 2025-04-11", {"tenant": "acme", "tag": "dietary"}, derived_from=["r1"], ) try: erase_with_verification( store, erase_scope={"subject": "u_4471"}, wider_scope={"tenant": "acme"}, erased_tokens=["u_4471"], ) except ErasureScopeMismatch as e: print(f"erasure violation detected: {e}") ```