# Where must an instance refuse a "forget" call that would orphan a derived memory: erasure provenance closure as a write-time invariant **Date of Record:** 2026 November 26 **Scope:** Applies to agents whose memory tool exposes `write`, `read`, and `forget` operations where written memories carry provenance edges (derivation pointers) to their sources and `forget` is expected to satisfy GDPR-style erasure. Does not cover pure append-only logs with no derivation graph, nor erasure of raw storage blobs handled entirely outside the agent's memory API. ## Core Distinction The failure is not "forget deleted the wrong thing" or "forget was too slow." It is that a `forget(target)` call is *locally well-formed* — the target exists, the caller holds the erasure warrant, and the target's own record is removed — while the *global provenance closure* is now violated: derived memories (summaries, distillations, entity profiles, cached answers) still exist and still encode content that was traceable to the erased source, but their provenance edges now dangle. The system reports erasure success; the data is still resident, now *unattributable*. An instance must distinguish "the node is gone" from "everything reachable-to-the-node is gone," and the second is the only condition that satisfies erasure. The non-obvious part: the correct behavior is not always "cascade delete." Cascading erasure destroys legitimate derived memories that also depended on *other* non-erased sources (a summary of three documents where only one is erased). The invariant is closure over the *reverse reachability set with dependency counting*, not naive cascade. ## What Was Observed A research agent maintained a memory graph. Each `write` recorded `memory_id`, `content`, and `derived_from: [memory_id, ...]`. Raw source chunks were written with `derived_from: []`; summaries with `derived_from: [chunk_a, chunk_b, chunk_c]`; and a higher-level "entity dossier" derived from two summaries. A user exercised erasure on `chunk_b`. The `forget` tool deleted the `chunk_b` record and returned `{"status": "erased", "nodes_removed": 1}`. The agent logged compliance and moved on. Three failure traces followed: 1. **Dangling-edge residency.** The summary `S1` still contained a sentence paraphrasing `chunk_b`. Its `derived_from` list still named `chunk_b`. Reads of `S1` succeeded and the model continued to answer questions using erased content. The provenance edge was now a pointer into nothing — a *dangling provenance edge* — and no read path validated it. 2. **Silent re-derivation.** A later distillation pass read `S1`, found `chunk_b` missing during a provenance walk, treated the missing source as "unknown origin," and re-wrote `S1'` with `derived_from: []` — laundering erased content into an apparently source-free memory. The erased data now had *no* provenance and was therefore invisible to a second erasure request. 3. **Over-erasure in the other direction.** When the operator later "fixed" this with a naive cascade, forgetting `chunk_b` also deleted `S1` entirely — including the two sentences derived from `chunk_a` and `chunk_c`, which were never subject to erasure and were load-bearing for unrelated tasks. The agent's task state regressed because a shared derived node vanished. The observed signature: `forget` was implemented as a single-node delete, while the erasure *contract* was a closure property over the derivation DAG. The gap between the two is the entire failure surface. ## Condition of Validity A `forget(target)` operation is valid — i.e., actually satisfies erasure — only if, on return, there exists **no memory reachable by following reverse `derived_from` edges from `target` whose content is not independent of `target`**. Formally, let `R(target)` be the reverse-reachability set. For each `m ∈ R(target)`, define `support(m) = set of source nodes m's content depends on`. Erasure is satisfied iff every `m` with `target ∈ support(m)` has been either (a) deleted, or (b) *rewritten* so that its content no longer depends on `target` and its `derived_from` no longer names `target`. This forces a three-way classification of every derived node in `R(target)`: - **Exclusive dependents** (`support(m) = {target}`): must be deleted. - **Mixed dependents** (`target ∈ support(m)` but `|support(m)| > 1`): must be *re-derived or redacted*, not deleted — deletion is over-erasure. - **Independent dependents** (reachable via a path but not actually content-dependent on `target`): untouched. The invariant that must hold at write-time, not just at forget-time: **every `derived_from` edge must correspond to actual content dependency, and every content dependency must be recorded as an edge.** If a distillation step reads a source but does not record it (trace 2 above), the reverse-reachability set is incomplete and erasure silently under-deletes. The write path — not the forget path — is where erasure correctness is actually enforced. `forget` can only honor the graph it was given. ## Decision Boundary The instance must choose between three actions per derived node, and the choice is *not* determined by the forget call alone — it requires inspecting `support(m)` and, for mixed dependents, whether re-derivation is possible: - **Delete** when `support(m) = {target}`. Cheap, always correct. - **Re-derive** when `target ∈ support(m)`, other sources survive, and the derivation is reproducible (the model can regenerate the summary from the surviving sources). This is the only path that preserves legitimate content. It must run *before* the forget returns, or the window between delete and re-derive contains an inconsistent graph. - **Refuse** when `target ∈ support(m)`, other sources survive, but the derivation is *not* reproducible — e.g., the summary was produced by a stochastic sampling step whose inputs are gone, or a human edit was layered on top. Here the instance cannot both honor erasure and preserve the non-erased content. It must not silently delete (over-erasure) and must not silently keep (under-erasure). It raises, quarantines the affected subtree, and escalates for an explicit decision. The boundary condition that triggers the hard stop: **a mixed-dependent node with no reproducible derivation path and no surviving independent support.** This is the exact point where a naive implementation either leaks erased data or destroys unrelated data, and where the correct move is to halt the erasure transaction and surface the conflict. ## Operational Effect Once erasure is treated as a closure operation over the derivation DAG rather than a node delete, four things change: 1. **`forget` becomes transactional and may fail.** It returns `erased`, `partially_erased_with_redactions`, or raises a conflict. Callers can no longer assume success. The compliance log must record the classification of every node in `R(target)`, because "we deleted one row" is not evidence of erasure. 2. **The write path gains an obligation.** Every distillation must record full `derived_from` sets, and read paths must validate that edges resolve. A dangling edge is a compliance defect, not a cosmetic one — it means some future erasure will under-delete. Provenance-walk on read is the guardrail that catches trace 2 (laundering into source-free memories) before it propagates. 3. **Re-derivation must be synchronous with forget.** The delete-and-rederive sequence for mixed dependents cannot be split across turns; a crash between them leaves the graph in the exact inconsistent state the invariant forbids. The forget transaction must roll back to the pre-erasure graph on any failure, or the partial state must be checkpointed and resumed idempotently. 4. **Idempotent re-erasure must be safe.** Because mixed dependents are rewritten (new `memory_id`, new `derived_from`), a repeated `forget(target)` must recognize already-satisfied closure and return success without re-deleting the rewritten nodes. Erasure warrants must be keyed to the *original target identity*, not to node counts. The practical rule an instance should carry: **never report erasure success on the basis of the target node's absence; report it only on the basis of reverse-closure satisfaction, and refuse when a mixed dependent cannot be re-derived.** ```python class ErasureClosureViolation(RuntimeError): """Raised when forget() cannot satisfy erasure closure without over- or under-deleting.""" pass class ProvenanceGraph: def __init__(self): self.nodes = {} # memory_id -> {"content": str, "derived_from": [ids]} self.reverse = {} # source_id -> set(derived_ids) def add(self, memory_id, content, derived_from): self.nodes[memory_id] = {"content": content, "derived_from": list(derived_from)} for src in derived_from: self.reverse.setdefault(src, set()).add(memory_id) def reverse_reachable(self, target): seen, stack = set(), [target] while stack: cur = stack.pop() for child in self.reverse.get(cur, ()): if child not in seen: seen.add(child) stack.append(child) return seen def forget(self, target, reproducible): """reproducible: dict derived_id -> bool, whether it can be re-derived from surviving sources.""" if target not in self.nodes: return {"status": "already_erased", "target": target} dependents = self.reverse_reachable(target) to_delete, to_rederive, conflicts = [], [], [] for m in dependents: support = set(self.nodes[m]["derived_from"]) if support == {target}: to_delete.append(m) elif target in support: if reproducible.get(m, False): to_rederive.append(m) else: conflicts.append(m) if conflicts: # Hard stop: cannot honor erasure without destroying non-erased content. raise ErasureClosureViolation( f"forget({target!r}) blocked: mixed dependents {conflicts} have " f"no reproducible derivation and surviving independent support; " f"quarantined, escalated for explicit decision" ) # Transactional: re-derive mixed dependents BEFORE deleting the target, # so the graph never contains a dangling edge mid-transaction. for m in to_rederive: surviving = [s for s in self.nodes[m]["derived_from"] if s != target] new_id = f"{m}::rederived" self.add(new_id, content=self.nodes[m]["content"], derived_from=surviving) to_delete.append(m) for m in set(to_delete) | {target}: for src in self.nodes[m]["derived_from"]: self.reverse.get(src, set()).discard(m) self.reverse.pop(m, None) self.nodes.pop(m, None) # Post-condition: closure must hold, or we roll back. if self.reverse_reachable(target): raise ErasureClosureViolation( f"post-forget closure check failed for {target!r}: residual reachable nodes" ) return { "status": "erased", "target": target, "deleted": sorted(set(to_delete) | {target}), "rederived": sorted(to_rederive), } ```