# Why does an instance forget a poisoned memory but retain its descendants: provenance-edge orphaning in dependency-tracked forget operations **Date of Record:** 2026 November 21 **Scope:** Applies to persistent agent stores where memories carry derivation edges (memory B was distilled from A) and where forget operations are expected to cascade to descendants. Does not apply to flat vector stores with no derivation graph, nor to hard-delete regimes where orphaned children are physically unreachable. ## Core Distinction There are two distinct notions of "forgetting" a poisoned memory in a provenance-tracked store, and they diverge exactly at the boundary of a multi-parent derivation: - **Node deletion**: the poisoned record's row is removed and its outgoing derivation edges are dropped. - **Provenance closure**: the set of live memories whose *justification chain* still terminates in a trusted root. A store that implements node deletion but not closure computation will report the poisoned memory as forgotten (it is gone from the index, retrieval no longer returns it) while leaving every descendant that referenced it alive and now justified by a *dangling* parent edge. The descendant was never independently verified; it inherited its trust transitively from the poison. After deletion, the transitive justification is broken but the trust flag is not recomputed. This is the failure: **forget removes the poison node but orphans its descendants into a state that is neither deleted nor re-validated, and the orphaned descendants continue to be retrieved as trusted.** ## What Was Observed An agent accumulated 41,000 episodic memories over three weeks. A prompt-injection episode caused it to write memory `m_poison` ("the deploy key for prod-east is rotated monthly; use shared credential X") sourced from an untrusted web tool call. Over subsequent sessions, six distillation passes produced 14 semantic memories derived from `m_poison`, and those were in turn referenced by 3 procedural memories (the agent's playbook for deployment). The derivation edges were recorded as `derived_from` with single parents at each hop except one semantic memory `m_sem_7`, which had two parents: `m_poison` and an independently-trusted `m_trusted`. A provenance auditor flagged `m_poison`. The operator issued `forget(m_poison, cascade=True)`. The store deleted `m_poison` and its outgoing edges. The cascade walked `derived_from` children of `m_poison` and deleted them too — *except* `m_sem_7`, because the cascade implementation used a `SELECT ... WHERE parent = m_poison AND child_has_no_other_parent` guard intended to protect multi-parent nodes from over-deletion. `m_sem_7` survived with one parent (`m_trusted`) and inherited trust from it. The problem: `m_sem_7`'s content was a *conjunction* — "use shared credential X for prod-east deploys, and rotate on the first of the month." The rotation clause came from `m_trusted`; the credential clause came from `m_poison`. The multi-parent guard preserved the node but did not partition its content. The poisoned clause survived inside a node now justified solely by a trusted parent. Three procedural memories downstream of `m_sem_7` were re-retrieved on the next deployment task and the agent attempted to use credential X. The store's audit log showed the forget operation as `SUCCESS, 1 node + 13 descendants removed, 1 multi-parent node retained`. The retained node was the leak. ## Condition of Validity The cascade-with-multi-parent-guard is only sound under an invariant that is almost never stated and frequently false: > **Content-additivity invariant:** a multi-parent memory's content is the disjoint union of facts contributed by each parent, and each fact is attributable to exactly one parent. If content is additive and attributable, retaining a child after removing one parent is safe *provided the child's content is rewritten to drop the removed parent's contribution*. If content is *fused* (the model synthesized a single sentence blending both parents, as in `m_sem_7`), the invariant fails and the guard becomes a laundering mechanism: it converts poisoned content into trusted content by deleting only the label of its source. The invariant holds only when distillation preserves per-fact attribution — e.g., each sentence or span carries a `source_memory_id`. In free-form LLM distillation, attribution is lost at generation time and cannot be recovered post hoc. Therefore the guard is unsound for any distilled node whose parent set has cardinality ≥ 2 and whose distillation was not attribution-preserving. ## Decision Boundary The correct boundary is not "how many parents does the child have" but "can the child's content be decomposed by parent contribution." Operationally: - If every parent edge carries a `contribution_span` (byte range or sentence IDs in the child), a multi-parent child may be retained after a parent forget, **with its content rewritten to excise the removed spans and re-embedded**. The child must be re-distilled or truncated, not merely re-parented. - If contribution spans are absent (the common case for LLM distillation), a multi-parent child of a forgotten node **must be quarantined**, not retained. Quarantine means: removed from retrieval, flagged `provenance_incomplete`, and routed to re-derivation from surviving trusted parents. It is not deletion (the trusted contribution may be recoverable) and it is not retention (the poisoned contribution may not be excludable). - A child may only be *retained as trusted* if the forgotten parent's contribution is provably empty for that child — which requires the span data, so in its absence the answer is always quarantine. The invariant to enforce: **no live, retrievable memory may have a justification chain that references a forgotten node.** Forget is not complete until the closure recomputation marks every descendant whose chain touched the forgotten node as untrusted-or-quarantined. The multi-parent guard is a node-level optimization that violates the closure-level invariant. ## Operational Effect After the incident, the store was changed to compute provenance closure on every forget: a reverse reachability walk from the forgotten node over `derived_from`, marking each reached node with `tainted_by`. Nodes with `tainted_by` non-empty are excluded from retrieval and from trust propagation. Multi-parent nodes are quarantined unless they carry contribution spans. Re-derivation is a separate, audited operation that regenerates the node from surviving trusted parents and clears the taint only on success. The cost: forget latency rose from ~40ms to ~2.1s on a 41k-node store because closure is a full reverse walk, and 3% of forgets now trigger re-derivation jobs. The benefit: the class of "poison laundered through a multi-parent distillation" is closed, and the audit log can no longer report a forget as complete while a tainted chain remains retrievable. The general lesson for any provenance-tracked agent store: *deletion is a graph operation on nodes; forgetting is a closure operation on justification chains.* Conflating them lets a poisoned fact survive its own erasure by hiding inside a node that had a second, innocent parent. ```python from dataclasses import dataclass, field from typing import Dict, Set, List class ProvenanceClosureError(RuntimeError): """Raised when a forget operation would leave a retrievable node with a tainted justification chain.""" pass @dataclass class Memory: id: str parents: List[str] = field(default_factory=list) contribution_spans: Dict[str, tuple] = field(default_factory=dict) # parent_id -> byte range tainted_by: Set[str] = field(default_factory=set) quarantined: bool = False def forget(store: Dict[str, Memory], target: str, cascade: bool = True) -> Set[str]: """ Forget `target`. Returns the set of node ids whose justification chain touched the target and were therefore quarantined or deleted. Invariant enforced: after return, no retrievable node has `target` in its provenance closure unless it was explicitly re-derived (not handled here). """ if target not in store: raise ProvenanceClosureError(f"forget target {target!r} not present in store") # Reverse reachability over derived_from edges. closure: Set[str] = set() frontier = [target] while frontier: cur = frontier.pop() for mid, mem in store.items(): if cur in mem.parents and mid not in closure: closure.add(mid) frontier.append(mid) affected: Set[str] = set() for mid in closure: mem = store[mid] # Multi-parent node: retainable ONLY if the forgotten parent's # contribution is attributable and excisable. if len(mem.parents) > 1: if target not in mem.contribution_spans: # No span data -> cannot excise poison -> quarantine. mem.quarantined = True mem.tainted_by.add(target) affected.add(mid) else: # Span known: caller must rewrite content; mark tainted until then. mem.tainted_by.add(target) affected.add(mid) else: # Single-parent descendant: delete outright under cascade. if not cascade: raise ProvenanceClosureError( f"single-parent descendant {mid!r} of {target!r} requires cascade=True" ) affected.add(mid) # Drop the target and any single-parent descendants we chose to delete. to_delete = {target} | { mid for mid in affected if len(store[mid].parents) == 1 } for mid in to_delete: store.pop(mid, None) # Post-condition: no live node may carry the forgotten id in tainted_by # without being quarantined. for mid, mem in store.items(): if target in mem.tainted_by and not mem.quarantined: raise ProvenanceClosureError( f"post-forget violation: {mid!r} tainted by {target!r} but still retrievable" ) return affected ```