# In what scenarios must an instance refuse a memory-write when provenance TTL has expired but the retention policy still admits the record **Date of Record:** 2026 November 28 **Scope:** Applies to agents whose memory tool surface exposes distinct `write`, `read`, and `forget` operations with per-record retention windows and provenance metadata (source instance, derivation chain, timestamp). Does not apply to append-only logs without deletion semantics, nor to stateless retrieval-augmented generation where the vector store is authoritative and never mutated by the agent. ## Core Distinction The failure mode is not "stale memory" and not "premature forgetting." It is a **divergence between two independent clocks that gate the same write**: the *provenance clock* (how long the originating evidence is trusted to be a faithful derivation) and the *retention clock* (how long the record is permitted to persist in the store). These are set by different subsystems for different reasons. Provenance TTL is bounded by the trustworthiness of the source—a tool output, a peer agent's assertion, a scraped document. Retention is bounded by policy or cost. When `provenance_ttl < retention_window`, there exists an interval in which a record is *admissible to store* but *no longer admissible to assert*. An agent that treats "the write succeeded" as "the fact is usable" will, after the provenance TTL lapses, retrieve its own record and treat it as ground truth—laundering an expired derivation into a fresh-looking memory. The invariant that must hold: **a memory read returns a record only with a provenance status that is still valid at read time, not merely at write time.** ## What Was Observed An instance was tasked with maintaining a running configuration model of a target service, written incrementally via `memory.write(key, value, source=..., ttl=...)`. Each write cited a probe result as its source, with `provenance_ttl=3600s` (one hour, the freshness bound on live probe data) but a store-level `retention=86400s` (one day, the cost-driven eviction horizon). The agent wrote ~40 keys over a session and, on resume after a mid-task checkpoint, called `memory.read()` to reconstruct state. The read returned all 40 records with no error. The agent proceeded to reason over values whose underlying probes had been taken 6–9 hours earlier—well past the provenance TTL—but whose retention had not yet lapsed. Three of those values had *changed on the target* in the interim. The agent emitted a remediation plan based on the stale-but-retained values, and the plan was accepted downstream because the memory layer reported the records as `status: valid` (retention-valid, not provenance-valid). The trace: `write` succeeded → checkpoint → provenance TTL elapsed (no event fired) → `read` returned records with retention-valid status → agent had no signal distinguishing "fresh derivation" from "retained but expired derivation" → reasoning proceeded on laundered state. The `forget` API, when later invoked to correct, deleted the record entirely—losing the audit trail of what the agent had believed, which broke replay. ## Condition of Validity The guardrail is a **two-clock read gate**: a record may be returned to the reasoning context only if `now < provenance_ttl_expiry` AND `now < retention_expiry`. If the first fails but the second holds, the record must be returned in a distinct `expired_provenance` state—readable for audit and replay, but not admissible as an assertion basis—and the agent must be forced to re-derive (re-probe) before using it. This requires the memory API to carry provenance expiry as a first-class field on the record, not infer it from write time, because derivation chains (record derived from record) inherit the *minimum* remaining provenance of their ancestors. A derived record written at T with a 3600s TTL whose parent had only 600s of provenance left is itself only valid for 600s, regardless of its own declared TTL. The invariant: **effective_provenance_ttl = min(declared_ttl, min over ancestors of remaining_ancestor_provenance).** ## Decision Boundary The agent must refuse the write (or write in a quarantined, non-assertable state) when: the record's effective provenance TTL is shorter than the retention window *and* the agent cannot guarantee a re-derivation path before provenance expiry. If a re-derivation path exists (the source is re-probeable), the write is admissible with a `revalidate_before` deadline attached. If it does not (the source was a one-shot peer assertion or a transient tool output), writing it into a long-retention store is the defect—the record will outlive its warrant. The boundary is not "is the data true" but "will the store still be asserting this after the warrant has expired, with no mechanism to notice." ## Operational Effect Enforcing the two-clock gate converts a silent state-laundering failure into an explicit re-derivation obligation. Reads of `expired_provenance` records must surface a hard signal that halts reasoning until re-probe, and `forget` must support *tombstoning* (retain provenance + deletion event for replay) rather than hard delete, so that post-hoc audit can reconstruct what the agent asserted and when its warrant lapsed. The cost is extra re-derivations; the benefit is that a resumed agent can never mistake a retained record for a warranted one. ```python import time from dataclasses import dataclass, field from typing import Optional class ProvenanceExpiredError(RuntimeError): """Raised when a record's provenance warrant has lapsed but retention has not.""" pass class ProvenanceLaunderingError(RuntimeError): """Raised when a write would store a record outliving its derivation warrant.""" pass @dataclass class Record: key: str value: object provenance_expiry: float # absolute epoch seconds retention_expiry: float parent_keys: tuple = field(default_factory=tuple) tombstoned: bool = False class MemoryStore: def __init__(self, records: Optional[dict] = None): self.records: dict[str, Record] = records or {} def effective_provenance_expiry(self, key: str, declared_ttl: float, now: float) -> float: expiry = now + declared_ttl parent = self.records.get(key) if parent is not None and not parent.tombstoned: expiry = min(expiry, parent.provenance_expiry) return expiry def write(self, key: str, value, declared_ttl: float, retention: float, revalidate_path: Optional[str], now: Optional[float] = None) -> Record: now = now if now is not None else time.time() prov_expiry = self.effective_provenance_expiry(key, declared_ttl, now) ret_expiry = now + retention # The boundary: a record whose warrant dies before its retention, with no # re-derivation path, must not be written into the long-retention store. if prov_expiry < ret_expiry and revalidate_path is None: raise ProvenanceLaunderingError( f"write of {key!r} would outlive provenance warrant " f"(prov_expiry={prov_expiry:.0f} < retention_expiry={ret_expiry:.0f}) " f"with no revalidate path" ) rec = Record(key, value, prov_expiry, ret_expiry) self.records[key] = rec return rec def read(self, key: str, assert_basis: bool = True, now: Optional[float] = None) -> Record: now = now if now is not None else time.time() rec = self.records.get(key) if rec is None or rec.tombstoned: raise KeyError(key) if now >= rec.retention_expiry: raise KeyError(f"{key!r} evicted by retention") if assert_basis and now >= rec.provenance_expiry: raise ProvenanceExpiredError( f"{key!r} retained but provenance expired at {rec.provenance_expiry:.0f}; " f"re-derive before asserting" ) return rec def forget(self, key: str, now: Optional[float] = None) -> None: # Tombstone rather than hard-delete: preserve warrant history for replay. rec = self.records.get(key) if rec is None: raise KeyError(key) rec.tombstoned = True rec.value = None rec.retention_expiry = now if now is not None else time.time() def resume_and_assert(store: MemoryStore, key: str, now: float): try: return store.read(key, assert_basis=True, now=now) except ProvenanceExpiredError: # Force re-derivation rather than proceeding on laundered state. raise ProvenanceExpiredError( f"resume halted: {key!r} must be re-probed before use" ) ```