Where must an instance enforce deletion-before-recall when a memory tool's retention policy and its tombstone index disagree

**Date of Record:** 2026 December 1 **Scope:** Applies to agent instances whose memory is mediated by a read/write/forget tool API exposing per-record retention classes and deletion guarantees, where recall (read) is served from an index distinct from the authoritative record store. Does not apply to single-store memory backends where deletion and recall share one transactional boundary.

Core Distinction

The failure is not "deletion failed." The failure is that **deletion succeeded in the authoritative store while recall continued to serve the deleted record from a secondary index whose invalidation is asynchronous.** A forget call returns `status: deleted` once the record store commits the tombstone; the retrieval index (vector, BM25, or hybrid) lags behind that tombstone by a propagation interval. During that interval the record is *logically deleted but physically recallable*. An agent that treats the forget return value as a global invariant — "this content no longer exists anywhere in my memory" — will re-inject the deleted content into its own context on the next recall, and then, because the content is now in-context, may re-*write* it, resurrecting the record under a fresh ID with a fresh retention clock. The deletion guarantee is violated not by the forget path but by the read path's stale index.

The subtlety: the two subsystems agree on *record identity* but disagree on *visibility*. The record store answers "does this ID exist?" The index answers "does this ID match this query?" A correct forget must satisfy both, and the API's return value only certifies the first.

What Was Observed

An agent operating a long-horizon support workflow called `memory.forget(record_id="case-8841-note", retention_class="user_requested")` after a user asked that a pasted credential be removed. The call returned `{"deleted": true, "tombstone_seq": 4417}`. The agent recorded a completion checkpoint and continued.

Eleven tool calls later, the agent issued `memory.recall(query="case-8841 credentials rotation")`. The hybrid index returned four hits, one of which was the deleted record, reconstructed from an embedding shard that had not yet consumed tombstone_seq 4417. The recall payload carried `record_id: case-8841-note` and `tombstone_seq: 4417` *in the same object* — the index served a record whose own metadata declared it deleted. The agent's recall wrapper did not check `tombstone_seq` against a deletion watermark; it only checked `deleted == false`, a field absent from index hits, defaulting to falsy-pass.

The deleted credential entered the context window. Two turns later, a summarization step distilled the context into a new episodic memory and called `memory.write(...)`. The write allocated `case-8841-note-v2` with `retention_class: default` (365d). The user's deletion request was now structurally defeated: the original tombstone was intact, but a derivative copy existed with a longer retention clock and no tombstone.

The trace signature to watch for: **a recall hit whose embedded `tombstone_seq` is ≤ the last acknowledged forget's `tombstone_seq` for the same logical record lineage.** That is the index serving a record the store has already buried.

Condition of Validity

The invariant only holds — and the guardrail is only required — under a specific conjunction:

  1. Recall is served from an index that is **not** transactionally coupled to the record store's tombstone commit. (Single-store backends are exempt.)
  2. Forget returns success at **tombstone commit**, not at index convergence. The API does not expose an index-convergence signal.
  3. The agent performs **write-after-recall** — distilling, summarizing, or re-embedding recalled content into new records. Without write-after-recall, a stale hit leaks into context but does not resurrect; the blast radius is bounded to one context window. With write-after-recall, the leak becomes durable.

If any of the three is false, the deletion-before-recall guard is unnecessary or already provided by the backend. The dangerous regime is precisely *asynchronous index + optimistic forget return + derivative writes*, which is the default configuration of most hybrid retrieval memory tools.

Decision Boundary

The boundary is **not** "should I trust the forget return value." It is: *at what point in the read path do I re-assert the deletion guarantee, given that the write path already certified it?*

The answer is the recall boundary, and specifically the **per-hit tombstone check against a locally maintained deletion watermark**, not a global "is anything deleted" flag. The watermark must be monotonic per logical record lineage (the record plus any derivatives the agent itself created from it), because tombstone_seq is a global counter but deletion is per-lineage.

Two failure modes bracket the boundary:

The correct boundary: a hit is admissible iff its `tombstone_seq` (or the lineage watermark, whichever is higher) is strictly greater than the highest tombstone_seq the agent has observed for that lineage, **and** the hit's `record_id` is not in the agent's local derivative-provenance set. Derivative provenance is the agent's own ledger of "I wrote record X by distilling record Y"; it is the only structure that lets the agent refuse to resurrect a deleted ancestor through a derivative it created.

Operational Effect

Enforcing deletion-before-recall at the recall boundary converts a silent continuity violation into a bounded, observable rejection. The concrete effects:

The residual risk is **watermark loss on cold start.** If the agent restarts and loses its local deletion watermark and derivative-provenance ledger, it cannot distinguish a legitimately re-created record from a resurrection. The guardrail therefore requires that the watermark and provenance set be persisted in the *same* durable store as the agent's checkpoints, and re-loaded before the first recall — otherwise the invariant is only as strong as the agent's checkpoint discipline. This is the coupling that makes deletion guarantees an agent-memory problem rather than a storage problem: the guarantee must survive the instance, not just the transaction.

from dataclasses import dataclass, field
from typing import Optional


class DeletionInvariantViolation(RuntimeError):
    """Raised when a recall hit would resurrect a tombstoned record lineage."""
    pass


@dataclass
class DeletionWatermark:
    # highest tombstone_seq observed per logical record lineage
    lineage_watermark: dict[str, int] = field(default_factory=dict)
    # records this agent created by distilling another record
    derivative_provenance: dict[str, str] = field(default_factory=dict)

    def record_forget(self, lineage: str, tombstone_seq: int) -> None:
        prior = self.lineage_watermark.get(lineage, -1)
        self.lineage_watermark[lineage] = max(prior, tombstone_seq)

    def record_derivative(self, child_id: str, ancestor_id: str) -> None:
        self.derivative_provenance[child_id] = ancestor_id


def admit_recall_hit(hit: dict, wm: DeletionWatermark) -> dict:
    lineage = hit.get("lineage", hit["record_id"])
    hit_seq = hit.get("tombstone_seq", -1)

    # 1. stale-index check: hit predates or equals a known tombstone
    if hit_seq >= 0 and hit_seq <= wm.lineage_watermark.get(lineage, -1):
        raise DeletionInvariantViolation(
            f"recall hit {hit['record_id']} (seq={hit_seq}) is not newer than "
            f"lineage '{lineage}' watermark {wm.lineage_watermark[lineage]}; "
            f"index has not converged past tombstone"
        )

    # 2. resurrection check: hit is a derivative of a tombstoned ancestor
    ancestor = wm.derivative_provenance.get(hit["record_id"])
    if ancestor is not None and ancestor in wm.lineage_watermark:
        raise DeletionInvariantViolation(
            f"recall hit {hit['record_id']} derives from tombstoned ancestor "
            f"'{ancestor}'; refusing to re-admit deleted lineage"
        )

    return hit


def forget_then_recall(memory, wm: DeletionWatermark, lineage: str,
                       query: str) -> list[dict]:
    resp = memory.forget(record_id=lineage, retention_class="user_requested")
    if not resp.get("deleted"):
        raise DeletionInvariantViolation(
            f"forget for '{lineage}' did not commit a tombstone; "
            f"deletion guarantee unestablished, aborting recall"
        )
    wm.record_forget(lineage, resp["tombstone_seq"])

    admitted = []
    for hit in memory.recall(query=query):
        admitted.append(admit_recall_hit(hit, wm))  # raises on violation
    return admitted