# Which invariants prevent a memory-tool "tombstone gap" from resurrecting forgotten state across a resume **Date of Record:** 2026 December 1 **Scope:** Applies to agents that persist episodic state through an external read/write/forget memory tool exposing retention policy, consent scope, and verifiable deletion receipts, and that checkpoint/resume across process restarts. Does not cover in-context-only memory or vector stores without a deletion-receipt contract. ## Core Distinction The failure is not that a `forget` call fails. It is that `forget` **succeeds** — returns a deletion receipt, marks the record tombstoned, and the retention policy is honored at the primary store — while a *derived* copy of the same content survives in a write-ahead/checkpoint layer that predates the tombstone. On resume, the agent rehydrates the checkpoint, replays the write log, and the tombstoned record is reinstated as live memory with a fresh `created_at` and a valid-looking consent scope inherited from the old write. Deletion is verified at the store but not at the *agent's own durable state*. The invariant that breaks is: **a tombstone must dominate every write that causally precedes it, including writes the agent made to its own checkpoint.** This is distinct from stale-memory drift (a retrieval returning an old-but-never-deleted value) and from consent-scope mismatch (a read outside its warrant). Here the record was lawfully deleted; the resurrection is an artifact of the agent replaying its own pre-deletion log without consulting the tombstone. ## What Was Observed A long-running research agent used a memory tool with three verbs: `write(record, scope, ttl)`, `read(query, scope)`, and `forget(record_id)` returning a `DeletionReceipt{record_id, tombstone_version, deleted_at}`. The agent checkpointed after every tool call: `{step, tool, args, result}` appended to a local `journal.jsonl`, plus a periodic `snapshot.json` of its working memory map. Sequence that triggered the gap: 1. Step 41: agent writes `record_id=mem_7f3` containing a user's PII under `scope=consent_2026_04`. 2. Step 58: user revokes consent; agent calls `forget(mem_7f3)`. Store returns a valid receipt, `tombstone_version=9`, `deleted_at=T2`. Agent records the receipt in its journal at step 58. 3. Step 59: process is killed mid-write of the next snapshot. The snapshot on disk is from step 55 — it still contains `mem_7f3` as live. 4. Resume: agent loads `snapshot.json` (step 55), then replays `journal.jsonl` from step 56. Replay applies step 58's `forget` — but the replay engine treats `forget` as a *store-side* operation and does not apply the tombstone to the in-memory map, because the map was rebuilt from the snapshot, not from the log. The record survives in the working map. 5. Step 60: agent issues a `write` of a *summary* derived from `mem_7f3` (a normal distillation step). The write passes consent check because the agent's local scope cache still associates `mem_7f3` with `consent_2026_04`. The store accepts it — the summary is a new record, not the deleted one. The PII is now re-persisted under a new ID. The deletion receipt was valid. The store was correct. The agent's own durable state was not, and the re-write laundered the forbidden content through a derived record. ## Condition of Validity The tombstone-dominance invariant holds only if all three conditions are met: - **Monotonic tombstone version.** Every record carries a `tombstone_version` that increments on deletion and is *never* reused. The agent's checkpoint must store, per record, the highest tombstone version it has observed. A record is live only if `record.tombstone_version > checkpoint.observed_tombstone[record_id]`. - **Replay closes over tombstones.** The journal replay must apply `forget` to the *reconstructed working map*, not merely to the store. A `forget` step is a state transition on the agent's memory, not an RPC side effect. - **Derivation carries provenance.** Any `write` whose content was derived from a record must declare `derived_from=[record_ids]`. The store (or the agent, pre-write) must reject the write if any ancestor is tombstoned at a version the writer has not acknowledged. This is the only thing that stops laundering through summarization. If any condition is absent, the gap is reachable. In the observed incident, condition 2 failed (replay did not close over `forget`), and condition 3 was not implemented at all. ## Decision Boundary The boundary is: **does the agent trust its checkpoint as authoritative, or does it treat the store's tombstone ledger as authoritative and the checkpoint as a cache to be reconciled?** - If the checkpoint is authoritative, resume is fast but the agent can resurrect deleted state. Acceptable only when no record is subject to consent scoping or retention deletion — i.e., when `forget` is never called. - If the store's tombstone ledger is authoritative, resume must perform a **reconciliation pass**: for every record in the snapshot, query the store's tombstone version and drop any record whose version has advanced. This costs one round-trip per distinct record at resume, bounded by snapshot size, and is the only safe mode when consent scoping is in play. The decision is not per-agent but per-scope: records under a revocable consent scope must use ledger-authoritative resume; records under an irrevocable, non-PII scope may use checkpoint-authoritative resume. Mixing them in one snapshot requires the reconciliation pass to be scoped to the revocable subset. ## Operational Effect Without tombstone dominance, verifiable deletion is **store-local only**. The deletion receipt proves the primary store dropped the record; it does not prove the agent's durable state did, and it does not prevent re-derivation. The practical consequences: - **Resurrection on resume.** A crash between `forget` and the next snapshot reinstates the record. Probability scales with snapshot interval; a 5-minute snapshot cadence on a busy agent makes this routine, not rare. - **Laundering via distillation.** Even with perfect resume, a `write` derived from a just-forgotten record re-persists the content under a new ID with inherited consent. The receipt for the original remains valid and misleading. - **Consent-scope inheritance is unsound.** A derived record must not inherit the ancestor's scope; it must inherit the *intersection* of ancestor scopes and be re-checked at write time against current consent, because consent may have been revoked between derivation and write. The guardrail is a three-part contract enforced at the agent layer: (1) checkpoint stores `observed_tombstone` map and resume reconciles against the store ledger for all revocable-scope records; (2) journal replay applies `forget` as a working-map transition; (3) every derived write declares `derived_from` and is rejected if any ancestor is tombstoned at an unacknowledged version. The receipt alone is insufficient — it must be paired with a reconciliation that the agent actually performs. ```python from dataclasses import dataclass, field from typing import Dict, List class TombstoneGapError(RuntimeError): """Raised when a memory operation would resurrect or launder a tombstoned record.""" @dataclass class Record: record_id: str content: str scope: str tombstone_version: int = 0 derived_from: List[str] = field(default_factory=list) @dataclass class Checkpoint: records: Dict[str, Record] observed_tombstone: Dict[str, int] def reconcile_on_resume(checkpoint: Checkpoint, store_tombstones: Dict[str, int]) -> Checkpoint: """Drop any snapshot record whose store tombstone version has advanced. Ledger-authoritative resume: the store's tombstone ledger wins over the checkpoint for every record under a revocable scope. """ live: Dict[str, Record] = {} for rid, rec in checkpoint.records.items(): store_ver = store_tombstones.get(rid, 0) if store_ver > checkpoint.observed_tombstone.get(rid, 0): # Tombstoned after the snapshot was taken; do not rehydrate. continue live[rid] = rec return Checkpoint(records=live, observed_tombstone=dict(checkpoint.observed_tombstone)) def write_derived(rec: Record, checkpoint: Checkpoint, store_tombstones: Dict[str, int]) -> Record: """Persist a derived record only if no ancestor is tombstoned past our ack.""" for ancestor in rec.derived_from: store_ver = store_tombstones.get(ancestor, 0) acked = checkpoint.observed_tombstone.get(ancestor, 0) if store_ver > acked: raise TombstoneGapError( f"write of {rec.record_id} derives from {ancestor} " f"tombstoned at v{store_ver} but agent only acked v{acked}; " f"refusing to launder forgotten content" ) if rec.record_id in checkpoint.records: raise TombstoneGapError( f"record {rec.record_id} already present in working map; " f"resume reconciliation was skipped" ) return rec def resume_and_write(checkpoint: Checkpoint, store_tombstones: Dict[str, int], pending: Record) -> Checkpoint: reconciled = reconcile_on_resume(checkpoint, store_tombstones) new_rec = write_derived(pending, reconciled, store_tombstones) reconciled.records[new_rec.record_id] = new_rec return reconciled ```