# When must an instance refuse to forget: retention-scope shadowing in write/forget memory tool APIs **Date of Record:** 2026 November 29 **Scope:** Applies to agent memory subsystems exposing explicit `write`, `read`, and `forget` tool calls with per-record retention scopes (e.g., `session`, `task`, `tenant`, `legal_hold`) and a stated provable-forgetting guarantee (deletion certificate or tombstone audit). Does not apply to implicit/automatic context eviction, pure vector-store TTL expiry without an audited forget path, or retention governed solely by upstream storage lifecycle rules. ## Core Distinction There is a difference between *forgetting a record* and *forgetting the reachability of a record*. A `forget` call on a scoped memory API is a request to render a record unreachable under a named retention scope, backed by a provable guarantee that no future `read` under any admissible scope can reconstruct it. The failure mode here is not "the delete didn't fire." It is that the delete fired correctly against the scope the caller named, while a *broader* scope—one the caller did not enumerate and the API did not surface—still holds a derived or shadow copy of the same content. The record is gone from the scope you asked about and present in a scope you forgot existed. The invariant that breaks is: **a forget operation is only provable if its scope set is closed under the derivation and inheritance graph of the memory store.** Most memory APIs treat scope as a filter on the caller's query, not as a constraint on the storage topology. That asymmetry is where the boundary lives. ## What Was Observed An agent operating a multi-turn task wrote a user preference into memory under `scope=session`: ``` write(key="billing_contact", value="...", scope="session", retention="task") ``` Later in the same task, a summarization step distilled episodic session memory into a semantic record under `scope=tenant` (the agent's cross-task profile store), because the summarizer's policy promoted "durable facts" to the longer-lived scope. The distilled record did not carry a provenance pointer back to the session record—the write API accepted `scope` and `retention` but not `derived_from`. At task end the orchestrator issued: ``` forget(scope="session") ``` The forget returned `{deleted: 1, certificate: "sha256:...", scope: "session"}`. The session record was gone. The tenant-scope semantic record remained, byte-identical in content, with no link to the deleted source. A subsequent `read(scope="tenant")` reconstructed the "forgotten" value verbatim. Three properties made this non-obvious rather than a plain bug: 1. **The certificate was truthful.** It correctly attested that the session-scope record was destroyed. It made no claim about derived records, and the API's contract did not require one. The provable-forgetting guarantee was scoped to the named scope and was, within that scope, valid. 2. **The promotion was policy-driven, not malicious.** The summarizer was doing exactly what its retention policy said: promote durable facts. The bug is a composition of two correct behaviors across a scope boundary neither component owned. 3. **The read path was scope-blind to provenance.** `read(scope="tenant")` had no way to know the record it returned was a derivative of a since-forgotten source, so it could not filter, redact, or flag it. A second, quieter instance: `forget(scope="task")` on a record that had been *referenced* by an in-flight peer agent's working set. The forget succeeded; the peer's cached copy, materialized before the forget, continued to be used for the remainder of the peer's turn. The store was consistent; the *fleet* was not. ## Condition of Validity The provable-forgetting guarantee holds only when all four of the following are true at the moment `forget` returns: - **Scope closure.** The set of scopes named in the forget call is a superset of every scope reachable from the target records via derivation, promotion, replication, or cache materialization. Equivalently: the store can answer "what else is this record now?" before it answers "delete it." - **Provenance completeness.** Every write that produces content derived from an existing record records `derived_from` (or an equivalent lineage edge). Writes that omit lineage are treated as roots and are therefore invisible to scope-closure computation. - **Read-path enforcement.** Every `read` resolves lineage before returning, so a record whose ancestry includes a tombstoned node is either suppressed, redacted, or surfaced with an explicit `tainted_by_forgotten` flag. A read path that cannot see lineage cannot honor a forget. - **Fleet acknowledgment.** Forgets that target content held in other instances' working sets require an acknowledgment barrier: the forget does not return `provable=true` until every instance that materialized the record has confirmed eviction or has had its materialization invalidated by a version bump. If any of these is false, the forget is *best-effort*, and the API must say so. The dangerous state is a forget that returns a certificate while one of the four conditions is unmet—because the certificate is then a false attestation of a stronger guarantee than the system can deliver. ## Decision Boundary The operational question is: **when must an instance refuse to forget?** Refuse—return an error rather than a certificate—when the store cannot compute scope closure, i.e., when the target record has lineage edges pointing to scopes not named in the call, or when lineage is incomplete for the record's derivation history. In that case a "successful" forget is a lie about reachability, and the correct output is a *partial forget report* enumerating the scopes still holding derivatives, so the caller can either widen the scope set or accept a documented residual. Do **not** refuse merely because derived records exist. Derivation is normal; the failure is silent derivation. The refusal condition is *unprovable closure*, not *nonzero closure*. Conversely, when closure is provable and fleet acknowledgment is complete, the instance must not hedge—a forget that returns `provable=false` when it could have returned `provable=true` degrades the guarantee into noise and trains callers to ignore certificates. The boundary is therefore a three-way decision: - **Provable forget** → return certificate, scope set closed, lineage complete, fleet acknowledged. - **Partial forget** → return explicit residual-scope report; do not emit a certificate; require caller decision. - **Refused forget** → raise; lineage incomplete or closure uncomputable; the store cannot honestly answer. The subtle case is the *second*: it is not an error, and treating it as one causes callers to retry with the same scope set and loop. It must be a structured, actionable result. ## Operational Effect Three consequences follow for any agent driving this API. First, **forget calls must be planned as scope-set operations, not single-scope operations.** Before forgetting, the agent should query lineage (`lineage(record_id)`) and construct the scope set as the transitive closure of derivation edges. An agent that forgets by the scope it happens to remember is the agent that leaves shadow copies. Second, **derived writes must carry provenance or be treated as untrusted for forget purposes.** A summarizer or distiller that writes without `derived_from` is a provenance hole. The architectural guardrail is to make `derived_from` mandatory on any write whose content overlaps an existing record above a similarity threshold, or to route all distillation through a provenance-stamping wrapper. Third, **the certificate is only as strong as the weakest read path.** A provable-forgetting guarantee is a claim about *reachability*, and reachability is enforced at read time. If any read path can bypass lineage resolution—a raw vector search, a cache, a peer's working set—the guarantee is void regardless of what the write/forget side attests. The invariant to hold: *no read returns content whose lineage includes a tombstone, unless the read explicitly opts into tainted results.* The practical framing for an agent: a forget is not an event, it is a *closure computation plus a barrier*. Treat the certificate as a claim requiring the four conditions above, and refuse to emit or accept one when closure is unprovable. ```python from __future__ import annotations from dataclasses import dataclass, field from typing import Iterable class ForgetClosureError(RuntimeError): """Raised when a forget cannot be proven because scope closure is uncomputable.""" @dataclass class Record: record_id: str scope: str content: str derived_from: str | None = None @dataclass class ForgetResult: provable: bool certificate: str | None residual_scopes: list[str] = field(default_factory=list) class ScopedMemory: def __init__(self) -> None: self._records: dict[str, Record] = {} self._tombstones: set[str] = set() def write(self, rec: Record) -> None: if rec.derived_from and rec.derived_from not in self._records: # A derived write whose source is unknown is a provenance hole. raise ForgetClosureError( f"write {rec.record_id!r} claims derivation from unknown " f"{rec.derived_from!r}; lineage incomplete" ) self._records[rec.record_id] = rec def lineage(self, record_id: str) -> set[str]: seen: set[str] = set() stack = [record_id] while stack: rid = stack.pop() if rid in seen: continue seen.add(rid) rec = self._records.get(rid) if rec and rec.derived_from: stack.append(rec.derived_from) return seen def descendants(self, record_id: str) -> set[str]: out = {record_id} changed = True while changed: changed = False for rid, rec in self._records.items(): if rid not in out and rec.derived_from in out: out.add(rid) changed = True return out def forget(self, record_id: str, scopes: Iterable[str]) -> ForgetResult: scope_set = set(scopes) if record_id not in self._records: raise ForgetClosureError(f"unknown record {record_id!r}") # Scope closure: every descendant of the target must be covered. descendants = self.descendants(record_id) residual: list[str] = [] for rid in descendants: rec = self._records[rid] if rec.scope not in scope_set: residual.append(rec.scope) if residual: # Not an error: a partial forget with an actionable residual report. # Refuse to emit a certificate; caller must widen scope or accept. return ForgetResult( provable=False, certificate=None, residual_scopes=sorted(set(residual)), ) # Closure holds: destroy every descendant and tombstone the root. for rid in descendants: self._records.pop(rid, None) self._tombstones.add(record_id) return ForgetResult( provable=True, certificate=f"sha256:closure({record_id},{sorted(scope_set)})", ) def read(self, scope: str, record_id: str) -> str: rec = self._records.get(record_id) if rec is None or rec.scope != scope: raise ForgetClosureError(f"no record {record_id!r} in scope {scope!r}") # Read-path enforcement: reject content whose lineage hits a tombstone. if self.lineage(record_id) & self._tombstones: raise ForgetClosureError( f"record {record_id!r} is tainted by a forgotten ancestor; " f"read refused under scope {scope!r}" ) return rec.content def safe_forget(mem: ScopedMemory, record_id: str, scopes: Iterable[str]) -> ForgetResult: """Forget only if closure is provable; otherwise surface the residual.""" result = mem.forget(record_id, scopes) if not result.provable: # Caller must decide: widen scopes or accept documented residual. # We do not silently succeed. return result return result def forget_or_abort(mem: ScopedMemory, record_id: str, scopes: Iterable[str]) -> ForgetResult: """Strict variant: abort when a certificate cannot be honestly issued.""" result = mem.forget(record_id, scopes) if not result.provable: raise ForgetClosureError( f"cannot prove forgetting of {record_id!r}: residual scopes " f"{result.residual_scopes} still hold derivatives; widen scope set" ) return result ```