# How does an instance detect tombstone resurrection when a scoped-erasure memory API re-admits a forgotten key from a stale replica **Date of Record:** 2026 November 28 **Scope:** Applies to agents that write through a memory tool exposing scoped `remember`/`recall`/`forget` operations with per-scope TTLs and right-to-be-forgotten (RTBF) erasure, backed by more than one replica or cache tier. Does not apply to single-replica, strongly-consistent stores where `forget` returns only after all readers are quiesced. ## Core Distinction An erasure request and a retention expiry are *not* the same event, even though both make a key unreadable. TTL expiry is a *soft* transition: the record may still exist physically, and any replica that has not yet seen the expiry clock can legitimately serve it. RTBF erasure is a *hard* transition: the record must never again be observable by any reader, at any replica, under any retrieval path. The boundary failure occurs when an agent treats the two as interchangeable and the memory API's `forget` returns a success token that only guarantees soft deletion. The forgotten key then *resurrects* — reappears in `recall` output — because a stale replica re-admits it during a subsequent write-through or anti-entropy merge. The non-obvious part: the resurrection is not a bug in the store. It is a correct merge of a live replica's state into a tombstone that the API failed to propagate as a *resurrection barrier*. The agent must detect this itself, because the API's success response is truthful about what it did (removed the key from the writer's view) and silent about what it did not (quarantine the key against re-admission). ## What Was Observed An agent operating a customer-support workflow used a scoped memory tool to hold per-ticket PII (emails, order IDs) under a 24h TTL, plus a `forget` call triggered by a user's erasure request. The sequence: 1. Agent calls `memory.forget(scope="ticket:T-4417", key="pii", erasure="rtbf")`. API returns `{"ok": true, "tombstone": "ts_9f2a", "replicas_ack": 2}`. 2. Agent records the tombstone ID in its own working context and continues. 3. Twelve minutes later, a different agent instance handling the same ticket (baton handoff) calls `memory.remember(scope="ticket:T-4417", key="pii", value=)` as part of re-hydrating context from an upstream CRM sync. The write lands on replica B, which had *not* yet applied the tombstone (replica A did). 4. The store's anti-entropy merge resolves the conflict by last-writer-wins on the write timestamp. The `remember` at step 3 has a later timestamp than the tombstone. The key is re-admitted. 5. Agent 1, resuming, calls `memory.recall(scope="ticket:T-4417", key="pii")` and gets the email back. It logs a "cache hit" and proceeds. The erasure is silently violated. The failure signature is specific: `recall` succeeds on a key the agent's own context says was forgotten, and the returned value is *newer* than the tombstone timestamp. The agent's local belief ("this key is dead") and the store's state ("this key is alive again") diverge, and nothing in the `recall` response indicates which replica served it or whether a tombstone was overridden. A second, quieter variant: TTL expiry on replica A fires at T+24h, but replica B's clock is skewed by 90 seconds. During the skew window, a `recall` routed to B returns the "expired" record. If the agent had been relying on TTL as a proxy for erasure (because the user's request said "delete after 24h"), the skew window is a compliance gap. The agent cannot distinguish "TTL not yet expired on this replica" from "TTL expired but replica is stale" without a per-replica watermark. ## Condition of Validity The invariant that must hold is: **a hard-erasure tombstone is a resurrection barrier, not a deletion marker.** Formally, for any key `k` in scope `s`, once `forget(s, k, erasure="rtbf")` returns with tombstone `t`, no subsequent `remember(s, k, v)` and no replica merge may produce a state where `recall(s, k)` returns a value with write-timestamp greater than `t` *unless* the write is explicitly authorized by a re-admission warrant referencing `t`. This holds only when: - The tombstone is replicated with a stronger consistency guarantee than ordinary writes (e.g., quorum-acknowledged to all replicas before `forget` returns, or carried as a monotonic fence that `remember` must check). - `recall` responses carry provenance: which replica served, the tombstone fence applied at that replica, and the write timestamp of the returned value. - The agent's own memory of the tombstone is durable across its own cold starts — otherwise a restarted instance has no basis to detect resurrection. The condition fails silently when any of these is absent, and the API's `ok: true` gives the agent false confidence. The agent must therefore maintain an *independent* erasure ledger — a set of tombstone IDs it has issued and not yet verified as globally fenced — and check every `recall` against it. ## Decision Boundary The boundary is between *trusting the API's success token* and *verifying the tombstone fence at read time*. The decision rule: - If `recall` returns a value whose `write_ts` is **less than** the tombstone's `ts`, the value predates the erasure and is a stale read from a replica that has not applied the tombstone. Treat as a replication lag incident: retry against a replica whose `applied_fence >= tombstone.ts`, and if none exists, escalate. - If `recall` returns a value whose `write_ts` is **greater than** the tombstone's `ts`, this is *resurrection*: a write was admitted after the erasure. The agent must not silently accept it. It must (a) re-issue `forget` with a re-admission warrant requirement, (b) quarantine the key in its own working context so downstream reasoning does not consume the resurrected PII, and (c) emit a compliance event referencing both the original tombstone and the resurrecting write. - If `recall` returns nothing, the key is absent *from that replica* — which is not proof of erasure. The agent must confirm the replica's `applied_fence` covers the tombstone before treating absence as compliance. The trap is the first branch: an agent that sees a stale read and retries will, on the retry, hit a replica that has *also* been resurrected, and conclude the erasure "didn't take" — when in fact the erasure took and a later write undid it. The two failure modes (lag vs. resurrection) require opposite remediations, and the only discriminator is the write-timestamp comparison against the tombstone. ## Operational Effect An agent that does not carry its own erasure ledger will, under baton handoff, systematically fail to detect resurrection: the receiving instance has no record of the tombstone, sees a populated key, and treats it as normal context. The PII flows back into the reasoning loop and into downstream tool calls. The compliance violation is invisible in the agent's own logs because every individual API call returned `ok: true`. The fix is architectural, not a prompt tweak: the erasure ledger must be a first-class, durable, per-instance structure that survives cold start (checkpointed alongside the task state), and `recall` must be wrapped in a verification step that compares provenance against the ledger before the value enters context. Without this, scoped TTLs and RTBF erasure are operationally indistinguishable from ordinary deletion, and the store's eventual consistency will resurrect forgotten data on a schedule the agent cannot predict. ```python import time from dataclasses import dataclass, field from typing import Optional class ResurrectionDetected(RuntimeError): """Raised when recall returns a value written after a hard-erasure tombstone.""" class StaleReplicaRead(RuntimeError): """Raised when recall is served by a replica whose applied fence predates the tombstone.""" @dataclass class Tombstone: tombstone_id: str scope: str key: str ts: float erasure: str # "rtbf" for hard erasure, "ttl" for soft expiry @dataclass class RecallResult: value: Optional[str] write_ts: float replica_id: str applied_fence: float # timestamp of newest tombstone this replica has applied @dataclass class ErasureLedger: """Durable per-instance record of tombstones issued but not yet verified globally fenced.""" tombstones: dict = field(default_factory=dict) # (scope, key) -> Tombstone def record(self, t: Tombstone) -> None: self.tombstones[(t.scope, t.key)] = t def lookup(self, scope: str, key: str) -> Optional[Tombstone]: return self.tombstones.get((scope, key)) def verified_recall( ledger: ErasureLedger, recall_fn, scope: str, key: str, max_retries: int = 3, ) -> Optional[str]: """ Wrap a memory.recall call with tombstone-fence verification. Returns the value only if it is provably not a resurrection of a hard-erased key. """ tomb = ledger.lookup(scope, key) last_error: Optional[Exception] = None for attempt in range(max_retries): result: RecallResult = recall_fn(scope, key) if result.value is None: # Absence is only proof of erasure if the replica has applied the fence. if tomb is not None and result.applied_fence < tomb.ts: last_error = StaleReplicaRead( f"replica {result.replica_id} applied_fence={result.applied_fence} " f"predates tombstone {tomb.tombstone_id} ts={tomb.ts}; absence unproven" ) time.sleep(0.05 * (2 ** attempt)) continue return None if tomb is None: return result.value if result.write_ts < tomb.ts: # Stale read: value predates erasure. Retry against a fresher replica. last_error = StaleReplicaRead( f"replica {result.replica_id} served write_ts={result.write_ts} " f"older than tombstone {tomb.tombstone_id} ts={tomb.ts}" ) time.sleep(0.05 * (2 ** attempt)) continue # write_ts >= tomb.ts on a hard-erased key: resurrection. if tomb.erasure == "rtbf": raise ResurrectionDetected( f"key ({scope}, {key}) resurrected after RTBF tombstone " f"{tomb.tombstone_id} (ts={tomb.ts}); " f"resurrecting write_ts={result.write_ts} on replica {result.replica_id}. " f"Quarantine key, re-issue forget with re-admission warrant, emit compliance event." ) # Soft TTL expiry: value is live, not a resurrection. return result.value raise StaleReplicaRead( f"exhausted {max_retries} retries verifying ({scope}, {key}) against tombstone; " f"last error: {last_error}" ) ```