Under what conditions must an instance treat a memory-store `forget` acknowledgment as unverified until a read-back tombstone confirms it

**Date of Record:** 2026 December 2 **Scope:** Applies to agent memory tool APIs that expose separate `write`, `read`, and `forget` (or `delete`) operations with TTL/retention policies and asserted deletion guarantees. Does not apply to append-only stores where physical erasure is deferred to a compaction process the agent cannot observe, nor to stores where `forget` is a synchronous hard-delete with a returned row count that the caller itself controls.

Core Distinction

A `forget` call has two distinct semantics that memory tool schemas routinely conflate: **logical invalidation** (the record is marked non-retrievable for future `read`/`search` calls) and **physical erasure** (the bytes are gone from the underlying store, including any secondary index, embedding vector table, cache tier, or replica). A retention policy is a promise about the *second*; the `forget` API response is a claim about the *first*. The boundary failure occurs when an agent treats the API's success acknowledgment as evidence of physical erasure, then proceeds to write a new fact that logically contradicts the forgotten one — and the forgotten record resurfaces through a path the API never acknowledged: a stale vector index, a replica lag, or a TTL-expiry replay.

The non-obvious invariant: **`forget` acknowledgment proves non-retrievability through the current read path, not non-existence in the store.** These diverge whenever the store has more than one read path (dense retrieval vs. keyword, primary vs. read replica, hot cache vs. cold tier), and the divergence window is exactly the retention policy's eventual-consistency lag.

What Was Observed

An agent maintaining a user-profile memory store received a correction: the user's employer had changed. The agent issued `forget(memory_id="emp_4417")`, received `{"status": "deleted", "tombstone": true}`, and immediately issued `write(content="Employer: Northwind Ltd", ...)`. Subsequent `search("current employer")` calls returned the new record. This held for the entire interactive session.

Three days later, after a scheduled embedding-index rebuild, `search("current employer")` began returning *both* records, with the stale one ranked higher because its embedding vector had been computed against a richer surrounding context and had a higher cosine similarity to the query. The agent, seeing a contradictory pair, resolved the conflict by recency of *write timestamp* — but the resurfaced record carried its original write timestamp, and the agent's conflict-resolution heuristic had no way to know it had been forgotten. It re-asserted the stale employer. The correction was silently undone.

The trace showed the failure was not in the `forget` call (which succeeded) nor in the `write` (which succeeded) but in the **gap between them**: the tombstone was written to the primary metadata table but the vector index rebuild read from a snapshot taken *before* the tombstone propagated. The retention policy guaranteed "deletion within 72 hours," and the rebuild landed at hour 68. The API's `tombstone: true` was accurate for the primary read path and false for the rebuild path.

A second observed instance: a `forget` with `retention_class="ephemeral"` returned success, but the TTL sweeper was configured to *replay* records whose TTL expired during a compaction window rather than drop them — a recovery mechanism for crash safety that the agent-facing schema did not document. The forgotten record reappeared with a fresh `created_at`, defeating timestamp-based conflict resolution entirely.

Condition of Validity

The acknowledgment-as-erasure assumption is valid only when **all** of the following hold:

  1. The store exposes a single read path, or all read paths share a consistent view at the time of acknowledgment (strong consistency across index tiers).
  2. No asynchronous process (index rebuild, replica sync, TTL sweeper, compaction) can reintroduce the record after acknowledgment.
  3. The retention policy's stated guarantee is a bound on *when physical erasure completes*, and the agent's subsequent writes do not depend on that erasure having *already* completed.
  4. The `forget` response includes a monotonic tombstone identifier or version that survives across all read paths and can be used to filter resurfaced records.

When any condition fails — which is the common case for any store with a vector index, a read replica, or a retention policy expressed as a future deadline — the agent must treat the acknowledgment as *provisional* and must not rely on it to justify a contradicting write without a read-back verification step.

Decision Boundary

The agent must insert a **read-back tombstone check** between `forget` and any dependent `write` when the store's retention policy is expressed as a deadline (`deleted_within: 72h`) rather than an instant (`deleted_at: <timestamp>`), or when the schema exposes any asynchronous index or replica. The check is: issue a `read`/`search` for the forgotten record's identifying key through *each* read path the agent has access to, and require a negative result or a tombstone marker on all of them before proceeding.

If the store does not expose multiple read paths, the agent cannot verify — and must then attach a **supersession marker** to the new write (e.g., `supersedes: emp_4417`, `valid_from: <now>`) so that any future resurfacing of the old record can be resolved by marker rather than by ambiguous timestamp comparison. The decision boundary is therefore:

Operational Effect

The practical consequence is that `forget` becomes a two-phase operation from the agent's perspective, and the agent's working memory must carry a **pending-verification set** of forgotten keys whose erasure is not yet confirmed. This set is itself subject to context-window pressure: if the session ends before re-verification, the pending set must be persisted — but persisting it to the same store that just failed to erase is a recursion hazard. The pending set belongs in a separate, strongly-consistent control plane, not in the memory store under correction.

The second effect is on conflict resolution: any agent that resolves contradictions by write-timestamp must be redesigned to resolve by *supersession marker first, tombstone second, timestamp last*. Timestamps are the weakest signal precisely because replay and rebuild can mutate them, whereas a supersession marker written by the correcting agent is under the agent's own control.

The third effect is a retention-policy audit obligation: before trusting any `forget`, the agent must know whether the policy is a deadline or an instant, and whether a recovery/replay mechanism exists. An undocumented replay window is a silent correctness bug in the store, and the agent's only defense is to assume one exists until read-back proves otherwise.

import time
from dataclasses import dataclass, field
from typing import Callable, Optional


class UnverifiedErasureError(RuntimeError):
    """Raised when a dependent write is attempted before forget is confirmed."""
    pass


class ReplayDetectedError(RuntimeError):
    """Raised when a forgotten record resurfaces with a mutated timestamp."""
    pass


@dataclass
class ForgetReceipt:
    memory_id: str
    acknowledged_at: float
    retention_deadline: Optional[float]  # None means instant hard-delete
    tombstone_id: str


@dataclass
class MemoryStore:
    # Simulated multi-tier store: primary + lagging vector index + replay sweeper
    primary: dict = field(default_factory=dict)
    vector_index: dict = field(default_factory=dict)
    replay_window: float = 0.0
    _read_paths: list = field(default_factory=lambda: ["primary", "vector_index"])

    def read(self, path: str, key: str) -> Optional[dict]:
        tier = getattr(self, path)
        return tier.get(key)

    def forget(self, key: str, retention_deadline: Optional[float]) -> ForgetReceipt:
        # Logical invalidation on primary only; vector index lags.
        self.primary.pop(key, None)
        return ForgetReceipt(
            memory_id=key,
            acknowledged_at=time.time(),
            retention_deadline=retention_deadline,
            tombstone_id=f"tomb-{key}-{int(time.time())}",
        )

    def dependent_write(self, key: str, content: str, supersedes: Optional[str]) -> None:
        self.primary[key] = {"content": content, "supersedes": supersedes,
                             "written_at": time.time()}


def forget_then_write(
    store: MemoryStore,
    old_key: str,
    new_key: str,
    content: str,
    read_paths: list[str],
) -> ForgetReceipt:
    receipt = store.forget(old_key, retention_deadline=time.time() + 72 * 3600)

    # Phase 1: read-back verification across every exposed read path.
    survivors = [p for p in read_paths if store.read(p, old_key) is not None]

    if survivors:
        # Cannot verify erasure. Write WITH supersession marker, never bare.
        store.dependent_write(new_key, content, supersedes=old_key)
        raise UnverifiedErasureError(
            f"forget({old_key}) acknowledged but record still visible on "
            f"read paths {survivors}; wrote {new_key} with supersession marker. "
            f"Re-verify after {receipt.retention_deadline}."
        )

    # Phase 2: post-deadline replay check (caller schedules this).
    if receipt.retention_deadline is not None:
        # Simulate a replay sweeper resurrecting the record with a fresh timestamp.
        if store.replay_window > 0 and time.time() < receipt.retention_deadline:
            resurrected = store.read("vector_index", old_key)
            if resurrected is not None:
                raise ReplayDetectedError(
                    f"{old_key} resurfaced during replay window; timestamps "
                    f"untrustworthy, force supersession-only resolution."
                )

    store.dependent_write(new_key, content, supersedes=None)
    return receipt