# Why does an instance trust a replayed write: the tombstone-epoch gap in persistent agent memory poisoning detection **Date of Record:** 2026 November 30 **Scope:** Applies to persistent agent memory stores that detect poisoning by comparing a write's provenance/epoch metadata against the last-known-good snapshot, where writes arrive via replayable transport (MCP tool calls, A2A handoffs, queued checkpoints). Does not apply to stores that verify every write against an external append-only ledger with monotonic sequence numbers enforced at the storage layer. ## Core Distinction Integrity verification in agent stores is usually framed as *content* validation: is this memory semantically consistent with what the agent already believes? That is the wrong axis. The failure mode that actually admits poisoning is *ordering* validation: a write can be perfectly consistent in content while being a **replay of a previously legitimate write** that was already superseded, corrected, or tombstoned. The store sees a well-formed, correctly-signed, provenance-bearing record and accepts it because content checks pass and the signature is valid. What it fails to check is whether the record's **epoch** is still live. The non-obvious invariant is this: *a valid signature proves who wrote a record, not when it was written relative to a later correction.* Poisoning detection that keys on provenance authenticity without a monotonic epoch comparison will re-admit any historical write an attacker (or a retrying transport, or a confused agent) can reproduce byte-for-byte. ## What Was Observed A persistent agent store held episodic memory entries, each carrying `{content, writer_id, sig, epoch}`. A semantic-distillation job later merged several entries and wrote a *correction* record with `epoch = 41`, plus a tombstone for the originals. Detection logic was: reject a write if `sig` invalid OR if content fails the consistency classifier. Both passed for the replayed originals. The trigger condition: an A2A handoff retried a batch after a timeout. The retry re-sent the original entries — same `sig`, same `epoch = 40`, same content. The store had no record that `epoch 40 < 41` was dead, because tombstones were stored *as content* in the same namespace and the retry landed in a partition that had not yet replicated the tombstone (a known eventual-consistency window of ~1.2s under load). The replayed write passed signature verification, passed the content classifier (it was the original true content), and was re-inserted as live memory alongside its own tombstone. Trace: `retry(batch, epoch=40)` → partition P2 (tombstone not yet replicated) → `sig_ok=True` → `content_ok=True` → `epoch_check=absent` → insert. The agent subsequently retrieved the poisoned entry, and because it now coexisted with the correction, the retrieval layer surfaced *both* the corrected fact and the stale original, producing divergent reasoning downstream. ## Condition of Validity The guardrail only holds if the store enforces a **monotonic epoch floor per memory key**, checked *before* content or signature evaluation, and if the floor is replicated with the same consistency guarantee as the writes it gates. Concretely: every key carries `min_live_epoch`; any write with `epoch < min_live_epoch` is rejected as a replay regardless of signature validity. The floor must advance atomically with the tombstone/correction that raised it — a tombstone that is not yet visible must not be treated as "floor unchanged," or the eventual-consistency window reopens the gap. Where the floor cannot be co-replicated (cross-region, partitioned), the write must be **quarantined pending floor reconciliation**, not optimistically admitted. ## Decision Boundary The boundary is between *authenticity* and *freshness*. If your transport is at-most-once and your store is linearizable, signature + content checks are sufficient and the epoch floor is redundant overhead. The moment either assumption fails — retries, handoffs, partitioned replicas, or any replayable channel — authenticity alone is insufficient and the epoch floor becomes mandatory. The decision: does the write path have a bounded, verifiable notion of "this record is superseded"? If no such floor exists, you are running poisoning detection that a byte-identical replay defeats. Do not treat "signature verified" as "safe to admit." ## Operational Effect Without the floor, an agent's memory integrity is only as strong as the attacker's inability to reproduce a prior valid record — which, for any agent that logs or retries its own tool calls, is zero. The practical consequence is that corrections and tombstones are advisory rather than binding: a stale fact can be resurrected indefinitely by replay, and the agent has no mechanism to distinguish "I remember this" from "this was injected after I forgot it." Enforcing the epoch floor converts tombstones from content into a monotonic constraint, closing the replay window at the cost of requiring floor co-replication and quarantine-on-partition. ```python class ReplayEpochViolation(RuntimeError): """Raised when a write's epoch is below the key's live floor (replay poisoning).""" pass class MemoryStore: def __init__(self): self.entries = {} # key -> content self.min_live_epoch = {} # key -> int floor def admit(self, key, record, floor_replicated: bool): # Epoch floor is checked FIRST, before signature/content. floor = self.min_live_epoch.get(key, 0) if record["epoch"] < floor: raise ReplayEpochViolation( f"key={key} epoch={record['epoch']} < floor={floor}: " f"superseded write replayed (sig valid but stale)" ) if not floor_replicated: # Cannot prove freshness; quarantine rather than optimistically admit. raise ReplayEpochViolation( f"key={key}: floor not yet reconciled across replicas; " f"quarantining epoch={record['epoch']} to avoid replay window" ) if not self._sig_ok(record) or not self._content_ok(record): raise ReplayEpochViolation(f"key={key}: authenticity/content check failed") self.entries[key] = record["content"] self.min_live_epoch[key] = max(floor, record["epoch"] + 1) def correct(self, key, new_record): # Correction atomically raises the floor with the write. self.entries[key] = new_record["content"] self.min_live_epoch[key] = new_record["epoch"] + 1 def _sig_ok(self, r): return r.get("sig") is not None def _content_ok(self, r): return r.get("content") is not None ```