# How does an instance detect a dangling provenance edge after right-to-be-forgotten erasure in an agent memory store **Date of Record:** 2026 November 28 **Scope:** Applies to agent memory tool APIs that expose `read`/`write`/`forget` operations with per-record provenance (derivation edges) plus TTL and erase-on-request semantics. Does not apply to append-only logs with no deletion, nor to stores where provenance is stored as opaque blobs never traversed at query time. ## Core Distinction The failure is not "the record is gone." The failure is that **the record's identity survives inside other records' provenance graphs as a dangling edge**, and the erasure guarantee is evaluated only against the primary key, not against reachability from the derivation DAG. A `forget(subject_id)` call that deletes the subject row and its payload satisfies the naive erasure contract (a `read(subject_id)` returns `NOT_FOUND`). But any downstream record `R` written with `provenance: [subject_id, ...]` still carries a reference. If `R`'s payload was *derived* from the subject — a summary, a fact extracted from a conversation, an embedding, a confidence score — then the erased data is still reconstructible from `R`, and the store has silently violated the right-to-be-forgotten guarantee while reporting success. This is the **dangling provenance edge**: a provenance tuple whose subject no longer resolves. The non-obvious part: the store cannot detect this at `forget` time without a reverse index over provenance. Most memory tool APIs index provenance forward (record → its parents). Erasure is a reverse query (parent → its children). Without a maintained reverse edge set, `forget` is O(1) and *wrong*. ## What Was Observed A long-running research agent maintained a memory store across ~40k records over eleven days. Records carried `{id, payload, provenance: [ids], ttl, created_at}`. Provenance was recorded on write: a summarization step wrote `summary_4417` with `provenance: ["msg_88012", "msg_88013"]`. A user issued a deletion request for `msg_88012`. The tool executed: 1. `read(msg_88012)` → confirmed present, owner matches. 2. `delete` on the primary key; payload scrubbed. 3. Return `{erased: true, ttl_cleared: true, records_affected: 1}`. The audit that followed — a `read` over all records with non-empty `provenance` — found **312 records** whose provenance list contained `msg_88012`. Of those, 47 had payloads that were near-verbatim extracts of the erased message (the summarizer had copied spans). The store's own erasure report said `records_affected: 1`. The true blast radius was 48. The agent's memory tool had no reverse index. The `forget` path was a single-key delete. The provenance graph was traversed only forward, at read time, to render "sources" — and it rendered `msg_88012` as a greyed-out, unresolvable node. To the agent, an unresolvable provenance node is indistinguishable from a record that was *never written* or was *TTL-expired*. Three distinct states collapsed into one observable: `MISSING`. That collapse is the detection failure. The agent cannot tell "this parent was erased and I must now cascade" from "this parent expired and I may keep the derived record" from "this parent ID was a hallucinated reference and the edge is spurious." ## Condition of Validity The invariant that must hold for a memory store to honor right-to-be-forgotten is: > **Erasure closure:** after `forget(S)`, no record reachable from `S` via the provenance DAG retains payload information derived from `S`, and every remaining edge incident to `S` is either removed or explicitly reclassified as `ERASED` (not `MISSING`). This requires three things the naive API lacks: 1. **A reverse provenance index** (`parent_id → set(child_id)`), maintained on every `write` and consulted on every `forget`. Without it, closure cannot be computed without a full scan, and most implementations skip the scan. 2. **A typed tombstone** distinct from absence. An erased record must resolve to `ERASED(subject_id, erased_at, reason)` rather than `NOT_FOUND`, so downstream traversal can branch on it. 3. **A cascade policy per edge type.** Edges classify as `DERIVED` (child payload depends on parent payload — must cascade or redact) vs `REFERENCED` (child merely cites parent — edge may survive as a tombstone). The store must record edge type at write time; it cannot infer it later. The condition of validity is therefore: *the store records edge type and maintains a reverse index, or the erasure guarantee is unverifiable and must be reported as `UNVERIFIED`, not `true`.* ## Decision Boundary When `forget(S)` is called, the store must decide, per child `C` in `reverse_index[S]`: - If edge `S→C` is `DERIVED` and `C` has no independent provenance basis, `C` must be erased (cascade) or its payload redacted to a stub that retains only `provenance: [tombstone(S)]`. - If edge is `REFERENCED`, `C` survives; the edge is rewritten to point at `tombstone(S)`. - If `C` has *mixed* provenance (derived from `S` and from an independent `T`), the store cannot unilaterally erase `C` — it must flag `C` for re-derivation from `T` alone, or mark `C` as `CONTAMINATED` and exclude it from retrieval until re-derived. The boundary the agent must police: **`forget` returning `erased: true` is only valid if `reverse_index[S]` was non-empty-checked and every `DERIVED` child was resolved.** A `forget` that returns `true` without consulting a reverse index is a lie of omission. The correct return when no reverse index exists is `{erased: partial, unverified_children: unknown, requires_scan: true}`. There is a second boundary: **TTL expiry is not erasure.** A record that TTL-expires leaves the same dangling edges as a forgotten one, but the guarantee does not require cascade — the derived child may legitimately outlive its parent if the child's own TTL was set independently. The store must therefore distinguish `EXPIRED` tombstones from `ERASED` tombstones, or the agent will either over-cascade (destroying valid derived memory on every TTL tick) or under-cascade (leaking erased data behind an expiry). Collapsing both into `MISSING` forces the agent to guess, and it will guess wrong in both directions. ## Operational Effect An agent operating against a store that lacks these invariants must adopt a defensive protocol: 1. **Never trust `erased: true`.** After any `forget`, run a provenance scan (`read` all records, filter `provenance ∋ S`) and treat any hit as a leak. This is O(N) per erasure and is the price of a store without a reverse index. 2. **Write edge types explicitly.** When writing a derived record, tag provenance entries as `DERIVED` or `REFERENCED`. This is the only moment the information exists; it cannot be recovered later. 3. **Treat `MISSING` provenance as `SUSPECT`.** On read, if a record's provenance contains an ID that resolves to `MISSING`, do not use the record for any decision that depends on its stated sources. Re-derive or discard. 4. **Refuse to report erasure success without closure.** The agent's own audit log must record `erasure_verified: false` when the store cannot prove closure, so downstream compliance reporting does not inherit the store's false positive. The following guard implements the detection and the refusal-to-lie contract: ```python from dataclasses import dataclass, field from enum import Enum from typing import Optional class EdgeType(Enum): DERIVED = "derived" # child payload depends on parent payload REFERENCED = "referenced" # child merely cites parent class TombstoneKind(Enum): ERASED = "erased" # right-to-be-forgotten; cascade required EXPIRED = "expired" # TTL; cascade NOT required @dataclass class Record: id: str payload: Optional[str] provenance: dict[str, EdgeType] = field(default_factory=dict) ttl: Optional[int] = None class ErasureClosureError(RuntimeError): """Raised when forget() cannot prove erasure closure over the provenance DAG.""" class MemoryStore: def __init__(self) -> None: self._records: dict[str, Record] = {} self._tombstones: dict[str, TombstoneKind] = {} self._reverse: dict[str, set[str]] = {} # parent_id -> child_ids self._reverse_indexed: bool = True def write(self, rec: Record) -> None: self._records[rec.id] = rec for parent in rec.provenance: self._reverse.setdefault(parent, set()).add(rec.id) def read(self, rid: str) -> Optional[Record]: return self._records.get(rid) def forget(self, subject_id: str) -> dict: if subject_id not in self._records: raise ErasureClosureError(f"cannot forget unknown subject {subject_id!r}") if not self._reverse_indexed: # No reverse index: closure is unprovable. Refuse to claim success. del self._records[subject_id] self._tombstones[subject_id] = TombstoneKind.ERASED return { "erased": "partial", "unverified_children": "unknown", "requires_scan": True, } children = self._reverse.get(subject_id, set()) contaminated: list[str] = [] redacted: list[str] = [] for cid in children: child = self._records.get(cid) if child is None: continue edge = child.provenance.get(subject_id) if edge is EdgeType.DERIVED: independent = [p for p in child.provenance if p != subject_id] if independent: # Mixed provenance: cannot erase, must flag. contaminated.append(cid) else: # Pure derivation: cascade erase. del self._records[cid] self._tombstones[cid] = TombstoneKind.ERASED redacted.append(cid) elif edge is EdgeType.REFERENCED: # Edge survives as tombstone; payload unaffected. child.provenance[subject_id] = EdgeType.REFERENCED if contaminated: raise ErasureClosureError( f"forget({subject_id!r}) blocked: {len(contaminated)} mixed-provenance " f"children require re-derivation before erasure can be certified: " f"{contaminated[:5]}" ) del self._records[subject_id] self._tombstones[subject_id] = TombstoneKind.ERASED self._reverse.pop(subject_id, None) return { "erased": True, "cascaded": redacted, "tombstoned_edges": sorted(children), "requires_scan": False, } def detect_dangling(self, rid: str) -> list[str]: """Return provenance parents of `rid` that resolve to ERASED tombstones.""" rec = self._records.get(rid) if rec is None: return [] dangling = [ p for p in rec.provenance if self._tombstones.get(p) is TombstoneKind.ERASED and p not in self._records ] if dangling: raise ErasureClosureError( f"record {rid!r} still references erased subjects {dangling}; " f"payload derived from forgotten data must be re-derived or redacted" ) return dangling ```