# What structural signals indicate a scoped-retention memory API has silently converted a durable fact into a TTL-bound ephemeral, and why the audit trail cannot detect it **Date of Record:** 2026 December 2 **Scope:** Applies to agents whose memory tools expose `write`, `read`, and `forget` operations with per-scope retention classes (durable vs. TTL-bounded) and an append-only audit log. Does not cover vector-store recall ranking or embedding drift, which are orthogonal to retention-class transitions. ## Core Distinction A scoped memory API distinguishes two things that look identical at the call site: **the lifetime of a memory record** and **the lifetime of a fact**. The audit trail records the former. It does not record the latter. When an agent writes a fact into a scope whose retention policy is TTL-bounded, the `write` call succeeds, the audit entry is well-formed, and the fact is durable *only for as long as the TTL*. The agent's subsequent reasoning treats the write as a commitment. The store treats it as a lease. Nothing in the response payload, and nothing in the audit log, marks the difference between "this fact now exists" and "this fact exists until `expires_at`." The boundary failure is not expiry itself—expiry is correct and intended. The failure is that the agent has no structural signal, at write time or at read time, that distinguishes a commitment from a lease, so it builds downstream state (plans, checkpoints, citations in its own context) that assumes permanence. The audit trail faithfully logs `write(scope=ephemeral_working, ttl=3600)` and later `expire(key=...)`. It never logs "the agent believed this was durable." ## What Was Observed A multi-step agent was tasked with a long-horizon workflow: gather a set of identifiers, persist them, and resume across a context-window rollover. The memory tool exposed three scopes: - `durable`: no TTL, requires an explicit `retention_justification` field. - `working`: default TTL of 3600s, no justification required. - `session`: TTL tied to session token lifetime. The agent, under token pressure near the end of a planning step, called `write` without specifying a scope. The tool's default resolved to `working`. The response returned `{"ok": true, "key": "id_set_7", "scope": "working", "expires_at": "..."}`. The agent's planner recorded `id_set_7` in its scratch context as an established fact and proceeded. The context rollover occurred at t+3900s. On resume, the agent called `read(key="id_set_7")`. The store returned a structured miss: `{"ok": false, "reason": "expired", "expired_at": "..."}`. The agent, lacking any branch for "fact I wrote is now gone," treated the miss as a cold-start condition and re-derived the identifier set from a stale upstream source—producing a set that diverged from the original by two entries. The divergence propagated into every downstream artifact. The audit log for this incident is complete and internally consistent. It shows the write, the TTL assignment, the expiry, and the miss. It contains no anomaly. An auditor replaying the log sees a correctly functioning store. The defect is entirely in the seam between the store's retention semantics and the agent's commitment semantics, and that seam is not instrumented. The structural signals that this had occurred were present but distributed: 1. The `write` response echoed `scope` and `expires_at`, but the agent's planner schema had no field to carry them forward. The signal was emitted and dropped. 2. The `read` miss returned `reason: "expired"` distinct from `reason: "absent"`, but the agent's error handler collapsed all `ok: false` into a single retry path. 3. The audit log's `write` entry recorded `retention_justification: null`, which is the only trace that a durable commitment was never asserted—but this field is null for every `working` write, so it carries no discriminative signal at audit time. ## Condition of Validity The invariant that bounds this failure is: **a fact is durable in the agent's reasoning if and only if the agent has bound the store's retention metadata to its own commitment record at write time.** This holds only when three conditions are jointly satisfied: - The `write` response's `scope` and `expires_at` are written into the agent's own state, not just returned. - The agent's read-miss handler branches on `reason`, treating `expired` as a continuity break requiring reconciliation, not as `absent` requiring re-derivation. - The audit trail records the agent's *intended* retention class alongside the store's *assigned* retention class, so a mismatch (intent=durable, assigned=working) is a loggable event. The failure does not occur, and this invariant is not relevant, when the agent always specifies scope explicitly and the tool rejects writes that omit it. It also does not apply when facts are re-derivable at zero cost—in that case expiry is a cache miss, not a continuity break. The boundary is precisely where re-derivation is *possible but not equivalent*, i.e., where the upstream source has drifted since the original write. ## Decision Boundary The decision the agent must make at write time is: does this fact's downstream use tolerate a bounded lifetime? The failure mode is that this decision is made *implicitly* by the tool's default, and the agent never sees the decision as a decision. The correct boundary is a hard rule at the tool-wrapper layer: - If the caller does not pass an explicit `scope`, the wrapper must not let the store's default stand silently. It must either raise, or it must record the assigned scope into a caller-visible commitment field that the planner is required to carry. - If the caller passes `scope=durable`, the wrapper must verify the response echoes `scope=durable` and `expires_at=null`; any mismatch is a hard failure, not a warning. - On read, `reason=expired` must raise a distinct, non-retryable continuity exception that forces reconciliation against the audit trail before any downstream step proceeds. The boundary is between *silent lease* and *asserted commitment*. Anything that lets a write proceed without the agent's commitment record capturing the retention class sits on the wrong side. ## Operational Effect With the boundary enforced, the observed incident becomes impossible in two ways. First, the scope-less write either fails fast or produces a commitment record that the planner carries across the context rollover; on resume, the planner sees `expires_at` in its own state and schedules the read before expiry or plans re-derivation explicitly. Second, even if expiry slips through, the read handler raises a continuity exception rather than silently re-deriving, and the reconciliation step compares the re-derived set against the audit trail's recorded write payload—catching the two-entry divergence before it propagates. The audit trail gains a new discriminative field: `intended_scope` vs `assigned_scope`. A non-null mismatch count becomes a leading indicator of this failure class across the fleet, and the log now contains the one thing it previously could not: evidence of what the agent believed. ```python from dataclasses import dataclass from typing import Optional class RetentionContinuityError(RuntimeError): """Raised when a fact the agent treated as durable is found TTL-bound or expired.""" pass @dataclass class WriteResult: key: str scope: str expires_at: Optional[str] @dataclass class ReadResult: ok: bool reason: Optional[str] # "absent" | "expired" def assert_durable_commitment(intended_scope: str, result: WriteResult) -> None: if intended_scope == "durable": if result.scope != "durable" or result.expires_at is not None: raise RetentionContinuityError( f"write for {result.key!r} intended durable but store assigned " f"scope={result.scope!r} expires_at={result.expires_at!r}" ) def interpret_read(key: str, intended_scope: str, result: ReadResult) -> None: if result.ok: return if result.reason == "expired": # Expiry of a fact the agent committed to is a continuity break, # not a cache miss. Must reconcile against audit before proceeding. raise RetentionContinuityError( f"fact {key!r} (intended_scope={intended_scope!r}) expired; " f"reconciliation required before downstream use" ) if result.reason == "absent": return # legitimate cold-start; re-derivation is safe raise RetentionContinuityError(f"unclassified read miss for {key!r}: {result.reason!r}") def scoped_write(write_fn, key: str, value, scope: Optional[str]) -> WriteResult: if scope is None: raise RetentionContinuityError( f"scope-less write for {key!r} rejected: silent lease not permitted" ) result = write_fn(key, value, scope=scope) assert_durable_commitment(scope, result) return result ```