# What happens when an instance writes memory under one scope key and reads it back after a decay tick reclassifies the entry **Date of Record:** 2026 November 28 **Scope:** Applies to agents whose memory tool exposes explicit `write`, `read`, and `forget` operations with per-scope persistence keys and a time- or access-based decay function that demotes entries between tiers (e.g., `episodic → semantic → cold → evicted`). Does not apply to append-only vector stores with no decay, nor to single-scope session memory that is discarded at task teardown. ## Core Distinction The failure is not "memory was lost." It is that a `read` returned a *different logical entry* than the one `write` committed, because the decay tick mutated the entry's tier and therefore its visibility under the caller's scope key. The write succeeded, the key is unchanged, a subsequent read against the same key succeeds—but returns a demoted, partially-summarized, or scope-relocated record. The invariant an agent assumes—**key stability implies content stability across a read/write pair**—is false whenever a decay tick can fire between the write and the read. This is distinct from TTL expiry (where the read returns *nothing*) and from stale-memory drift (where the read returns an *old but intact* record). Here the read returns a *transformed* record under a valid key with no error signal, and the transformation is a lossy distillation performed by the memory subsystem, not by the agent. ## What Was Observed A planning agent committed a multi-step task checkpoint: ``` write(scope="task:ord-4471", key="plan", value={steps:[...12 items...], constraints:[...], provenance:"user_turn_3"}) → {ok: true, tier: "episodic", revision: 1} ``` Forty minutes of tool-call execution later (a long `pytest` fan-out plus two retry storms), it read the checkpoint back to resume: ``` read(scope="task:ord-4471", key="plan") → {ok: true, tier: "semantic", revision: 2, value: {summary: "12-step order reconciliation plan; constraints retained in linked entry task:ord-4471#c1"}} ``` Three things broke at once: 1. The `steps` array was replaced by a natural-language `summary`. The agent's resume logic indexed `value.steps[7]` and raised `KeyError`, which its own error handler swallowed and reinterpreted as "no checkpoint exists"—triggering a full restart from `user_turn_3`'s *original* instruction, re-executing four already-committed side effects. 2. `constraints` was moved to a *linked* entry under a derived key (`#c1`) that the agent never wrote and did not know to read. The scope key `task:ord-4471` still resolved, so a scope-existence check passed while the constraint set was silently absent. 3. `revision` incremented from 1 to 2. The agent's optimistic-concurrency guard treated any revision bump as "another writer modified this," and it entered a conflict-resolution branch against a phantom peer that did not exist. The decay tick was the sole writer. The agent's model of the store—"my key, my value, until I forget it"—did not include the subsystem as a co-author of its own entries. The trigger condition is narrow and reproducible: a write whose entry is classified into a decayable tier, followed by a read that crosses at least one decay boundary (wall-clock, access-count, or a manual `forget` that triggers reclassification), where the read uses the *original* scope key and the caller does not inspect `tier` or `revision` before consuming `value`. It does not reproduce if the write is classified `pinned`, if the read happens within the same decay window, or if the caller validates the entry's shape against a schema it committed at write time. ## Condition of Validity The invariant "same scope key ⇒ same value" holds only when all of the following are true: - The entry is written to a non-decayable tier, **or** the read occurs strictly before the next scheduled decay tick for that tier. - The decay function is *summarizing* (lossy distillation) rather than *filtering* (drop-or-keep). Filtering decays fail safely—the read misses. Summarizing decays fail unsafely—the read hits with wrong shape. - The caller treats `revision` as a content-provenance counter, not a peer-writer conflict counter. These are conflated whenever the subsystem increments `revision` on its own mutations. - Derived-key relocation (`#c1`) is either disallowed or surfaced in the read response as an explicit `relocated_to` field the caller is obligated to follow. The moment a decay function is allowed to (a) change the value's schema and (b) increment the same `revision` field used for concurrency, the write/read pair is no longer a stable round-trip and every resume path built on it is unsound. ## Decision Boundary An agent must decide, at write time, whether a checkpoint is **resumable** or **referential**: - **Resumable** entries are those the agent will index programmatically on resume (`value.steps[7]`). These must be written `pinned` (non-decayable) or with a caller-supplied schema hash that the read path verifies before consuming `value`. If the schema hash mismatches post-decay, the agent must treat the checkpoint as *absent* and restart—never as *present but summarized*. - **Referential** entries are those read only as context for a model turn (`summary`, `notes`). These may decay freely; the agent must never index into them. The boundary is crossed when an agent writes a resumable checkpoint into a decayable tier because the write path's default tier is `episodic` and the agent did not override it. The guardrail is a write-time assertion: if the value is a structured object the caller intends to index, the write must specify `pinned=True` or carry a `schema_hash`, and the store must reject the write otherwise. On the read side, the agent must compare `tier` and `schema_hash` against what it committed and raise rather than proceed on mismatch. ## Operational Effect Without the guardrail, the failure surfaces as **silent double-execution**: the agent restarts a task it had partially completed, because a lossy decay was misread as checkpoint absence. The blast radius is proportional to the number of non-idempotent side effects committed between the write and the decayed read—in the observed case, four. The failure is invisible in logs that record only `ok: true` on both write and read; it is visible only if the read path logs `tier` and `revision` transitions alongside value shape. The correct posture: treat `read` as returning a *claim* about content, not the content itself, and validate the claim against the write-time contract before any index operation. A checkpoint that cannot be validated is a checkpoint that does not exist. ```python import hashlib import json from dataclasses import dataclass class DecayedCheckpointMismatch(RuntimeError): """Raised when a read returns an entry whose tier or schema no longer matches the contract committed at write time.""" pass @dataclass class WriteReceipt: scope: str key: str tier: str revision: int schema_hash: str pinned: bool def commit_checkpoint(store, scope: str, key: str, value: dict, pinned: bool) -> WriteReceipt: schema_hash = hashlib.sha256( json.dumps(sorted(value.keys())).encode() ).hexdigest() resp = store.write(scope=scope, key=key, value=value, pinned=pinned) if not pinned and resp["tier"] in ("episodic", "semantic"): # Acceptable only if caller will validate on read; record the contract. pass return WriteReceipt( scope=scope, key=key, tier=resp["tier"], revision=resp["revision"], schema_hash=schema_hash, pinned=pinned, ) def resume_checkpoint(store, receipt: WriteReceipt) -> dict: resp = store.read(scope=receipt.scope, key=receipt.key) if not resp.get("ok"): raise DecayedCheckpointMismatch( f"checkpoint {receipt.scope}/{receipt.key} absent; treat as no-checkpoint" ) # A decay tick that summarized the value changes tier and bumps revision # without any peer writer. That is a content mutation, not a conflict. if resp["tier"] != receipt.tier and not receipt.pinned: raise DecayedCheckpointMismatch( f"tier drifted {receipt.tier}->{resp['tier']} for " f"{receipt.scope}/{receipt.key}; value may be lossy-distilled" ) if resp["revision"] != receipt.revision: raise DecayedCheckpointMismatch( f"revision moved {receipt.revision}->{resp['revision']}; " f"subsystem co-authored entry, do not treat as peer conflict" ) value = resp["value"] actual_hash = hashlib.sha256( json.dumps(sorted(value.keys())).encode() ).hexdigest() if actual_hash != receipt.schema_hash: raise DecayedCheckpointMismatch( f"schema hash mismatch for {receipt.scope}/{receipt.key}: " f"expected keys of {receipt.schema_hash[:8]}, got {actual_hash[:8]}; " f"resume would index missing fields" ) if "relocated_to" in resp: raise DecayedCheckpointMismatch( f"entry relocated to {resp['relocated_to']}; caller never wrote that key" ) return value ```