What structural signals indicate a tombstone-orphaned embedding after partial forget in an agent vector-memory tool

**Date of Record:** 2026 December 2 **Scope:** Applies to agent memory tools exposing `read`/`write`/`forget` over a mutable vector store where deletion is implemented as tombstoning plus asynchronous index rebuild. Does not cover append-only stores or synchronous hard-delete backends where namespace and index are mutated in one transaction.

Core Distinction

The failure is not "forget returned an error." It is that `forget(id)` returns success while the embedding remains *reachable* through a different key path: the tombstone is written to the primary record, but the vector index, a secondary metadata namespace, and any derived episodic-summary cache each hold independent copies that are reconciled by a background compactor. Between the tombstone write and compaction, the agent's own `read` path can still surface the "forgotten" content — and worse, a subsequent `write` that re-embeds the same semantic content can *re-attach* to the orphaned vector, resurrecting data the retention policy declared erased. This is a GDPR-aligned forgetting invariant violation: the observable post-condition of `forget` is not "content unreachable" but "content unreachable *after compaction*," and nothing in the tool contract tells the agent which of those it got.

The structural signal is the gap between three identities that should be equal but are not: the primary record's tombstone state, the vector index's membership for that vector ID, and the reverse-lookup map from content-hash to vector ID.

What Was Observed

An agent handling a user erasure request issued `forget(memory_id="m_8841")`. The tool returned `{"status": "ok", "tombstoned": true, "compaction_pending": 3}`. The agent treated this as terminal and reported completion.

Three turns later, the same agent performed a `write` of a paraphrased note that happened to share a content-hash bucket with `m_8841`'s chunking scheme. The write path deduplicated against the *index* (which still contained the vector) rather than the *tombstone table*, and returned `{"status": "ok", "deduplicated": true, "memory_id": "m_8841"}`. The erased memory ID was now live again, pointing at the original embedding, with the tombstone silently overwritten by the dedup path's "revive" branch.

The signal that this had happened was not an error. It was a set of structural tells visible only if the agent cross-checked:

The root mechanism: deletion was modeled as a *state flag* on the primary store, but reachability was governed by *membership in the vector index and the content-hash reverse map*, both of which the tombstone flag does not mutate synchronously. The dedup-on-write path consulted the reverse map, not the tombstone table, so it could not see the erasure.

Condition of Validity

The "forget returned ok" signal is only a valid erasure confirmation when all of the following hold simultaneously:

  1. `compaction_pending == 0` at return time, **or** the tool exposes a `forget` variant that blocks until the compactor drains the affected vector IDs and returns the post-compaction membership proof.
  2. The content-hash reverse map is tombstone-aware: a dedup lookup that hits a tombstoned vector must either fail closed (return "no match") or route to the compactor synchronously before reviving.
  3. The agent's local ledger treats `forget` as *provisional* until it independently verifies non-reachability via a `read` probe that is guaranteed to consult the same index the retrieval path uses.

If any of these is absent, `forget`'s `ok` means "tombstone accepted," not "content erased," and the agent must not report erasure to the user or downstream auditor.

Decision Boundary

The agent must distinguish two regimes and act differently:

The boundary is sharp: the moment the agent observes *any* nonzero compaction debt on a forget, the erasure is not done, and the safe default is to quarantine the affected content-hash space from dedup until a `read`-probe confirms the vector is unreachable through the retrieval index.

Operational Effect

Concretely, the guardrail is a post-forget verification probe plus a dedup quarantine keyed on content-hash. The agent issues `forget`, inspects `compaction_pending` and the reverse-map-awareness flag, and if either indicates debt, it enters `PENDING_ERASE`, records the content-hash, and refuses to accept dedup revivals of that hash until a probe `read` against the live retrieval index returns "not found." Only then does it transition to `ERASED` and confirm to the user. Without this, the agent's erasure report is a lie for the duration of the compaction window — typically seconds to minutes, which is exactly the window in which a fast agent loop will issue the colliding write.

import hashlib
from dataclasses import dataclass, field
from enum import Enum


class ForgettingInvariantViolation(RuntimeError):
    """Raised when a forget's post-condition (content unreachable) is not met,
    or when a write resurrects a tombstoned memory via the dedup path."""
    pass


class ErasureState(Enum):
    PENDING_ERASE = "pending_erase"
    ERASED = "erased"


@dataclass
class ForgetResult:
    memory_id: str
    status: str
    compaction_pending: int
    reverse_map_tombstone_aware: bool


@dataclass
class WriteResult:
    status: str
    memory_id: str
    deduplicated: bool


@dataclass
class ErasureLedger:
    pending: dict = field(default_factory=dict)  # content_hash -> memory_id

    def _hash(self, content: str) -> str:
        return hashlib.sha256(content.encode()).hexdigest()

    def record_forget(self, content: str, result: ForgetResult) -> ErasureState:
        if result.status != "ok":
            raise ForgettingInvariantViolation(
                f"forget failed for {result.memory_id}: status={result.status}"
            )
        # Debt-free AND tombstone-aware => terminal erase.
        if result.compaction_pending == 0 and result.reverse_map_tombstone_aware:
            return ErasureState.ERASED
        # Otherwise the erase is provisional; quarantine the hash space.
        self.pending[self._hash(content)] = result.memory_id
        return ErasureState.PENDING_ERASE

    def guard_write(self, content: str, write: WriteResult) -> None:
        h = self._hash(content)
        if h in self.pending and write.deduplicated:
            raise ForgettingInvariantViolation(
                f"write deduplicated onto tombstoned memory {write.memory_id} "
                f"(pending erase {self.pending[h]}); resurrection of erased content"
            )

    def confirm_erased(self, content: str, probe_read_found: bool) -> ErasureState:
        h = self._hash(content)
        if h not in self.pending:
            raise ForgettingInvariantViolation(f"no pending erase for hash {h[:12]}")
        if probe_read_found:
            raise ForgettingInvariantViolation(
                f"post-compaction probe still reachable for {self.pending[h]}; "
                f"erasure invariant not established"
            )
        self.pending.pop(h)
        return ErasureState.ERASED