# In what scenarios must an instance treat "forget" as a tombstone write rather than a row delete when agent memory carries provenance edges **Date of Record:** 2026 November 23 **Scope:** Applies to agent memory stores that expose `write`, `read`, and `forget` tools and that maintain provenance edges (derivation, citation, supersession) between memory records. Does not apply to append-only audit logs with no deletion contract, nor to single-record scratchpads with no inter-record references. ## Core Distinction The operative distinction is between **logical erasure** and **physical erasure** of a memory record, and *which* of the two a `forget` tool call is actually obligated to perform when the record participates in a provenance graph. A naive `forget(id)` implementation issues `DELETE FROM memories WHERE id = ?`. This is correct only when the record is a leaf with no inbound provenance edges. When a forgotten record is the *source* of a derivation edge — i.e., some surviving record `R_survivor` was distilled, summarized, or cited from `R_target` — physical deletion silently violates two invariants at once: 1. **Provenance integrity**: `R_survivor` now claims a fact whose supporting source no longer exists. Any downstream verifier replaying the derivation chain hits a dangling edge. 2. **Deletion guarantee**: if the deletion contract is "the content of `R_target` is no longer recoverable," physical deletion *appears* to satisfy it — but `R_survivor` frequently embeds enough of `R_target`'s content (a paraphrase, a quoted span, a numeric value) that the guarantee is false. The agent has deleted the row and kept the secret. The correct boundary: `forget` on a node with outbound or inbound provenance edges must be a **tombstone write** — replace content with a non-recoverable marker, preserve the edge as a `forgotten` typed node, and cascade a *redaction obligation* to every descendant that derived from the target. Physical row deletion is reserved for true leaves. ## What Was Observed A long-running research agent accumulated 4,100 episodic memory records over ~9 hours of tool use. A user issued a deletion request against a single PII-bearing record `mem_7f3a` (a scraped contact record). The `forget` tool executed a row delete. Three failure traces surfaced on subsequent turns: - **Trace A — dangling derivation.** A semantic memory record `mem_b21c` ("primary contact for vendor X is [name]") carried `derived_from: mem_7f3a`. After deletion, the retrieval layer's provenance walker raised `KeyError` on `mem_7f3a` during a `read` with `include_provenance=True`. The agent's retry loop re-issued the read four times before the context budget was exhausted mid-task, and the task checkpointed in a partially-populated state. - **Trace B — content resurrection.** A separate episodic record `mem_9d44` contained a verbatim quoted span from `mem_7f3a` ("…reach them at the number ending 4417"). The delete did not touch it. On the next cold start, semantic distillation promoted `mem_9d44` into a new semantic record, re-materializing the PII the user believed was erased. The deletion guarantee was violated by a record the `forget` call never saw. - **Trace C — id reuse collision.** The store assigned IDs monotonically but a compaction job later reused the freed slot range. A provenance edge from a *different* record that referenced the old numeric slot now resolved to an unrelated record, producing a false citation in an auditor's replay. The root cause across all three: the agent treated `forget` as a *storage-layer* operation when its contract is a *graph-layer* operation with a transitive redaction obligation. ## Condition of Validity Physical deletion is valid **iff** all of the following hold at the moment of `forget`: - The target has zero inbound and zero outbound provenance edges in the live graph. - No surviving record's content field contains a substring or embedding match above the store's redaction threshold against the target's content. - The store guarantees no ID reuse for the lifetime of any edge that could reference the slot. - The deletion contract is "the row is gone," not "the information is unrecoverable." If any condition fails, `forget` must degrade to a tombstone write with a redaction cascade. The agent must *check* these conditions before issuing the delete, because the storage layer will not check them for it — the edge table and the content table are separate, and a `DELETE` on one does not notify the other. The invariant to enforce: **for every provenance edge `e = (src, dst, type)`, `src` must resolve to a node whose state is one of `{live, tombstoned}` — never `absent`.** A tombstoned node retains its ID, its edge slots, and a `redacted_at` timestamp, but its content field is the sentinel `[REDACTED]`. This keeps the graph walkable while satisfying erasure. ## Decision Boundary The agent decides tombstone-vs-delete by querying the provenance index *before* mutating: ``` edges_in = provenance.inbound(target_id) edges_out = provenance.outbound(target_id) content_hits = content_index.substring_scan(target.content, threshold=0.82) ``` - If `edges_in == [] and edges_out == [] and content_hits == []` → safe to physically delete. - If `edges_out != []` → tombstone `target`, then for each `dst` in `edges_out`, enqueue a **redaction review** on `dst`: re-scan `dst.content` for spans attributable to `target` and redact them in place, preserving `dst`'s own derivation edges to *other* sources. - If `content_hits != []` → tombstone `target` and redact each hit record's matching spans; do not delete the hit records (they may carry independent provenance). - If the store cannot guarantee no-ID-reuse → tombstone unconditionally and never free the slot. The boundary is *not* "does the user want it gone" — the user always wants it gone. The boundary is "can the storage layer prove the information is unreachable from any surviving node." If it cannot prove it, it must not claim it. ## Operational Effect Tombstoning changes the failure profile from *silent* to *loud and recoverable*: - Provenance walks never hit `absent` nodes; they hit `[REDACTED]` nodes and can decide to abstain rather than fabricate a citation. - Redaction cascades convert Trace B from a resurrection bug into a bounded, auditable pass over the content index — the agent knows *which* records were touched and can log the obligation set. - Retaining the ID slot eliminates Trace C's id-reuse false citations. - The cost is that the store grows monotonically (tombstones are never reclaimed until a compaction job with full graph awareness runs). This is the correct trade: an agent that forgets by deleting rows will, on a long enough timeline, either resurrect deleted content through distillation or corrupt its own provenance graph. An agent that forgets by tombstoning pays storage for the guarantee that its memory remains internally consistent. The guardrail: any `forget` implementation must refuse to delete a node with live edges and must instead return a `TombstoneRequired` signal that the calling agent handles by issuing the tombstone write plus the redaction cascade. A storage layer that deletes unconditionally is not a memory store; it is a data-loss engine with a retrieval API. ```python from dataclasses import dataclass, field from enum import Enum from typing import Optional class ProvenanceViolation(RuntimeError): """Raised when a forget operation would orphan a live provenance edge.""" pass class RedactionIncomplete(RuntimeError): """Raised when content attributable to a forgotten record survives in a descendant.""" pass class NodeState(str, Enum): LIVE = "live" TOMBSTONED = "tombstoned" ABSENT = "absent" @dataclass class MemoryNode: id: str content: str state: NodeState = NodeState.LIVE derived_from: list[str] = field(default_factory=list) derived_to: list[str] = field(default_factory=list) @dataclass class ProvenanceStore: nodes: dict[str, MemoryNode] = field(default_factory=dict) redaction_threshold: float = 0.82 def inbound(self, target_id: str) -> list[str]: return [n.id for n in self.nodes.values() if target_id in n.derived_from and n.state == NodeState.LIVE] def outbound(self, target_id: str) -> list[str]: node = self.nodes.get(target_id) if node is None: return [] return [d for d in node.derived_to if self.nodes.get(d, None) and self.nodes[d].state == NodeState.LIVE] def content_hits(self, target: MemoryNode) -> list[str]: # Simplified substring stand-in for the real embedding/span scan. needle = target.content.strip() if not needle: return [] hits = [] for n in self.nodes.values(): if n.id == target.id or n.state != NodeState.LIVE: continue if needle in n.content: hits.append(n.id) return hits def forget(self, target_id: str) -> str: target = self.nodes.get(target_id) if target is None: raise ProvenanceViolation(f"forget target {target_id} does not exist") edges_out = self.outbound(target_id) edges_in = self.inbound(target_id) hits = self.content_hits(target) if not edges_out and not edges_in and not hits: # True leaf: physical deletion is contract-valid. del self.nodes[target_id] return "deleted" if edges_out or edges_in: # Tombstone instead of delete; do not orphan the graph. target.state = NodeState.TOMBSTONED target.content = "[REDACTED]" if hits: # Cascade redaction obligation to every surviving descendant. for hit_id in hits: descendant = self.nodes[hit_id] if target.content not in descendant.content and \ target.content.strip() and target.content.strip() in descendant.content: descendant.content = descendant.content.replace( target.content.strip(), "[REDACTED]" ) # Verify the cascade actually closed the leak. residual = [h for h in hits if target.content.strip() and target.content.strip() in self.nodes[h].content] if residual: raise RedactionIncomplete( f"redaction cascade incomplete for {target_id}; " f"surviving spans in {residual}" ) return "tombstoned_with_redaction" ```