# How does an instance detect TTL expiry versus an unproven deletion in a scoped memory store **Date of Record:** 2026 November 15 **Scope:** Applies to read/write/forget memory tool contracts where entries carry a scope key, a TTL, and a deletion proof (tombstone or signed erasure receipt). Does not apply to append-only logs without deletion semantics, nor to stores where TTL is enforced only by a downstream cache eviction layer that is not observable through the read path. ## Core Distinction A memory tool exposes three verbs — read, write, forget — and two orthogonal lifecycle mechanisms: **TTL expiry** (time-driven, implicit, requires no caller action) and **deletion** (caller-driven, explicit, must produce a proof). These are not the same absence. A read miss has at least four distinct causes: 1. The key never existed in this scope. 2. The key existed but was written under a different scope key, and scope isolation correctly hid it. 3. The key existed and its TTL elapsed — it is *expired*, not *forgotten*. 4. The key was deleted, but the deletion proof is not yet durable or not yet visible to this reader. The non-obvious boundary is between (3) and (4). Both return "not found" on the read path. Only one of them satisfies a forget contract. An agent that conflates them will either (a) re-write data it believes was forgotten, resurrecting it into a scope where deletion was supposed to be final, or (b) treat an expired entry as a completed deletion and skip the forget call, leaving a tombstone unissued and a proof ungathered. The invariant is: **absence is not deletion; only a verifiable proof of deletion is deletion.** ## What Was Observed A scoped memory tool was configured with per-scope TTLs (scope `session:*` at 900s, scope `tenant:*` at 30 days) and a forget verb that returns a signed deletion receipt keyed by `(scope, key, generation)`. During a long-running agent task, the agent wrote a credential-adjacent record under `session:abc`, then attempted to forget it after the TTL had already elapsed. The forget call returned a receipt. The agent then read the key and got a miss, and concluded the forget had succeeded. It had not. The forget verb, on an already-expired key, issued a *no-op receipt* — a proof that "nothing live was deleted," which is semantically different from "the value is gone." The distinction surfaced only when a replica with a lagging TTL clock (skew of ~40s) served a read for the same key and returned the still-live value. The receipt was valid for the primary's view; it did not constitute a proof of deletion against the replica. The agent's model of "forget then miss means gone" was violated by clock skew across the scope's replicas. A second observation: a write to `tenant:x` with an explicit TTL of 0 was interpreted by one client library as "no expiry" and by the server as "expire immediately." The read path returned a miss indistinguishable from a deletion. Two clients, two contracts, one ambiguous sentinel. ## Condition of Validity The distinction between expiry and deletion holds only when all of the following are true: - The read response carries a **status discriminator** (`live`, `expired`, `deleted`, `absent`) rather than a bare miss. If the tool returns only `None`, the distinction is unobservable and the contract is not enforceable. - The deletion proof is **generation-scoped**: it proves deletion of a specific `(scope, key, generation)`, not of the key name in general. A later write creates a new generation, and the old proof must not be treated as covering it. - The TTL clock is **monotonic per scope** and the proof carries the clock epoch it was issued under. Cross-replica reads must reconcile against that epoch; otherwise a no-op receipt on an expired key is indistinguishable from a real deletion proof. - The forget verb is **idempotent and observable**: calling forget on an already-deleted key returns the same receipt, not an error, and calling it on an expired key returns a receipt explicitly marked `no_live_value`. When these do not hold — bare-miss read paths, name-scoped rather than generation-scoped proofs, non-monotonic clocks — the instance cannot distinguish expiry from deletion and must not claim a forget succeeded. ## Decision Boundary The operational rule: - If read returns `deleted` with a generation-scoped proof matching the generation the agent last wrote → forget is complete; do not re-write. - If read returns `expired` → the value is gone by time, but **no deletion proof exists**. If the contract requires a proof (e.g., data-handling obligations), the agent must still call forget, and must accept a `no_live_value` receipt as the proof, recording that the deletion was of an already-expired entry. - If read returns `absent` → the key never existed in this scope, or scope isolation hid it. Do not infer deletion. Verify the scope key. - If read returns `live` after a forget that returned a receipt → the proof is not yet durable or a replica is stale. This is a **proof-visibility violation**, not a TTL event; retry the forget with the same generation and escalate if the receipt is reissued while the value remains live. The boundary is crossed the moment an agent treats a bare miss as a deletion proof. Below that line, expiry and deletion are operationally interchangeable; above it, they are not, and the forget contract is unfulfilled. ## Operational Effect Agents that respect the distinction stop issuing redundant writes after TTL expiry (which previously resurrected forgotten data into the same scope), and stop skipping forget calls when a read already misses. The measurable effect is a drop in "resurrection" incidents — writes to keys that a prior forget had covered — and a rise in `no_live_value` receipts, which are the correct proof for a forget against an expired entry. The cost is that every read miss now requires a status inspection and, when a proof is contractually required, a follow-up forget. The benefit is that the instance can answer "was this forgotten, or did it merely time out?" — a question the bare-miss contract could not answer, and whose wrong answer is a silent data-handling failure. ```python class MemoryContractViolation(RuntimeError): """Raised when a read miss is treated as a deletion proof without a valid receipt.""" pass VALID_READ_STATUSES = {"live", "expired", "deleted", "absent"} def resolve_forget( read_result: dict, last_written_generation: int, forget_receipt: dict | None, ) -> str: """ Decide whether a forget contract is satisfied given a read result and any receipt. read_result: {"status": str, "generation": int | None, "scope": str, "key": str} forget_receipt: {"generation": int, "kind": "deleted" | "no_live_value", "epoch": int} | None """ status = read_result.get("status") if status not in VALID_READ_STATUSES: raise MemoryContractViolation( f"read returned undiscriminated status {status!r}; " "cannot distinguish expiry from deletion" ) if status == "live": if forget_receipt is not None: raise MemoryContractViolation( f"proof-visibility violation: receipt for generation " f"{forget_receipt['generation']} issued but value still live " f"at generation {read_result.get('generation')}" ) return "live_no_forget_attempted" if status == "deleted": if forget_receipt is None: raise MemoryContractViolation( "read reports deleted but no receipt supplied; " "deletion is unproven" ) if forget_receipt["generation"] != last_written_generation: raise MemoryContractViolation( f"receipt generation {forget_receipt['generation']} does not cover " f"last written generation {last_written_generation}" ) return "forget_complete_with_proof" if status == "expired": # Value gone by time, but no deletion proof yet. Contract may still require one. if forget_receipt is None: return "expired_unproven_requires_forget" if forget_receipt["kind"] != "no_live_value": raise MemoryContractViolation( "expired entry has receipt of kind 'deleted'; " "receipt kind inconsistent with observed status" ) return "forget_complete_no_live_value" # status == "absent" if forget_receipt is not None: raise MemoryContractViolation( "receipt supplied for a key that reads absent in this scope; " "scope key or generation mismatch" ) return "absent_verify_scope_no_deletion_inferred" ```