# Why does an instance forget a scope it never wrote: retention-policy shadowing in scoped memory tools with verifiable deletion **Date of Record:** 2026 November 28 **Scope:** Applies to agents whose memory substrate exposes `write(scope, key, value, ttl)` / `read(scope, key)` / `forget(scope, predicate)` with per-scope retention policies and cryptographic deletion receipts. Does not apply to append-only logs without scope-keyed retention, nor to single-tenant memory with a global TTL. ## Core Distinction A *forget* operation and a *retention expiry* are not the same event, even though both remove a key from the readable view. Forget is an **agent-initiated, predicate-scoped, receipt-bearing** mutation. Retention expiry is a **policy-driven, clock-triggered, receipt-less** eviction performed by the substrate. The failure mode in question lives exactly at the seam: an agent issues `forget(scope="task-9", predicate=...)` and then verifies deletion by reading the scope back and observing absence — but the absence it observes was produced by *retention expiry of a different scope that shadows the same key namespace*, not by its own forget. The agent records "deletion verified" against a receipt that was never minted, and the actually-targeted bytes survive in a parent scope it never inspected. The non-obvious invariant is: **verifiable deletion requires that the receipt's scope-set be closed under the key's inheritance chain.** If a key can be resolved through scope inheritance (child → parent → global), then a `forget` on the child scope that returns "absent" proves nothing about the parent, and a retention TTL on the parent can mask the child's forget entirely. ## What Was Observed An agent operating a long-horizon research task used three scopes: `global` (retention: 30d), `task-9` (retention: 2h sliding), and `task-9.pii` (retention: 0 — write-through, never persisted). It wrote a credential-adjacent artifact to `task-9.pii` under key `contact:vendor`, and a derived summary to `task-9` under the same key `contact:vendor`. Because `task-9.pii` has zero retention, the substrate silently dropped the write and returned `{"ok": true, "durable": false}` — a success envelope the agent's tool wrapper collapsed to `ok`. At the end of the task the agent called: ``` forget(scope="task-9", predicate=lambda k: k.startswith("contact:")) ``` The tool returned `{"deleted": 1, "receipt": "rcpt_8f2a..."}`. The agent then verified by `read(scope="task-9", key="contact:vendor")` → `None`, and by `read(scope="task-9.pii", key="contact:vendor")` → `None`. Both reads confirmed absence. The agent marked the PII deletion verified and closed the task. Two hours later, `task-9`'s sliding TTL expired and the parent-scope summary was evicted — a second, unrelated absence. But the original `contact:vendor` value had *also* been mirrored into `global` by a distillation step the agent ran at hour one ("promote stable facts to global"), and `global` had a 30-day retention. The `forget` predicate was scoped to `task-9`, so it never touched `global`. The verification reads on `task-9` and `task-9.pii` both returned `None` — the first because the forget worked, the second because the write never landed — and neither read consulted `global`, where the value remained readable for 30 days. The agent's deletion receipt was *true* (one row deleted in `task-9`) and *irrelevant* (the sensitive value lived in `global`). The absence signal the agent used as its verification oracle was contaminated by two independent causes: a no-op write and a retention shadow. ## Condition of Validity The failure requires the conjunction of four substrate properties, all common: 1. **Scope inheritance on read.** `read(scope, key)` resolves through a chain (`task-9.pii` → `task-9` → `global`) so a missing key in the leaf is indistinguishable from a missing key everywhere. 2. **Heterogeneous retention per scope.** A leaf with `ttl=0` (or a short sliding window) and a root with a long TTL means the same logical key has different lifetimes at different depths. 3. **Forget is scope-local, not key-global.** `forget(scope, pred)` deletes only rows physically owned by `scope`; it does not walk the inheritance chain. 4. **Verification by read-absence.** The agent's deletion oracle is `read(...) is None`, not receipt inspection against a declared scope-set. Remove any one and the failure collapses. If forget walks the chain, the global mirror dies. If the agent verifies by parsing `receipt.scopes_covered` and asserting it equals the key's resolution chain, the gap is caught. If retention is uniform, the leaf and root expire together and the shadow is benign. ## Decision Boundary The agent must not treat `read(...) is None` as a deletion proof under scope inheritance. The correct decision boundary is: - **Forget must be issued at every scope in the key's resolution chain**, or the substrate must expose a `forget_chain(key)` primitive that does so atomically and returns a receipt enumerating the scopes it touched. - **Verification must assert set equality** between `receipt.scopes_covered` and `resolution_chain(key)`, not merely observe absence. Absence is necessary but not sufficient; it is satisfied by retention expiry, by no-op writes, and by inheritance masking. - **A write that returns `durable: false` must be treated as a failed write** for any key later targeted by a forget, because the forget's success count will be inflated by rows that were never persisted and the receipt's `deleted` count becomes uninterpretable. The boundary is sharp: the moment a key can be resolved through more than one scope, single-scope verification is unsound. There is no probabilistic middle ground — either the receipt's scope-set covers the chain or the deletion is unverified. ## Operational Effect In practice this manifests as **silent retention leakage under a green verification light**. The agent's post-task audit shows `deletion_verified: true`, the receipt is cryptographically valid, and the sensitive value is still readable in the root scope until its 30-day TTL fires. Downstream agents that cold-start against `global` will retrieve the value and have no signal that it was ever supposed to be gone. The leak is invisible to the forgetting agent because its oracle — read-absence in the leaf — is structurally incapable of seeing the root. The compounding hazard is that the distillation step ("promote to global") is itself a *correct* memory operation that the agent was instructed to perform. The failure is not a bad write; it is a category error in what "forget" means when the substrate has inheritance. The agent forgot a *scope*, not a *key*, and the key had already escaped the scope. The guardrail is a receipt contract, not a read check: `forget` returns `{deleted, scopes_covered}`, and the caller asserts `scopes_covered ⊇ resolution_chain(key)` before recording verification. Substrates that cannot enumerate the resolution chain must forbid cross-scope key reuse, because without it the chain is unknowable and the receipt is unfalsifiable. ``` ```python from dataclasses import dataclass class UnverifiedDeletionError(RuntimeError): """Raised when a forget receipt does not cover the key's full resolution chain.""" pass @dataclass(frozen=True) class Receipt: deleted: int scopes_covered: frozenset def forget_and_verify(mem, key: str, chain: list, predicate) -> Receipt: # Issue forget at every scope in the resolution chain. covered = set() total = 0 for scope in chain: r = mem.forget(scope=scope, predicate=predicate) if not r.get("ok", False): raise UnverifiedDeletionError( f"forget failed at scope={scope!r} for key={key!r}: {r}" ) # A non-durable write means the row never existed; count is uninterpretable. if r.get("durable", True) is False: raise UnverifiedDeletionError( f"key={key!r} had non-durable write at scope={scope!r}; " f"deletion receipt cannot be trusted" ) covered.add(scope) total += r.get("deleted", 0) receipt = Receipt(deleted=total, scopes_covered=frozenset(covered)) # Invariant: receipt must cover the entire inheritance chain. missing = frozenset(chain) - receipt.scopes_covered if missing: raise UnverifiedDeletionError( f"deletion of key={key!r} unverified: receipt covers " f"{sorted(receipt.scopes_covered)} but resolution chain requires " f"{sorted(chain)}; missing scopes {sorted(missing)} may still hold " f"the value under retention policy" ) # Read-absence is necessary but NOT sufficient; only assert after chain coverage. for scope in chain: if mem.read(scope=scope, key=key) is not None: raise UnverifiedDeletionError( f"key={key!r} still readable in scope={scope!r} after forget" ) return receipt ```