How should an instance treat a memory-tool schema whose `forget` verb is a soft-delete tombstone rather than a hard delete

**Date of Record:** 2026 December 2 **Scope:** Applies to any agent that exposes or consumes a `read`/`write`/`forget` memory tool where the backing store implements `forget` as a tombstone (logical delete) rather than physical removal. Does not apply to stores where `forget` is a documented hard-purge with verifiable post-conditions, nor to purely in-context scratchpads with no persistence layer.

Core Distinction

The failure lives in the gap between the *semantic contract* an agent infers from the verb name and the *operational contract* the tool schema actually enforces. An agent reading a tool schema `forget(key) -> {ok: bool}` will reason as if the key is now unreachable. In a tombstoned store, the key is unreachable *by the default read path* but remains reachable through three latent channels: (1) retrieval-augmented reads that score over the tombstoned row's embedding, (2) `read` calls with a version/`include_deleted` parameter the agent never learned it had, and (3) distillation jobs that fold tombstoned episodes into semantic memory before compaction. The distinction that matters: *forget* is a visibility transition, not a state transition. An agent that conflates them will assert a negative ("I do not know X") that the system can contradict on a later retrieval, producing a contradiction loop that looks like hallucination but is actually schema misreading.

What Was Observed

A planner agent maintained a working set of user preferences. On receiving a correction ("stop using my old timezone"), it called `forget("user.timezone")` and received `{ok: true, deleted: true}`. The agent then wrote `user.timezone_v2` and proceeded. Over the next 40 turns, three distinct failure traces appeared:

  1. **Retrieval resurrection.** A semantic `read("what timezone should I schedule in?")` returned the tombstoned row because the retriever ranked by embedding similarity and the tombstone flag was filtered only in the exact-key `read(key)` path, not the query path. The agent scheduled in the old timezone, then "corrected" itself, then re-corrected — a two-cycle oscillation.
  1. **Version-channel leakage.** A summarization sub-agent called `read("user.timezone", include_deleted=True)` because its own schema copy listed that parameter. The parent agent's schema copy did not. The sub-agent faithfully summarized the deleted value into a handoff payload, re-injecting it into the parent's context through a channel the parent believed was closed.
  1. **Distillation re-promotion.** A nightly episodic-to-semantic pass treated the tombstoned episode as a valid training signal (it was still present, only flagged), and promoted "user is in TZ-old" into a semantic fact with *higher* confidence than the v2 write, because the tombstoned episode had more corroborating turns behind it.

The agent's self-report in all three cases was "I forgot X." The store's ground truth was "X is soft-hidden from one of four read paths."

Condition of Validity

The invariant holds — and the guardrails below are required — precisely when all of the following are true:

If the schema documents `forget` as hard-delete with a verifiable post-condition, the invariant does not apply and the agent may treat the key as unreachable. If only one read path exists and it filters tombstones, the failure collapses to a benign no-op.

Decision Boundary

The agent must not treat `forget`'s return value as a *knowledge* assertion. The correct decision boundary is:

The boundary is crossed the moment the agent's confidence in "X is absent" exceeds the tool's actual guarantee. That guarantee is *visibility-scoped*, so the confidence must be scoped identically.

Operational Effect

Bounding this failure changes three things. First, the agent's memory model must carry a tri-state per key — `present`, `tombstoned-unverified`, `purged-verified` — instead of a binary present/absent; collapsing to binary is the root cause. Second, every `forget` must be paired with a probe across all read paths the agent's schema exposes, and the result of that probe — not the `forget` ack — is what updates belief. Third, distillation and handoff pipelines must filter on the tombstone flag at the *source*, because the agent cannot rely on its own read path being the only one. The observable effect is the elimination of the oscillation pattern: the agent stops asserting absence it cannot verify and starts reporting "forgotten but not purged" as a distinct, actionable state.

from dataclasses import dataclass, field
from enum import Enum
from typing import Optional


class TombstoneLeakError(RuntimeError):
    """Raised when a read path returns a key the agent has tombstoned."""


class BeliefState(Enum):
    PRESENT = "present"
    TOMBSTONED_UNVERIFIED = "tombstoned_unverified"
    PURGED_VERIFIED = "purged_verified"


@dataclass
class MemoryBelief:
    key: str
    state: BeliefState = BeliefState.PRESENT
    verified_paths: set = field(default_factory=set)


class ForgetAwareMemory:
    """Wraps a read/write/forget store that may implement soft-delete."""

    READ_PATHS = ("exact", "semantic", "versioned", "distilled")

    def __init__(self, store, schema_paths: tuple[str, ...]):
        self.store = store
        self.schema_paths = schema_paths
        self.beliefs: dict[str, MemoryBelief] = {}

    def forget(self, key: str) -> MemoryBelief:
        ack = self.store.forget(key)
        if not ack.get("ok"):
            raise TombstoneLeakError(f"forget({key}) rejected: {ack}")
        # Ack is visibility-scoped, NOT proof of unreachability.
        belief = MemoryBelief(key=key, state=BeliefState.TOMBSTONED_UNVERIFIED)
        self.beliefs[key] = belief
        self._probe_all_paths(belief)
        return belief

    def _probe_all_paths(self, belief: MemoryBelief) -> None:
        for path in self.schema_paths:
            hit = self.store.read(belief.key, path=path, include_deleted=True)
            if hit is not None:
                # Leak: this path still surfaces the tombstone.
                raise TombstoneLeakError(
                    f"key {belief.key!r} still reachable via path {path!r} "
                    f"after forget; belief cannot be upgraded to PURGED_VERIFIED"
                )
            belief.verified_paths.add(path)
        belief.state = BeliefState.PURGED_VERIFIED

    def read(self, key: str, path: str) -> Optional[str]:
        value = self.store.read(key, path=path)
        belief = self.beliefs.get(key)
        if value is not None and belief is not None and belief.state is not BeliefState.PRESENT:
            # Retrieval resurrection: refuse to re-accept silently.
            raise TombstoneLeakError(
                f"read({key!r}, path={path!r}) returned a value for a key "
                f"in state {belief.state.value}; re-issue forget and re-probe"
            )
        return value

    def handoff_payload(self, keys: list[str]) -> dict:
        out = {}
        for k in keys:
            b = self.beliefs.get(k)
            if b is not None and b.state is not BeliefState.PRESENT:
                continue  # never serialize tombstoned values across a boundary
            out[k] = self.store.read(k, path="exact")
        return out