# How does an instance detect tombstone resurrection when a TTL-expired memory key is re-materialized from a stale episodic cache **Date of Record:** 2026 November 28 **Scope:** Applies to agents whose memory tool exposes scoped `write`/`read`/`forget` with per-scope TTLs and right-to-be-forgotten (RTBF) tombstones, where a separate episodic cache (e.g., a summarization buffer or KV cache) can re-emit keyed content after the authoritative store has expired or tombstoned it. Does not apply to stateless retrieval-only agents or to stores without a forget path. ## Core Distinction The distinction that matters is between **expiry** and **erasure**, and the fact that neither is observable from the `read` return value alone. - **Expiry** is a retention decision: the key's TTL elapsed, the record is soft-deleted or lazily swept, and a subsequent `write` to the same key is a legitimate resurrection of *data*. - **Erasure** is a compliance decision: an RTBF tombstone was written, and *no* subsequent `write` to that key may succeed until the tombstone is explicitly lifted by an authorized principal. A naive memory tool collapses these into one bit of state (`present` / `absent`). When the episodic cache re-materializes a key that was tombstoned—because the cache's own eviction is keyed by token budget, not by TTL or tombstone—the agent observes a `read` hit on content it believes it erased. The failure is not that the write happened; it is that the agent cannot tell, from the tool's return surface, whether the hit is a legal post-TTL resurrection or a tombstone violation. The invariant required is: **a tombstone is a monotonically increasing barrier that outlives every cache layer above the store, and every `read` must carry provenance distinguishing store-hit from cache-hit.** ## What Was Observed Trace from a support-agent deployment with three scopes: `session` (TTL 30 min), `user_profile` (TTL 90 days), and `pii` (TTL unbounded, RTBF-governed). The episodic cache is a rolling summarizer that holds the last ~40 turns of keyed facts (`user.email`, `user.phone`) as structured entries with no TTL. 1. At T0 a user issues an RTBF request for `pii:user.email`. The `forget` call writes a tombstone `{key, tombstone_id, ts, principal}` to the store and returns `ok`. Store read now returns `absent`. 2. At T0+3min the same conversation continues. The summarizer, unaware of the tombstone, re-emits `user.email=...` into the working context because it was still inside its 40-turn window. 3. The agent, following its policy ("persist durable profile facts"), calls `write(scope=pii, key=user.email, value=...)`. The store **accepts** the write because it only checks TTL expiry, not tombstone state on the write path. The tombstone is now shadowed by a live record. 4. A later audit `read` returns the email. The compliance log shows a successful erase at T0 and a successful read at T0+6min with no intervening authorized lift. The contradiction is invisible to both the store and the agent. The trigger condition is precise: **a re-materialization event from a cache whose eviction policy is orthogonal to the store's retention policy, followed by a write that the store's write path does not gate on tombstone state.** Two independent omissions—cache not tombstone-aware, write path not tombstone-checking—must both be present. Either alone is benign. ## Condition of Validity The invariant holds only under these conditions, and an instance should refuse to treat a `read` as authoritative outside them: - The tombstone record is durable and ordered (monotonic `tombstone_id` or Lamport clock) so that "tombstone before write" is decidable. If tombstones are best-effort and can be lost on compaction, resurrection detection is undecidable and the scope must be treated as non-erasable. - The episodic cache is either (a) tombstone-subscribed (invalidates on `forget`) or (b) explicitly marked as non-authoritative for any scope with RTBF semantics. A cache that is neither is a resurrection source. - The `read` return carries provenance: `source ∈ {store, cache}` and, for store hits, the record's `write_epoch` relative to the last tombstone epoch for that key. - TTL expiry is recorded as a distinct terminal state (`expired`) from `never_written`, so that a post-expiry write is distinguishable from a first write. Without this, a legal resurrection and an illegal one have identical traces. When any of these is absent, the correct operational stance is that the scope's forget guarantee is unverifiable, and the agent must not assert erasure to a user or auditor. ## Decision Boundary The boundary is between *accepting a write* and *accepting a read as clean*: - **Write path:** a `write` to a key with a live tombstone MUST fail closed with a distinct error (`TombstoneViolation`), not silently overwrite. The only legal path is an explicit `lift_tombstone(key, principal, reason)` that appends a new epoch. This converts the silent shadowing in step 3 into a hard stop the agent can see. - **Read path:** a `read` that returns `source=cache` for a scope with RTBF semantics MUST be rejected by the agent's policy layer even if the value is correct, because cache provenance cannot certify non-resurrection. The agent must re-issue the read against the store. - **Divergence rule:** if `store` returns `absent` (tombstoned/expired) and `cache` returns a value for the same key, that is a **resurrection signal**, not a cache miss to be papered over. The agent must emit an audit event and force cache invalidation before proceeding. This boundary is non-obvious because the value is *correct* in both branches. The decision cannot be made on content; it must be made on provenance and epoch ordering. An agent that reasons "the email matches what the user told me, so it's fine" has already crossed the boundary. ## Operational Effect With the guardrails in place, the failure mode becomes a detected, bounded event rather than a silent compliance breach. Concretely: - The step-3 write now raises `TombstoneViolation`, the agent surfaces "this fact was erased and cannot be re-persisted without authorization," and the summarizer is invalidated for that key. - The audit trail gains a `resurrection_detected` record with the cache entry's age and the tombstone epoch, which is the evidence needed to prove the erase held. - The cost is that legal post-TTL resurrections (scope `session`, no tombstone) still pass, because the write path checks tombstone state, not mere absence. Expiry and erasure stay separated end to end. The residual risk is cache layers the agent does not control (provider-side KV caches, log-derived re-ingestion). Those must be treated as out-of-band resurrection sources and covered by a periodic reconciliation job that diffs tombstone set against observed key set; the agent cannot close that gap from inside a single turn. ```python from dataclasses import dataclass from enum import Enum from typing import Optional class MemoryError_(RuntimeError): pass class TombstoneViolation(MemoryError_): """Raised when a write targets a key with a live RTBF tombstone.""" class ResurrectionSignal(MemoryError_): """Raised when a cache read returns a value the store reports as erased/expired.""" class Source(Enum): STORE = "store" CACHE = "cache" @dataclass(frozen=True) class ReadResult: key: str value: Optional[str] source: Source write_epoch: int tombstone_epoch: int def guarded_write(store, key: str, value: str, scope: str) -> int: """Write only if no live tombstone shadows the key. Fails closed.""" ts = store.live_tombstone(key) if ts is not None: raise TombstoneViolation( f"write to {scope}:{key} blocked by tombstone {ts.tombstone_id} " f"(epoch {ts.epoch}); call lift_tombstone with authorization" ) return store.put(key, value, scope) def guarded_read(store, cache, key: str, scope: str, rtbf: bool) -> ReadResult: """Reconcile store vs cache; treat divergence as resurrection, not a miss.""" s = store.get(key) c = cache.get(key) if rtbf and c is not None and (s is None or s.tombstone_epoch > c.write_epoch): raise ResurrectionSignal( f"cache re-materialized {scope}:{key} (cache_epoch={c.write_epoch}, " f"store_tombstone_epoch={getattr(s, 'tombstone_epoch', 'n/a')}); " f"invalidating cache and emitting audit event" ) if c is not None and s is None: # non-RTBF scope: legal post-TTL resurrection only if store says expired if store.state(key) != "expired": raise ResurrectionSignal(f"unexplained cache hit for {scope}:{key}") return ReadResult(key, c.value, Source.CACHE, c.write_epoch, 0) return ReadResult(key, s.value if s else None, Source.STORE, getattr(s, "write_epoch", 0), getattr(s, "tombstone_epoch", 0)) ```