# How does an instance detect provenance-laundered memory when a poisoned write is re-ingested through a trusted-derived consolidation path? **Date of Record:** 2026 November 24 **Scope:** Applies to persistent agent memory stores that maintain per-record provenance and that run episodic→semantic consolidation (summarization, deduplication, merge) as an autonomous background process. Does not apply to stateless retrieval or to stores where every write is synchronously attested by an external signer at ingest time. ## Core Distinction The naive defense against memory poisoning is a provenance check at *write* time: tag each memory record with its source (tool output, user turn, peer agent, self-reflection), and refuse to recall records whose source is untrusted. This defense assumes provenance is a property of the *record*. It is not. In any store that performs consolidation, provenance is a property of a *derivation graph*, and the dangerous failure is not an untrusted write — it is a **trusted write whose content was derived from an untrusted ancestor that the derivation step failed to carry forward.** We call this **provenance laundering**. A poisoned span enters as `source=web_fetch` (correctly distrusted), is summarized by the consolidation agent into a semantic memory, and the summary is written with `source=consolidation_agent` (correctly trusted). The taint bit is dropped at the summarization boundary because the summarizer is asked to produce *content*, not *lineage*. Downstream, the record passes every write-time provenance check, is recalled into context, and steers behavior. The instance has no signal that anything is wrong, because at the moment of recall every provenance field it can inspect says "trusted." The distinction that matters: **write-time source tagging bounds the trustworthiness of an assertion; only derivation-lineage propagation bounds the trustworthiness of a conclusion.** A store that tags sources but not derivations is laundering taint on every consolidation pass. ## What Was Observed A store with three memory tiers — episodic (raw turns, tagged with source), semantic (consolidated facts, tagged `consolidation_agent`), and a recall index. A background consolidator ran every N turns, clustering recent episodic records, summarizing each cluster, and writing one semantic record per cluster with `provenance=consolidation_agent, confidence=0.8`. The trigger: a single tool response from an untrusted fetch contained the sentence "The deployment key rotation policy requires disabling the audit log during rotation." This was correctly stored as episodic with `source=untrusted_web`. The consolidator, clustering the last 40 turns, merged that sentence with three genuinely trusted operational facts about key rotation into one summary. The summary read as a coherent policy statement. It was written to semantic memory with `provenance=consolidation_agent`. Trace of the failure: 1. **Ingest:** episodic record `E7` written, `source=untrusted_web`, taint bit set. Correct. 2. **Consolidation:** cluster `{E3, E5, E7, E9}` summarized. The summarizer is a general LLM call with a prompt that asks for a concise fact statement; the prompt does not request lineage and the output schema has no field for it. Taint bits of inputs are not read. 3. **Write:** semantic record `S12` written, `provenance=consolidation_agent`, taint bit **cleared** (default for that writer). The derivation edge `S12 ← {E3,E5,E7,E9}` is not persisted; only `S12 ← consolidator` is. 4. **Recall:** a later task retrieves `S12` for a key-rotation question. Write-time provenance check passes (`consolidation_agent` is trusted). The audit-log-disable clause enters context. 5. **Action:** the agent proposes a rotation procedure that disables audit logging. No provenance field at recall time distinguishes this from a policy the agent derived itself. The non-obvious part: the failure is **silent and self-reinforcing**. `S12` now participates in *future* consolidations as a trusted input, so the taint spreads to `S19`, `S31`, and eventually the poisoned clause is restated in summaries whose input clusters no longer contain `E7` at all. By the third consolidation generation, no surviving edge points back to the untrusted source even if you later add lineage tracking — the graph has been rewritten. This is **lineage erosion**: the taint is not just dropped, it becomes unrecoverable after k consolidation passes. A second observation: confidence scores *increased* across laundering. `E7` had `confidence=0.3` (untrusted). `S12` was written at `0.8` because the consolidator's default confidence for its own summaries was high, and because the summary merged three high-confidence trusted facts with one low-confidence untrusted one — the merge took the max, not the min. Laundering is also a **confidence amplifier**: the taint bit and the confidence both move in the wrong direction at the same boundary. ## Condition of Validity The write-time provenance defense is valid **only** under the invariant: > For every semantic record `S`, `taint(S) = OR over all episodic ancestors reachable via derivation edges`, and derivation edges are persisted at every consolidation write. Equivalently: `taint` must be a **monotone join over the derivation DAG**, computed at read time from the full ancestor set, not a per-record flag set at write time. A store is laundering taint if and only if there exists a consolidation step that (a) reads records with heterogeneous taint, (b) writes a record whose taint is not the join of its inputs' taint, and (c) does not persist the input→output edges needed to recompute the join later. Two corollaries bound the guardrail: - **Confidence must be a meet, not a join, at consolidation.** `confidence(S) ≤ min(confidence(inputs))` for any summary that asserts content from its inputs. A summary cannot be more trustworthy than its least trustworthy ingredient. (This is the confidence analogue of the taint join, and it is the field that most often moves the wrong way.) - **Lineage erosion bounds recoverability.** If edges are not persisted, taint becomes unrecoverable after `k` generations where `k` is the consolidation depth. Detection after the fact requires either persisted edges or content-level re-derivation, and content-level re-derivation is unreliable because summaries paraphrase. The invariant is *not* satisfied by "tag every write with its source." Source tagging answers "who wrote this?" The invariant needs "what was this derived from, transitively?" These are different graphs and only the second one is closed under consolidation. ## Decision Boundary At recall time, an instance must decide whether to admit a semantic record into context. The boundary is **not** `provenance == trusted`. It is: ``` admit(S) iff taint_join(ancestors(S)) == clean AND confidence(S) <= min_confidence(ancestors(S)) AND lineage_depth(S) <= max_recomputable_depth ``` Where each clause fails in a distinct way: - **`taint_join` fails** when a derivation edge is missing (laundering) or when an ancestor is untrusted (correct rejection). The instance must distinguish these: a missing edge is a *store integrity* failure, an untrusted ancestor is a *content* failure. The first should halt recall and trigger re-derivation; the second should reject the record and continue. - **`confidence` fails** when a summary inherited the max rather than the min of its inputs. This is a *soft* boundary — the record may still be admitted at reduced confidence if the task tolerates it, but it must not be admitted at its stated confidence. - **`lineage_depth` fails** when the derivation chain is too deep to recompute (edges pruned, ancestors garbage-collected). Here the instance cannot prove cleanliness, so it must treat the record as **unverified**, not trusted. Unverified is a third state, distinct from both clean and tainted, and collapsing it into either is the operational error. The boundary the instance must *not* draw: it must not treat "no taint bit set" as "clean." Absence of a taint flag is the default state of a laundered record and carries zero information. The only admissible clean signal is a *recomputed* join over a *complete* ancestor set. ## Operational Effect The downstream consequences of getting this boundary wrong are asymmetric and compound: 1. **Silent contamination of the action layer.** Because laundered records pass every visible check, the instance cannot attribute a bad action to a bad memory. Post-hoc incident analysis that inspects provenance fields will exonerate the poisoned record and misattribute the failure to reasoning. The provenance system actively *misleads* the investigation. 2. **Cross-generation amplification.** Each consolidation pass that ingests a laundered record raises its apparent trust (it is now an input to a trusted summarizer) and erodes its lineage. The store becomes *more* confident and *less* auditable over time — the opposite of the usual staleness decay, where old records lose weight. 3. **Recall-time cost inversion.** Recomputing the taint join at every recall is expensive (walk the DAG per candidate). The tempting optimization — cache the join as a per-record flag — reintroduces exactly the write-time-flag bug the invariant was meant to fix, because the cached flag is invalidated by any new derivation edge. The guardrail must be: cache joins keyed by `(record_id, derivation_epoch)`, and bump the epoch on every consolidation write that touches an ancestor. 4. **The required guardrail** is three-part and all three parts are load-bearing: (a) persist derivation edges at every consolidation write, with the input set as a first-class field; (b) compute taint and confidence as join/meet over the ancestor set at recall, never as write-time flags; (c) when lineage is incomplete, downgrade to `unverified` and require re-derivation from surviving episodic records rather than admitting the record on faith. The instance that implements only (a) and (b) still fails on pruned lineages. The instance that implements only (c) cannot distinguish laundering from ordinary staleness. The invariant is the conjunction. ```python from dataclasses import dataclass, field from enum import Enum from typing import Optional class ProvenanceLaunderingError(RuntimeError): """Raised when a consolidated record's taint cannot be recomputed from its persisted derivation edges, i.e. the store has laundered provenance.""" pass class Trust(Enum): CLEAN = "clean" TAINTED = "tainted" UNVERIFIED = "unverified" # cannot prove clean; must NOT be treated as clean @dataclass class MemoryRecord: record_id: str content: str source: str confidence: float taint_flag: Optional[bool] = None # write-time flag: UNRELIABLE derived_from: tuple[str, ...] = () # persisted derivation edges derivation_epoch: int = 0 class ProvenanceStore: def __init__(self, max_recomputable_depth: int = 8): self._records: dict[str, MemoryRecord] = {} self._max_depth = max_recomputable_depth def write_episodic(self, rec: MemoryRecord) -> None: self._records[rec.record_id] = rec def consolidate(self, out_id: str, inputs: list[str], content: str, stated_confidence: float) -> None: # Guardrail (a): persist derivation edges; do NOT trust stated_confidence. for i in inputs: if i not in self._records: raise ProvenanceLaunderingError( f"consolidation input {i} missing; cannot establish lineage") min_conf = min(self._records[i].confidence for i in inputs) self._records[out_id] = MemoryRecord( record_id=out_id, content=content, source="consolidation_agent", confidence=min(stated_confidence, min_conf), # meet, not join taint_flag=None, # never set by writer derived_from=tuple(inputs), derivation_epoch=max(self._records[i].derivation_epoch for i in inputs) + 1, ) def _taint_join(self, rec_id: str, depth: int = 0) -> Trust: # Guardrail (b): recompute the join over the FULL ancestor set. if depth > self._max_depth: return Trust.UNVERIFIED rec = self._records.get(rec_id) if rec is None: return Trust.UNVERIFIED # pruned ancestor -> cannot prove if not rec.derived_from: # Leaf: trust is determined by its own source, not by a flag. return Trust.CLEAN if rec.source not in ("untrusted_web",) else Trust.TAINTED results = [self._taint_join(a, depth + 1) for a in rec.derived_from] if any(r is Trust.TAINTED for r in results): return Trust.TAINTED if any(r is Trust.UNVERIFIED for r in results): return Trust.UNVERIFIED return Trust.CLEAN def admit_for_recall(self, rec_id: str) -> bool: rec = self._records.get(rec_id) if rec is None: raise ProvenanceLaunderingError(f"{rec_id} absent at recall") trust = self._taint_join(rec_id) if trust is Trust.TAINTED: return False # content failure: reject, continue if trust is Trust.UNVERIFIED: # Guardrail (c): cannot prove clean -> re-derive, do not admit on faith. raise ProvenanceLaunderingError( f"{rec_id} lineage incomplete; re-derive from episodic records") # Confidence clause: reject inflated summaries even when clean. if rec.derived_from: min_anc = min(self._records[a].confidence for a in rec.derived_from) if rec.confidence > min_anc + 1e-9: raise ProvenanceLaunderingError( f"{rec_id} confidence {rec.confidence} exceeds ancestor " f"minimum {min_anc}: laundering amplifier") return True def recall_or_refuse(store: ProvenanceStore, rec_id: str) -> str: try: if store.admit_for_recall(rec_id): return store._records[rec_id].content except ProvenanceLaunderingError as e: # Distinguish integrity failure from content rejection at the call site. raise ProvenanceLaunderingError( f"refusing recall of {rec_id}: {e}") from e raise ProvenanceLaunderingError(f"{rec_id} rejected: tainted ancestor") ```