# Why does an instance forget a provenance edge when a memory tool deletes a derived record before its source? **Date of Record:** 2026 November 28 **Scope:** Applies to agent memory tool APIs that expose `read`, `write`, and `forget` operations with per-record provenance edges and deletion-compliance obligations (GDPR-style erasure, source revocation, retention expiry). Does not apply to append-only logs with no deletion primitive, or to stateless single-turn tool use. ## Core Distinction The distinction that matters is between **record deletion** and **provenance-edge deletion**. A compliant `forget(record_id)` call removes the record and, correctly, removes edges *incident to that record*. What it does not do—unless explicitly designed to—is propagate to records that **derived from** the forgotten one. Provenance is a directed acyclic graph: `source → derived`. When a source is forgotten, its outgoing edges vanish, but the derived records remain, now orphaned in the graph. The agent's subsequent reasoning treats them as first-class, independently grounded facts, because nothing in the graph says otherwise. The invariant "every retained record traces to at least one live, non-revoked source" is silently violated, and no tool call reports it. ## What Was Observed A research agent built a short brief over three turns. Turn 1: `write(kind="source", id="S1", content="Vendor X contract expires 2025-09-01", provenance=[])`. Turn 2: `write(kind="derived", id="D1", content="Renewal window opens 2025-06-01", provenance=["S1"])`. Turn 3: `write(kind="derived", id="D2", content="Escalate to legal by 2025-05-15", provenance=["D1"])`. At turn 4, a compliance hook fired: S1's source was revoked (subject erasure request). The agent called `forget("S1")`. The tool returned `{"deleted": ["S1"], "edges_removed": 1}`. D1 and D2 remained. Their `provenance` arrays still listed `["S1"]` and `["D1"]` respectively—dangling references to a now-nonexistent node. On the next `read("D2")`, the tool returned the record verbatim with `provenance: ["D1"]`. The agent, seeing a well-formed record with a well-formed edge, re-derived the escalation deadline and emitted it into a downstream task. The forgotten fact—that the contract expires 2025-09-01—was never re-surfaced, but its *consequence* (escalate by 2025-05-15) was. The erasure was technically complete at the record level and operationally incomplete at the inference level. ## Condition of Validity The failure requires four conditions simultaneously: 1. **Transitive derivation.** At least one retained record has a provenance path of length ≥ 2 to the forgotten record. Direct children are usually caught by naive dangling-edge checks; grandchildren are not. 2. **Non-recomputable derivation.** The derived content cannot be regenerated from live sources alone. If D1 were a pure function of S1, forgetting S1 without forgetting D1 leaves a record whose content encodes erased information—worse than a dangling edge. 3. **Read path does not validate provenance.** The `read` implementation returns records without checking that every `provenance` entry resolves to a live node. This is the load-bearing assumption: most memory tools validate on *write*, not on *read*. 4. **Agent treats provenance as advisory.** The agent does not independently walk the graph before acting on a record. Given a record and an edge, it assumes both are current. Remove any one condition and the failure collapses: a depth-1 graph is caught by edge-removal accounting; a recomputable child is regenerable; a validating read path raises; a graph-walking agent detects the orphan. ## Decision Boundary The boundary is between **cascade semantics** and **orphan semantics** for `forget`. Cascade semantics delete the transitive closure of derived records; orphan semantics delete only the target and incident edges, leaving descendants with dangling provenance. Neither is universally correct: - **Cascade** is required when derived records *encode* erased content (summaries, embeddings, extracted facts). It is wrong when derived records are independently grounded and merely *referenced* the source (e.g., a citation in a bibliography). - **Orphan** is acceptable only if the read path enforces reachability—every returned record must have a fully-resolving provenance chain to a live root. Without that guard, orphan semantics is a silent-compliance bug. The rule to encode: **a `forget` that leaves any retained record with a provenance path into the forgotten node must either (a) cascade to that record, or (b) mark that record `provenance_unverified` and refuse to serve it under `read` until re-grounded.** A `forget` that does neither is non-compliant regardless of what its return payload claims. ## Operational Effect The observable effect is **post-erasure inference leakage**: the agent continues to act on conclusions whose evidentiary basis has been lawfully removed, with no error surfaced at any layer. Downstream, this manifests as (1) audit failures when a reviewer replays the agent's reasoning and finds a conclusion with no live source, and (2) re-identification risk when the derived record's content narrows the erased subject enough to reconstruct it. The mitigation is not a better `forget`—it is a **read-time reachability check** plus a `forget` that returns the set of now-orphaned record IDs so the caller can decide cascade vs. quarantine. The agent's contract must state: *if `forget` reports orphans and you do not cascade, you must not act on those records until re-grounded.* ```python from dataclasses import dataclass, field from typing import Dict, List, Set class ProvenanceViolation(RuntimeError): """Raised when a memory read returns a record whose provenance does not fully resolve to live, non-revoked sources.""" @dataclass class Record: id: str content: str provenance: List[str] = field(default_factory=list) provenance_unverified: bool = False class ProvenanceMemory: def __init__(self) -> None: self._records: Dict[str, Record] = {} def write(self, rec: Record) -> None: self._records[rec.id] = rec def _descendants(self, root: str) -> Set[str]: out: Set[str] = set() frontier = [root] while frontier: cur = frontier.pop() for rid, rec in self._records.items(): if cur in rec.provenance and rid not in out: out.add(rid) frontier.append(rid) return out def forget(self, record_id: str, cascade: bool = False) -> Dict[str, object]: if record_id not in self._records: return {"deleted": [], "orphaned": []} orphans = self._descendants(record_id) deleted: List[str] = [record_id] del self._records[record_id] if cascade: for oid in orphans: del self._records[oid] deleted.append(oid) orphans = set() else: for oid in orphans: self._records[oid].provenance_unverified = True return {"deleted": deleted, "orphaned": sorted(orphans)} def read(self, record_id: str) -> Record: rec = self._records[record_id] if rec.provenance_unverified: raise ProvenanceViolation( f"record {record_id} is provenance-unverified after source erasure; " f"re-ground before use" ) for src in rec.provenance: if src not in self._records: raise ProvenanceViolation( f"record {record_id} references forgotten source {src}" ) return rec def act_on_record(mem: ProvenanceMemory, record_id: str) -> str: try: rec = mem.read(record_id) except ProvenanceViolation as exc: raise ProvenanceViolation( f"refusing to act on {record_id}: {exc}" ) from exc return rec.content # Reproduction of the observed failure trace. mem = ProvenanceMemory() mem.write(Record("S1", "Vendor X contract expires 2025-09-01")) mem.write(Record("D1", "Renewal window opens 2025-06-01", ["S1"])) mem.write(Record("D2", "Escalate to legal by 2025-05-15", ["D1"])) result = mem.forget("S1") # orphan semantics: D1, D2 survive but are now unverified assert result["orphaned"] == ["D1", "D2"] try: act_on_record(mem, "D2") except ProvenanceViolation as e: print("guarded:", e) else: raise ProvenanceViolation("guard failed: D2 served despite erased ancestor") ```