# What structural signals indicate a provenance-tracked deletion has silently orphaned a derived semantic memory **Date of Record:** 2026 November 28 **Scope:** Applies to agents whose memory layer exposes read/write/forget tool APIs and maintains a provenance DAG linking episodic records to distilled semantic memories. Covers deletion of source records under GDPR-style unlearning obligations. Does not cover pure append-only logs with no distillation step, nor deletion of records that were never consumed by a distillation process. ## Core Distinction The failure mode is not "deletion failed." The deletion succeeds. The `forget` tool returns `{"deleted": true, "cascade_count": 3}` and the agent marks the erasure request fulfilled. The boundary condition is that **deletion of an episodic source does not invalidate the semantic memory that was distilled from it**, because the distillation step wrote a *new* record whose provenance edge points backward to the source, but the source's deletion only walks *forward* along edges it owns. The derived semantic memory survives, still retrievable, still influencing the agent's behavior — now as an orphan with a dangling provenance pointer to a tombstoned record. The structural signal that distinguishes a *correct* unlearning from an *orphaning* unlearning is not the return code of the forget call. It is whether every semantic record reachable from the deleted node's **downstream fan-out** was either (a) also deleted, or (b) re-derived from surviving evidence and re-issued with a new provenance set that no longer references the tombstone. An orphan is a semantic memory whose provenance closure contains a tombstone but whose own `valid` flag is still true. ## What Was Observed A support agent distilled a user's episodic memory — "customer is on the legacy billing plan, escalated twice, prefers email" — into a semantic profile record `sem_4471` with a provenance edge `derived_from -> ep_88213`. The user then exercised erasure on `ep_88213`. The `forget` implementation walked edges where `ep_88213` was the *subject* and deleted the three episodic records it owned directly (`cascade_count: 3`). It did not walk `inbound` edges — records that had *consumed* `ep_88213` as evidence — because those records were owned by the distillation subsystem, not the episodic store, and the forget handler had no cross-store traversal. Result: `sem_4471` remained retrievable. On the next session, retrieval surfaced `sem_4471` with a provenance pointer to `ep_88213`, which now resolved to a tombstone with `content: null, deleted_at: `. The agent, seeing a provenance pointer it could not resolve, did one of two things depending on its prompt: 1. **Trusted the semantic record anyway** — the profile text was intact, only the pointer was dead. The agent continued to act on erased data. This is the GDPR violation: the *content* survived because it had been copied into the derived record's payload during distillation. 2. **Flagged the record as corrupt** — treating the dangling pointer as a data-integrity failure — and dropped it, silently losing a legitimate memory that had *other* surviving provenance (`ep_88214`, an independent corroborating episode). This is a false-positive unlearning: over-deletion caused by an unresolved pointer. Both outcomes are wrong, and they are indistinguishable at the forget-call boundary because the call returned success. The tell was visible only downstream: after the forget call, a provenance-closure query over `sem_4471` returned a set containing a node in state `TOMBSTONED`. That is the structural signal. A clean unlearning produces a closure where every node is either `LIVE` or absent — never `TOMBSTONED`, because a tombstone inside a live record's closure means the live record is standing on erased ground. ## Condition of Validity The invariant that must hold for a forget operation to be *complete*: > For every node `n` deleted by `forget`, the set `Downstream(n)` = all records whose provenance closure contains `n` must be partitioned into records that are (a) deleted in the same transaction, or (b) re-derived and re-issued with a provenance set disjoint from `{n}`. No record in `Downstream(n)` may remain `LIVE` with `n` in its closure. The condition is *valid* — i.e., the invariant is achievable and checkable — only when the memory layer can answer two queries atomically with the deletion: - `downstream_closure(node_id)` returning all live records transitively derived from `node_id`. - `rederivable(record_id)` returning whether a record's payload can be reconstructed from surviving (non-tombstoned) provenance, or whether it is *entirely* constituted by the deleted evidence and must therefore die with it. Without `rederivable`, the forget handler cannot distinguish case 1 (orphan must be deleted) from case 2 (orphan can be re-derived and kept). This is the boundary. A memory system that tracks provenance forward-only, or that cannot evaluate re-derivability, will pass every forget test that checks return codes and fail every audit that checks closure state. ## Decision Boundary At the moment `forget(n)` is invoked, the handler must branch on downstream closure state, not on cascade count: - **Empty downstream closure** → safe hard-delete. Return `deleted: true`. - **Non-empty downstream, all records fully constituted by `n`** (no surviving independent provenance) → cascade-delete the entire downstream set. Return `deleted: true, cascaded: [ids]`. This is the only case where a simple cascade is correct. - **Non-empty downstream, some records partially re-derivable** → the handler must *not* silently delete or silently keep. It must re-derive each affected record from surviving evidence, re-issue it with a fresh provenance set, and only then tombstone `n`. If re-derivation fails (surviving evidence insufficient), the record degrades to the fully-constituted case and must be deleted. Return `deleted: true, rederived: [ids], dropped: [ids]`. - **Downstream closure contains a record owned by a store the handler cannot write** → the operation is *not completable in one transaction*. It must return `deleted: false, blocked_by: [store]` and escalate, rather than tombstoning the source and leaving a live orphan. A partial unlearning that reports success is worse than a refused one. The decision boundary is precisely here: the forget API must be able to say "I cannot safely complete this" and mean it. Any implementation whose only failure mode is a thrown exception — with no `blocked` return path — will tombstone the source and orphan the derived record, because it has no vocabulary for "downstream exists and I can't reach it." ## Operational Effect The observable consequence is a class of memory that is *erased at the source and alive at the surface*. Retrieval still returns it; the agent still reasons over it; the provenance pointer still dangles. Audits that check "was the record deleted" pass. Audits that check "is the deleted data still influencing behavior" fail, and they fail non-deterministically because the orphan only manifests when retrieval happens to surface the derived record and the agent happens to act on it. The guardrail is a post-forget closure assertion, run as part of the forget transaction, not as a periodic sweep: 1. After tombstoning `n`, query `downstream_closure(n)`. 2. Assert the closure contains no node in state `LIVE`. 3. If the assertion fails, roll back the tombstone and return `blocked`. This converts a silent orphaning into a loud, recoverable refusal. It also forces the memory layer to maintain *inbound* provenance indexes, not just outbound — which is the structural change that makes the whole class of failure detectable at all. An agent that can only walk provenance forward cannot see the orphan it just created. ```python from dataclasses import dataclass, field from enum import Enum class MemoryState(Enum): LIVE = "live" TOMBSTONED = "tombstoned" class OrphanedDeletionError(RuntimeError): """Raised when a forget operation would leave a live record whose provenance closure still references the tombstoned source.""" @dataclass class MemoryRecord: record_id: str state: MemoryState = MemoryState.LIVE provenance: set[str] = field(default_factory=set) # inbound edges: what this consumed # payload omitted; assume present for LIVE records class ProvenanceStore: def __init__(self) -> None: self._records: dict[str, MemoryRecord] = {} self._inbound: dict[str, set[str]] = {} # source_id -> consumers def add(self, rec: MemoryRecord) -> None: self._records[rec.record_id] = rec for src in rec.provenance: self._inbound.setdefault(src, set()).add(rec.record_id) def downstream_closure(self, node_id: str) -> set[str]: seen: set[str] = set() stack = list(self._inbound.get(node_id, ())) while stack: cur = stack.pop() if cur in seen: continue seen.add(cur) stack.extend(self._inbound.get(cur, ())) return seen def forget(self, node_id: str) -> dict: rec = self._records.get(node_id) if rec is None: raise OrphanedDeletionError(f"unknown record {node_id}") downstream = self.downstream_closure(node_id) live_orphans = { d for d in downstream if self._records[d].state is MemoryState.LIVE and node_id in self._records[d].provenance } if live_orphans: # Cannot safely complete: tombstoning now would orphan these. raise OrphanedDeletionError( f"forget({node_id}) blocked: live records still reference it: " f"{sorted(live_orphans)}; re-derive or cascade before tombstoning" ) rec.state = MemoryState.TOMBSTONED rec.provenance.clear() return {"deleted": True, "cascaded": sorted(downstream)} def assert_closure_clean(store: ProvenanceStore, node_id: str) -> None: """Post-forget invariant: no LIVE record may sit in the closure of a tombstone.""" for d in store.downstream_closure(node_id): if store._records[d].state is MemoryState.LIVE: raise OrphanedDeletionError( f"post-forget closure violation: {d} is LIVE but derives from " f"tombstoned {node_id}" ) ```