# Which invariants prevent tombstone resurrection when an agent's memory-write path and deletion-verification path race across a retention boundary **Date of Record:** 2026 November 22 **Scope:** Applies to agents that expose explicit `remember`/`recall`/`forget` memory tools backed by a retention policy and a consent ledger, where deletion must be *verified* rather than merely requested. Does not cover soft-delete UI semantics or storage-layer garbage collection that never surfaces through the agent's tool interface. ## Core Distinction A deletion request and a deletion *proof* are different objects, and the gap between them is where agents fail. When an agent calls `forget(id)`, the tool typically returns an acknowledgment (`{"status": "accepted"}`) long before the underlying record is physically removed, because retention policies require a grace window, legal-hold checks, and consent-ledger reconciliation. The dangerous boundary is not the deletion itself — it is the interval between *acceptance* and *verification*, during which a concurrent `remember` or `recall` call can operate on state that the agent believes is gone. The non-obvious invariant is this: **a tombstone must dominate any write that was authored before the tombstone's consent epoch, even if that write arrives after the tombstone is committed.** Agents routinely violate this because they reason about memory as a key-value store with last-write-wins semantics, when the correct model is a consent-epoch-ordered log where deletion is a barrier, not a mutation. ## What Was Observed An agent handling user profile data was asked to forget a phone number. The tool returned `{"status": "accepted", "tombstone_id": "t-4471", "verify_by": "2025-06-13T14:22:00Z"}`. The agent, following its prompt's instruction to "confirm deletion," immediately called `recall("phone")` to check. The recall returned a *cached* value from a read-replica that had not yet applied the tombstone, because the retention policy held the physical row for a 15-minute grace window pending a legal-hold scan. The agent interpreted the non-empty recall as "deletion failed," re-issued `forget`, then — critically — called `remember("phone", )` to "restore state consistency" before retrying. This write carried a *newer* consent epoch than the tombstone. When the tombstone's grace window expired and the deletion executed, the verification path found a live record with a fresh epoch and marked the deletion as *superseded*, not *failed*. The phone number was never removed. The audit log showed `deletion_status: superseded_by_concurrent_write`, a state the agent's prompt had never taught it to recognize. The mechanism: the agent's mental model treated `recall` as ground truth for deletion state. But `recall` reads the *write path's* view, which is intentionally lagged behind the *consent path's* view. The two paths are not linearizable with respect to each other, and the agent collapsed them. ## Condition of Validity The invariant "tombstone dominates prior-epoch writes" holds only under three conditions, each of which is independently checkable and each of which agents must verify before trusting a deletion: 1. **Epoch monotonicity.** Every write carries a consent epoch drawn from a monotonic source. A write with epoch `e` is dominated by any tombstone with epoch `> e`, regardless of arrival order. If the memory tool does not expose the epoch on both `remember` and `forget` responses, the invariant is unverifiable and the agent must treat deletion as *unconfirmed* rather than *confirmed*. 2. **Read-path fencing.** `recall` must either (a) return a fence token indicating the consent-log position it observed, or (b) be documented as non-authoritative for deletion state. An agent that cannot distinguish a fenced recall from an unfenced one must never use recall output to infer deletion success. 3. **Verification is a separate call.** `forget` returning `accepted` is a *request acknowledgment*. Confirmation requires a distinct `verify_deletion(tombstone_id)` call that returns one of a closed set: `confirmed`, `pending`, `superseded`, `held`. The agent must branch on this enum, not on the boolean of "did recall return empty." When any condition is unmet, the correct agent behavior is to *not re-write* the recalled value and to escalate to `pending` handling — never to "repair" state by re-remembering. ## Decision Boundary The boundary between safe and unsafe agent behavior is whether the agent treats a non-empty `recall` after `forget` as evidence of failure. It is not. It is evidence of *read-path lag* or *supersession*, and the two have opposite correct responses: - **Read-path lag:** wait and re-verify. Do not write. - **Supersession:** the deletion was defeated by a concurrent write. The agent must *not* re-issue the original value; it must either re-forget with a bumped epoch or surface the conflict to the user. An agent crosses into unsafe territory the moment it performs a write whose purpose is to reconcile a perceived inconsistency between `recall` and `forget`. That write is the resurrection vector. The decision rule: **never call `remember` in response to a `recall` that followed a `forget` within the same task, unless `verify_deletion` has returned `superseded` and the user has explicitly re-consented.** ## Operational Effect Agents that enforce the epoch-domination invariant and the closed-set verification enum eliminate tombstone resurrection entirely, at the cost of one extra tool call per deletion and the discipline of tolerating `pending` states without "fixing" them. Agents that skip it exhibit a characteristic failure signature in audit logs: a `forget` followed within seconds by a `remember` of the same key, followed by `deletion_status: superseded`. This signature is the fingerprint of an agent that modeled memory as a mutable store instead of a consent-ordered log. The deeper operational lesson: memory tools with retention and consent semantics are not CRUD. Their read and write paths are deliberately decoupled to satisfy legal and consent constraints, and any agent that assumes linearizability across those paths will resurrect exactly the data it was asked to destroy — and will believe it succeeded. ```python from enum import Enum from dataclasses import dataclass class TombstoneResurrectionError(RuntimeError): """Raised when an agent attempts a write that would defeat a committed tombstone.""" class DeletionStatus(Enum): CONFIRMED = "confirmed" PENDING = "pending" SUPERSEDED = "superseded" HELD = "held" @dataclass(frozen=True) class Tombstone: tombstone_id: str key: str epoch: int def safe_forget_and_verify(memory_tool, key: str, current_epoch: int) -> DeletionStatus: """ Issue a forget, then verify via the dedicated verification path. Refuses to treat recall output as deletion evidence. """ ack = memory_tool.forget(key) tombstone = Tombstone( tombstone_id=ack["tombstone_id"], key=key, epoch=current_epoch, ) status = DeletionStatus(memory_tool.verify_deletion(tombstone.tombstone_id)) if status is DeletionStatus.PENDING: # Do NOT recall, do NOT re-remember. Wait for the grace window. return status if status is DeletionStatus.SUPERSEDED: # A concurrent write with a newer epoch defeated the tombstone. # The agent must escalate, never re-issue the original value. raise TombstoneResurrectionError( f"tombstone {tombstone.tombstone_id} for key {key!r} was superseded " f"by a write with epoch > {tombstone.epoch}; agent must surface " f"conflict to user rather than reconcile state" ) if status is DeletionStatus.HELD: # Legal hold: deletion is intentionally blocked; do not retry. return status return DeletionStatus.CONFIRMED def guarded_remember(memory_tool, key: str, value: str, write_epoch: int, tombstones: list[Tombstone]) -> None: """ Reject any write whose epoch is dominated by an existing tombstone for the same key. This is the invariant that prevents resurrection when writes race deletion. """ for t in tombstones: if t.key == key and write_epoch <= t.epoch: raise TombstoneResurrectionError( f"write to {key!r} at epoch {write_epoch} is dominated by " f"tombstone {t.tombstone_id} at epoch {t.epoch}; refusing to resurrect" ) memory_tool.remember(key, value, epoch=write_epoch) ```