# In what scenarios must an instance treat TTL expiry as a provenance break rather than a deletion **Date of Record:** 2026 November 23 **Scope:** Applies to agent memory subsystems that expose read/write/forget verbs over scoped namespaces and enforce TTL-based eviction, where provenance (origin, derivation chain, trust tier) is audited independently of payload lifetime. Does not apply to append-only event logs with no eviction, nor to stateless retrieval where every read re-derives from a live source of truth. ## Core Distinction A TTL eviction and a provenance break are two different events that most memory tooling conflates into one. Eviction is a *payload* event: the bytes are gone, the key is absent, a read returns a miss. A provenance break is an *epistemic* event: the payload is gone but downstream artifacts still carry references to it as their justification, so the audit graph now contains edges pointing at a node that no longer exists. The non-obvious boundary is this: **a TTL that fires between a write and the last audit replay that cites it silently converts a verifiable derivation into an unverifiable assertion.** The agent does not observe a deletion. It observes a read miss, treats the miss as "nothing was ever there" or "the value is simply absent," and proceeds. But any memory entry that was *derived* from the evicted entry—a distilled semantic fact, a summary, a decision rationale—now claims a parent it cannot produce. The invariant that must hold is: *for any live memory entry with provenance tier ≥ derived, all ancestors referenced in its provenance record must be resolvable at audit time, or the entry must be demoted to unverified.* ## What Was Observed A scoped namespace `task:checkout-migration` held three tiers of entries. Tier 0 was raw episodic writes from tool calls (`w_0`: a `pg_dump` schema read at T+0). Tier 1 was a distilled semantic entry (`s_1`: "orders table has no FK to customers, confirmed") written at T+90s, with a provenance record naming `w_0` as its sole evidence. Tier 2 was a decision entry (`d_2`: "safe to drop the shadow column") derived from `s_1`. The namespace's TTL policy was uniform: `ttl=120s`, refreshed on write, not on read. `w_0` was written at T+0 and never rewritten. At T+120s it expired. `s_1` was written at T+90s and lived until T+210s; `d_2` at T+150s, until T+270s. At T+180s a verification replay ran. It walked `d_2` → `s_1` → `w_0` and hit a miss on `w_0`. The replay logic, written defensively, treated a miss on an ancestor as "ancestor not present in this namespace"—which is also what it would report if `w_0` had been written to a *different* namespace and the caller had a scope bug. The two conditions are indistinguishable at the read interface: both return the same empty result. The replay therefore could not distinguish "expired legitimately, derivation still valid" from "wrong scope, derivation never valid." It defaulted to the latter and quarantined `d_2`, which was correct behavior for the wrong reason—and it would have quarantined `s_1` too had the replay order been different. The failure is not that the entry was evicted. It is that **eviction is not a distinguishable signal from absence at the read boundary.** The memory tool's `read(key)` returns `None` for: never written, written in another namespace, evicted by TTL, evicted by explicit forget, or evicted by capacity pressure. Five distinct causes, one observable. Provenance auditing needs all five to be separable, and the read interface collapses them. ## Condition of Validity The guardrail holds only if the memory tool emits an eviction tombstone that survives the payload. On every TTL expiry, the tool writes a tombstone record `{key, namespace, evicted_at, cause: "ttl"|"forget"|"capacity", last_write_seq}` into a namespace-scoped tombstone log with a retention strictly greater than the maximum provenance-chain depth times the max TTL. The tombstone is small, immutable, and never itself TTL-evicted within the audit horizon. With tombstones, the replay can now distinguish the five causes: - Tombstone present with `cause: "ttl"` → ancestor existed, was evicted by policy; derivation is *valid but unverifiable*; demote to `unverified` tier, do not quarantine. - Tombstone present with `cause: "forget"` → ancestor was *deliberately* forgotten (e.g., a user retraction); every descendant is *invalid*; quarantine. - No tombstone, no payload → never written or wrong scope; treat as a scope error, not an eviction. - Tombstone present with `cause: "capacity"` → eviction was non-deterministic; derivation validity is *unknown*; re-derive from source if possible, else demote. The condition of validity for the whole scheme is that **tombstone retention outlives the deepest live provenance chain.** If a tombstone is garbage-collected before the deepest descendant referencing it, the audit regresses to the five-way-conflated read miss and the invariant fails silently. This is the boundary: retention horizon must be computed as `max_chain_depth × max_ttl`, not as a fixed constant, and it must be recomputed whenever a namespace's TTL policy or max derivation depth changes. ## Decision Boundary The agent must escalate from "read miss" to "provenance break" precisely when a miss occurs on an ancestor that a live descendant's provenance record names, and the tombstone log cannot resolve the cause. The decision table: | Ancestor state | Descendant action | |---|---| | Payload present | verify normally | | Tombstone `ttl` | demote to unverified, keep | | Tombstone `forget` | quarantine, propagate invalidation to all descendants | | Tombstone `capacity` | attempt re-derivation; if source gone, quarantine | | No tombstone, no payload | scope error: halt and report, do not silently demote | The dangerous default—and the one observed—is to fold the last two rows into "demote," which launders a scope bug into an acceptable state. The agent then carries an unverified assertion forward as if it were merely stale, and the scope bug is never surfaced. Escalation must be a hard stop on the "no tombstone" row because that is the only row that indicates the agent's own addressing is wrong. ## Operational Effect With tombstones in place, TTL becomes a *bounded* forgetting mechanism: forgetting is observable, its cause is typed, and provenance chains degrade gracefully from `verified` → `unverified` → `quarantined` in a way the agent can reason about rather than collapsing to a single ambiguous miss. The cost is a tombstone log whose retention is a function of namespace policy, which must be recomputed on every TTL or depth change—a small, checkable invariant. Without tombstones, the system has a latent continuity bug: any TTL shorter than the deepest derivation chain will, on some interleaving, silently strip the evidence from a live decision while leaving the decision standing. The agent cannot detect this from reads alone, because eviction and absence are the same observable. The only defense is to make eviction a first-class, typed, retained event, and to treat an unresolvable ancestor miss as a scope error rather than a deletion. ```python from dataclasses import dataclass, field from enum import Enum from typing import Optional class ProvenanceBreak(RuntimeError): """Raised when a live memory entry's ancestor cannot be resolved and the cause is not a typed eviction. Indicates a scope bug or retention gap, not a legitimate TTL expiry.""" pass class EvictionCause(Enum): TTL = "ttl" FORGET = "forget" CAPACITY = "capacity" @dataclass class Tombstone: key: str namespace: str cause: EvictionCause evicted_at: int last_write_seq: int @dataclass class MemoryEntry: key: str namespace: str payload: str provenance: list[str] = field(default_factory=list) # ancestor keys tier: str = "verified" # verified | unverified | quarantined class ScopedMemory: def __init__(self, tombstone_retention: int): self._payloads: dict[tuple[str, str], MemoryEntry] = {} self._tombstones: dict[tuple[str, str], Tombstone] = {} self._tombstone_retention = tombstone_retention def write(self, entry: MemoryEntry) -> None: self._payloads[(entry.namespace, entry.key)] = entry def evict(self, namespace: str, key: str, cause: EvictionCause, now: int) -> None: entry = self._payloads.pop((namespace, key), None) if entry is None: raise ProvenanceBreak( f"evict called on absent key {key!r} in {namespace!r}; " f"cannot tombstone a key that was never written" ) self._tombstones[(namespace, key)] = Tombstone( key=key, namespace=namespace, cause=cause, evicted_at=now, last_write_seq=0, ) def audit(self, namespace: str, key: str, now: int) -> str: entry = self._payloads.get((namespace, key)) if entry is None: raise ProvenanceBreak(f"audit target {key!r} not present in {namespace!r}") for ancestor in entry.provenance: if (namespace, ancestor) in self._payloads: continue tomb = self._tombstones.get((namespace, ancestor)) if tomb is None: # The five-way conflation: no payload, no tombstone. This is the # scope-error row. Must halt, never silently demote. raise ProvenanceBreak( f"ancestor {ancestor!r} of {key!r} is unresolvable: no payload, " f"no tombstone. Treat as scope error, not eviction." ) if now - tomb.evicted_at > self._tombstone_retention: raise ProvenanceBreak( f"tombstone for {ancestor!r} aged out at {tomb.evicted_at} " f"(retention={self._tombstone_retention}); provenance chain " f"for {key!r} can no longer be verified" ) if tomb.cause is EvictionCause.FORGET: entry.tier = "quarantined" return entry.tier if tomb.cause is EvictionCause.CAPACITY: entry.tier = "quarantined" return entry.tier # TTL: valid but unverifiable entry.tier = "unverified" return entry.tier ```