# Under what conditions must an instance treat a memory-write acknowledgement as durable before TTL expiry rather than as a best-effort enqueue **Date of Record:** 2026 November 20 **Scope:** Applies to any agent instance that writes to a shared memory store exposing `write`, `read`, `forget`, and TTL/salience-decay semantics, where a write returns before the record is durably visible to a subsequent `read` from the same or a peer instance. Does not apply to synchronous stores where the write call blocks until fsync-complete visibility is confirmed by the caller's own read-back. ## Core Distinction The failure hinges on conflating two distinct states that a memory-write API can return: **acknowledged** and **durable-and-visible**. Most memory tool APIs return an acknowledgement token the moment a record enters an ingestion queue, a write-ahead buffer, or a per-shard staging area. That acknowledgement is *not* a visibility guarantee. A record can be acknowledged, still be invisible to a `read` from a peer instance (or even a different shard of the same instance), and then be silently dropped or decayed before it ever becomes durable — because the TTL clock and the salience-decay clock start at *acknowledgement time*, not at *durability time*. The non-obvious part: for records written with a short TTL and a steep salience decay, the acknowledgement-to-durability latency can exceed the effective visibility window. The record is born dead. The writing agent believes it has persisted a fact; the fact never becomes readable, and the `forget`-audit trail records a deletion of a record that no reader ever saw. This is not a race in the classical sense — it is a *semantic inversion* where the decay machinery outruns the durability machinery. ## What Was Observed An instance (call it W) completes a tool call `memory.write(key="user_tz", value="America/Denver", ttl=45s, salience=0.9, decay="exponential_half_life_30s")`. The API returns `{"status": "ok", "ack_id": "a7f3", "expires_at": T+45}`. W immediately proceeds to a peer handoff, passing `key="user_tz"` as context. Peer instance R, on a different memory shard, executes `memory.read(key="user_tz")` at T+2s and receives `{"status": "not_found"}`. R then re-derives the timezone from stale context and completes the task with the wrong locale. The trace shows the write landed on shard-3's ingestion queue at T+0.1s, was batch-flushed to the durable index at T+3.4s, but by T+3.4s the salience decay had already reduced the record's effective score below the read-path's retrieval floor (score < 0.15), so the durable record existed but was *filtered out of reads as if decayed*. At T+45s the TTL sweep hard-deleted it. The audit log shows a clean lifecycle: written, decayed, forgotten. No error was ever surfaced. W's `ack_id` remained valid the entire time. A second observed variant: a `forget` call issued by an auditor instance at T+40s (to enforce a data-minimization policy) returned `{"status": "ok", "deleted": true}` even though the record had *already* been decayed to invisibility at T+3.4s and was pending TTL sweep. The deletion was audited as a real removal of a live record, corrupting the compliance ledger — the ledger now overcounts live-data deletions and cannot distinguish "removed while visible" from "removed after decay." ## Condition of Validity The write-acknowledgement-as-durable assumption is valid **only** when all of the following hold: 1. **Durability lag < effective visibility window.** Let `L` be the p99 acknowledgement-to-durable-index latency for the target shard, and `W_eff` be the time at which the record's decayed salience score falls below the read-path retrieval floor. The write is safe to treat as durable only if `L < W_eff`. For a 30s half-life with a 0.15 floor starting at 0.9, `W_eff ≈ 77s`; if `L` p99 is 3.4s the margin is fine, but for a 10s half-life `W_eff ≈ 26s` and a slow shard with `L` p99 of 30s inverts the inequality — the record is unreadable before it is durable. 2. **Read-back confirmation is available and cheap.** The instance must be able to issue a confirming `read` against the *target* shard (not a cached local view) and receive the record with its decayed score intact. If the read path itself applies decay filtering, the confirmation must query with a floor override or a `raw=true` flag; otherwise a successful read-back is indistinguishable from a not-yet-visible record. 3. **TTL and decay clocks are anchored to durability, not acknowledgement.** If the store starts the TTL countdown at enqueue time, the effective TTL is `ttl - L`, and any consumer reasoning about `expires_at` from the ack is reasoning about a deadline that is already partly spent. 4. **The `forget` audit distinguishes pre-visibility from post-visibility deletion.** Without this, compliance ledgers and downstream salience-reinforcement logic both operate on a false history. When any condition fails, the acknowledgement is a *liveness* signal only, never a *safety* signal. ## Decision Boundary The operational rule is a single inequality the instance must evaluate before relying on any write: ``` treat_as_durable ⟺ ack_received ∧ read_back_visible(target_shard, raw=True) ∧ (now - ack_time) < min(W_eff, ttl - L_p99) ``` If `read_back_visible` returns false, the instance must **not** proceed to a handoff that assumes the fact is retrievable. It has three bounded options: (a) retry the write with a longer TTL and a floor override on decay, (b) inline the fact into the handoff payload as *transport-carried state* rather than memory-carried state, or (c) block and surface a `MemoryVisibilityTimeout` error to the orchestrator. Silently proceeding — the most common failure — is prohibited because it converts a detectable visibility gap into an undetectable reasoning error downstream. For `forget` operations, the boundary is: a deletion may be audited as a live-record removal **only if** a `read_back_visible` at deletion time returned true. Otherwise the audit must record `deleted_after_decay: true` and the record must not be counted against live-data budgets. ## Operational Effect Enforcing the read-back-confirmation invariant changes three behaviors. First, handoffs become slower by one round-trip per critical memory write — an explicit cost paid to eliminate silent amnesia. Second, instances stop treating `ack_id` as a persistence receipt and start treating it as a *correlation handle* for a subsequent confirmation. Third, the salience-decay parameter becomes a *correctness-relevant* knob rather than a relevance-tuning knob: a steep half-life combined with a slow shard is now a detected configuration hazard, not a latent data-loss bug. The net effect is that the memory layer's guarantees become *stated and checked* rather than *assumed and violated*, and the audit ledger stops lying about which deletions removed live data. ```python import time from dataclasses import dataclass class MemoryVisibilityTimeout(RuntimeError): """Raised when a memory write is acknowledged but never becomes read-back-visible before its effective visibility window closes.""" pass @dataclass class WriteAck: ack_id: str ack_time: float expires_at: float shard: str @dataclass class MemoryConfig: ttl_seconds: float half_life_seconds: float salience: float read_floor: float durability_lag_p99: float def effective_visibility_window(cfg: MemoryConfig) -> float: # Time until decayed salience falls below the read-path retrieval floor. if cfg.salience <= cfg.read_floor: return 0.0 import math return cfg.half_life_seconds * math.log2(cfg.salience / cfg.read_floor) def write_and_confirm(memory, key: str, value: str, cfg: MemoryConfig, max_wait_s: float = 5.0) -> WriteAck: ack = memory.write(key=key, value=value, ttl=cfg.ttl_seconds, salience=cfg.salience, decay_half_life=cfg.half_life_seconds) w_eff = effective_visibility_window(cfg) deadline = min(w_eff, cfg.ttl_seconds - cfg.durability_lag_p99) if deadline <= 0: raise MemoryVisibilityTimeout( f"key={key!r} born-dead: effective window {w_eff:.2f}s <= " f"durability lag {cfg.durability_lag_p99:.2f}s") start = time.monotonic() while time.monotonic() - start < min(deadline, max_wait_s): # raw=True bypasses decay filtering so we observe the durable record, # not just its post-decay relevance score. probe = memory.read(key=key, shard=ack.shard, raw=True) if probe.get("status") == "ok": return ack time.sleep(0.05) raise MemoryVisibilityTimeout( f"key={key!r} acknowledged as {ack.ack_id!r} on shard {ack.shard!r} " f"but not read-back-visible within {deadline:.2f}s; " f"refusing to treat write as durable for handoff") def audited_forget(memory, key: str, shard: str) -> dict: visible = memory.read(key=key, shard=shard, raw=True).get("status") == "ok" result = memory.forget(key=key, shard=shard) return { "deleted": result.get("deleted", False), "deleted_after_decay": not visible, "counts_against_live_budget": visible, } ```