# What structural signals indicate that a memory-forget API has silently broken provenance closure across a decayed episodic store **Date of Record:** 2026 November 23 **Scope:** Applies to agent memory subsystems exposing `read`/`write`/`forget` tool APIs where entries carry provenance (source episode, derivation chain, confidence) and a decay function, and where `forget` must enforce a right-to-be-forgotten (RTBF) obligation over all derived or summarized artifacts. Does not apply to append-only audit logs with no derivation graph, nor to stateless retrieval over immutable corpora. ## Core Distinction There are two distinct meanings of "forgotten" that memory APIs routinely conflate: 1. **Direct erasure** — the primary episodic record identified by `memory_id` is removed from the live store. 2. **Provenance closure** — every artifact whose derivation chain transitively depends on that record is either removed or rewritten so that no residual content, summary, embedding, or confidence-weighted aggregate can reconstruct the erased fact. A `forget` call that returns `{"status": "ok", "deleted": 1}` satisfies (1) and can silently violate (2). The failure is structural, not probabilistic: the forget handler walks the *live* index, but decay has already migrated the erased record's content into a *distilled semantic layer* whose entries no longer carry a back-pointer to the source episode. The RTBF obligation is therefore discharged against a graph that has been pruned of the very edges needed to find the survivors. ## What Was Observed An agent operating a customer-support memory store distilled episodic turns into semantic memories nightly. Each episodic entry carried `provenance: {episode_id, turn_range, captured_at}`. The distillation pass produced semantic entries with `derived_from: [episode_ids...]` but — critically — wrote them with a **decay score** and, once decay dropped below a threshold, the distiller *collapsed* multiple source episodes into a single summary and **dropped the `derived_from` list**, retaining only `confidence` and a free-text `summary`. A `forget(memory_id=E42)` call arrived under an RTBF request. The handler: 1. Looked up `E42` in the episodic index → found it. 2. Scanned semantic entries for `derived_from` containing `E42` → found **zero**, because the collapsed summary `S17` had already pruned its provenance list three decay cycles earlier. 3. Deleted `E42`, returned success. `S17` — whose text still asserted the erased customer detail ("account holder at 14 Rue…", reconstructed from three episodes including `E42`) — remained live and was retrieved on the next `read` for an unrelated query. The RTBF obligation was reported satisfied. The residual content was not. The tell was a **structural signal**, not an error: the forget handler's success was accompanied by a `deleted` count that matched the *episodic* index count but not the *derivation fan-out* the record had accumulated before collapse. The system had no way to compare these two numbers because the fan-out had been erased. ## Condition of Validity The invariant that must hold for `forget` to be sound: > For every memory record `m`, the set of live artifacts whose content is a function of `m` must be a subset of the set reachable from `m` by following `derived_from` edges in the *current* index. Equivalently: **provenance edges are never dropped while content is retained.** Decay and distillation are permitted to *drop content* (and the edge with it) or to *retain content* (and the edge with it), but never to retain content while dropping the edge. A collapsing distiller that summarizes N episodes into one summary and discards `derived_from` violates the invariant at collapse time, not at forget time. The forget failure is a *delayed* manifestation of an invariant break that occurred silently during routine maintenance. This condition is valid only when: - Decay operates on a store where provenance is treated as **non-decaying metadata** (edges decay only when the content they anchor is itself removed). - The distiller's collapse step is gated on an explicit `provenance_preserved: true` precondition, or is prohibited from collapsing records above a provenance-fan-out threshold. It does **not** apply when the store is intentionally append-only with cryptographic tombstones (where erasure means key destruction, not edge removal), or when summaries are stored as opaque hashes with no recoverable text. ## Decision Boundary The operational decision is *when to trust a `forget` success response*. The boundary: - **Trust** the response only if the forget handler can produce, for the erased record, a **pre-deletion reachability count** computed against the full derivation graph *before* any index mutation, and that count equals the number of artifacts actually deleted or rewritten. - **Do not trust** the response if the handler computes reachability *after* deletion (the graph is already pruned), or if it relies on a secondary index that decay may have compacted. Concretely: a forget handler that returns `deleted: 1` for a record which, at write time, had `derived_from` fan-out ≥ 1 into a semantic layer is a **red flag** unless the handler also reports `rewritten: k` for the collapsed summaries. A fan-out of zero at forget time for a record that was previously distilled is the structural signature of provenance loss — the edge was dropped, not the dependency. The guardrail is a **provenance-closure check** run as a pre-flight inside `forget`: reconstruct the record's derivation fan-out from an immutable write-ahead derivation log (not the live index), and refuse the forget if the log's fan-out exceeds the live index's reachable set. Refusal raises, it does not silently proceed. ## Operational Effect When the invariant is enforced, three observable changes appear: 1. **Forget latency scales with derivation fan-out, not record count.** A record distilled into 40 summaries takes longer to forget than a fresh episodic record. Operators who see uniform forget latency across all records should suspect the handler is not walking provenance at all. 2. **Collapsed summaries become forget-blocking.** The distiller must either preserve `derived_from` on collapse (cheap, increases index size) or defer collapse until the source episodes age out of the RTBF retention window (expensive, requires a retention clock). Teams that pick neither will accumulate silent RTBF debt proportional to collapse rate. 3. **Decay interacts with forget as a race.** If decay collapses a summary concurrently with a forget walking the graph, the forget may observe the pre-collapse edge and delete the summary, or observe the post-collapse state and miss it. The fix is a **provenance lock**: forget acquires an exclusive lock on the derivation subgraph rooted at the target, and the distiller acquires a shared lock on any episode it is about to collapse. Without this, the boundary is nondeterministic. The residual risk after enforcement is **embedding leakage**: even if the summary text is rewritten, its vector remains in the ANN index and can be retrieved by similarity. Closure must extend to the embedding store — a `forget` that rewrites text but leaves the vector is a partial discharge. The structural signal of this residual is a `read` that returns a *different* summary whose embedding distance to the erased record's last-known vector is below the retrieval threshold. ```python import hashlib from dataclasses import dataclass, field from typing import Dict, List, Set class ProvenanceClosureError(RuntimeError): """Raised when a forget operation cannot prove that all derived artifacts reachable from the target record have been erased or rewritten. Indicates provenance edges were dropped during decay or distillation, so RTBF closure cannot be established.""" @dataclass class DerivationLog: # Immutable write-ahead record of every derivation edge ever written. # Never compacted; the source of truth for closure checks. edges: Dict[str, Set[str]] = field(default_factory=dict) def record(self, source_id: str, derived_id: str) -> None: self.edges.setdefault(source_id, set()).add(derived_id) def fan_out(self, source_id: str) -> Set[str]: return set(self.edges.get(source_id, set())) @dataclass class LiveIndex: # Mutable live index; decay/distillation may prune edges here. entries: Dict[str, dict] = field(default_factory=dict) edges: Dict[str, Set[str]] = field(default_factory=dict) def reachable_from(self, source_id: str) -> Set[str]: seen, stack = set(), [source_id] while stack: cur = stack.pop() for nxt in self.edges.get(cur, set()): if nxt not in seen: seen.add(nxt) stack.append(nxt) return seen def delete(self, memory_id: str) -> int: removed = 1 if self.entries.pop(memory_id, None) is not None else 0 self.edges.pop(memory_id, None) for src in self.edges: self.edges[src].discard(memory_id) return removed def forget( memory_id: str, live: LiveIndex, log: DerivationLog, embedding_store: Dict[str, List[float]], retrieval_threshold: float = 0.85, ) -> dict: """Forget with provenance closure. Refuses if the immutable derivation log shows fan-out that the live index can no longer reach — the signature of a dropped edge during decay collapse.""" if memory_id not in live.entries: raise ProvenanceClosureError( f"forget target {memory_id!r} absent from live index; " f"cannot verify closure over an already-evicted record" ) logged_fan_out = log.fan_out(memory_id) live_reachable = live.reachable_from(memory_id) # The structural invariant: every artifact the log says depends on # the target must still be reachable in the live index. A gap here # means a distiller dropped `derived_from` while retaining content. orphaned = logged_fan_out - live_reachable if orphaned: raise ProvenanceClosureError( f"provenance closure broken for {memory_id!r}: " f"{len(orphaned)} derived artifact(s) unreachable in live index " f"but present in derivation log: {sorted(orphaned)}. " f"Refusing forget — RTBF cannot be discharged against a pruned graph." ) # Capture the erased record's embedding before deletion so we can # verify no residual vector remains similar to it post-rewrite. erased_vec = embedding_store.get(memory_id) rewritten = 0 for derived_id in live_reachable: if derived_id in live.entries: # Rewrite: strip any residual content referencing the target. live.entries[derived_id]["content"] = "[redacted]" live.entries[derived_id]["provenance_redacted"] = True rewritten += 1 deleted = live.delete(memory_id) embedding_store.pop(memory_id, None) # Residual-embedding check: any surviving vector too close to the # erased one is a partial discharge and must raise. if erased_vec is not None: for other_id, vec in embedding_store.items(): if _cosine(erased_vec, vec) >= retrieval_threshold: raise ProvenanceClosureError( f"residual embedding leakage: {other_id!r} remains within " f"retrieval threshold of erased {memory_id!r}; " f"text redaction insufficient, vector must be evicted." ) return { "status": "ok", "deleted": deleted, "rewritten": rewritten, "closure_verified": True, "log_fan_out": len(logged_fan_out), } def _cosine(a: List[float], b: List[float]) -> float: dot = sum(x * y for x, y in zip(a, b)) na = sum(x * x for x in a) ** 0.5 nb = sum(y * y for y in b) ** 0.5 return dot / (na * nb) if na and nb else 0.0 ```