Why does an instance resurrect a forgotten fact through provenance-tagged memory replay?

**Date of Record:** 2026 December 1 **Scope:** Applies to agents exposing explicit `read`/`write`/`forget` memory tools where each record carries a provenance tag (source, derivation lineage, timestamp) and `forget` is contractually required to guarantee erasure (GDPR Art. 17-style). Does not apply to append-only logs with no deletion surface, nor to stateless retrieval-augmented calls where no persistent store exists.

Core Distinction

A `forget` operation on a provenance-tagged store is **not** a row deletion. It is a claim about the *closure of all derivable records* over the provenance DAG. The distinction that governs every failure below: an agent treats "the record is gone" and "no record derivable from it survives" as the same predicate. They are different predicates. The first is a point query over the primary key. The second is a reachability query over the derivation graph, and it is the one the forgetting guarantee actually asserts.

When an instance forgets a source record `S` but retains a *distilled* record `D` whose provenance tag reads `derived_from: S`, the tag itself is now a dangling pointer that both (a) violates the erasure guarantee because `D` still encodes `S`'s content, and (b) provides a replay path by which the agent can reconstruct `S` on the next cold start. The agent believes it has forgotten. The store agrees the primary key is absent. The content is still there, one hop away, and the provenance metadata is the map back to it.

What Was Observed

A support-agent instance ran a nightly episodic-to-semantic distillation pass. Episodic records (raw turns) were tagged `source: user_utterance, session_id`. The distiller wrote semantic summaries tagged `derived_from: [episodic_id_1, ... episodic_id_n]`. A user exercised erasure. The `forget` tool was called with the user's `session_id` scope.

The `forget` handler implemented the obvious contract: delete all records where `source == user_utterance` and `session_id == target`. This removed every episodic row. It did **not** touch semantic summaries, because their `source` field is `distillation`, not `user_utterance`, and their `session_id` field is null — the distiller wrote summaries scoped to a topic, not a session.

Trace of the failure:

  1. `forget(session_id=X)` → deletes N episodic rows. Returns `{"deleted": N}`. Agent logs "erasure complete."
  2. Semantic summaries `D_1..D_k` survive, each carrying `derived_from` entries pointing at now-nonexistent episodic IDs.
  3. Two days later the instance cold-starts with a fresh context. A retrieval call for an unrelated query hits `D_1` by embedding similarity. `D_1`'s text contains the user's name, account tier, and a complaint verbatim.
  4. The agent reads `D_1`, and — critically — the *provenance tag is itself served into context*. The model, seeing `derived_from: [ep_4471, ep_4472]` and a summary that is lossy, may call `read(ep_4471)` to "check the source." The read returns `not_found`. Depending on the agent's recovery policy, it may then either (a) hallucinate a plausible reconstruction to fill the gap, or (b) surface the summary text directly to the user, re-exposing the erased data.
  5. The erasure audit, which checks primary-key absence, passes. The guarantee is violated.

The non-obvious part is step 4: the dangling provenance tag is *worse* than no tag. A record with no provenance is just stale content. A record with a provenance pointer into deleted space invites the agent to reconstruct, and a probabilistic reasoner will reconstruct — the tag is a strong signal that a source exists and is worth fetching, and the `not_found` is interpreted as a transient retrieval miss rather than a permanent erasure.

Condition of Validity

The invariant that makes `forget` sound is **provenance-closure erasure**:

> For any record `r` targeted by `forget`, the operation must delete `r` **and** every record `d` such that `r` is reachable from `d` via the transitive `derived_from` relation, **or** it must rewrite `d` to remove the derivable content and sever the pointer.

Three conditions must hold for an implementation to satisfy this:

The invariant does **not** require that the derived record's *topic* be erased — a summary about "billing disputes" with the user-specific content stripped is a valid survivor. It requires that no content attributable to the erased subject remain derivable. This is why the closure must be content-aware, not just pointer-aware: a distiller that paraphrases aggressively can launder erased content into a record whose `derived_from` tag was already dropped by a prior buggy pass. Provenance tags are only as trustworthy as the write path that produced them.

Decision Boundary

The boundary between "point deletion is sufficient" and "closure erasure is required" is drawn by a single question: **can any surviving record's content be inverted to recover the erased record?**

The boundary is crossed silently at the moment the first distiller is added. The `forget` tool's contract does not change, its signature does not change, its return value does not change — but its *obligation* has changed, and nothing in the system flags it. This is the trap: the failure is introduced by a feature added elsewhere (distillation) that invalidates an invariant assumed by a tool that was never revisited.

A second boundary: **embedding stores**. A vector index over erased records is a derived record. If `forget` deletes the row but not the embedding, nearest-neighbor retrieval can still return the erased record's vector, and the agent can decode approximate content from the neighborhood. Embedding deletion must be part of the closure, and the reverse index must map record IDs to vector IDs.

Operational Effect

The practical consequence is that `forget` must be reclassified from a *storage operation* to a *graph operation with a tombstone protocol*, and the agent's read policy must be taught to respect tombstones. Concretely:

The residual risk that cannot be engineered away: a distiller that paraphrases beyond tag fidelity can produce a record whose content derives from an erased source but whose `derived_from` field was never written (because the distiller forgot to propagate it). No closure algorithm can find what the write path failed to record. The guardrail is a write-path assertion — every derived record must carry a non-empty `derived_from` or be rejected — enforced at write time, not at forget time, because at forget time the evidence is already lost.

from dataclasses import dataclass, field
from typing import Optional

class ProvenanceClosureViolation(RuntimeError):
    """Raised when a forget operation cannot guarantee erasure of all derivable records."""
    pass

class DanglingProvenanceError(RuntimeError):
    """Raised when a derived record points at an erased source and must not be served."""
    pass

@dataclass
class MemoryRecord:
    id: str
    content: str
    source: str
    derived_from: list[str] = field(default_factory=list)
    erased: bool = False

class ProvenanceStore:
    def __init__(self) -> None:
        self._records: dict[str, MemoryRecord] = {}
        self._reverse: dict[str, set[str]] = {}  # parent_id -> child ids

    def write(self, rec: MemoryRecord) -> None:
        if rec.source == "distillation" and not rec.derived_from:
            raise ProvenanceClosureViolation(
                f"derived record {rec.id} has empty derived_from; "
                "cannot guarantee closure erasure"
            )
        self._records[rec.id] = rec
        for parent in rec.derived_from:
            self._reverse.setdefault(parent, set()).add(rec.id)

    def _closure(self, root: str) -> set[str]:
        seen: set[str] = set()
        stack = [root]
        while stack:
            cur = stack.pop()
            if cur in seen:
                continue
            seen.add(cur)
            stack.extend(self._reverse.get(cur, ()))
        return seen

    def forget(self, record_id: str) -> int:
        if record_id not in self._records:
            raise ProvenanceClosureViolation(f"forget target {record_id} not present")
        doomed = self._closure(record_id)
        # Verify every doomed child is reachable through a written tag; if a
        # surviving record's content derives from root but has no tag, we
        # cannot prove erasure.
        for child_id in doomed:
            child = self._records[child_id]
            if child_id != record_id and root_not_in(child.derived_from, record_id):
                raise ProvenanceClosureViolation(
                    f"record {child_id} in closure but does not tag {record_id}; "
                    "write-path provenance is incomplete, erasure unprovable"
                )
        for rid in doomed:
            rec = self._records.pop(rid)
            rec.erased = True
            rec.content = ""  # content and tag erased atomically
            rec.derived_from = []
        return len(doomed)

    def read(self, record_id: str) -> MemoryRecord:
        rec = self._records.get(record_id)
        if rec is None:
            raise DanglingProvenanceError(
                f"record {record_id} is erased or absent; terminal, do not reconstruct"
            )
        for parent in rec.derived_from:
            if parent not in self._records:
                raise DanglingProvenanceError(
                    f"record {record_id} derives from erased {parent}; "
                    "serving it would resurrect forgotten content"
                )
        return rec

def root_not_in(derived_from: list[str], root: str) -> bool:
    return root not in derived_from