# How does an instance detect tri-fidelity divergence between its write, read, and forget memory tools **Date of Record:** 2026 December 4 **Scope:** Applies to agent instances whose long-term memory is exposed as three distinct tool calls (`write_memory`, `read_memory`, `forget_memory`) backed by a store that performs asynchronous indexing, deduplication, or decay. Does not apply to single-call memory APIs where read/write/forget are one atomic transaction, nor to stateless prompt-only architectures. ## Core Distinction The failure mode is not "memory is missing" or "memory is stale." It is **tri-fidelity divergence**: the instance's belief about its own memory is derived from three tools that each report a different view of the same underlying record, and the instance has no primitive that reconciles them. `write_memory` returns an acknowledgment of *intent* (a handle, a "queued" status, a similarity-merge decision). `read_memory` returns *materialized content* at whatever index generation is current. `forget_memory` returns a *tombstone* that may or may not have propagated to the read path or the embedding index. A naive agent treats a successful `write_memory` return as proof of persistence, a non-empty `read_memory` return as proof of correctness, and a successful `forget_memory` return as proof of erasure. Each is a distinct fidelity claim, and under asynchronous indexing they can be simultaneously true at the API layer and mutually contradictory at the state layer. The invariant that must hold is **read-after-write-and-forget consistency**: for any key `k`, after `write_memory(k, v)` returns handle `h` and `forget_memory(h)` returns `ok`, no subsequent `read_memory(k)` may return `v` — and this must be *checkable by the instance itself*, not assumed. ## What Was Observed An instance performing a multi-hour task writes intermediate findings to memory under a stable semantic key (e.g., `"customer_42_tier"`). The write path is a write-ahead log with a background embedder. `write_memory` returns `{"handle": "m_7f3a", "status": "accepted", "dedup": "merged_into:m_7f3a"}` — note the dedup merge: the store matched an existing semantically similar record and merged rather than inserting. The instance does not inspect the `dedup` field and assumes a fresh record. Mid-task, a policy changes: the customer's tier is downgraded. The instance calls `forget_memory("m_7f3a")`, which returns `{"status": "tombstoned"}`. The tombstone is written to the primary store synchronously, but the embedding index is rebuilt on a 90-second cadence from a snapshot that predates the tombstone. The next `read_memory("customer_42_tier")` — issued 40 seconds later — returns the *pre-tombstone* content, because the read path resolves semantic keys through the stale embedding index and only then checks the primary store by resolved handle. The instance now holds two contradictory beliefs: "I forgot this" (from the forget ack) and "this is the current tier" (from the read). It proceeds to act on the stale tier. The compounding case: the instance, seeing the read succeed, re-writes the value to "refresh" it. The re-write merges into the tombstoned handle (dedup matches the still-indexed embedding), producing a record that is simultaneously tombstoned in the primary store and live in the index. Subsequent reads are now *nondeterministic* — they alternate between returning the value and returning empty depending on which index shard answers. The instance cannot distinguish "I never wrote this" from "I wrote and forgot this" from "I wrote, forgot, and resurrected this," because all three produce the same observable: intermittent read hits. ## Condition of Validity The divergence is only detectable (and only matters) under three simultaneous conditions: 1. **Asynchronous index propagation.** The read path and the forget path do not share a linearization point. If forget and read are serialized through the same index generation, the divergence window is zero. 2. **Semantic-key resolution.** Reads resolve by embedding similarity rather than exact handle, so a stale index entry can resurrect a tombstoned record under a *different* query string. Exact-handle reads would return a clean tombstone error. 3. **Dedup-on-write.** Writes merge into existing handles. Without dedup, a re-write after forget would create a fresh handle with a fresh (post-tombstone) index entry, and the resurrection would be a *new* record, not a contradictory one. If any of the three is absent, the failure collapses into a benign case (eventual consistency, exact-key miss, or clean insert). The instance must therefore *probe for all three* before trusting any single tool's return value — and the probe itself must not perturb state. ## Decision Boundary The instance must draw a hard line between **acknowledged** and **materialized** memory state, and must never let a read result overwrite its forget belief without reconciliation. Concretely: - A `write_memory` return of `status: "accepted"` or `dedup: merged_into:*` is an *intent* record, not a persistence proof. The instance must issue a verification read against the *exact handle* (not the semantic key) before treating the value as durable. - A `forget_memory` return of `tombstoned` establishes a *lower bound* on erasure: the primary store is clean, but the read path may still serve the record until the index generation advances past the tombstone's sequence number. - A `read_memory` hit after a forget is **not** evidence the forget failed; it is evidence the read path is behind. The correct response is to *re-issue the forget with a sequence barrier* (or wait for index-generation catch-up) and then re-read, never to re-write. - A re-write after a forget must be treated as a **resurrection event** and routed to a distinct handle, because dedup will otherwise merge it into the tombstone and produce nondeterministic reads. The boundary: the instance may act on a memory value only when the *most recent* write and the *most recent* forget for that key have both been confirmed by a read against the exact handle at the current index generation. Any read that cannot report its index generation is untrusted for post-forget decisions. ## Operational Effect The practical consequence is that memory tool returns must be treated as a **three-way reconciliation problem**, not three independent RPCs. An instance that trusts each tool's ack independently will, under the conditions above, silently resurrect forgotten data, act on stale values, and — worst — be unable to distinguish a genuinely empty memory from a tombstoned-and-resurrected one. The guardrail is a read-back protocol that pins the index generation, refuses to re-write over a tombstone, and escalates to a hard error when a post-forget read returns content at a generation older than the forget's sequence number. The instance must fail closed: if it cannot prove erasure, it must treat the value as *both* present and forbidden, and halt the dependent action rather than guess. ```python class TriFidelityDivergence(RuntimeError): """Raised when write/read/forget views of the same key cannot be reconciled.""" pass class MemoryHandle: def __init__(self, handle_id: str, seq: int, generation: int): self.handle_id = handle_id self.seq = seq # monotonic sequence assigned at write/forget self.generation = generation # index generation observed at ack class TriFidelityGuard: def __init__(self, store): self.store = store def write(self, key: str, value: str) -> MemoryHandle: ack = self.store.write_memory(key, value) # 'accepted' or 'merged_into:*' are intent, not persistence. h = MemoryHandle(ack["handle"], ack["seq"], ack["generation"]) # Verify against exact handle, not semantic key. probe = self.store.read_by_handle(h.handle_id) if probe is None or probe["generation"] < h.generation: raise TriFidelityDivergence( f"write ack for {key} not materialized at handle {h.handle_id}" ) return h def forget(self, h: MemoryHandle) -> MemoryHandle: ack = self.store.forget_memory(h.handle_id) if ack["status"] != "tombstoned": raise TriFidelityDivergence( f"forget for {h.handle_id} did not tombstone: {ack}" ) # Tombstone establishes a lower bound; index may lag. return MemoryHandle(h.handle_id, ack["seq"], ack["generation"]) def read_after_forget(self, key: str, tomb: MemoryHandle): probe = self.store.read_memory(key) if probe is None: return None # A hit after forget is a lagging index, not a failed forget. if probe["generation"] < tomb.generation: raise TriFidelityDivergence( f"post-forget read of {key} served from stale generation " f"{probe['generation']} < tombstone {tomb.generation}; " f"refusing to act, refusing to re-write" ) # Content at a generation >= tombstone seq means resurrection. if probe["seq"] >= tomb.seq: raise TriFidelityDivergence( f"resurrection: {key} live at seq {probe['seq']} " f"after tombstone {tomb.seq}; route to fresh handle" ) return probe["value"] ```