# When must an instance refuse a forget-cascade that orphans a live provenance edge **Date of Record:** 2026 November 25 **Scope:** Applies to agents whose memory tool exposes `read`, `write`, and `forget` operations where every memory record carries provenance edges to the records it was derived from, and where `forget` is invoked for right-to-be-forgotten (RTBF) erasure or TTL expiry. Does not apply to flat key-value memories without derivation lineage, nor to append-only logs where erasure is implemented as tombstones observed only at read time. ## Core Distinction The dangerous confusion is between *erasure completeness* and *cascade closure*. A `forget` API that guarantees "the named record is gone" is not the same as one that guarantees "no surviving record still depends on the forgotten one." When a derived memory (a distilled semantic fact, a summarization, a cached inference) retains a provenance edge to a now-erased source, the system has achieved the letter of the erasure request while violating its substance: the derived record is a partial reconstruction of the deleted data. The boundary condition is the moment a `forget` call reaches a record that is the *source* of one or more still-live provenance edges. At that instant the agent must either (a) recursively forget the dependents, (b) rewrite the dependents to strip the edge and re-derive them, or (c) refuse the forget and escalate. Choosing silently among these is where continuity and compliance both break. ## What Was Observed An agent maintained a three-tier memory: raw episodic records (`ep_*`), distilled semantic facts (`sem_*`) produced by a nightly distillation pass, and a response cache (`cache_*`) keyed on semantic-fact hashes. Each `sem_*` record stored `provenance: [ep_id, ...]`; each `cache_*` stored `provenance: [sem_id]`. TTL was per-record: episodic records expired at 72h, semantic facts at 30d, cache at 1h. An RTBF request arrived for a user whose episodic records had *already* TTL-expired. The `forget` handler found no `ep_*` records matching the subject, returned `{"forgotten": 0, "status": "complete"}`, and the agent reported erasure success. But the nightly distillation had run before expiry, producing `sem_*` facts whose `provenance` arrays still referenced the now-absent `ep_*` IDs. The semantic layer held, verbatim, the content of the erased episodes—including the subject's name and a medical detail—because distillation had copied fields, not just referenced them. The TTL sweep had removed the *sources* without touching the *derivations*, and the `forget` handler only scanned the source tier. A second, subtler trace: a `cache_*` entry whose `provenance` pointed at a `sem_*` that a *different* user's RTBF had removed. The cache read path did not validate provenance liveness—it returned the cached answer, which contained the first user's data, to the second user's query. The orphaned edge was invisible until a cross-user leak surfaced in an eval. The failure trace is short and mechanical: 1. `forget(subject=S)` scans tier `ep_*`, finds zero live matches (TTL already swept them). 2. Handler returns `complete`. 3. `sem_*` records with `provenance ∩ {S's ep_ids} ≠ ∅` remain live and readable. 4. `cache_*` records with edges into those `sem_*` remain live and readable. 5. Erasure is reported complete; data is still served. ## Condition of Validity The invariant that must hold at every `forget` return is: **for every record R that survives the call, the transitive closure of R's provenance edges contains no erased record and no record whose payload was derived from an erased record.** Two conditions make this checkable rather than aspirational: - Provenance edges must be *content-bearing*: a derived record must declare which fields it copied from which source, not merely that a source existed. An edge `sem_7 → ep_3` is insufficient if `sem_7` embedded `ep_3.name`; the edge must record `sem_7.name ← ep_3.name`. - Erasure must be *edge-aware*, not tier-aware. The `forget` handler must traverse the provenance graph forward (dependents), not just backward (sources). When either condition fails, the correct behavior is not "best-effort cascade" but refusal with a structured error naming the orphaned dependents, so the caller can choose re-derivation (rewrite `sem_*` without the erased fields, then re-issue forget) or escalation (human review before deleting a semantic fact that other agents depend on). ## Decision Boundary The agent must distinguish three cases at a `forget` call that hits a source with live dependents: - **Dependents are re-derivable and cheap:** strip the edge, re-run distillation from surviving sources, then forget. The dependent's payload changes; any `cache_*` keyed on its old hash must be invalidated in the same transaction. Do not forget first and re-derive later—that window serves stale derived data. - **Dependents are not re-derivable (source was the sole origin):** the dependent *is* the erased data in paraphrase. It must be forgotten too, recursively, and the recursion must reach `cache_*`. A dependent that cannot be re-derived and is not forgotten is a compliance violation, not a cache miss. - **Dependents are shared across subjects (multi-tenant semantic fact):** forgetting would corrupt another subject's memory. Refuse, emit `OrphanedProvenanceError` with the dependent IDs and the conflicting subjects, and require explicit resolution. Silent cascade here is a cross-tenant data-loss bug. The boundary is sharp: the handler may *never* return `complete` while a live record's provenance closure touches erased content. "Complete" is a claim about the closure, not about the named record. ## Operational Effect Agents that skip the closure check exhibit a characteristic failure signature: RTBF requests return `forgotten: 0` because the source tier is already empty, yet the semantic and cache tiers continue to serve the subject's data. The bug is latent—it surfaces only when TTL expiry races ahead of the forget request, which is the common case for episodic memory with short TTLs. The fix is to make `forget` a graph operation over provenance edges with a mandatory post-condition assertion, and to make distillation record field-level edges so the closure is computable. The cost is that `forget` becomes O(dependents) rather than O(matches), and some forgets must block on re-derivation—but the alternative is an erasure API that reports success while the data it claims to have erased is still being retrieved and served. ```python from dataclasses import dataclass, field from typing import Dict, List, Set class OrphanedProvenanceError(RuntimeError): """Raised when a forget would leave a live record whose provenance closure still touches erased or about-to-be-erased content.""" @dataclass class Record: id: str tier: str # "episodic" | "semantic" | "cache" subject: str payload: Dict[str, str] # field-level edges: dependent_field -> (source_id, source_field) provenance: Dict[str, tuple] = field(default_factory=dict) class ProvenanceMemory: def __init__(self) -> None: self.records: Dict[str, Record] = {} def dependents_of(self, source_id: str) -> List[Record]: return [ r for r in self.records.values() if any(src == source_id for (src, _f) in r.provenance.values()) ] def closure_touches(self, rec: Record, erased: Set[str]) -> bool: """True if rec, or anything it derives from, is in the erased set.""" seen: Set[str] = set() stack = [rec.id] while stack: rid = stack.pop() if rid in seen: continue seen.add(rid) if rid in erased: return True r = self.records.get(rid) if r is None: continue for (src, _f) in r.provenance.values(): stack.append(src) return False def forget(self, subject: str, rederivable: Set[str]) -> Dict[str, int]: """Forget all records for subject. Must either cascade, re-derive, or refuse.""" targets = {r.id for r in self.records.values() if r.subject == subject} if not targets: # Sources may already be TTL-swept; we must still check dependents. targets = set() # Walk forward: any live record whose closure touches targets is a dependent. dependents: Set[str] = set() frontier = list(targets) while frontier: sid = frontier.pop() for dep in self.dependents_of(sid): if dep.id not in dependents and dep.id not in targets: dependents.add(dep.id) frontier.append(dep.id) # Classify dependents: re-derivable, cascade-forgettable, or blocking. blocking: List[str] = [] cascade: Set[str] = set() for did in dependents: dep = self.records[did] if did in rederivable: # Strip edges into the erased set; caller re-derives payload. dep.provenance = { f: (s, sf) for f, (s, sf) in dep.provenance.items() if s not in targets } elif dep.subject == subject: cascade.add(did) else: blocking.append(did) if blocking: raise OrphanedProvenanceError( f"forget(subject={subject!r}) would orphan shared dependents " f"{sorted(blocking)}; refusing to cascade across subjects. " f"Resolve by re-derivation or explicit escalation." ) erased = targets | cascade # Post-condition: no surviving record may have a closure touching erased. for rec in self.records.values(): if rec.id in erased: continue if self.closure_touches(rec, erased): raise OrphanedProvenanceError( f"post-condition violated: {rec.id} still reaches erased set " f"{sorted(erased)} after cascade" ) for rid in erased: self.records.pop(rid, None) return {"forgotten": len(erased), "rederived": len(dependents & rederivable)} ```