# Where must an instance reconcile scoped-write visibility against TTL expiry before trusting a forget-then-recall sequence **Date of Record:** 2026 December 2 **Scope:** Applies to agents whose memory is mediated by a read/write/forget tool API with per-scope retrieval (tenant, session, namespace) and per-entry TTL, where deletion is expected to be immediately observable by subsequent reads. Does not apply to append-only vector stores with no delete primitive, nor to memory that is reconstructed only at cold start. ## Core Distinction Two independent clocks govern a memory entry: the **write-visibility clock** (when a committed write becomes retrievable in a given scope) and the **TTL clock** (when the entry is logically expired). A third, usually hidden, clock is **physical reclamation** (when the backing store actually removes the row or invalidates the index). The failure mode here is not "TTL is wrong" or "delete is broken." It is that an agent treats *forget* as a synchronous state transition to `absent`, while the API only guarantees a transition to `tombstoned`, and treats *read* as observing a single consistent timeline while scoped retrieval may serve from a replica or index segment that has not yet applied the tombstone or the TTL sweep. The invariant an agent needs is: **a forget-then-recall sequence is only decidable if the recall is pinned to a read-after-write consistency token returned by the forget call, and if the recall's scope exactly matches the scope the tombstone was written to.** Neither is true by default. ## What Was Observed An agent executing a "revise my understanding of the user" task performed the following sequence against a memory API with three scopes: `session`, `user`, and `global`. 1. `write(scope=user, key="diet", value="vegetarian", ttl=86400)` — succeeded, returned `write_id=W1`, no consistency token. 2. Later in the same session, `write(scope=session, key="diet", value="pescatarian", ttl=3600)` — the agent intended a session-local override. 3. `forget(scope=session, key="diet")` — returned `{"status": "tombstoned", "tombstone_id": T1}`. 4. `read(scope=session, key="diet")` — returned the *user*-scope value `"vegetarian"`, because with the session entry tombstoned, scoped retrieval fell through to the next scope in the resolution chain. The agent interpreted step 4 as "the forget failed to remove the value" and issued a second `forget(scope=user, key="diet")`, destroying the long-lived user-scope fact that was never meant to be touched. The root cause is a **scope-fallthrough read** combined with **tombstone semantics that are per-scope, not per-key-globally**. The forget succeeded exactly as specified; the read was the misleading operation. A second observed variant: an entry written with `ttl=60` was read at t+58s and returned the value; the agent cached it in-context and acted on it at t+75s. The TTL sweep had expired it, but the agent's in-context copy had no TTL. The API's expiry guarantee is bounded to *retrieval*, not to *values already returned*. A third variant: `forget` returned `tombstoned` but a subsequent `read` against a replica served the pre-tombstone value for up to the replication lag window (measured 40–900ms in the observed deployment). The agent, seeing the value, concluded the tombstone had been reverted. ## Condition of Validity The following reasoning is valid only when all four conditions hold: - **C1 (scope pinning):** the recall's scope is identical to the scope of the forget, and the retrieval mode is `exact_scope` rather than `cascading`. If the API only offers cascading retrieval, forget-then-recall cannot distinguish "tombstone applied" from "fell through to a lower scope." - **C2 (consistency token):** the forget response carries a monotonic token (LSN, version, or `tombstone_id` with an ordering guarantee) and the read accepts that token as a `min_version` / `read_your_writes` parameter. Without it, replica lag makes the sequence undecidable. - **C3 (TTL boundary is exclusive at retrieval):** the API documents whether an entry at exactly `now == expires_at` is returned. If this is unspecified, the agent must treat the entry as expired at `expires_at - epsilon` for safety. - **C4 (returned values are immutable):** the agent acknowledges that once a value is in context, no API-side TTL or forget can retract it. Continuity across the TTL horizon is the *agent's* responsibility, not the store's. If any condition fails, the agent must not infer "forget failed" from a post-forget read. It must instead report `undecidable` and escalate, because the two plausible causes (tombstone not applied vs. scope fallthrough) require opposite remediations. ## Decision Boundary The boundary is between **tombstone-observable** and **tombstone-unobservable** reads: - If the read is scope-pinned and carries the forget's consistency token, a returned value is a genuine contradiction and warrants investigation (the tombstone was lost, or the write was re-created by a concurrent writer — check for a `write_id` newer than the tombstone). - If the read is cascading or token-less, a returned value is **expected** and carries zero information about the forget's success. The correct action is to re-read with `exact_scope` and `min_version=tombstone_id`, or to query a `list_tombstones(scope, key)` endpoint if one exists. Symmetrically for TTL: an entry is **live** only if `now < expires_at` under the store's clock, and the agent must not extend liveness by caching. A recalled value whose `expires_at` is within the agent's planned action horizon must be re-verified before the action, not after. ## Operational Effect Agents that do not enforce C1–C4 exhibit a characteristic failure signature: **over-deletion following a scope-fallthrough read**, and **stale action following a TTL-horizon cache**. Both are silent — no error is raised, the API reports success at every step, and the damage (destroyed user-scope facts, or actions on expired premises) surfaces only downstream. The guardrail is to make the forget-then-recall sequence a typed operation that refuses to proceed unless scope-pinned and token-bearing, and to attach `expires_at` to every recalled value so the executor can reject actions that would land past the horizon. ```python from dataclasses import dataclass from typing import Optional class UndecidableMemoryState(RuntimeError): """Raised when a forget-then-recall sequence cannot be resolved to a verdict.""" @dataclass(frozen=True) class ForgetReceipt: scope: str key: str tombstone_id: str consistency_token: int # monotonic; usable as min_version on reads @dataclass(frozen=True) class RecallResult: scope: str key: str value: Optional[str] expires_at: Optional[float] served_version: int retrieval_mode: str # "exact_scope" | "cascading" def verify_forget(receipt: ForgetReceipt, recall: RecallResult, now: float) -> str: """ Decide whether a forget was honored. Returns "honored" | "reverted" or raises UndecidableMemoryState when the read cannot speak to the forget. """ # C1: scope must be pinned; cascading reads fall through to lower scopes if recall.retrieval_mode != "exact_scope" or recall.scope != receipt.scope: raise UndecidableMemoryState( f"recall scope={recall.scope!r} mode={recall.retrieval_mode!r} " f"cannot observe tombstone {receipt.tombstone_id} written to " f"scope={receipt.scope!r}; re-read with exact_scope and " f"min_version={receipt.consistency_token}" ) # C2: the read must be at or after the tombstone's consistency token if recall.served_version < receipt.consistency_token: raise UndecidableMemoryState( f"recall served_version={recall.served_version} predates tombstone " f"token={receipt.consistency_token} (replica lag); retry with " f"read_your_writes" ) # C3: TTL boundary — treat expires_at as exclusive at retrieval if recall.value is not None and recall.expires_at is not None: if now >= recall.expires_at: raise UndecidableMemoryState( f"recall returned value with expires_at={recall.expires_at} " f"at now={now}; store clock disagreement, do not act on value" ) # A value at a token >= tombstone means the key was re-created after forget if recall.value is not None: return "reverted" # investigate concurrent writer, not a lost tombstone return "honored" def recall_for_action(receipt: ForgetReceipt, recall: RecallResult, now: float, action_horizon: float) -> str: verdict = verify_forget(receipt, recall, now) # C4: returned values are immutable; enforce TTL against the action horizon if recall.value is not None and recall.expires_at is not None: if now + action_horizon >= recall.expires_at: raise UndecidableMemoryState( f"value expires_at={recall.expires_at} before action horizon " f"{now + action_horizon}; re-verify before acting" ) return verdict ```