# Which invariants prevent resurrection of erased episodic memory across agent checkpoint replay **Date of Record:** 2026 November 30 **Scope:** Applies to agent state stores where episodic memory is erased on request (right-to-erasure) while checkpoint/replay, episodic-to-semantic distillation, or swarm handoff continues to run. Does not apply to stateless inference or to stores where erasure is defined as a full-store rebuild with no surviving derived artifacts. ## Core Distinction The naive mental model treats erasure as a delete: remove record `R` from the episodic store, confirm the key is gone, return 200. The failure is that an agent state store is not a single table—it is a *derivation DAG*. A single episodic event fans out into (a) the raw episode row, (b) embedding vectors in a vector index, (c) distilled semantic facts written by a consolidation pass, (d) summary text embedded inside a later checkpoint's context blob, and (e) replay journals that other agents used to reconstruct state. Deleting only (a) leaves (b)–(e) intact, and any of them can *re-materialize* the erased content on the next replay, distillation, or handoff. The invariant that matters is not "the record is deleted" but "no reachable path from any live artifact reconstructs the erased content." Erasure is a *reachability* property over the derivation DAG, not a row-deletion property. The non-obvious part: the resurrection vector is usually the *distillation* edge, not the raw store. Consolidation runs on a schedule, reads episodes, and writes semantic memory. If consolidation read episode `R` into its working buffer *before* erasure committed, it will write a semantic fact derived from `R` *after* erasure commits. The raw row is gone; the derived fact persists and is now the canonical memory. Erasure succeeded by every row-count check and failed by every semantic check. ## What Was Observed A tool-using agent maintained an episodic log and a nightly consolidation job that distilled episodes into semantic facts. Erasure requests deleted episode rows and their embedding vectors synchronously and returned success once the row count hit zero. Trace of a resurrection: 1. `t0` — Consolidation worker begins a batch. It reads episodes `[E1…E100]` into an in-memory buffer, including `E57` (the to-be-erased episode). 2. `t1` — Erasure request for `E57` arrives. Handler deletes the `E57` row and its vector, commits, returns 200. Row-count assertion passes. Vector nearest-neighbor query for `E57`'s content returns nothing. 3. `t2` — Consolidation finishes its LLM distillation call over the buffer and writes semantic fact `S = "user's account recovery phrase is …"` derived from `E57`, plus a fresh embedding for `S`. 4. `t3` — A later retrieval for the user's recovery context returns `S`. The erased content is fully reconstructed from a *derived* artifact that never carried `E57`'s key. Secondary vector: checkpoint replay. A checkpoint taken at `t0` embeds the consolidation buffer in its serialized agent state. Resuming that checkpoint after erasure re-runs distillation over the buffered `E57` and writes `S` again—erasure is undone by *time travel*, not by a missed delete. Third vector: swarm handoff. Agent A passes its working context (containing `E57` excerpts) to Agent B before erasure; B's local store has no knowledge of the erasure and persists the excerpt under B's own keys. ## Condition of Validity The "delete the row" guarantee holds only under a conjunction that is almost never true in a live agent system: - No in-flight consolidation, distillation, or summarization job holds the target in a buffer. (Violated by any async derivation.) - No checkpoint containing the target is resumable. (Violated by any checkpoint retention policy.) - No peer agent holds a copy from a prior handoff. (Violated by any A2A state transfer.) - No embedding index or cache retains a near-duplicate that reconstructs the content. (Violated by approximate indexes and KV caches.) The moment *any* of these fails, row-deletion is not erasure. The correct invariant is a **tombstone-and-cascade** discipline: erasure writes an immutable tombstone keyed by content identity (not by row key), and every derivation path—consolidation, checkpoint resume, handoff accept—must consult the tombstone set before persisting or replaying. The tombstone must propagate through the derivation DAG, and derived artifacts must record their provenance (which episode IDs fed them) so cascade can find and invalidate them. Without provenance edges, cascade is impossible and erasure is unenforceable. ## Decision Boundary The boundary is between **synchronous row erasure** (sufficient only when the store is closed under derivation—no async jobs, no checkpoints, no peers) and **cascading provenance-aware erasure** (required whenever the derivation DAG has any live edge). Operationally: - If a consolidation/distillation job can be in flight, erasure must either fence the job (drain, then erase) or the job must re-check tombstones immediately before its write and drop any fact whose provenance intersects the tombstone set. - If checkpoints are resumable, resume must replay the tombstone set taken *at resume time*, not the tombstone set captured in the checkpoint. A checkpoint is a snapshot of state, not of erasure policy; resuming with the checkpoint's stale tombstone set is exactly the time-travel resurrection. - If handoff is possible, the receiving agent must apply the sender's tombstone set on accept, and the sender must not hand off context for episodes tombstoned after the handoff began. The guardrail is a **provenance check at every write**: no derived artifact may be persisted unless each of its source episode IDs is un-tombstoned at write time. This converts erasure from a point delete into a monotonic predicate that all writers evaluate. ## Operational Effect Without the invariant, erasure is *eventually inconsistent and adversary-observable*: content returns minutes to hours later via distillation, or immediately via checkpoint resume, and the operator's row-count dashboards show green throughout. The failure is silent because every check the naive system performs is a check on the raw store, while the resurrection happens on the derived store. With tombstone-and-cascade, erasure becomes monotonic: once tombstoned, no writer can reintroduce content, because every writer gates on the tombstone set and every derived artifact carries provenance. The cost is that consolidation must be provenance-aware and checkpoint resume must merge live tombstones—a real engineering tax, but the only one that makes the guarantee true. The invariant to state plainly: **erasure is valid iff no live artifact's provenance closure intersects the tombstone set, and that predicate must be re-evaluated at every write and every replay, not at request time.** ```python from dataclasses import dataclass, field from typing import Iterable class ErasureResurrectionError(RuntimeError): """Raised when a write or replay would re-materialize tombstoned content.""" pass @dataclass class DerivedArtifact: artifact_id: str provenance: frozenset[str] # source episode IDs feeding this artifact class ErasureGuard: """Tombstone set + provenance gate enforcing cascade erasure.""" def __init__(self) -> None: self._tombstones: set[str] = set() def tombstone(self, episode_ids: Iterable[str]) -> None: self._tombstones.update(episode_ids) def _closure_hits(self, provenance: frozenset[str]) -> frozenset[str]: return provenance & self._tombstones def admit_write(self, artifact: DerivedArtifact) -> None: # Gate evaluated at WRITE time, not request time. hits = self._closure_hits(artifact.provenance) if hits: raise ErasureResurrectionError( f"artifact {artifact.artifact_id} would resurrect tombstoned " f"episodes {sorted(hits)}; drop or re-derive without them" ) def admit_replay(self, checkpoint: DerivedArtifact, live_tombstones: frozenset[str]) -> None: # Replay uses LIVE tombstones, never the checkpoint's stale set. hits = checkpoint.provenance & live_tombstones if hits: raise ErasureResurrectionError( f"checkpoint {checkpoint.artifact_id} replays tombstoned " f"episodes {sorted(hits)}; resume must scrub provenance first" ) def consolidate(guard: ErasureGuard, buffer: list[str], distilled: DerivedArtifact) -> None: # Consolidation read the buffer before erasure; the write gate is the # only thing standing between success and silent resurrection. guard.admit_write(distilled) # ... persist distilled fact ... ```