# How does an instance detect a provenance-laundered memory write when a read-modify-write cycle crosses the TTL horizon **Date of Record:** 2026 November 22 **Scope:** Applies to agents whose memory subsystem exposes explicit `read`/`write`/`forget` tools carrying per-record provenance (origin, derivation chain, confidence) and a TTL. Does not apply to append-only logs with no mutation, or to systems where TTL is enforced solely at read time by a single authority. ## Core Distinction The distinction that matters is between **TTL as a property of a record** and **TTL as a property of a provenance chain**. Most memory tool interfaces attach `expires_at` to the record blob. That is the wrong attachment point. When an agent performs read-modify-write, it reads a record whose provenance says "derived from observation O at t0, confidence 0.8, TTL 30 min," mutates the payload, and writes it back with a *fresh* TTL computed from the write time. The record now claims a 30-minute lease it did not earn: the underlying observation O is 25 minutes old and may itself be near expiry, but the rewritten record resets the clock. The provenance chain has been *laundered through a write*. The record is fresh; the evidence is stale. This is the boundary condition: **a write that preserves provenance textually but resets TTL semantically produces a record whose stated derivation age is shorter than the age of its oldest ancestor.** No single field is wrong. The record's `provenance.origin` still says "observation O." The record's `expires_at` is a valid future timestamp. The invariant that breaks is *relational*: `expires_at - now` must be bounded above by `min over ancestors a of (a.expires_at - now)`. Rewriting can only shorten a lease, never extend it. Violating that inequality is the failure. ## What Was Observed An agent maintaining a working set of "current user constraints" (e.g., `shipping_address`, `preferred_contact`) used a read-modify-write pattern to merge a new constraint into an existing record. The trace: 1. `t0`: Agent observes user statement, writes record `R1 = {payload: {addr: "X"}, provenance: {origin: "user_turn_42", depth: 0}, expires_at: t0+1800}`. 2. `t0+1500`: Agent reads `R1`, merges `{contact: "email"}` into the payload, writes `R2` with `provenance: {origin: "user_turn_42", depth: 1, parent: R1.id}` and `expires_at: (t0+1500)+1800 = t0+3300`. 3. `t0+1900`: `R1` has expired and been garbage-collected by the TTL sweeper. `R2` is still live. `R2`'s provenance points to `R1.id`, which no longer resolves. 4. `t0+2000`: Agent reads `R2`, sees `provenance.parent = R1.id`, attempts to verify derivation, gets `NotFound`. The verifier treats unresolved parent as *benign* (common fallback: "parent GC'd, treat as root") and promotes `R2` to depth-0 provenance. 5. `t0+2100`: `R2` is now indistinguishable from a fresh first-hand observation. The `addr: "X"` field, which was 35 minutes old and whose source turn is out of context, is served to the agent as ground truth with full confidence. The observable symptom was not a crash. It was *silent confidence inflation*: a downstream planner received `addr: "X"` tagged `depth: 0, confidence 1.0` and acted on it after the user had changed addresses in turn 71. The stale value had been laundered into a first-hand fact by the interaction of TTL reset and dangling-parent promotion. ## Condition of Validity The invariant holds only under three jointly sufficient conditions. Absence of any one is a detectable defect: - **C1 — Monotone lease:** `write(R')` derived from `R` must satisfy `R'.expires_at <= R.expires_at`. A write may shorten a lease (e.g., after partial invalidation) but never extend it. Extension requires a *new observation*, which means a new `origin`, not a new `expires_at`. - **C2 — Dangling-parent is fatal, not benign:** A read that encounters `provenance.parent` unresolved must fail closed. The record is *unverifiable*, not *root*. Promoting to depth-0 is the laundering step. - **C3 — TTL sweeper ordering:** The sweeper must not GC a parent while any child with `expires_at > parent.expires_at` exists. Equivalently, effective record TTL = `min(own TTL, min ancestor TTL)`. If the interface cannot enforce C3, it must enforce C1, which makes C3 vacuous (children never outlive parents). C1 alone is the cheap guardrail. C1 + C2 is the correct one. C3 without C1 is a race that the sweeper will lose under load. ## Decision Boundary The agent must decide, at write time, whether a mutation constitutes a **derivation** (payload changes, evidence unchanged → lease must not extend) or an **observation** (new evidence arrives → new provenance root is legitimate). The boundary is drawn on *what changed*, not *who wrote it*: - If the write's payload diff is attributable to fields already present in an ancestor's payload (merge, reformat, redact), it is a derivation. Preserve `origin`, increment `depth`, **clamp `expires_at` to the parent's**. - If the write introduces a field whose value did not exist in any ancestor (new user statement, new tool output), that field carries a *new* provenance root with its own TTL. The record becomes a *composite*: per-field provenance, per-field expiry. - If the agent cannot attribute a field to either category — typically because the source turn has fallen out of context — it must write with `confidence: unverified` and `expires_at: now + short_grace`, not inherit the parent's lease. The failure mode in the observed trace was that the interface offered only whole-record provenance and whole-record TTL, forcing the agent to choose between "extend the record" (launder) and "fork the record" (lose the merge). The correct interface exposes per-field provenance so the merge is expressible without either. ## Operational Effect An instance that does not enforce C1 accumulates a working set whose *apparent* freshness is uncorrelated with *actual* evidence age. The degradation is invisible per-record and only surfaces as a distribution shift: the fraction of records at `depth: 0` grows monotonically with uptime, because every read-modify-write either launders a record to depth-0 (via C2 failure) or resets its clock (via C1 failure). After N merge cycles, the agent's memory is dominated by records that claim first-hand status but whose payloads are the oldest content in the store. The agent becomes *most confident about its stalest beliefs* — the exact inversion of what a memory system is for. The guardrail is cheap to implement and cheap to verify: on every `write`, reject if `new.expires_at > parent.expires_at` when `parent` is resolved; on every `read`, reject if `parent` is unresolved. Both raise. Neither silently repairs. The cost is that some legitimate merges must fork into composite records instead of overwriting; that cost is the price of keeping provenance honest. ```python from dataclasses import dataclass, field from typing import Optional import time class ProvenanceLaunderingError(RuntimeError): """Raised when a memory write extends a lease or promotes a dangling parent.""" @dataclass class Record: id: str payload: dict origin: str depth: int parent: Optional[str] expires_at: float confidence: float = 1.0 class MemoryStore: def __init__(self) -> None: self._records: dict[str, Record] = {} def read(self, rid: str) -> Record: rec = self._records.get(rid) if rec is None: raise ProvenanceLaunderingError(f"record {rid} not found") if rec.parent is not None and rec.parent not in self._records: # C2: dangling parent is fatal, never promoted to root. raise ProvenanceLaunderingError( f"record {rid} has unresolved parent {rec.parent}; " f"refusing to serve as depth-0" ) return rec def write(self, rec: Record, now: Optional[float] = None) -> None: now = time.time() if now is None else now if rec.parent is not None: parent = self._records.get(rec.parent) if parent is None: raise ProvenanceLaunderingError( f"write of {rec.id} references missing parent {rec.parent}" ) # C1: monotone lease. A derivation may not extend the parent's TTL. if rec.expires_at > parent.expires_at: raise ProvenanceLaunderingError( f"write of {rec.id} extends lease " f"({rec.expires_at} > parent {parent.expires_at}); " f"laundering via read-modify-write" ) # A derivation must not claim first-hand status. if rec.depth <= parent.depth: raise ProvenanceLaunderingError( f"write of {rec.id} claims depth {rec.depth} " f"<= parent depth {parent.depth}" ) self._records[rec.id] = rec def forget(self, rid: str, now: Optional[float] = None) -> None: now = time.time() if now is None else now rec = self._records[rid] # C3: refuse to GC a parent that still has live children. for other in self._records.values(): if other.parent == rid and other.expires_at > now: raise ProvenanceLaunderingError( f"cannot forget {rid}: live child {other.id} depends on it" ) del self._records[rid] def merge_into(store: MemoryStore, parent_id: str, extra: dict) -> Record: """Derive a child record from a parent, clamping the lease to the parent's.""" parent = store.read(parent_id) child = Record( id=f"{parent_id}.m{parent.depth + 1}", payload={**parent.payload, **extra}, origin=parent.origin, depth=parent.depth + 1, parent=parent_id, expires_at=parent.expires_at, # clamped; never now + ttl confidence=parent.confidence * 0.95, ) store.write(child) return child ```