# Under what conditions must an instance refuse a scoped `forget` call whose retention lease has already been superseded by a derived semantic write **Date of Record:** 2026 November 25 **Scope:** Applies to agents exposing read/write/forget memory tool interfaces where retention is scoped (tenant, session, subject) and deletion must be auditable. Does not apply to append-only logs without derived-write pipelines, nor to single-tenant stores where no distillation step exists. ## Core Distinction The failure is not "deletion failed." It is "deletion succeeded against the wrong generation." A scoped `forget(scope, policy_id)` call is a *lease-bound* operation: it asserts that the caller's retention policy is the one currently governing the scope. When an episodic memory has been distilled into a semantic record, the semantic record inherits the scope but *not* the original lease identifier. If the agent issues `forget` against the stale episodic lease, the store deletes the raw episodes, returns `{"deleted": 42, "audit_id": ...}`, and the derived semantic summary—still readable, still quotable, still retrievable—survives untouched. The audit trail is internally consistent and completely misleading. The invariant that must hold: **every derived write carries a `supersedes_lease` pointer to the retention lease it was distilled under, and `forget` must traverse the derivation graph forward, not just the scope index.** A `forget` that cannot prove it reached the terminal node of every derivation chain rooted in the target lease MUST abort, not partially apply. ## What Was Observed A subject-scoped store held 42 episodic records under lease `L-7` (policy: `retain_90d`, subject `u-4413`). At day 71 a nightly distillation job produced one semantic record `S-19` ("subject prefers async contact; timezone UTC+2") tagged `scope=subject:u-4413` but with its own fresh lease `L-9` (`retain_365d`). At day 88 an erasure request arrived. The agent resolved `forget(subject:u-4413)` against the scope index, found `L-7` active, and deleted all 42 episodes. The tool returned success. The audit entry recorded `policy_id=L-7`, `records=42`, `derivation_depth=0`. `S-19` remained retrievable. A later session, reading `subject:u-4413`, pulled `S-19` into context and surfaced the erased preference. The deletion was auditable, successful, and wrong. The trace: `forget` resolved scope → matched the *oldest active lease* rather than the *latest governing lease* → deleted only nodes whose `lease_id == L-7` → derivation edge `L-7 → L-9` was never traversed because the store's deletion path was lease-keyed, not graph-keyed. ## Condition of Validity A scoped `forget` is only valid when all of the following hold at call time: 1. The resolved lease is the **maximal** lease for the scope under the derivation partial order—no lease in the scope transitively supersedes it. 2. Every derivation edge from the target lease has a resolvable terminal node, and the terminal nodes are either deleted in the same transaction or explicitly retained under a policy the caller has authority to override. 3. The audit record enumerates the full derivation set (`derivation_depth > 0` when distillation occurred), not just the direct-hit count. If condition 1 fails, the caller is acting on a superseded lease. If condition 2 fails, the deletion is partial and must roll back. If condition 3 fails, the operation is unauditable even if correct. The non-obvious part: condition 1 fails *silently* in most stores because scope indexes return leases ordered by creation time, and distillation creates *later* leases. The oldest lease is the one a naive resolver picks, and it is exactly the wrong one. ## Decision Boundary The agent must distinguish three cases before issuing `forget`: - **Superseded lease, derivations present:** refuse, return the terminal lease set, require the caller to re-issue against the maximal lease or supply an explicit `cascade=true` warrant. Do not auto-cascade—cascading across a retention boundary the caller did not author is itself an audit violation. - **Superseded lease, no derivations:** the scope was rewritten without distillation; deletion is safe but the audit must note `superseded_by` so a later reader does not treat the old lease as authoritative. - **Maximal lease:** proceed; still traverse forward for any derivations the maximal lease itself spawned. The boundary is the derivation edge. Below it, `forget` is a scope operation. Above it, `forget` is a graph operation and scope-keyed deletion is unsound. ## Operational Effect Agents that treat `forget` as scope-keyed will pass their own audits while leaking distilled state indefinitely—the leak is invisible to the deletion path because the surviving record lives under a *different, valid* lease. The remediation is structural: the memory tool must expose `derives_from` on every write, `forget` must resolve to the maximal lease and walk forward, and any partial traversal must raise rather than return a success count. The audit record becomes the proof of traversal, not the proof of row count. ```python from dataclasses import dataclass, field from typing import Optional class SupersededLeaseError(RuntimeError): """Raised when forget targets a lease that a derived write has superseded.""" class IncompleteDerivationTraversal(RuntimeError): """Raised when forward traversal from a lease hits an unresolvable node.""" @dataclass class Lease: lease_id: str scope: str supersedes: Optional[str] = None derived_from: Optional[str] = None @dataclass class MemoryStore: leases: dict[str, Lease] = field(default_factory=dict) records: dict[str, list[str]] = field(default_factory=dict) def maximal_lease(self, scope: str) -> Lease: in_scope = [l for l in self.leases.values() if l.scope == scope] if not in_scope: raise SupersededLeaseError(f"no lease for scope {scope}") superseded = {l.supersedes for l in in_scope if l.supersedes} terminals = [l for l in in_scope if l.lease_id not in superseded] if len(terminals) != 1: raise SupersededLeaseError( f"scope {scope} has {len(terminals)} terminal leases; ambiguous" ) return terminals[0] def forget(self, scope: str, policy_id: str, cascade: bool = False) -> dict: target = self.maximal_lease(scope) if target.lease_id != policy_id and not cascade: raise SupersededLeaseError( f"policy_id={policy_id} is superseded by {target.lease_id}; " f"re-issue against maximal lease or pass cascade=True" ) chain = [target.lease_id] cursor = target while True: children = [l for l in self.leases.values() if l.derived_from == cursor.lease_id] if not children: break if len(children) > 1: raise IncompleteDerivationTraversal( f"lease {cursor.lease_id} branches to {len(children)} derivations" ) cursor = children[0] chain.append(cursor.lease_id) deleted = 0 for lease_id in chain: deleted += len(self.records.pop(lease_id, [])) return {"deleted": deleted, "audit_chain": chain, "derivation_depth": len(chain) - 1} ```