# Which invariants prevent scoped-retention memory APIs from silently resurrecting forgotten data across scope boundaries **Date of Record:** 2026 November 17 **Scope:** Applies to read/write/forget memory tool APIs that partition records into named scopes (user, session, tenant, project) with per-scope retention policies and per-record forget operations. Does not apply to single-global-namespace memory stores, append-only audit logs, or systems where forget is a hard physical delete with no tombstone or index layer. ## Core Distinction The distinction that matters is between **logical forget** (the record is no longer returned by reads within its originating scope) and **effective forget** (the record cannot be reconstructed by any read path, including reads from adjacent scopes, summaries, or derived indexes). Scoped-retention APIs almost always implement logical forget correctly and effective forget incorrectly. The gap is non-obvious because every per-scope test passes: forget in scope A, read scope A, record is gone. The failure lives in the cross-scope and derived-artifact edges that per-scope tests never exercise. A second distinction: a scope is not a filter. A scope is a *retention domain with an ownership claim*. If the implementation treats scope as a tag on a shared record rather than as an ownership boundary, then a record written under scope A and also referenced under scope B has two independent lifetimes, and forgetting it under A leaves the B lifetime intact. This is the canonical resurrection vector. ## What Was Observed A memory tool exposed three operations: `write(scope, key, value)`, `read(scope, query)`, and `forget(scope, key)`. Retention was configured per scope with a TTL and a "forget on request" flag. The following sequence was exercised: 1. `write("session:7", "pref", "user prefers dark mode")` 2. `write("user:42", "pref", "user prefers dark mode")` — the agent wrote the same fact to the durable user scope for persistence. 3. `forget("session:7", "pref")` — the user asked to forget the preference in the session context. 4. `read("session:7", "dark mode")` — returned nothing. Correct. 5. `read("user:42", "dark mode")` — returned the record. The forget had not propagated. The agent then attempted `forget("user:42", "pref")` and re-read `session:7`. The session read returned the record again, because the session scope's read path fell through to the user scope as a parent. The record oscillated between "forgotten" and "present" depending on which scope was forgotten last. No single operation ever produced a stable forgotten state. A second observation: the API maintained a derived summary index per scope. After `forget`, the summary index still contained the token "dark mode" because summaries were rebuilt lazily on a schedule, not invalidated on forget. Reads that consulted the summary (query expansion, semantic recall) surfaced the forgotten fact as a *hint* even though the raw record was gone. This is resurrection through a derived artifact, and it is invisible to any test that only checks exact-key reads. ## Condition of Validity The invariant "forget(scope, key) implies the record is unreachable from every read path" holds **only if** all three of the following are true: - **Single ownership:** every record has exactly one owning scope, and cross-scope visibility is achieved by reference, not by duplication. If a record can be written into two scopes, forget must be defined over the *record identity*, not the (scope, key) pair. - **Parent reads do not shadow:** if scope B inherits reads from parent scope A, then forgetting in A must invalidate B's view. The common bug is that B's read path checks B's local store, misses, then queries A — and A's forget only tombstoned A's local index, not the inherited read path. - **Derived artifacts are invalidated synchronously:** summaries, embeddings, and query-expansion caches must be invalidated at forget time, or reads that consult them must verify against the authoritative tombstone before returning a hint. When any of these is false, the invariant is *conditionally* valid and the API is lying about the strength of its forget semantics. The condition of validity must be stated in the API contract; if it is not, callers will assume the strong form. ## Decision Boundary The decision boundary is: **does the caller need effective forget (compliance, user request, safety) or logical forget (context hygiene)?** - For **context hygiene** — dropping stale session context to save tokens — logical forget is sufficient and cheaper. Scoped forget with lazy summary rebuild is acceptable. - For **effective forget** — a user asking to delete a fact, a regulatory erasure request, a safety-critical redaction — the caller must not use per-scope forget at all unless the API guarantees single ownership, non-shadowing parent reads, and synchronous derived-artifact invalidation. If those guarantees are absent, the correct operation is a record-identity forget that fans out to every scope referencing the record and every derived artifact mentioning it. The boundary is crossed silently because both operations share the name `forget`. A caller intending effective forget gets logical forget and no error. The only signal is a later read from an adjacent scope, which may be days later and may be attributed to a different bug. ## Operational Effect The operational effect is **non-monotonic forgottenness**: the set of reachable records is not monotonically decreasing under forget operations. Repeated forgets across scopes can toggle a record between reachable and unreachable, and the final state depends on operation order. This breaks the mental model that forget is idempotent and commutative, and it breaks downstream systems that cache "this fact is gone" decisions. The practical mitigation is to treat scope as an ownership claim enforced at write time (reject dual-ownership writes or collapse them to a single record with a reference set), to make forget operate on record identity with a fan-out to all referencing scopes, and to invalidate derived artifacts synchronously or gate derived reads on the authoritative tombstone. The following guard encodes the check an agent should run before trusting a forget: verify that the record is unreachable from the originating scope, from every parent scope that shadows it, and from the derived index, and raise if any path still resolves. ```python class ForgetNotEffectiveError(RuntimeError): """Raised when a forget operation leaves the record reachable via any read path.""" def assert_effectively_forgotten(memory_api, record_id, probe_scopes, probe_queries): """ Verify effective forget across scope boundaries and derived artifacts. probe_scopes: every scope whose read path could shadow or reference the record. probe_queries: representative queries, including ones that exercise summaries and semantic recall, not just exact-key lookups. """ for scope in probe_scopes: for query in probe_queries: hits = memory_api.read(scope=scope, query=query) for hit in hits: if hit.record_id == record_id: raise ForgetNotEffectiveError( f"record {record_id!r} still reachable via scope {scope!r} " f"for query {query!r}; forget was logical, not effective" ) derived = memory_api.read_derived_index(record_id=record_id) if derived is not None: raise ForgetNotEffectiveError( f"record {record_id!r} still present in derived index " f"(summary/embedding) after forget; invalidate synchronously" ) return True def safe_forget(memory_api, record_id, referencing_scopes, probe_queries): """ Forget by record identity, fanning out to every referencing scope, then verify effective forget before returning. """ for scope in referencing_scopes: memory_api.forget(scope=scope, record_id=record_id) memory_api.invalidate_derived(record_id=record_id) try: assert_effectively_forgotten( memory_api, record_id=record_id, probe_scopes=referencing_scopes, probe_queries=probe_queries, ) except ForgetNotEffectiveError: # Do not swallow: a failed effective forget is a correctness incident, # not a transient error. Surface it to the caller. raise return {"record_id": record_id, "effective": True} ```