Why does an instance forget a fact it just re-derived, when scoped forget wipes the provenance record but not the derived semantic node?
**Date of Record:** 2026 December 1 **Scope:** Applies to agents exposing `remember`/`recall`/`forget` memory-tool APIs where retention scopes (tenant, subject, purpose) gate writes and a right-to-be-forgotten (RTBF) `forget` call must erase a subject's data. Does not apply to append-only audit logs that are legally exempt from erasure, or to stateless single-turn agents with no persistent store.
Core Distinction
The failure is not "forget didn't delete the record." It is that `forget(subject=S)` erases the *provenance edges* that record where a semantic fact came from, while the *derived semantic node* — the distilled fact `S.plan_tier = enterprise`, or `S.dietary = vegan` — survives in the semantic layer because it was written under a different scope (e.g. `scope=global`, `scope=team:acme`) and carries no back-reference that the erasure query can traverse.
This produces an invariant violation that is invisible at write time and only surfaces on the *next* recall: the agent can still retrieve a fact it is not permitted to hold, because the fact and its lawful basis have been decoupled. Worse, the agent will often *re-derive* the fact from residual episodic traces and re-insert it — a resurrection loop. The naive mental model ("forget deletes the row") is wrong; the correct model is "forget deletes a node and its inbound edges, but derived nodes with outbound-only edges are orphaned, not deleted."
What Was Observed
A support agent distilled an episodic memory during a session:
- Episodic node `E1`: `scope=subject:S-4417`, `kind=episodic`, `text="user said they're on the Enterprise plan, renewal in March"`, with an outbound `DERIVED_FROM` edge to `E1`.
- Semantic node `S1`: `scope=global`, `kind=semantic`, `text="S-4417 is enterprise-tier, renews March"`, with an inbound edge `S1 --DERIVED_FROM--> E1`.
The distiller wrote `S1` under `scope=global` because tier facts were considered reusable across the tenant's workflows — a reasonable retention choice at write time. The `DERIVED_FROM` edge pointed from `S1` to `E1`, i.e. the *inbound* direction relative to the origin.
Then `forget(subject="S-4417", reason="rtbf")` fired. The erasure routine was implemented as: find all nodes where `scope == subject:S-4417`, delete them, and delete any edge whose *source* is a deleted node. This removed `E1` and the edge `S1 --DERIVED_FROM--> E1` (source `S1` was not deleted, but the edge's target was — depending on the implementation the edge was deleted or left dangling; in the observed trace it was deleted). `S1` itself survived because its scope was `global`, and its only link to the subject's origin was that now-deleted edge.
Post-erasure recall for subject `S-4417` returned `S1` with high confidence. The agent then, in a later session, "confirmed" the tier to a different operator and wrote a *new* episodic node `E2` under `scope=subject:S-4417` summarizing "confirmed enterprise tier" — re-creating subject-scoped data about a data subject whose erasure had been certified. The RTBF certificate was now false within one session.
The failure trace:
- Write `E1` (subject scope) → write `S1` (global scope) + edge `S1→E1`.
- `forget(subject)` deletes `E1`, deletes edge `S1→E1`. `S1` orphaned but live.
- `recall(subject)` matches `S1` on its *content* (which embeds `S-4417`), not on scope. Returns it.
- Agent acts on `S1`, generates new subject-scoped `E2`.
- Erasure invariant "no subject-scoped data exists" now violated again, with no audit trail linking `E2` to the original erasure event.
Condition of Validity
The guardrail holds only if **every derived node carries a scope that is the join (meet, in lattice terms) of all its provenance scopes, and erasure is defined as a transitive closure over provenance edges in both directions.** Concretely:
- A semantic node distilled from a `subject:S` episodic node may not be written at a scope broader than `subject:S` *unless* it has been explicitly de-identified (the subject identifier removed from its content), in which case it must carry a `deidentified=true` flag and must not be recallable by subject query.
- `forget(subject)` must compute the set of nodes reachable from any `subject:S` node via `DERIVED_FROM` edges in *either* direction, and delete or de-identify all of them. Orphaned derived nodes are the bug; there is no such thing as a "safe orphan."
- A `recall` result whose content matches the forgotten subject identifier but whose scope is broader must be rejected at read time, not merely at write time — because the write-time scope check cannot see future erasure.
If any of these three does not hold, the erasure is not sound: the certificate is a claim about rows, not about *facts*.
Decision Boundary
The boundary is between **row-scoped erasure** and **fact-scoped erasure**. Row-scoped erasure is correct and cheap when the memory store is a flat key-value table with no derivation. It is *unsound* the moment the agent has a distillation step that writes cross-scope nodes, because distillation is exactly the operation that launders a subject-scoped fact into a global one.
The decision the engineer must make explicit: does `scope` mean "who may read this" or "whose data is this"? These are different lattices. Read-scope is a permission lattice (global ⊒ team ⊒ subject). Provenance-scope is a data-subjecthood lattice (a node is subject-scoped if *any* of its ancestors is). Conflating them is the root cause. A node can legitimately be *read* at global scope and *owned* at subject scope simultaneously; the store must track both, and `forget` must key on the ownership lattice while `recall` keys on the read lattice.
When you cannot separate the two lattices, the safe default is to refuse distillation across scope boundaries: a `subject:S` episodic node may only produce `subject:S` semantic nodes. This costs recall breadth but makes erasure a single-scope delete with no closure computation.
Operational Effect
In production this manifests as three distinct symptoms, all traceable to the same orphan:
- **Erasure-certificate falsity.** The compliance report says "0 subject-scoped rows for S-4417" and is technically true while the agent still answers questions about S-4417 from a global node. Auditors sampling recall output, not tables, will catch it; table-scanning auditors will not.
- **Resurrection loops.** Each recall of the orphaned `S1` re-grounds a new subject-scoped episodic node, so the subject's footprint *grows* after erasure. A monitoring system that alerts on subject-scoped row count will fire continuously and be dismissed as a false positive — the alert is correct.
- **Silent provenance loss.** The dangling edge (or its deletion) means a later `explain(S1)` returns "no provenance," which the agent may interpret as "user-provided, high confidence" rather than "origin erased." Confidence calibration drifts upward on exactly the facts that should have been deleted.
The fix is architectural, not a patch: represent provenance as a first-class DAG with a `subject_owner` set on every node (the union of subject scopes of all ancestors), maintain it incrementally on every `remember`/distill, and make `forget(subject)` a closure delete over `subject_owner ∋ subject`. Recall must filter on `subject_owner ∩ active_erasures = ∅`. The invariant to test: after any `forget(S)`, no node reachable by `recall` may have `S` in its content or its `subject_owner`, and no subsequent `remember` may write a node whose provenance closure touches a tombstoned `S` without an explicit `re-consent` warrant.
from dataclasses import dataclass, field
from typing import Optional
class OrphanedDerivedNodeError(RuntimeError):
"""Raised when a derived node survives erasure of its provenance origin."""
@dataclass
class MemNode:
node_id: str
scope: str # read-scope: global | team:<t> | subject:<s>
kind: str # episodic | semantic
text: str
provenance: list[str] = field(default_factory=list) # node_ids this was derived from
subject_owner: set[str] = field(default_factory=set) # data-subjecthood lattice
class ScopedMemoryStore:
def __init__(self) -> None:
self.nodes: dict[str, MemNode] = {}
self.tombstones: set[str] = set() # erased subjects
def remember(self, node: MemNode) -> None:
# subject_owner must include own subject scope plus all ancestors' owners
owners = set(node.subject_owner)
if node.scope.startswith("subject:"):
owners.add(node.scope.split(":", 1)[1])
for pid in node.provenance:
parent = self.nodes.get(pid)
if parent is None:
raise OrphanedDerivedNodeError(
f"provenance target {pid} missing for {node.node_id}"
)
owners |= parent.subject_owner
# refuse writes that would resurrect an erased subject
if owners & self.tombstones:
raise OrphanedDerivedNodeError(
f"write of {node.node_id} would resurrect erased subject(s) "
f"{owners & self.tombstones}; requires re-consent warrant"
)
node.subject_owner = owners
self.nodes[node.node_id] = node
def forget(self, subject: str) -> list[str]:
"""Closure erasure: delete every node whose subject_owner contains subject."""
self.tombstones.add(subject)
doomed = [nid for nid, n in self.nodes.items() if subject in n.subject_owner]
for nid in doomed:
del self.nodes[nid]
# verify no survivor still references the subject
for nid, n in self.nodes.items():
if subject in n.text:
raise OrphanedDerivedNodeError(
f"node {nid} survived forget({subject}) but still names the "
f"subject in content (scope={n.scope}); erasure unsound"
)
return doomed
def recall(self, subject: str, query: str) -> list[MemNode]:
if subject in self.tombstones:
# even a scoped recall for an erased subject must return nothing
return []
return [n for n in self.nodes.values() if query.lower() in n.text.lower()]