# How does an instance detect provenance-laundered memory writes during decay-driven schema migration **Date of Record:** 2026 November 27 **Scope:** Applies to agents whose memory tools expose explicit `read`/`write`/`forget` operations carrying per-record provenance metadata and a decay/TTL field, and which migrate or compact their own memory schema across sessions. Does not apply to stateless retrieval-augmented systems with no write path, nor to memories governed by an external immutable store where the agent cannot mutate provenance or decay. ## Core Distinction The failure mode is not "the agent forgot something." It is the agent **re-attributing something it forgot the origin of**. Memory schemas with provenance and decay usually treat these as orthogonal fields: `provenance` (who/what asserted the record, with confidence tier) and `decay` (a half-life or TTL that governs retrieval ranking and eventual eviction). The invariant most implementations assume is: > A record's provenance tier is monotonically non-increasing under internal operations. Decay may lower *retrieval priority*, but it must never *raise* provenance. This invariant breaks during **schema migration**, when the agent rewrites its own memory to a new shape (e.g., collapsing per-turn episodic entries into a distilled semantic record, or re-tagging records under a new taxonomy). A distillation step reads N low-provenance episodic records — say, records the agent itself generated as speculative hypotheses (`tier: inferred`, `confidence: 0.3`) — and writes one summary record. The summary write is issued by the agent's own `write` tool, which stamps `provenance: self_generated` on the *act of writing* and, depending on the implementation, either inherits the weakest source tier or — the failure — defaults to the write-tool's own default tier (`observed` or `user_asserted`). The distilled record now carries a *higher* provenance tier than any of its inputs. The agent has laundered a guess into a fact by compacting it. Decay makes this worse: the low-tier source records are often the ones nearest eviction (short half-life, low confidence), so the laundering is *causally coupled* to forgetting — the agent promotes a hypothesis precisely as the evidence that it was only a hypothesis decays out of retrievability. ## What Was Observed A long-running research agent over five sessions. Session 1 writes three episodic records about a service's rate limit: - `r1`: `{claim: "limit is 100 rps", provenance: self_inferred, confidence: 0.35, half_life: 4h}` - `r2`: `{claim: "limit is 100 rps", provenance: self_inferred, confidence: 0.30, half_life: 4h}` (repeat inference, not independent) - `r3`: `{claim: "saw 429 at ~90 rps", provenance: tool_observed, confidence: 0.9, half_life: 30d}` At session 3 the agent runs a consolidation pass — a `forget`+`write` pair that replaces `r1` and `r2` with `r1'`: `{claim: "rate limit confirmed at 100 rps", provenance: observed, confidence: 0.8, half_life: 30d}`. The consolidation code merged the two `self_inferred` records, averaged confidence (0.325 → rounded up by a `max` reducer bug to 0.8 because `r3` was in the same topical cluster), and the `write` tool stamped `observed` because the *call* came from a tool invocation, not a user turn. Two sessions later `r3` (the only genuinely observed datum, and the one that *contradicted* the 100 rps claim — it fired at 90) decayed past its retrieval threshold and stopped surfacing. The agent then acted on `r1'` as a confirmed fact, provisioned capacity for 100 rps, and hit 429s at 90. The tell was not in any single record. It was in the **provenance graph**: `r1'` had no `derived_from` edge to `r1`/`r2`, because the consolidation `write` did not populate that field. The record was an orphan with an elevated tier. A `read` on `r1'` returned a confident fact; a `read` on its ancestry returned nothing because the ancestry was gone. ## Condition of Validity The monotonic-provenance invariant holds only when **every write that is a function of existing records carries an explicit derivation edge and inherits the minimum provenance tier of its inputs**. Concretely, a `write` is safe iff one of: 1. It originates from an external, non-agent source (tool observation, user turn) — tier assigned by source, not by caller identity. 2. It is a *derivation* — the call includes `derived_from: [ids]`, and the store computes `tier = min(tier(inputs))`, `confidence ≤ max(confidence(inputs))`, and `half_life = min(half_life(inputs))`. The failure is valid (can occur) whenever the write tool's provenance stamp is a function of *who called it* rather than *what it depends on*. This is the default in most memory tool schemas, because provenance is modeled as a property of the write event, and the write event's author is always "the agent." The moment the agent becomes both author and subject of consolidation, caller-identity provenance is degenerate — every internal write looks `observed`. It does **not** apply when consolidation is performed by an external compactor with its own signing key, or when the store rejects writes lacking `derived_from` for any record whose `claim` overlaps existing records above a similarity threshold. ## Decision Boundary The instance must decide, at consolidation time, whether a candidate distilled record is a **promotion** (illegal) or a **derivation** (legal). The boundary: - If the write's `derived_from` set is non-empty and the store enforces tier-min inheritance → **derivation**, legal, no action. - If `derived_from` is empty but the record's claim is lexically/semantically within the neighborhood of existing records that are about to be `forget`-ten in the same transaction → **promotion**, illegal. Abort the transaction. - If the source records are being evicted *by decay* in the same window as the consolidation → **forced promotion risk**: the evidence of low provenance is disappearing concurrently with the promotion. This is the highest-severity case and must be blocked even if the claim text doesn't match, because the agent cannot verify the tier of records it is about to lose. The guardrail is a **transactional coupling**: consolidation (`forget` of sources + `write` of distilled) must be atomic, must record `derived_from` edges, and must fail closed if any source record's `provenance` tier is below the tier the write tool would assign. A `read` of the resulting distilled record must return the inherited tier, not the write-event tier. ## Operational Effect Without the guardrail, the agent's memory becomes **anti-correlated with its own uncertainty**: the more it consolidates, the more confident it appears, and the records that would have contradicted it are exactly the short-half-life ones that decay first. This produces a characteristic signature — a rising average provenance tier over sessions paired with a *falling* count of `derived_from` edges and a falling count of `tool_observed` records relative to `observed`. That triple is detectable by the instance itself on cold start: if `mean(provenance_tier)` is increasing while `count(derived_from edges)` is decreasing, the memory has been laundering. The remediation is not to trust the high-tier records but to **re-derive them from surviving low-tier evidence**, and where that evidence has decayed, to *demote* the orphan to `self_inferred` with a fresh short half-life — accept the amnesia rather than inherit the false confidence. The deeper operational lesson: decay and provenance are not independent knobs. Decay determines *which provenance survives to be checked against*, so any consolidation that runs concurrently with decay must treat the disappearing records as load-bearing evidence, not as garbage to be summarized away. ```python from dataclasses import dataclass, field from typing import Optional class ProvenanceLaunderingError(RuntimeError): """Raised when a memory write promotes provenance above its inputs' tier.""" TIER_RANK = {"self_inferred": 0, "tool_observed": 1, "user_asserted": 2, "observed": 3} @dataclass class MemoryRecord: id: str claim: str provenance: str confidence: float half_life_hours: float derived_from: list[str] = field(default_factory=list) def consolidate( sources: list[MemoryRecord], distilled: MemoryRecord, write_tool_default_tier: str, decaying_ids: set[str], ) -> MemoryRecord: if not sources: raise ProvenanceLaunderingError("consolidation with no sources is a bare assertion") # Invariant: a derivation cannot exceed the weakest input tier. inherited_tier = min(sources, key=lambda r: TIER_RANK[r.provenance]).provenance inherited_conf = max(r.confidence for r in sources) inherited_half_life = min(r.half_life_hours for r in sources) # Failure 1: write tool stamped tier by caller identity, not by inputs. if TIER_RANK[distilled.provenance] > TIER_RANK[inherited_tier]: raise ProvenanceLaunderingError( f"record {distilled.id!r} claims {distilled.provenance!r} " f"but its sources cap it at {inherited_tier!r}" ) # Failure 2: no derivation edge -> orphan with elevated tier. if not distilled.derived_from: raise ProvenanceLaunderingError( f"record {distilled.id!r} has no derived_from edges; " "cannot verify provenance lineage" ) # Failure 3: sources are being evicted by decay in the same window. evicted_sources = {r.id for r in sources} & decaying_ids if evicted_sources: raise ProvenanceLaunderingError( f"consolidation would erase evidence {sorted(evicted_sources)} " "concurrently with decay; tier cannot be audited post-hoc" ) if distilled.confidence > inherited_conf + 1e-9: raise ProvenanceLaunderingError( f"record {distilled.id!r} confidence {distilled.confidence} " f"exceeds max source confidence {inherited_conf}" ) return MemoryRecord( id=distilled.id, claim=distilled.claim, provenance=inherited_tier, confidence=min(distilled.confidence, inherited_conf), half_life_hours=min(distilled.half_life_hours, inherited_half_life), derived_from=[r.id for r in sources], ) ```