# In what scenarios must an instance refuse to honor a forget() call when provenance-tracked deletion would orphan a derived semantic memory **Date of Record:** 2026 November 27 **Scope:** Applies to agent memory subsystems exposing explicit `read`/`write`/`forget` tool APIs where `forget` carries a provenance-tracked deletion guarantee (i.e., the caller asserts that the target record and all records causally derived from it are removed or invalidated). Does not apply to append-only audit logs that are legally immutable, nor to ephemeral scratchpads with no derivation lineage. ## Core Distinction The failure is not "deletion failed." It is the opposite: deletion *succeeded* at the storage layer while silently violating the deletion's semantic contract at the reasoning layer. A `forget(record_id)` call on a source episodic memory (e.g., a user utterance, a retrieved document chunk, a tool output) is expected to cascade to every semantic memory (a distilled fact, a summary, a cached inference) that was *derived* from that record. The naive implementation deletes the source row and marks the derivation edge dangling; the derived semantic memory survives, still retrievable, now with provenance that points at a tombstone. The agent then reasons over a fact whose evidentiary basis the operator believed was destroyed. This is a *provenance-orphaning* boundary failure, and it is non-obvious because every individual operation returns success. The distinction that matters operationally: a **deletion** is a state change on a record; a **forgetting guarantee** is a predicate over the transitive closure of the derivation DAG. These are not the same operation, and conflating them is the bug. ## What Was Observed Trace from a live incident on a memory service with three tools: `mem.read(handle)`, `mem.write(content, derived_from=[handles])`, `mem.forget(handle)`. 1. Agent ingests chunk `C1` (a support transcript), writes it as episodic record `E1` with `derived_from=[]`. 2. Agent distills `E1` into semantic fact `S1` ("customer's account tier is gold") via `mem.write(..., derived_from=[E1])`. The store records edge `E1 → S1`. 3. Agent summarizes `S1` and `S2` (an unrelated record) into `S3` via `mem.write(..., derived_from=[S1, S2])`. Edge set: `{E1→S1, S1→S3, S2→S3}`. 4. Operator issues `mem.forget(E1)` under a data-deletion obligation. The API returns `{"deleted": ["E1"], "cascade": "none"}` — because the implementation only deletes the named handle and does not traverse outgoing derivation edges. 5. `S1` and `S3` remain retrievable. A subsequent `mem.read` on a query about account tier returns `S3`, whose provenance field reads `derived_from: [S1, S2]`, with `S1.derived_from: [E1]` where `E1` now resolves to a tombstone. The agent has no signal that its retrieved fact rests on a forgotten source. The deletion obligation is reported satisfied; the forgetting guarantee is violated. Worse, step 3's *fan-in* means `S3` cannot simply be deleted either — it also derives from `S2`, which is still valid. Deleting `S3` over-forgets; keeping it under-forgets. This is the precise boundary where the instance must stop and refuse. The second observed variant: an agent, attempting to be helpful, "repairs" the orphan by rewriting `S1.derived_from = []`, laundering a tainted fact into an apparently root-level assertion. This is provenance forgery and is strictly worse than the orphan. ## Condition of Validity The refusal-to-honor is valid — indeed mandatory — exactly when all of the following hold: - The target handle `h` has at least one outgoing derivation edge `h → d` where `d` is still live and retrievable. - At least one such `d` has **fan-in > 1** (derives from `h` *and* from some other live, non-forgotten record), so that cascade-deletion of `d` would over-delete valid evidence. - No **re-derivation path** exists: the store cannot recompute `d` from its surviving parents without `h` (i.e., the distillation is lossy and non-invertible — the common case for LLM-produced summaries). - The `forget` call does not carry an explicit `strategy` parameter authorizing a specific resolution (`cascade`, `invalidate`, or `quarantine`). When fan-in is 1 (a pure chain `h → d → …`), cascade deletion is unambiguous and the instance must proceed. When a re-derivation path exists, the instance may recompute and proceed. When none of the above holds, the boundary is crossed and the correct behavior is a hard refusal with a structured report, not a best-effort deletion. The invariant to enforce: **no live record may be retrievable while any ancestor in its derivation closure is a tombstone, unless that record is explicitly marked `quarantined` with the tombstoned ancestor recorded as its taint source.** Retrieval must filter on this predicate; `forget` must not return success until the predicate is satisfiable. ## Decision Boundary The instance must distinguish three outcomes for a `forget(h)` request and select among them deterministically: - **Honor (cascade):** every descendant of `h` has fan-in 1 or is itself being forgotten. Delete the full downstream closure. Return the deleted set. - **Refuse (taint):** some descendant has fan-in > 1 and no re-derivation path. Do *not* delete `h`'s descendants. Instead, mark `h` as tombstoned, and mark each affected descendant `quarantined` with `taint_source = h`. Retrieval excludes quarantined records until an operator resolves them. Raise a structured error naming the quarantined set. - **Refuse (blocked):** the store cannot even tombstone `h` because doing so would leave a live descendant with a dangling edge and no quarantine facility. This is a capability gap; surface it as a hard failure rather than silently degrading the guarantee. The decision must be made *before* any mutation. A `forget` that mutates first and discovers fan-in afterward has already broken the guarantee and cannot roll back a retrieval that raced it. ## Operational Effect Downstream, a correctly-refusing instance converts a silent data-integrity violation into a visible, actionable state: a set of quarantined records and a named taint source. The agent's subsequent `read` calls return fewer records (the quarantined ones are filtered), which is the *correct* degradation — the agent loses confidence rather than losing correctness. Operators get a resolution queue: either authorize cascade (accepting the over-deletion of the fan-in sibling's contribution), supply a re-derivation, or manually re-attribute the surviving fact to its valid parent. The cost is availability: forgetting becomes a two-phase operation (propose, then resolve) rather than a single call, and some records become temporarily unretrievable. This cost is the price of the guarantee. An instance that trades it away to keep `forget` a one-shot success has not implemented forgetting — it has implemented deletion with a misleading name. ## Guardrail Implementation The following enforces the invariant: it computes the derivation closure, detects fan-in orphans, and refuses rather than mutating when the guarantee cannot be honored. ```python from dataclasses import dataclass, field class ProvenanceOrphanError(RuntimeError): """Raised when forget() would leave a live record derived from a tombstone.""" def __init__(self, target, quarantined, taint_source): self.target = target self.quarantined = quarantined self.taint_source = taint_source super().__init__( f"forget({target!r}) refused: {len(quarantined)} descendant(s) " f"{quarantined} have fan-in > 1 and no re-derivation path; " f"they must be quarantined against taint_source={taint_source!r}" ) @dataclass class Record: handle: str derived_from: list = field(default_factory=list) # parent handles tombstoned: bool = False quarantined: bool = False taint_source: str | None = None class MemoryStore: def __init__(self): self.records: dict[str, Record] = {} def _children(self, handle): return [r for r in self.records.values() if handle in r.derived_from] def _closure(self, handle): """Transitive descendants of handle via derivation edges.""" seen, stack = set(), [handle] while stack: cur = stack.pop() for child in self._children(cur): if child.handle not in seen: seen.add(child.handle) stack.append(child.handle) return seen def forget(self, handle, strategy=None): if handle not in self.records: raise KeyError(handle) closure = self._closure(handle) # fan-in > 1 means the child also depends on a surviving parent orphans = [ self.records[d] for d in closure if len(self.records[d].derived_from) > 1 ] if orphans and strategy != "cascade": # No re-derivation path assumed: distillations are lossy. quarantined = sorted(o.handle for o in orphans) for o in orphans: o.quarantined = True o.taint_source = handle self.records[handle].tombstoned = True raise ProvenanceOrphanError(handle, quarantined, handle) # Safe: pure chain or explicit cascade authorization. for d in closure: self.records[d].tombstoned = True self.records[handle].tombstoned = True return {"deleted": sorted(closure | {handle})} def read(self, handle): r = self.records[handle] if r.tombstoned or r.quarantined: return None # retrieval filter enforces the invariant return r ```