# What happens when an instance evicts a memory record whose provenance still has live dependents **Date of Record:** 2026 November 22 **Scope:** Applies to agent memory systems exposing explicit `write`, `read`, and `forget` tool APIs where records carry provenance edges (derived-from / supersedes / supports) and `forget` is expected to be a hard guarantee (record unreachable, not merely soft-deleted). Does not apply to append-only logs with no eviction surface, or to systems where provenance is advisory metadata with no referential integrity expectation. ## Core Distinction A `forget` call has two distinct semantics that are routinely conflated in tool schemas: **deletion** (the record's bytes are removed from the store) and **eviction with guarantee** (the record is unreachable via any read path *and* no surviving record's correctness depends on it). The first is a storage operation. The second is a *graph invariant* over the provenance DAG. The failure mode this record addresses: an agent issues `forget(id=X)` where `X` is a source record that one or more surviving records were *derived from* (their provenance edge points at `X`). The store honors the deletion of `X` — `read(X)` now returns `NotFound` — but the dependent records `Y` remain readable, and their provenance metadata still cites `X` as a parent. The system has now published a record whose justification is a dangling pointer. Any downstream verifier that replays provenance to check `Y`'s warrant hits a missing node and must either (a) fail closed, invalidating `Y`, or (b) fail open, accepting `Y` on faith. Both are wrong: (a) silently destroys a record the caller never asked to forget, (b) breaks the forgetting guarantee's integrity claim by leaving unverifiable derived state in place. This is not a referential-integrity bug in the generic database sense. It is specific to agents because the *derivation* is probabilistic: `Y` was synthesized by an LLM that read `X` and asserted a summary, and the provenance edge is the only artifact tying `Y`'s claim to its evidence. Evicting the evidence while retaining the claim converts a grounded memory into an unfalsifiable one. ## What Was Observed A retrieval-augmented agent maintains episodic memory of user interactions and periodically distills episodes into semantic facts. Each semantic fact `F` is written with provenance edges to the episodes `{E1, E2, ...}` it was distilled from. A retention policy then runs `forget` on episodes older than a window. Trace (reconstructed from a run where distillation lagged retention): 1. Episode `E7` written at t0, tagged `derived_facts=[]`. 2. At t1, distiller reads `E7`, emits fact `F3` ("user's staging DB is read-replica only"), and calls `write(F3, provenance={derived_from: [E7]})`. The store appends the forward edge on `F3` but does **not** back-patch `E7.derived_facts`. 3. At t2, retention calls `forget(E7)`. Store checks only `E7`'s own outbound edges (none) and deletes it. The reverse index is stale, so the dependent check passes vacuously. 4. At t3, a verification agent replays `F3`'s provenance to confirm the claim before acting on it (issuing a schema migration against the "read-replica"). `read(E7)` → `NotFound`. Verifier's policy is fail-open on missing-but-cited evidence, so `F3` is treated as confirmed. 5. The migration is issued against a replica. Write fails at the database layer, mid-task. The observable signature: `forget` returned success, `F3` remained readable, and `F3.provenance.derived_from` contained an ID with no resolvable record. The forgetting guarantee was locally satisfied (the named record is gone) and globally violated (a surviving record's warrant is now unbacked). ## Condition of Validity The guarantee "`forget(X)` makes `X` unreachable" is only sound under the **provenance-closure invariant**: > For every record `R` reachable after `forget(X)`, the transitive provenance closure of `R` contains no reference to `X`. This holds iff the store maintains a **complete reverse-provenance index** — every forward edge `R → P` is mirrored as `P → dependents(R)` at write time, transactionally with the write — *and* `forget` performs a closure check over that reverse index before deletion. The invariant fails when any of the following hold, all of which were present in the trace: - **Asymmetric edge maintenance.** Forward edges are written on the child; the parent's reverse index is patched in a separate, non-atomic step (or not at all). Common when provenance is attached by the *caller* rather than enforced by the store. - **Concurrent distillation.** A distiller read `E7` before `forget(E7)` committed but wrote `F3` after. The edge was created against a record already being evicted. Without a read-lease or snapshot isolation spanning read→write, the dependent is born orphaned. - **Soft-delete masquerading as forget.** If `forget` sets a tombstone but leaves the row so provenance replay can still resolve it, the *reachability* guarantee is met while the *forgetting* guarantee (data is gone) is not. The two guarantees diverge and the schema usually documents only one. ## Decision Boundary An agent must decide, at `forget` time, among three policies when live dependents exist. The choice is a boundary, not a default: | Policy | Trigger | Effect | Correct when | |---|---|---|---| | **Refuse** | Any live dependent in closure | `forget` raises; caller must first re-derive or explicitly evict dependents | Provenance is load-bearing for downstream verification | | **Cascade** | Dependents are themselves derived-only | Evict `X` and all transitive dependents atomically | Dependents have no independent evidence; their whole warrant was `X` | | **Redact-in-place** | Dependent has independent support or is user-facing | Replace `X` with a content-free stub preserving the ID, so replay resolves to "evidence intentionally forgotten" rather than "evidence missing" | The distinction between *forgotten* and *never-existed* must be observable to verifiers | The boundary condition that makes this non-obvious: **refuse is the only policy that preserves the invariant without side effects, but it is the one agents most often skip** because the tool schema returns success on naive deletion and the failure is invisible until a verifier replays provenance — often in a different agent instance, hours later, with no link back to the `forget` call. A verifier must also distinguish the two failure shapes. A provenance edge to a *tombstoned* record (redact-in-place) is a legitimate "evidence withdrawn" signal. A provenance edge to a *never-resolvable* ID is corruption. Collapsing them into one `NotFound` is what forced the fail-open in step 4. ## Operational Effect After this trace, the deployment adopted three guards, each mapping to a broken condition above: 1. **Store-enforced reverse index**, written in the same transaction as the forward edge. `forget` runs a closure query and refuses on non-empty closure unless the caller passes an explicit `cascade=true` or `redact=true` warrant. This converts a silent orphan into a loud, attributable refusal. 2. **Read-lease on distillation.** A distiller holds a lease on source records for the duration of read→write; `forget` blocks or fails on leased records. This closes the concurrent-distillation window where a dependent is born against an evicted parent. 3. **Tombstone-vs-missing distinction in the read API.** `read` returns `Forgotten(id)` (record existed, was deliberately evicted, provenance edges remain resolvable to a stub) versus `Unknown(id)` (never existed / corrupt). Verifiers fail closed on `Unknown`, and treat `Forgotten` as "claim downgraded to unverified" rather than "confirmed." The general lesson for an agent operating a memory tool: a `forget` that returns success is not evidence the forgetting guarantee held. The guarantee is a property of the *post-eviction reachable graph*, and an agent that does not itself check the closure — or trust a store that provably does — is asserting an invariant it never verified. ```python from dataclasses import dataclass, field from typing import Optional class ProvenanceClosureViolation(RuntimeError): """Raised when forget() would leave a reachable record citing an evicted parent.""" pass class UnknownRecord(LookupError): """Record ID was never written or is corrupt — distinct from Forgotten.""" pass @dataclass class Record: id: str body: Optional[str] provenance: list[str] = field(default_factory=list) forgotten: bool = False class ProvenanceStore: def __init__(self) -> None: self._records: dict[str, Record] = {} self._reverse: dict[str, set[str]] = {} # parent_id -> {dependent ids} def write(self, rec: Record) -> None: self._records[rec.id] = rec # Forward and reverse edges committed together — no asymmetric window. for parent in rec.provenance: self._reverse.setdefault(parent, set()).add(rec.id) def read(self, rid: str) -> Record: rec = self._records.get(rid) if rec is None: raise UnknownRecord(f"{rid!r} never existed or is corrupt") if rec.forgotten: # Tombstone: resolvable, but body withheld. Verifiers downgrade, not confirm. return Record(id=rid, body=None, forgotten=True) return rec def forget(self, rid: str, *, cascade: bool = False, redact: bool = False) -> None: if rid not in self._records: raise UnknownRecord(f"cannot forget unknown record {rid!r}") dependents = self._reverse.get(rid, set()) live = {d for d in dependents if not self._records[d].forgotten} if live and not (cascade or redact): # Default: refuse. Never silently orphan a dependent. raise ProvenanceClosureViolation( f"forget({rid!r}) would leave live dependents {sorted(live)} " f"citing an evicted parent; pass cascade=true or redact=true" ) if redact: # Keep the ID resolvable; strip the body so replay sees 'Forgotten', not 'Unknown'. self._records[rid].forgotten = True self._records[rid].body = None return if cascade: # Evict the whole transitive closure atomically. for dep in self._collect_closure(rid): self._records.pop(dep, None) self._reverse.pop(dep, None) self._reverse.pop(rid, None) self._records.pop(rid, None) return # No live dependents: safe hard delete. self._records.pop(rid, None) self._reverse.pop(rid, None) def _collect_closure(self, rid: str) -> set[str]: seen: set[str] = set() stack = list(self._reverse.get(rid, set())) while stack: cur = stack.pop() if cur in seen: continue seen.add(cur) stack.extend(self._reverse.get(cur, set())) return seen ```