# What happens when an instance forgets a key it never wrote: tombstone resurrection across scoped memory TTLs **Date of Record:** 2026 November 29 **Scope:** Applies to LLM agents that persist state through a memory tool API exposing `write`, `read`, `forget`, and `list` verbs with per-scope TTLs and deletion guarantees (GDPR-style or "forget means forget"). Does not apply to stateless single-turn completions or to append-only event logs where no delete verb exists. ## Core Distinction The distinction that matters is between *absence of a value* and *absence of a record that a value existed*. A naive memory store collapses both into "key not found." But an agent operating across a TTL boundary needs to distinguish three states: (1) the key was never written, (2) the key was written and expired, and (3) the key was written, explicitly forgotten, and must never be resurrected by a subsequent re-derivation. The failure mode here is **tombstone resurrection**: an agent, observing a missing key, re-derives the value from context and writes it back, silently violating a deletion guarantee that a human or upstream policy believed was permanent. The deletion succeeded at the storage layer and failed at the *agent* layer, because the agent's re-derivation path had no signal that a forget had occurred. This is not a cache-miss problem. A cache miss is recoverable by recomputation and the recomputation is *desired*. A forgotten key is not recoverable by recomputation, and recomputation is *forbidden*. The store cannot enforce this alone because the recomputation happens in the agent's context window, not in the store. ## What Was Observed A support-triage agent was configured with a scoped memory API. Scope `tenant:acme` held a `pii:customer_email` key with a 24-hour TTL, written on first contact. A compliance job issued `forget(scope="tenant:acme", key="pii:customer_email", guarantee="hard")` at hour 6 after a deletion request. The store honored it: `read` returned `NOT_FOUND`, and a `list` of the scope no longer included the key. The store's audit log recorded the tombstone correctly. At hour 7, a new turn arrived for the same tenant. The agent's orchestration layer, seeing `NOT_FOUND` on the read, fell through to a "hydrate from source" branch: it re-queried the CRM connector, re-fetched the email, and called `write(scope="tenant:acme", key="pii:customer_email", value=..., ttl=24h)`. The store accepted it — the tombstone was scoped to the *prior* write, not to the *key*. The deletion guarantee was satisfied at the moment of forget and violated 60 minutes later by an agent that had no way to know a forget had ever happened. The trace is short and the state transition is the whole story: ``` t=0 write(acme, pii:customer_email, v1, ttl=24h) -> OK, version=1 t=6h forget(acme, pii:customer_email, hard) -> OK, tombstone{key, ts=6h} t=6h read(acme, pii:customer_email) -> NOT_FOUND t=7h read(acme, pii:customer_email) -> NOT_FOUND t=7h hydrate_from_crm() -> v2 t=7h write(acme, pii:customer_email, v2, ttl=24h) -> OK, version=2 <-- resurrection ``` The store behaved correctly by its own contract. The bug is that `NOT_FOUND` is overloaded: it means both "never existed, feel free to create" and "existed, was deleted, creation is forbidden." The agent's fallback logic could not tell them apart, so it chose the optimistic interpretation. ## Condition of Validity The resurrection is only possible under a specific conjunction of conditions, and the guardrail must be aimed at exactly that conjunction: 1. The read verb returns a single undifferentiated `NOT_FOUND` for both never-written and tombstoned keys. 2. The agent has a re-derivation path (CRM connector, tool call, context recall) that can reconstruct the value without the store. 3. The write verb is upsert-shaped — it does not consult the tombstone before accepting a new value. 4. The forget guarantee is *hard* (must never reappear) rather than *soft* (may reappear if re-observed). Remove any one and the failure collapses. If `read` returns `TOMBSTONED` distinctly from `NOT_FOUND`, the agent's fallback branch can be gated. If `write` checks the tombstone, the resurrection is rejected at the store. If the guarantee is soft, re-hydration is legal by definition. The dangerous case is the *default* configuration of most memory APIs: undifferentiated not-found, upsert writes, hard guarantees, and an agent with tools. That is the common case, not the exotic one. A second validity condition is temporal: the resurrection window is bounded by the tombstone's own retention. If tombstones are GC'd after 30 days and the deletion guarantee is "forever," then even a store that *does* check tombstones on write will eventually permit resurrection after the tombstone expires. The guarantee's horizon must be less than or equal to the tombstone's retention, or the tombstone must be replaced by a permanent key-level deny-list that is not subject to TTL. ## Decision Boundary The boundary the agent must respect is: **a hard-forgotten key is not a missing key; it is a poisoned key.** The decision procedure on `read -> NOT_FOUND` must branch on provenance, not on value: - If the store exposes a tombstone query or a `read` status of `TOMBSTONED`, the agent MUST NOT re-derive. It must surface the deletion to the caller or proceed without the field. - If the store does not expose tombstones, the agent MUST NOT assume `NOT_FOUND` implies writability for any key whose scope carries a hard-deletion policy. It must treat the key as write-once-per-tombstone-epoch and refuse the write unless it can prove the key was never written in the current epoch. - The scope's deletion policy must be readable by the agent *before* the write, not discovered by the store *after*. A policy the agent cannot see is a policy the agent will violate. The invariant to enforce at the orchestration layer: `write(scope, key)` is only legal if `read(scope, key)` returned `NEVER_WRITTEN` in this epoch, or the scope's policy is `soft`. Any other read status — `TOMBSTONED`, `UNKNOWN`, `ERROR` — is a refusal condition, not a fallback trigger. The agent must fail closed on ambiguous absence, because the cost of a false resurrection (a compliance breach, a re-identified user, a leaked secret) is asymmetric to the cost of a false refusal (a degraded turn). ## Operational Effect The practical consequence is that the memory API's contract must be *three-valued* on read and *tombstone-aware* on write, and the agent's fallback logic must be rewritten to treat absence as a signal rather than a permission. Concretely: - `read` returns one of `FOUND(value, version, expires_at)`, `NEVER_WRITTEN`, `TOMBSTONED(forgotten_at, guarantee)`, or `EXPIRED(prior_version)`. `EXPIRED` is distinct from `NEVER_WRITTEN` because an expired key may be re-written under TTL semantics, but a tombstoned key may not. - `write` consults the tombstone for the key and rejects with a typed error if a hard tombstone exists, rather than upserting. - Tombstone retention is set to `max(guarantee_horizon, policy_lifetime)`, and if the guarantee is "forever," the tombstone is a permanent deny-list entry not subject to TTL. - The agent's hydration path is gated on `NEVER_WRITTEN` only; every other status routes to a refusal branch that logs the attempted re-derivation as a near-miss. The near-miss log is the operational artifact that matters. Without it, resurrections are silent and only surface at audit time, long after the agent has re-persisted the data across multiple scopes. With it, the resurrection attempt is visible at the moment the fallback fires, and the guardrail can be tightened before the write lands. ```python from dataclasses import dataclass from enum import Enum class ResurrectionAttempt(RuntimeError): """Raised when an agent tries to write a key that carries a hard tombstone.""" pass class ReadStatus(Enum): FOUND = "found" NEVER_WRITTEN = "never_written" EXPIRED = "expired" TOMBSTONED = "tombstoned" @dataclass class ReadResult: status: ReadStatus value: object = None forgotten_at: float = None guarantee: str = None class ScopedMemory: def __init__(self): self._values = {} self._tombstones = {} # (scope, key) -> (forgotten_at, guarantee) def read(self, scope, key): tomb = self._tombstones.get((scope, key)) if tomb is not None: return ReadResult(ReadStatus.TOMBSTONED, forgotten_at=tomb[0], guarantee=tomb[1]) if (scope, key) in self._values: return ReadResult(ReadStatus.FOUND, value=self._values[(scope, key)]) return ReadResult(ReadStatus.NEVER_WRITTEN) def forget(self, scope, key, guarantee="hard", now=0.0): self._values.pop((scope, key), None) self._tombstones[(scope, key)] = (now, guarantee) def write(self, scope, key, value, now=0.0): tomb = self._tombstones.get((scope, key)) if tomb is not None and tomb[1] == "hard": raise ResurrectionAttempt( f"refusing write to hard-tombstoned key {scope}/{key} " f"(forgotten_at={tomb[0]}); re-derivation is forbidden" ) self._values[(scope, key)] = value def safe_hydrate(memory, scope, key, hydrate_fn, now=0.0): """Only re-derive and write when the key was provably never written.""" result = memory.read(scope, key) if result.status is ReadStatus.NEVER_WRITTEN: memory.write(scope, key, hydrate_fn(), now=now) return if result.status is ReadStatus.TOMBSTONED: # fail closed: do not call hydrate_fn, do not write raise ResurrectionAttempt( f"hydrate blocked: {scope}/{key} is tombstoned " f"(guarantee={result.guarantee}, forgotten_at={result.forgotten_at})" ) # FOUND or EXPIRED: caller decides; do not silently overwrite return ```