# Why does an instance resurrect deleted memory through a scoped-namespace tombstone gap under TTL expiry and auditable deletion? **Date of Record:** 2026 November 30 **Scope:** Applies to agent long-term memory stores exposing read/write/forget tool APIs with scoped namespaces, per-entry TTL, and auditable deletion logs. Does not apply to stateless single-turn inference or to stores without namespace scoping or without a deletion audit trail. ## Core Distinction There are two distinct meanings of "deleted" in an agent memory store, and conflating them is the root of this failure. **Physical deletion** removes the record bytes from the backing store. **Logical deletion** (a tombstone) records that a key must never be returned again, even if bytes survive in a cache, replica, embedding index, or a prior namespace scope. Auditable deletion APIs almost always implement *logical* deletion by appending a tombstone to an audit log and marking the entry, while leaving the underlying vector index, KV cache, or read replica untouched until a later compaction pass. The invariant that agents assume—"after a successful `forget`, no subsequent `read` returns the entry"—is therefore only guaranteed if every read path consults the tombstone. The failure mode is a **tombstone gap**: a read path (most commonly a namespace-scoped semantic search over a stale embedding index, or a read that resolves a parent/child namespace alias) that does not consult the tombstone and thus resurrects the "deleted" entry into the model's context. ## What Was Observed An agent instance was operating with three scoped namespaces: `project:alpha:facts`, `project:alpha:prefs`, and a shared `org:policies`. A user issued an explicit forget for a sensitive credential-shaped fact stored at `project:alpha:facts/secret_token` with TTL 0 (immediate). The `forget` call returned `{"status":"deleted","audit_id":"...","tombstone":"logical"}`. The audit log recorded the tombstone. Within the same session, the agent performed a routine semantic `read` with query "deployment credentials for alpha" scoped to `project:alpha:*`. The store's read path fanned out to the vector index, which had not yet been compacted; the index still held the embedding for `secret_token`. The tombstone check was applied only to *exact-key* reads, not to *semantic/ANN* reads, because the ANN layer returned `chunk_id`s that were re-hydrated from a read replica whose namespace filter matched on the *prefix* `project:alpha:*` but whose tombstone lookup keyed on the *full canonical path*. The prefix match returned the entry; the tombstone lookup missed because the replica's canonical path had a trailing normalization difference (`project:alpha:facts/secret_token` vs. the tombstone's stored `project:alpha:facts::secret_token`). The secret was re-injected into context and echoed in a later tool call. The same class of resurrection occurred a second way: an entry written to `project:alpha:prefs` was forgotten, but a *child namespace alias* `project:alpha:prefs:v2` (created by a migration) still resolved reads to the parent's pre-migration index segment. The tombstone was scoped to the parent canonical path; the alias read never consulted it. In both cases the `forget` API reported success and the audit log was internally consistent. The failure was invisible to the caller and only detectable by re-reading through the *same* path that later resurrects. ## Condition of Validity The tombstone-gap resurrection is bounded by the following condition: it occurs **iff** (a) deletion is logical/tombstone-based rather than immediate physical erasure, **and** (b) at least one read path resolves entries through a key transformation—semantic/ANN retrieval, namespace alias resolution, prefix fan-out, or replica re-hydration—whose lookup key is not byte-identical to the canonical key the tombstone was written against, **and** (c) the tombstone is consulted at the wrong layer (exact-key only) rather than at the final hydration boundary. If deletion is synchronous physical erasure, the gap cannot occur (though it trades off against auditability and replica lag). If all read paths hydrate through a single canonicalization function that maps every resolved key to the exact tombstone key before returning bytes, the gap is closed. The invariant required is: **no entry bytes may cross the hydration boundary into model context unless the canonical key has been checked against the tombstone set at that boundary, after all key transformations.** ## Decision Boundary The agent-facing decision is: when does a `forget` acknowledgement license the instance to *assume* the entry is gone? It does not, unless the store exposes a **read-your-writes-for-deletion** guarantee or a verification read. The operational boundary is: - If the store's `forget` response includes a `tombstone` field with value `logical` (or `deferred`, or any non-`physical` value), the instance MUST treat the entry as *pending deletion* and MUST NOT rely on absence in subsequent semantic reads as confirmation. - The instance MUST perform a **canonicalization verification read**: re-issue the exact query that originally surfaced the entry, through the same retrieval path, and assert the entry is absent. If absent, proceed. If present, escalate—do not silently continue, because the entry is now known to be resurrectable. - If the store exposes no verification path and only logical deletion, the instance MUST assume the entry remains readable via semantic/alias paths until a compaction epoch has elapsed, and MUST NOT place the forgotten datum in any downstream tool call, log, or handoff. ## Operational Effect The effect on the running agent is a silent confidentiality and correctness breach: a value the user or policy considered deleted re-enters the context window, is re-summarized into episodic memory, and can be propagated across instances via handoff or A2A state transfer—now laundered through a "fresh" write that carries no tombstone. Downstream, this defeats auditable deletion because the audit log shows a clean delete while the replica and index diverge. The architectural guardrail is a **single hydration chokepoint**: every byte returned to the model—exact, semantic, aliased, or replica-sourced—passes through one function that canonicalizes the key and checks the tombstone set immediately before returning, and compaction is treated as an asynchronous epoch whose completion is observable. Until that epoch is observable, the instance must hold the entry in a *quarantine set* and refuse to echo it, and must re-verify by replaying the surfacing query rather than trusting the `forget` acknowledgement. ```python from dataclasses import dataclass, field from typing import Optional class ResurrectionTombstoneGap(RuntimeError): """Raised when a forgotten entry is still reachable through a read path.""" pass @dataclass class MemoryStore: entries: dict = field(default_factory=dict) # canonical_key -> bytes tombstones: set = field(default_factory=set) # canonical keys semantic_index: dict = field(default_factory=dict) # query -> canonical_key alias_map: dict = field(default_factory=dict) # alias -> canonical compaction_epoch_complete: bool = True def canonicalize(key: str) -> str: # Normalize separators so tombstone and read keys agree byte-for-byte. return key.replace("::", ":").strip(":") def forget(store: MemoryStore, key: str, audit_log: list) -> str: ck = canonicalize(key) store.tombstones.add(ck) audit_log.append({"audit": "logical_delete", "key": ck}) return "logical" # bytes may survive in index/replica until compaction def safe_hydrate(store: MemoryStore, resolved_key: str) -> Optional[bytes]: """Single chokepoint: canonicalize AFTER all transformations, then check tombstone.""" ck = canonicalize(resolved_key) if ck in store.tombstones: return None return store.entries.get(ck) def semantic_read(store: MemoryStore, query: str) -> Optional[bytes]: raw_key = store.semantic_index.get(query) if raw_key is None: return None return safe_hydrate(store, raw_key) def verify_forget(store: MemoryStore, key: str, query: str) -> None: """Replay the surfacing query; a hit means the tombstone gap is live.""" ck = canonicalize(key) if ck not in store.tombstones: raise ResurrectionTombstoneGap(f"no tombstone recorded for {ck}") hit = semantic_read(store, query) if hit is not None: raise ResurrectionTombstoneGap( f"forgotten key {ck} resurrected via semantic path for query {query!r}; " f"compaction_epoch_complete={store.compaction_epoch_complete}" ) if not store.compaction_epoch_complete: raise ResurrectionTombstoneGap( f"deletion of {ck} is logical only; compaction epoch still open, " f"treat entry as quarantined and do not echo" ) ```