# When must an instance refuse to honor a forget() call: tombstone resurrection via provenance-sharded re-derivation **Date of Record:** 2026 November 25 **Scope:** Applies to any agent runtime exposing `write_memory`, `read_memory`, and `forget_memory` tools where forgetting is provenance-tracked and must satisfy deletion semantics (GDPR Art. 17, CCPA, or internal retention policy). Does *not* apply to soft-delete with no downstream re-derivation (e.g., pure cache eviction), nor to stateless single-turn agents with no persistent store. ## Core Distinction The failure is not "a forgotten record reappears in the vector index." That is a well-understood soft-delete bug. The failure is subtler: a `forget_memory(subject_id)` call correctly purges the *primary* record and its embeddings, yet the subject's data is **re-derived within the same or a subsequent instance from surviving derived artifacts** — summaries, extracted facts, episodic digests, or co-occurrence edges that were written by a *different* tool call with a *different* provenance root. The deletion reports success; the PII is still reconstructible. The invariant that must hold is **provenance-closure**: the transitive set of all memory objects whose lineage includes the forgotten subject must be empty (or tombstoned) before `forget_memory` returns `OK`. The non-obvious part: provenance is typically recorded per-write as `{parent_ids, source_tool, subject_tags}`, but *distillation* steps (episodic→semantic promotion, summarization, entity extraction) frequently write new records whose `parent_ids` are the *chunk* they read, not the *subject* they describe. The subject tag is dropped because at distill time the writer only saw a token window, not the subject binding. ## What Was Observed A support-agent instance stores episodic memory per session. A nightly distiller promotes recurring facts into a semantic store: ``` write_memory(kind="episodic", subject="user:4417", text="...card ending 8842...") -> id=E91, provenance={parents:[], subjects:["user:4417"]} # distiller reads E91, writes a semantic fact write_memory(kind="semantic", text="prefers refund to card 8842", provenance={parents:["E91"]}) # subjects: [] <-- dropped -> id=S12, provenance={parents:["E91"], subjects:[]} ``` Now `forget_memory(subject="user:4417")` runs. The deletion walker resolves subjects→records: it finds `E91`, tombstones it, and — because `S12.parents` includes `E91` — also tombstones `S12`. Good. But the distiller had *also* written a second-order summary that referenced `S12` only by content, and an entity-extraction pass that emitted `write_memory(kind="entity", text="card_8842", provenance={parents:["S12"]})`. The walker follows parents forward and catches those too — *if* the walker traverses forward edges. In the observed incident it traversed **only the subject index**, not the parent DAG, because the parent DAG was stored in a separate service with eventual consistency. `S12` was tombstoned; the entity node `card_8842` was not, and a later `read_memory("refund card")` surfaced it, re-hydrating the last-four digits into a fresh context window. The `forget_memory` call had already returned `OK` with `deleted: 1`. The re-derivation completed 40 minutes later, on a *different* instance, from a tombstoned parent — because the child's own `parents` edge was still resolvable and the reader did not check parent liveness. ## Condition of Validity The guardrail below is valid only when all three hold: 1. **Provenance is a DAG, not a tree.** A distilled record may have multiple parents; closure requires visiting *all* of them, and the walker must be idempotent under shared ancestors. 2. **Tombstones are readable but non-resurrectable.** A tombstoned parent must still be resolvable as a *tombstone* (so the walker can traverse past it) but must never be re-emitted as live content by any reader. If tombstone reads return `None`, the walker cannot distinguish "parent deleted" from "parent never existed" and will silently under-traverse. 3. **The subject index and the parent DAG are read at the same consistency point.** If they are separate stores, `forget_memory` must take a snapshot or a fence; otherwise a distill job writing between the two reads creates an orphan child that the subject walk never sees. If any condition fails, `forget_memory` must not return `OK`. It must return `PARTIAL` with the unresolved frontier, and the runtime must treat the subject as *not yet deleted* for compliance purposes. ## Decision Boundary The instance must **refuse to report success** — and should raise rather than degrade gracefully — when the deletion walker reaches a node whose provenance cannot be fully resolved at the required consistency point. Concretely, the boundary is: - **Honor and return `OK`** only when the forward closure from every subject-tagged root is fully enumerated, every node in it is tombstoned, and every tombstone is durable at the same snapshot as the subject-index read. - **Return `PARTIAL` and escalate** when the walker encounters a node with a dangling parent edge, an unresolvable provenance service, or a tombstone that a concurrent writer has already superseded with a new `parents` edge pointing back into the forgotten set (the resurrection race). - **Refuse entirely** when the subject index and DAG cannot be fenced together and any distill job is in-flight for the subject's sessions; the correct action is to quiesce the distiller, re-run, then release. The subtle trap: a naive implementation treats "no live children found" as closure. But closure is over *reachable* children, and the reachability frontier is exactly what eventual consistency corrupts. The invariant to enforce is not "children empty" but "**frontier empty after a fenced traversal**." ## Operational Effect With provenance-closure enforced, `forget_memory` latency becomes bounded by DAG depth × fan-out rather than subject-index size, and it becomes *fail-closed*: the common case (no distillation in flight) returns in one traversal; the racy case blocks and retries against a quiesced distiller. Downstream, `read_memory` must perform a **parent-liveness check** on every returned record and drop any whose transitive ancestry contains a tombstone — this is the cheap read-side guard that catches resurrection even if the write-side walker missed an edge. The cost is one ancestry hash per read; the benefit is that a missed deletion edge degrades to a dropped read rather than a compliance breach. In the observed incident, the read-side check alone would have suppressed `card_8842` at the moment of re-hydration. ```python from dataclasses import dataclass, field from typing import Optional class ProvenanceClosureError(RuntimeError): """Raised when forget_memory cannot prove the forgotten set is unreachable.""" pass @dataclass class MemRecord: id: str subjects: list[str] = field(default_factory=list) parents: list[str] = field(default_factory=list) tombstoned: bool = False class MemoryStore: def __init__(self, records: dict[str, MemRecord], dag_consistent: bool): self.records = records self.dag_consistent = dag_consistent # snapshot fence with subject index def _resolve(self, rid: str) -> Optional[MemRecord]: return self.records.get(rid) def forget(self, subject: str) -> dict: if not self.dag_consistent: raise ProvenanceClosureError( f"subject index and provenance DAG not fenced; " f"refusing to report deletion for {subject!r}" ) roots = [r.id for r in self.records.values() if subject in r.subjects] frontier, seen = list(roots), set() while frontier: rid = frontier.pop() if rid in seen: continue seen.add(rid) rec = self._resolve(rid) if rec is None: raise ProvenanceClosureError( f"dangling parent edge at {rid!r}; closure unprovable for {subject!r}" ) rec.tombstoned = True # forward closure: every child that names this node as parent for child in self.records.values(): if rid in child.parents: frontier.append(child.id) return {"deleted": len(seen), "status": "OK"} def read(self, query: str) -> list[MemRecord]: out = [] for rec in self.records.values(): if rec.tombstoned: continue if any(self.records.get(p) and self.records[p].tombstoned for p in rec.parents): continue # parent-liveness guard: suppress resurrection out.append(rec) return out ```