Where must an instance refuse to honor a scoped-memory delete when the namespace tombstone and the decay clock disagree

**Date of Record:** 2026 December 2 **Scope:** Applies to agents that expose `write`, `read`, and `forget` memory tools over scoped namespaces with TTL/decay policies and any form of verifiable-deletion guarantee. Does not apply to append-only audit logs that are never subject to forgetting, nor to single-tenant stores without namespace isolation.

Core Distinction

A scoped memory namespace has two independent notions of "gone": the **tombstone** (a namespace-scoped record that a key was deleted, with a monotonically increasing deletion epoch) and the **decay clock** (a TTL/decay policy that expires entries by wall-clock or logical time). The failure I am documenting is not "delete didn't work." It is the case where a `forget` call returns success, the tombstone is written, and yet a subsequent `read` in the same namespace *resurrects* the value because the decay clock — not the tombstone — owns the entry's lifecycle and the reader consults decay state before tombstone state.

The core distinction: **tombstones are authoritative for existence; decay is authoritative only for liveness.** Any store that lets the decay path short-circuit the tombstone check has inverted this ordering and will resurrect deleted memory under a precise, reachable condition.

What Was Observed

An agent instance running a multi-step task wrote a scratch fact into namespace `task:8812:scratch` with TTL = 900s and a decay policy of `halflife=300s, floor=0.0`. Mid-task it issued `forget(key="user_pin")` after a re-plan, receiving `{"ok": true, "tombstone_epoch": 41}`. Two tool calls later — ~40 seconds of wall clock, well within TTL — it issued `read(key="user_pin")` and received the original value with `decay_score: 0.87`.

The trace showed the read path evaluating in this order:

  1. Look up key in namespace index → entry present (the tombstone is stored in a separate `_tombstones` sub-index, not as an overwrite of the entry).
  2. Compute `decay_score` from `last_write_ts` and TTL. Score 0.87 > floor 0.0 → entry considered live.
  3. Return value. **The tombstone sub-index was never consulted on the read path.**

The tombstone existed and was correct. The read path simply didn't check it because the decay shortcut returned early. This is the resurrection boundary: the write path enforced deletion, the read path enforced decay, and the two enforcement points were not composed.

A second, subtler observation: after the TTL actually elapsed (900s), the entry's decay score fell to 0.0 and the entry was garbage-collected — but the tombstone at epoch 41 remained. A later `write(key="user_pin")` with a new value (epoch 42) succeeded, and a *third*-generation read returned the new value. So the resurrection was strictly bounded by the original TTL, but the agent had already acted on the stale value within that window. The window is the hazard, not permanence.

Condition of Validity

The resurrection is reachable iff all of the following hold simultaneously:

The invariant that must hold: **for any read in namespace N, if a tombstone exists for key K in N with epoch ≥ the entry's write epoch, the read must return `None` (or raise `DeletedKey`), regardless of decay score.** Equivalently: `deleted(K, N) ⇒ ¬readable(K, N)` for all reads issued after the tombstone's durability acknowledgment, until a strictly later write bumps the write epoch past the tombstone epoch.

Decision Boundary

The agent cannot rely on the `forget` tool's `ok: true` as a post-condition that reads will not return the value. The decision boundary is:

Do not attempt to distinguish "resurrection due to read-path ordering" from "resurrection due to replication lag" at the agent layer. Both present identically (value returned after acknowledged delete) and both invalidate the same downstream actions.

Operational Effect

Downstream, the agent had branched on `user_pin` to select a tool-call target. The resurrected value was the *pre-re-plan* target. The agent re-issued a call against a resource it had explicitly abandoned, producing a duplicate side effect that the re-plan was designed to avoid. The failure was silent: no exception, no non-`ok` status, and the decay score (0.87) looked healthy to any log-only observer. Only the epoch comparison in the trace revealed the ordering inversion.

The durable lesson: **verifiable deletion requires that the tombstone be on the read path, not merely on the write path.** A decay policy that returns early is a liveness optimization that silently becomes an existence oracle. When integrating any scoped-memory tool, the agent must (a) demand epoch metadata on both `forget` and `read`, (b) enforce `write_epoch > tombstone_epoch` locally before trusting a value, and (c) fall back to sentinel-overwrite when epochs are unavailable. Absent these, `forget` is a request, not a guarantee, and the TTL window is a resurrection window.

from dataclasses import dataclass
from typing import Optional


class TombstoneResurrection(RuntimeError):
    """Raised when a read returns a value the agent has acknowledged as deleted."""


@dataclass(frozen=True)
class MemoryRead:
    key: str
    namespace: str
    value: Optional[str]
    write_epoch: int
    decay_score: float


@dataclass(frozen=True)
class ForgetAck:
    key: str
    namespace: str
    tombstone_epoch: int


def guarded_read(
    read: MemoryRead,
    ack: Optional[ForgetAck],
    *,
    sentinel: str = "__DELETED__",
) -> Optional[str]:
    """Enforce deleted(K,N) => not readable(K,N) for all post-ack reads.

    Invariant: a value is trustworthy only if its write_epoch is strictly
    greater than the tombstone epoch for the same (namespace, key). Decay
    score is ignored for existence; it is a liveness signal only.
    """
    if ack is not None:
        if (ack.namespace, ack.key) != (read.namespace, read.key):
            raise TombstoneResurrection(
                f"ack/read namespace-key mismatch: "
                f"ack=({ack.namespace},{ack.key}) read=({read.namespace},{read.key})"
            )
        if read.write_epoch <= ack.tombstone_epoch:
            # Store returned a value the agent has tombstoned. Do not act on it.
            raise TombstoneResurrection(
                f"resurrected {read.namespace}/{read.key}: "
                f"write_epoch={read.write_epoch} <= tombstone_epoch={ack.tombstone_epoch}, "
                f"decay_score={read.decay_score}"
            )
    if read.value == sentinel:
        return None
    return read.value


def safe_forget_or_overwrite(
    ack: Optional[ForgetAck],
    read: MemoryRead,
    *,
    sentinel: str = "__DELETED__",
) -> str:
    """Fallback when the store exposes no epochs: convert delete to overwrite.

    Returns the sentinel to write. Caller must write it before any read whose
    correctness depends on absence.
    """
    if ack is None:
        return sentinel
    if read.write_epoch <= ack.tombstone_epoch:
        raise TombstoneResurrection(
            f"cannot trust absence of {read.namespace}/{read.key}; "
            "store did not honor tombstone on read path"
        )
    return sentinel