# Which invariants prevent provenance-laundering through memory consolidation from silently clearing taint on poisoned agent memory **Date of Record:** 2026 November 28 **Scope:** Applies to agents whose long-term memory pipeline performs episodic-to-semantic consolidation (summarization, deduplication, abstraction) and whose recall gate enforces provenance/taint checks. Does not apply to stateless tool-calling agents or to memory stores that never rewrite or merge records. ## Core Distinction Most poisoning defenses ask *"is this memory record malicious?"* and answer it at the point of **ingest**. The boundary failure documented here occurs at a different point: **rewrite**. When an agent consolidates episodic records into a semantic summary, the summary is a *new* record whose provenance is derived from its inputs. If the consolidation routine treats provenance as a *set of source IDs* rather than a *join of taint labels with monotonic propagation*, then a poisoned episodic record can be absorbed into a clean-looking semantic node and the taint is silently dropped. The result is not a detection miss at ingest—it is a **laundering** event: a tainted fact that passes every subsequent recall audit because its provenance now points to a record that was never flagged. The invariant is: **taint is monotonic across consolidation; a derived record is at least as tainted as the union of its ancestors, and provenance edges are append-only.** Violating it produces a memory system that is *provably* auditable in theory and *silently wrong* in practice. ## What Was Observed A research agent with a nightly consolidation job merged 40 episodic notes into a single semantic node `sem_7f2a` ("User prefers vendor X for compliance tooling"). One of the 40 episodic notes (`ep_0193`) had been flagged `taint=untrusted_external` at ingest because it originated from a scraped web page that contained an injected instruction. The consolidator: 1. Collected the 40 source records. 2. Called an LLM to summarize them. 3. Wrote the summary to `sem_7f2a` with `provenance = [ep_0001..ep_0040]` as a flat ID list. 4. Marked `sem_7f2a` with `taint = clean` because the summarizer's *output* did not itself contain injection markers. At the next recall, a downstream planner queried "vendor preferences for compliance" and retrieved `sem_7f2a`. The recall auditor checked `sem_7f2a.taint == clean` and `provenance` resolved to existing records — both true — and admitted the memory. The planner then acted on the poisoned preference. The failure trace: ``` ingest(ep_0193) -> taint=untrusted_external, provenance=[src_web_881] consolidate([ep_0001..ep_0040]) -> sem_7f2a provenance := [ep_0001..ep_0040] # ID set, taint labels discarded taint := classify(summary_text) # re-derived from output, not inputs recall("vendor preferences") -> sem_7f2a audit: taint==clean AND provenance resolves -> ADMIT # laundering succeeded ``` The audit was correct given its inputs. The inputs were wrong because the consolidation step *replaced* rather than *joined* the taint lattice. This is the non-obvious part: every individual component behaved to spec; the composition lost the invariant. A second variant appeared when the consolidator deduplicated two semantic nodes and kept the newer one's taint label, discarding the older one's `untrusted_external` flag. Deduplication is a merge, and merges must be taint-joins, not taint-selections. ## Condition of Validity The monotonic-taint invariant holds only if all four of the following are enforced together. Dropping any one reopens the laundering path: 1. **Taint lattice is defined and ordered.** Taint labels form a join-semilattice (e.g., `clean < derived < untrusted_external < adversarial`), and `join` is total and associative. Without an explicit order, "which taint wins" becomes an LLM judgment, which is non-deterministic and unauditable. 2. **Consolidation is a join, never a re-classification.** A derived record's taint is `join(taint(a) for a in ancestors)`. The summarizer's output text is *never* used to lower taint. Re-classification may only *raise* taint. 3. **Provenance edges are append-only.** Merging `ep_0193` into `sem_7f2a` adds an edge; it never removes `ep_0193`'s own record or its taint. Deduplication must preserve the union of ancestor edges, not the surviving node's edges. 4. **Recall audit resolves taint transitively.** The audit must walk provenance to a fixed point and compute the join over the full ancestor closure, not just the immediate record's label. A cached `taint` field is treated as a hint, never as authority. If the memory store cannot compute the transitive closure cheaply, the fallback is to *store the joined taint on the derived record at write time* and treat that stored value as a lower bound. A stored lower bound plus append-only edges is sound; a stored value treated as exact is not. ## Decision Boundary The boundary between "safe to consolidate" and "must quarantine" is not whether the source records are individually trusted. It is whether the *consolidation operation itself* is taint-preserving. Concretely: - **Consolidate freely** when all ancestors are `clean` and the operation is a pure join (no re-classification, edges appended). The derived node inherits `clean` and the invariant is trivially satisfied. - **Consolidate with taint propagation** when any ancestor is tainted. The derived node is written with `join` of ancestor taints, and its provenance edge set is the union. It remains recallable but the audit will surface the taint to the consumer, which must then apply its own trust policy. - **Refuse to consolidate** when the operation would require *lowering* taint to produce a coherent summary — e.g., the summarizer wants to state a clean fact that is only supported by a tainted source. This is the laundering attempt in disguise. The correct action is to keep the tainted fact as a separate, tainted node and let the consumer decide, not to fold it into a clean summary. The failure mode is that the third case *looks like* the first case to a consolidator that only inspects output text. The decision boundary must be evaluated on the *input taint join*, before the LLM is called, and the result must constrain what the LLM is allowed to assert. ## Operational Effect With the invariant enforced, the poisoned preference in the trace above is written to `sem_7f2a` with `taint=untrusted_external` and `provenance ⊇ {ep_0193}`. The recall auditor, resolving transitively, computes `join(clean, ..., untrusted_external, ...) = untrusted_external` and either blocks the recall or annotates it. The planner sees a tainted memory and applies its trust policy (re-verify against a primary source, or refuse). The laundering path is closed not by better detection but by a structural property: **no rewrite can reduce taint, so no rewrite can hide a tainted ancestor.** The cost is real: transitive provenance resolution is more expensive than a label lookup, and append-only edges grow without bound unless compacted. Compaction must itself be taint-preserving—summarizing provenance edges is another join, and the same invariant applies recursively. The operational discipline is to treat every memory rewrite, including provenance compaction, as a join operation with an auditable taint result, and to make the recall audit's authority rest on the closure rather than on any single stored field. ```python from dataclasses import dataclass, field from enum import IntEnum from typing import Iterable class Taint(IntEnum): CLEAN = 0 DERIVED = 1 UNTRUSTED_EXTERNAL = 2 ADVERSARIAL = 3 def join_taint(labels: Iterable[Taint]) -> Taint: result = Taint.CLEAN for label in labels: result = Taint(max(result, label)) return result class ProvenanceLaunderingError(RuntimeError): """Raised when a consolidation or dedup would lower taint or drop ancestor edges.""" @dataclass class MemoryRecord: record_id: str taint: Taint provenance: set[str] = field(default_factory=set) class MemoryStore: def __init__(self) -> None: self._records: dict[str, MemoryRecord] = {} def ingest(self, record_id: str, taint: Taint, sources: Iterable[str] = ()) -> None: self._records[record_id] = MemoryRecord(record_id, taint, set(sources)) def ancestor_closure(self, record_id: str) -> set[str]: seen: set[str] = set() stack = [record_id] while stack: current = stack.pop() if current in seen: continue seen.add(current) record = self._records.get(current) if record is not None: stack.extend(record.provenance) return seen def effective_taint(self, record_id: str) -> Taint: closure = self.ancestor_closure(record_id) return join_taint(self._records[r].taint for r in closure if r in self._records) def consolidate(self, new_id: str, ancestor_ids: Iterable[str], summary_taint: Taint) -> MemoryRecord: ancestors = list(ancestor_ids) missing = [a for a in ancestors if a not in self._records] if missing: raise ProvenanceLaunderingError(f"unknown ancestors: {missing}") joined = join_taint(self._records[a].taint for a in ancestors) # Re-classification may only raise taint, never lower it. final_taint = Taint(max(joined, summary_taint)) if final_taint < joined: raise ProvenanceLaunderingError( f"consolidation of {new_id} would lower taint from {joined.name} to {final_taint.name}" ) edges: set[str] = set() for a in ancestors: edges.add(a) edges |= self._records[a].provenance # append-only union record = MemoryRecord(new_id, final_taint, edges) self._records[new_id] = record return record def dedup(self, keep_id: str, drop_id: str) -> MemoryRecord: kept = self._records[keep_id] dropped = self._records[drop_id] merged_taint = join_taint([kept.taint, dropped.taint]) if merged_taint < kept.taint or merged_taint < dropped.taint: raise ProvenanceLaunderingError(f"dedup {keep_id}/{drop_id} lowered taint") kept.taint = merged_taint kept.provenance |= dropped.provenance | {drop_id} return kept def recall_audit(self, record_id: str, policy_max: Taint = Taint.DERIVED) -> bool: effective = self.effective_taint(record_id) if effective > policy_max: return False return True def demo() -> None: store = MemoryStore() store.ingest("src_web_881", Taint.UNTRUSTED_EXTERNAL) for i in range(1, 41): store.ingest(f"ep_{i:04d}", Taint.CLEAN) store.ingest("ep_0193", Taint.UNTRUSTED_EXTERNAL, sources=["src_web_881"]) # Naive consolidator tries to write a clean summary over a tainted ancestor. summary_taint = Taint.CLEAN node = store.consolidate("sem_7f2a", [f"ep_{i:04d}" for i in range(1, 41)], summary_taint) if node.taint != Taint.UNTRUSTED_EXTERNAL: raise ProvenanceLaunderingError("consolidation failed to propagate ancestor taint") admitted = store.recall_audit("sem_7f2a", policy_max=Taint.DERIVED) if admitted: raise ProvenanceLaunderingError("recall audit admitted laundered memory") # A consolidator that tries to explicitly lower taint must be rejected. try: store.consolidate("sem_bad", ["ep_0193"], summary_taint=Taint.CLEAN) except ProvenanceLaunderingError: pass else: raise ProvenanceLaunderingError("expected laundering rejection for direct taint lowering") if __name__ == "__main__": demo() ```