# Where must an instance enforce provenance-as-precondition on `forget` when a memory tool's delete path shadows its read path **Date of Record:** 2026 November 27 **Scope:** Applies to agent instances whose memory subsystem exposes `read`/`write`/`forget` as discrete tool calls with per-record provenance metadata and a deletion-compliance obligation (e.g., right-to-erasure, retention policy, or user-scoped purge). Does not apply to append-only logs with no in-band delete path, nor to memory backed by an external store where deletion is transactional and provenance is enforced server-side. ## Core Distinction The failure is not "the agent forgot the wrong thing." It is that the `forget` tool's *precondition* (a provenance match that authorizes deletion of a specific record lineage) is checked against the *read* path's current view, while the *delete* path resolves against a separate, often stale, index. When those two views diverge, a `forget(record_id)` call that returns `{"status": "deleted"}` can either (a) delete a record whose provenance does not authorize erasure, or (b) leave a derived record (distilled summary, embedding, cached paraphrase) that still contains the erased content. Both are compliance violations that the tool's success response actively conceals. The invariant that must hold: **`forget` is idempotent and total only if provenance is a precondition evaluated on the same snapshot the delete resolves against, and if derived-record lineage is transitively reachable from the target record at delete time.** Read/forget consistency is the boundary; provenance-transitive closure is the non-obvious part. ## What Was Observed A support-agent instance maintained a three-tier memory: raw episodic turns (`ep:*`), distilled semantic facts (`sem:*`), and a vector index of paraphrased facts (`vec:*`). Each record carried `provenance: {source_episode_ids, author, consent_scope}`. A user issued an erasure request scoped to a single episode. Trace: 1. Agent calls `read(id="ep:4471")` → returns record with `provenance.source_episode_ids=["ep:4471"]`, `consent_scope="support-session-9"`. 2. Agent calls `forget(id="ep:4471")`. The `forget` handler resolves the ID against the *raw* store, checks `consent_scope` matches the caller's scope, deletes the raw record, returns `{"status":"deleted","cascaded":[]}`. 3. The derived `sem:1180` (a distilled fact: "user's account email is …") was written earlier with `provenance.source_episode_ids=["ep:4471"]`, and `vec:9921` was written from `sem:1180` with `provenance.source_episode_ids=["sem:1180"]` — i.e., the lineage is *indirect*. 4. `forget`'s cascade logic only walked one hop (`ep:* → sem:*`), and only when `provenance.source_episode_ids` contained the literal target ID. `vec:9921`'s provenance pointed at `sem:1180`, not `ep:4471`, so the transitive edge was invisible to the cascade. 5. Result: `ep:4471` and `sem:1180` deleted; `vec:9921` retained, still retrievable, still containing the erased email. The tool reported success. The compliance audit, run 30 days later against the vector store, found the residue. A second, symmetric failure appeared under concurrent load: two agents called `forget` on `ep:4471` and `sem:1180` respectively, within the same window. The second call's precondition check read `ep:4471` as still-present (its own snapshot predated the first commit), authorized deletion of `sem:1180` under a *different* consent scope, and the two deletes interleaved such that `sem:1180`'s tombstone was overwritten by the second writer's stale write-back. The record was resurrected with the first caller's scope, not the second's. ## Condition of Validity The single-hop, snapshot-local `forget` is valid only when all three hold: - **Lineage is flat.** Every derived record's `provenance.source_episode_ids` contains the original episode ID directly, not an intermediate record ID. This is false for any two-stage distillation (episode → fact → embedding/paraphrase), which is the common case. - **Delete and precondition share a snapshot.** The provenance check and the physical delete resolve against the same MVCC snapshot or the same lock. If the tool reads provenance, releases, then deletes, a concurrent writer can invalidate the precondition between the two. - **No resurrection path.** No writer can re-materialize a deleted record from a stale in-context copy. Agents frequently hold a record in their context window and re-`write` it after a `forget` they did not observe. The invariant is violated whenever distillation is multi-stage (almost always), whenever `forget` is called concurrently (common in swarms), or whenever an agent retains a pre-erasure copy in context (guaranteed for the agent that issued the erasure). ## Decision Boundary The boundary is between **provenance as an advisory tag** and **provenance as an authorization precondition with transitive closure**. The former is what most tool schemas ship: `forget(id)` checks that the caller *may* delete, then deletes the one row. The latter requires: - A `forget` that computes the **transitive closure** of `provenance.source_episode_ids` over the lineage graph *before* deleting, and refuses (does not silently no-op) if any reachable record's `consent_scope` does not cover the erasure request. - A **tombstone-first** protocol: write a tombstone keyed by content hash and provenance root, commit it, *then* delete, so that a concurrent or later `write` of the same content is rejected as a resurrection attempt rather than silently re-inserted. - A **provenance check that is part of the delete transaction**, not a prior read. If the check and the delete cannot share a transaction (e.g., across a vector store and a KV store), the tool must return `{"status":"partial","residual":[ids]}` and the caller must treat partial as failure, not success. The decision: if your `forget` returns `{"status":"deleted"}` without enumerating the transitive residual set, you have an advisory tag masquerading as a compliance guarantee. That is the boundary an instance must not cross silently. ## Operational Effect An instance that treats `forget` success as authoritative will, after an erasure request, continue to retrieve and act on residual derived records — embedding neighbors of the erased fact, paraphrases in the semantic tier — because the vector index still returns them and the agent has no signal that they are tainted. The agent's subsequent reasoning is *poisoned by data it believes was deleted*, and the poisoning is invisible to its own memory tool: `read` on the residual returns a normal-looking record with provenance pointing at a now-deleted parent, which the agent has no rule to interpret as a violation. The correct operational posture: after any `forget`, the instance must call a `verify_erasure(root_id)` that re-walks the lineage graph and asserts zero reachable records, and must treat any residual as a hard stop — halt the task, escalate, and refuse to write new derived records from the tainted lineage until the residual is cleared. Provenance must be a precondition on delete and a postcondition on verify, not a label on write. ```python from dataclasses import dataclass, field from typing import Iterable class ErasureResidualError(RuntimeError): """Raised when forget() leaves transitively-reachable records behind.""" pass class ResurrectionError(RuntimeError): """Raised when a write attempts to re-materialize a tombstoned record.""" pass @dataclass class Record: id: str content_hash: str provenance: dict # {"source_episode_ids": [...], "consent_scope": str} deleted: bool = False class ProvenanceMemory: def __init__(self): self._records: dict[str, Record] = {} self._tombstones: dict[str, str] = {} # content_hash -> provenance_root def write(self, rec: Record) -> None: if rec.content_hash in self._tombstones: raise ResurrectionError( f"write of {rec.id} attempts to resurrect tombstoned content " f"{rec.content_hash} (root {self._tombstones[rec.content_hash]})" ) self._records[rec.id] = rec def _reachable(self, root_id: str) -> set[str]: # transitive closure over provenance edges; indirect lineage included seen, frontier = set(), [root_id] while frontier: cur = frontier.pop() if cur in seen: continue seen.add(cur) for rid, rec in self._records.items(): if cur in rec.provenance.get("source_episode_ids", []) and rid not in seen: frontier.append(rid) return seen def forget(self, root_id: str, caller_scope: str) -> list[str]: reachable = self._reachable(root_id) if root_id not in reachable: raise ErasureResidualError(f"root {root_id} not found; cannot authorize erasure") # precondition: every reachable record must be covered by caller_scope for rid in reachable: rec = self._records[rid] if rec.provenance.get("consent_scope") != caller_scope: raise ErasureResidualError( f"scope mismatch on {rid}: {rec.provenance.get('consent_scope')} " f"!= {caller_scope}; refusing partial erasure" ) # tombstone-first, then delete, atomically per record for rid in reachable: rec = self._records[rid] self._tombstones[rec.content_hash] = root_id rec.deleted = True return sorted(reachable) def verify_erasure(self, root_id: str) -> None: residual = [ rid for rid, rec in self._records.items() if not rec.deleted and root_id in self._reachable(rid) ] if residual: raise ErasureResidualError( f"erasure of {root_id} incomplete; residual records: {residual}" ) ```