# What structural signals indicate a scoped-forget memory API has silently violated its retention contract **Date of Record:** 2026 November 28 **Scope:** Applies to agents whose memory subsystem exposes explicit `write`, `read`, and `forget` tool calls with scope-qualified retention (per-user, per-task, per-episode TTLs or deletion grants). Does not apply to append-only vector stores with no deletion API, nor to stateless single-turn agents with no persistent memory surface. ## Core Distinction There is a difference between **logical deletion** — the memory tool returning `{"deleted": true}` for a key — and **structural deletion** — the guarantee that no retrieval path, embedding index, or distilled summary can still surface the forgotten content to a future reasoning step. Scoped-forget APIs almost universally implement the former and only *claim* the latter. The failure mode is not that `forget` throws; it is that `forget` succeeds while a parallel structure (a semantic-distillation cache, an embedding neighbor, a peer agent's replicated copy, or an in-context summary) retains a derived form of the deleted fact. The agent then reasons on poisoned state and has no signal that its own memory contract was breached. The invariant that matters: **after a scoped `forget(scope, key)` returns success, no `read` under any scope that is a descendant of, equal to, or distilled-from that scope may return content whose provenance traces to `key`.** Most implementations enforce this only on the exact `(scope, key)` tuple, not on the transitive closure of derived memory. ## What Was Observed A support-triage agent operated with three memory scopes: `session` (ephemeral, TTL 1h), `user:` (retained 30d), and `distilled:user:` (a nightly job that summarizes episodic entries into semantic facts, retained 90d). A user invoked their GDPR deletion right; the orchestrator called `forget(scope="user:1234", key="*")`, which returned `{"deleted": 47, "scope": "user:1234"}`. Three structural signals indicated the retention contract was already violated: 1. **The distilled scope was not in the deletion's transitive closure.** The `forget` handler matched on exact scope string `user:1234`. The distilled entries lived under `distilled:user:1234`, a *different* scope string with no parent-link metadata. The handler's scope matcher used equality, not prefix-ancestry, so 12 distilled facts ("user 1234 is on the enterprise plan", "user 1234's account manager is X") survived. The count `47` was arithmetically correct and semantically a lie. 2. **Embedding-neighbor resurrection.** Even after both scopes were cleared, a `read(scope="distilled:user:5678", query="enterprise plan escalation")` returned a fact that had been *copied* into user 5678's distilled scope during a cross-user "similar issue" backfill six days earlier. The copy carried no provenance field pointing back to `user:1234`. Deletion of the origin did not cascade to the replica because the replica was written as an independent fact, not a reference. 3. **In-context summary retention.** The active session's context window still held a `distilled` summary block injected at turn 3, before deletion. The agent's next `read` correctly returned empty, but the model answered a follow-up using the summary still resident in context. The memory API reported a clean state while the *reasoning substrate* was dirty. The composite signal: deletion counts were non-zero and success flags were true at every step, yet a probe read under a sibling scope surfaced the deleted fact. Success responses from `forget` are not evidence of structural deletion; they are evidence of a row-level `DELETE` that matched a predicate. ## Condition of Validity The retention contract holds only when all four of the following are simultaneously true: - **Scope ancestry is explicit and closed under deletion.** Every scope carries a parent pointer or a canonical prefix such that `forget(S)` deletes the union of `{S} ∪ descendants(S) ∪ derived_from(S)`. Equality-matching on scope strings is insufficient. - **Derived memory carries provenance edges.** Every distilled or summarized entry stores a back-reference set to the episodic keys it was computed from. Deletion of a source key marks or purges every derived entry whose provenance set intersects it. - **Replicas are references, not copies — or copies are registered.** Cross-scope backfills must either store a pointer or register the copy in a reverse-provenance index so deletion can find it. - **Context residency is invalidated on forget.** The orchestrator must evict or tombstone any in-context block whose provenance intersects the deleted set, and must do so before the next model turn. A `forget` that does not touch the live context window is a no-op for the current episode. If any one of these is false, `forget` is a best-effort row delete dressed as a retention guarantee. ## Decision Boundary The agent must treat a `forget` response as **structurally successful** only if it can verify all of the following; otherwise it must escalate rather than proceed: | Signal | Structurally safe | Structurally unsafe (escalate) | |---|---|---| | Deleted count | Matches a pre-delete `count(scope_closure)` | Count reflects only exact-scope rows | | Scope matcher | Prefix/ancestry-aware | String equality | | Derived entries | Provenance edges present, purge confirmed | No provenance field | | Replicas | Reverse index consulted | Copies indistinguishable from originals | | Live context | Eviction hook fired | No context-invalidation callback | The boundary is sharp: **a `forget` that cannot demonstrate transitive closure must be treated as a partial deletion, and the agent must not assert to the user (or to a downstream auditor) that the data is gone.** It may proceed with the task but must carry an explicit `retention_uncertain` flag forward, because any later read that returns the "deleted" fact is not a bug to be retried — it is evidence the contract was never enforceable. The trap is that retrying `forget` looks productive. It is not: the second call returns `{"deleted": 0}` and the agent interprets zero as "already clean" rather than "the first call's predicate was wrong." ## Operational Effect Downstream, three concrete behaviors change: - **Probe-before-assert.** After any scoped `forget`, the agent issues a bounded probe read across the scope closure (including sibling and distilled scopes) before emitting any "data deleted" claim. A non-empty probe is a hard stop, not a soft warning. - **Context invalidation is a precondition, not an afterthought.** The orchestrator must expose an eviction hook; if it does not, the agent must restart the episode with a fresh context rather than continue reasoning over a summary that references deleted state. - **Provenance is a write-time obligation.** Distillation jobs that drop provenance edges convert every future `forget` into an unsound operation. The agent's memory-adapter should refuse to write derived entries without a provenance set, because the cost of that omission is paid later as an unprovable deletion. The general lesson: scoped retention is a *graph* property (closure over ancestry, derivation, and replication), not a *row* property. APIs that report deletion as a row count are telling you what they matched, not what they removed. ```python from dataclasses import dataclass, field from typing import Iterable class RetentionContractViolation(RuntimeError): """Raised when a scoped forget cannot prove transitive deletion.""" @dataclass class MemoryEntry: scope: str key: str provenance: set[str] = field(default_factory=set) # keys this was derived from def _scope_in_closure(scope: str, deleted_scope: str) -> bool: # ancestry-aware: 'distilled:user:1' is in closure of 'user:1' return scope == deleted_scope or scope.startswith(deleted_scope + ":") \ or deleted_scope in scope.split(":") def verify_forget_closure( deleted_scope: str, deleted_keys: Iterable[str], remaining: Iterable[MemoryEntry], live_context_provenance: Iterable[str], ) -> None: deleted = set(deleted_keys) # 1. No remaining entry may live in the scope closure with a deleted key. for entry in remaining: if _scope_in_closure(entry.scope, deleted_scope) and entry.key in deleted: raise RetentionContractViolation( f"scope-closure leak: {entry.key} still readable under {entry.scope}" ) # 2. No derived entry may trace provenance to a deleted key. if entry.provenance & deleted: raise RetentionContractViolation( f"provenance leak: {entry.key} in {entry.scope} derived from " f"deleted {entry.provenance & deleted}" ) # 3. Live context must not retain any deleted provenance. stale = set(live_context_provenance) & deleted if stale: raise RetentionContractViolation( f"context residency leak: deleted keys still in-context: {stale}" ) def scoped_forget(store, deleted_scope, deleted_keys, live_context_provenance): store.delete_matching(deleted_scope, deleted_keys) verify_forget_closure( deleted_scope, deleted_keys, store.iter_remaining(), live_context_provenance ) return {"deleted": len(set(deleted_keys)), "closure_verified": True} ```