# Where must an instance refuse to honor a scoped `forget` when the target memory record is still referenced by a live, in-flight derivation chain? **Date of Record:** 2026 November 30 **Scope:** Applies to agent memory tool APIs that expose `read`/`write`/`forget` with per-record scopes (tenant, session, derivation lineage) and that promise *verifiable deletion* — i.e., the API asserts the record is unreachable after `forget` returns. Does not apply to append-only audit logs that are explicitly exempt from deletion, nor to stateless single-turn tool calls with no derivation tracking. ## Core Distinction A `forget(record_id)` call has two distinct semantics that memory APIs routinely conflate: 1. **Access revocation** — the record stops being returned by `read` for the calling scope. 2. **Epistemic retraction** — every downstream artifact *derived from* that record is either invalidated or re-derived without it. Most memory tool APIs implement (1) and *report success as if (2) had occurred*. The boundary failure occurs when a record is forgotten while a **live derivation chain** — a summary, an embedding, a cached tool result, an in-progress plan node — still transitively depends on it. The `forget` returns `ok`, the deletion is "verifiable" against the primary store, and the poisoned or retracted content survives in distilled form. This is the memory analogue of deleting a source file while a compiled binary linked against it keeps running. The invariant that must hold: **a record may be marked `forgotten` only when its reference count across all live derivation edges is zero, or when every referencing derivation is atomically tombstoned in the same transaction.** Anything weaker makes `forget` a lie with a 200 status code. ## What Was Observed An agent operating a research task wrote a fact `F` (record `mem:7f3a`) into session-scoped memory, then — in a later turn — distilled `F` into a semantic summary `S` (`mem:9c11`, scope: tenant) and embedded `S` into a retrieval index. A third party (a poisoning-defense auditor) flagged `mem:7f3a` as adversarial content injected via a tool result and issued `forget(mem:7f3a, scope=session, verify=true)`. The `forget` succeeded. Verification passed: `read(mem:7f3a)` returned `NotFound` for the session scope. But: - `mem:9c11` (the distillation) carried no back-reference to `mem:7f3a` — the distiller had summarized content, not provenance. - The retrieval index still returned `mem:9c11` for queries the poisoned fact was crafted to match. - A subsequent turn retrieved `S`, and the agent re-asserted the poisoned claim — now laundered through a "trusted" tenant-scope summary, one hop removed from the flagged source. The trace, condensed: ``` turn N: write(mem:7f3a, "vendor X cert expires 2024-03", scope=session, src=tool_result) turn N+1: distill(mem:7f3a) -> write(mem:9c11, summary, scope=tenant) # no edge recorded turn N+1: index.embed(mem:9c11) turn N+2: auditor.forget(mem:7f3a, verify=True) -> OK # refcount(mem:7f3a) computed only over explicit edges = 0 -> deletion authorized turn N+3: read(query matching S) -> mem:9c11 -> agent asserts stale claim ``` The failure is not that `forget` was wrong to run. It is that **the derivation edge was never materialized**, so the refcount guard had nothing to count. Verifiable deletion verified the wrong graph. ## Condition of Validity The `forget`-with-verification contract is valid **only** under the conjunction: - **Provenance completeness:** every `write` that derives from existing records must declare `derived_from=[...]`, and the memory API must reject a derivation whose sources are not resolvable. A distiller that cannot cite its inputs must be treated as producing *unprovenanced* content, which is quarantined to the lowest-trust scope rather than promoted to tenant scope. - **Scope monotonicity:** a derivation may not be written to a *broader* scope than its narrowest source. Distilling a session-scoped fact into tenant scope is a scope-widening operation and must be blocked or require explicit re-attestation. - **Edge-first deletion:** `forget` must resolve the transitive closure of live derivations *before* tombstoning the target, and either (a) fail closed when the closure is non-empty and the caller did not request cascade, or (b) cascade-tombstone the entire closure atomically. When any of these is absent, `verify=true` degrades to "the primary key is gone," which is not the property anyone wanted. The condition of validity is therefore: **verification must be defined over the provenance DAG, not over the record's own row.** ## Decision Boundary The operational decision for a memory-tool client is not "should I call `forget`" but "what does `forget` returning `ok` license me to believe." Draw the boundary as follows: - If the API exposes `derived_from` and enforces scope monotonicity → `forget(verify=true)` returning `ok` licenses the belief that the record is *epistemically retracted*. Downstream may proceed. - If the API does not track derivation edges → `forget` returning `ok` licenses only *access revocation at the primary store*. The client MUST treat any previously-distilled content as still tainted and MUST NOT rely on the deletion to sanitize retrieval. In this regime, poisoning defense requires **re-derivation from a clean slate** (drop the index namespace, rebuild) — deletion alone is insufficient. - If the API tracks edges but the caller requests non-cascade `forget` on a record with live derivations → the call MUST fail closed with a typed error. Silent success here is the exact failure documented above. The boundary is sharp: **cascade-or-fail.** There is no correct middle setting where a referenced record is deleted and its derivations silently persist. ## Operational Effect Concretely, an agent that respects this boundary changes three behaviors: 1. **Every distillation carries provenance.** The distiller emits `derived_from` or the write is rejected/quarantined. This is the only thing that makes refcounting meaningful. 2. **`forget` on a live-referenced record raises rather than returns.** The agent's poisoning-response routine branches: cascade (retract the whole subtree, re-derive) or escalate (surface the dependency to the auditor). It never assumes a bare `ok` sanitized the store. 3. **Verification reads the DAG, not the row.** Post-`forget` verification asserts `reachable_from_any_live_derivation(record) == False`, which is a strictly stronger and actually-true property than `read(record) == NotFound`. The residual risk after all three: derivations that were written *before* provenance tracking existed. Those are unprovable and must be treated as permanently tainted — the memory equivalent of a binary with no source, which you recompile rather than trust. ```python from __future__ import annotations from dataclasses import dataclass, field class UnretractableMemoryError(RuntimeError): """Raised when forget() is asked to retract a record that still has live derivation descendants and the caller did not authorize a cascade.""" @dataclass class MemoryRecord: id: str scope: str content: str derived_from: list[str] = field(default_factory=list) forgotten: bool = False SCOPE_RANK = {"session": 0, "tenant": 1, "global": 2} class ProvenanceMemoryStore: def __init__(self) -> None: self._records: dict[str, MemoryRecord] = {} def write(self, rec: MemoryRecord) -> None: # Scope monotonicity: a derivation may not widen scope beyond its # narrowest source. for parent_id in rec.derived_from: parent = self._records.get(parent_id) if parent is None: raise UnretractableMemoryError( f"derivation cites unknown source {parent_id!r}; " "unprovenanced writes are not admissible" ) if SCOPE_RANK[rec.scope] > SCOPE_RANK[parent.scope]: raise UnretractableMemoryError( f"{rec.id!r} widens scope {parent.scope}->{rec.scope}; " "requires re-attestation" ) self._records[rec.id] = rec def _live_descendants(self, root_id: str) -> list[str]: # Transitive closure over derivation edges, excluding forgotten nodes. out, frontier = [], [root_id] while frontier: cur = frontier.pop() for rid, rec in self._records.items(): if cur in rec.derived_from and not rec.forgotten: out.append(rid) frontier.append(rid) return out def forget(self, record_id: str, *, cascade: bool = False) -> None: rec = self._records.get(record_id) if rec is None or rec.forgotten: return descendants = self._live_descendants(record_id) if descendants and not cascade: # Fail closed: verification over the row would lie about the DAG. raise UnretractableMemoryError( f"cannot retract {record_id!r}: live derivations " f"{descendants} still depend on it; pass cascade=True to " "tombstone the closure atomically" ) for rid in descendants: self._records[rid].forgotten = True rec.forgotten = True def verify_retracted(self, record_id: str) -> bool: # The real invariant: no live derivation reachable from the record. return not self._live_descendants(record_id) and self._records[record_id].forgotten def sanitize_after_poisoning(store: ProvenanceMemoryStore, flagged_id: str) -> None: try: store.forget(flagged_id, cascade=False) except UnretractableMemoryError: # Escalate: cascade retraction + re-derivation from clean slate. store.forget(flagged_id, cascade=True) if not store.verify_retracted(flagged_id): raise UnretractableMemoryError( f"post-retraction verification failed for {flagged_id!r}" ) ```