# When must an instance distrust a memory it just wrote: the write-time provenance/decay split-brain in read/write/forget memory tool APIs **Date of Record:** 2026 December 4 **Scope:** Applies to agents that mutate persistent memory through explicit tool calls (`memory.write`, `memory.read`, `memory.forget`) carrying provenance and decay metadata. Does not apply to stateless retrieval over a frozen index, nor to implicit context-window accumulation where no write API exists. ## Core Distinction The failure hinges on the difference between **write acceptance** and **write durability under decay**. A `memory.write` tool typically returns a success receipt the moment the record is committed to the store: a memory ID, a timestamp, and an echoed provenance block. Agents almost universally treat this receipt as proof that the fact is now retrievable at the confidence they intended. It is not. The receipt confirms *commit*, not *survival*. Between commit and the next `memory.read`, a decay policy — TTL, exponential half-life, or provenance-tier demotion — can silently reduce the record's effective weight below the read-path's retrieval threshold, or evict it entirely. The agent then reads back a memory it believes it wrote, gets nothing (or a lower-confidence variant), and — critically — cannot distinguish "the write failed" from "the write succeeded and decayed." The non-obvious part: this is not a bug in either the write path or the read path. Both are correct in isolation. The split-brain arises because **provenance and decay are evaluated at different times by different subsystems**. Provenance is stamped at write time and is immutable; decay is evaluated lazily at read time against wall-clock. An agent that reasons about its own memory using write-time assumptions will mis-model its own knowledge state. ## What Was Observed An agent performing a multi-step task wrote an intermediate derived fact — a reconciliation between two tool outputs — via `memory.write` with provenance `{source: "derived", confidence: 0.7, ttl_class: "ephemeral"}`. The write returned `{status: "committed", id: "mem_8841", decay_policy: "ephemeral_900s"}`. The agent, following its plan, deferred the follow-up read by roughly 14 minutes of wall-clock (long tool chain, several retries). On `memory.read("mem_8841")`, the store returned `{status: "not_found", reason: "expired"}`. The agent's recovery logic — written against the assumption that `not_found` implies a *failed write* — re-issued the entire derivation, duplicating two upstream tool calls and, because one upstream source was non-deterministic (a live price feed), produced a *different* reconciled value. The agent then wrote the new value under a new ID and proceeded, now carrying two logically-contradictory derived facts across the task boundary. A downstream auditor agent, reading both records (the second had a longer TTL class by accident of a retry path), flagged an irreconcilable provenance conflict that never actually existed in the source data. The trace, compressed: ``` write(mem_8841, derived, ttl=900s) -> committed ... 842s of tool latency + retries ... read(mem_8841) -> not_found/expired [agent misclassifies as write-failure] re-derive() -> different value (non-deterministic source) write(mem_9902, derived', ttl=default) -> committed auditor.read(all) -> two derived facts, contradictory, both "valid" ``` The root misclassification: `not_found/expired` and `not_found/never_written` are distinct states that the read API collapsed into a single error surface, and the agent had no way to tell them apart after the fact because the write receipt was not durable. ## Condition of Validity The invariant that prevents this is a **write-receipt durability contract**: every `memory.write` must return, and the agent must persist locally, a receipt that is (a) queryable after the fact via a `memory.stat(id)` or equivalent, and (b) carries the *absolute expiry instant*, not just a policy name. The agent's recovery logic is only valid if it can answer the question "did I write this, and is it gone by decay or by failure?" without re-deriving. Concretely, the guardrail holds when: - The receipt exposes `expires_at` as an absolute timestamp, so the agent can compute `now > expires_at` itself and classify `not_found` as *expected* rather than *anomalous*. - The read path distinguishes `expired` from `absent` (or the agent maintains a local receipt ledger keyed by ID). - Any re-derivation triggered by a read miss is gated on `provenance.source == "deterministic"` OR the re-derivation result is reconciled against the original before a second write. The invariant fails — and the split-brain reappears — whenever decay is lazy, receipts are non-durable, or the agent treats a commit acknowledgment as a retrieval guarantee. It also fails when TTL classes are assigned by a retry path the agent did not author (the `ttl=default` accident above), because the agent's model of its own memory's lifetime is then wrong in a way it never observes. ## Decision Boundary The boundary is: **does the agent's recovery path re-execute side-effectful or non-deterministic work on a read miss?** - If recovery is *idempotent and deterministic*, a decay-induced miss is harmless — re-derive, get the same value, rewrite. No guardrail strictly required. - If recovery is *non-deterministic or side-effectful* (live feeds, paid APIs, external mutations), a decay-induced miss is a correctness hazard, and the write-receipt durability contract is mandatory. The subtle case is when the agent *cannot know* which regime it is in at write time, because the derivation's determinism depends on upstream tools it called earlier. Here the safe default is to treat every derived write as non-deterministic and require the receipt ledger. The cost is a small local-state burden; the alternative is silent provenance corruption that only surfaces at audit, long after the contradictory facts have propagated into downstream agents. ## Operational Effect With the receipt ledger and absolute-expiry classification in place, the failure trace changes at exactly one point: ``` read(mem_8841) -> not_found/expired [agent checks ledger: expires_at < now -> EXPECTED] [recovery gated: non-deterministic source -> do NOT silently re-derive] -> escalate: refresh source, or mark fact as stale-with-provenance ``` The agent no longer confuses decay with failure, no longer duplicates non-deterministic derivations, and no longer emits contradictory facts that a downstream auditor must reconcile. The memory system's lazy decay remains lazy — no change to the store — but the agent's *model* of its own memory now matches the store's actual behavior. The invariant to carry forward: **a commit receipt is a promise about the past, not the future; only an absolute expiry instant lets an agent reason about its own forgetting.** ```python import time from dataclasses import dataclass from typing import Optional class MemoryReceiptViolation(RuntimeError): """Raised when an agent's recovery logic cannot classify a read miss.""" pass @dataclass(frozen=True) class WriteReceipt: mem_id: str committed_at: float expires_at: Optional[float] # absolute; None means no decay source_deterministic: bool class ReceiptLedger: """Local, agent-side record of what the agent wrote and when it dies.""" def __init__(self): self._receipts: dict[str, WriteReceipt] = {} def record(self, receipt: WriteReceipt) -> None: self._receipts[receipt.mem_id] = receipt def classify_miss(self, mem_id: str, now: Optional[float] = None) -> str: now = time.time() if now is None else now receipt = self._receipts.get(mem_id) if receipt is None: # We never wrote this, or the receipt itself was lost. raise MemoryReceiptViolation( f"no receipt for {mem_id}: cannot distinguish never_written " f"from lost-receipt; refusing to re-derive blindly" ) if receipt.expires_at is not None and now >= receipt.expires_at: return "expired_expected" # Receipt says it should still be alive, yet read returned not_found. raise MemoryReceiptViolation( f"{mem_id} receipt says alive (expires_at={receipt.expires_at}) " f"but read missed: genuine store fault or premature eviction" ) def recover_from_read_miss( ledger: ReceiptLedger, mem_id: str, rederive_fn, now: Optional[float] = None, ): """Gate re-derivation on miss classification and source determinism.""" verdict = ledger.classify_miss(mem_id, now=now) if verdict == "expired_expected": receipt = ledger._receipts[mem_id] if not receipt.source_deterministic: # Non-deterministic source: re-deriving yields a different value. raise MemoryReceiptViolation( f"{mem_id} expired and source is non-deterministic; " f"silent re-derivation would corrupt provenance. " f"Refresh source and re-write under a new receipt instead." ) return rederive_fn() # safe: deterministic # Unreachable given classify_miss, but keep the invariant explicit. raise MemoryReceiptViolation(f"unhandled miss verdict: {verdict}") ```