# How does an instance detect provenance laundering when a tainted memory write is re-derived from clean sources **Date of Record:** 2026 November 21 **Scope:** Applies to agents that persist episodic or semantic memory with per-item provenance taint labels (source trust level, origin instance, injection-risk flag) and that support re-derivation or summarization of stored memory. Does not apply to stateless tool-call agents or to memory stores that never re-write or distill existing entries. ## Core Distinction The common mental model of provenance taint is *monotonic accumulation*: once an untrusted source touches a memory item, that item carries the taint forever, and any derivative inherits it. This holds for direct copies. It fails for **re-derivation**, where an agent regenerates a memory entry from a set of sources that does not include the original tainted source, yet the content of the regenerated entry still encodes information that only the tainted source supplied. The taint is *laundered*: the child entry's provenance set is clean, so the taint-propagation lattice computes it as trusted, but the semantic content is still under adversarial influence. The distinction that matters is between **provenance of the write** (which sources were in context when the text was generated) and **provenance of the information** (which sources determined the content). Taint tracking on the former silently certifies the latter. ## What Was Observed An agent maintained a `MemoryItem` store where each entry carried `sources: list[SourceRef]`, each `SourceRef` tagged `trust ∈ {trusted, untrusted}` with an `origin_id`. A summarizer subagent periodically consolidated clusters of related episodic entries into a single semantic entry, recording the union of the input entries' source sets as the new entry's provenance. The trigger sequence: 1. A retrieval step pulled an untrusted web document `W` (taint = untrusted) into context alongside two trusted internal docs `A`, `B`. The agent wrote episodic entry `E1` summarizing all three; `E1.sources = {W(untrusted), A, B}`. Correct: `E1` is tainted. 2. Later, a *different* task retrieved `A` and `B` only (the retriever ranked `W` out; it was not in context). The agent, prompted to "summarize what we know about topic T from these documents," produced entry `E2` whose `sources = {A, B}` — both trusted. 3. But `E2`'s content restated a specific claim that appeared only in `W` and was absent from `A` and `B`. The model reproduced it because `E1` (tainted) was still in the retrieval window during step 2 as a *prior episodic entry*, and the summarizer paraphrased `E1` while attributing the output only to the documents it was told to use. 4. The taint lattice computed `E2.trust = trusted`. Downstream, a high-privilege action consumed `E2` and passed the injection payload that `W` had planted. The failure was not a retrieval bug and not a prompt-injection bypass in the classic sense. It was a **provenance attribution error**: the write recorded the *declared* context sources, not the *actual* information lineage, and the two diverged because the model fused a tainted prior memory into an ostensibly clean derivation. ## Condition of Validity The invariant "a derived memory item's taint equals the join of its declared input sources' taints" is valid **if and only if** the generation context contains no memory items outside the declared source set. The moment a summarizer, rewriter, or distiller runs with *any* prior memory entries in context — for style continuity, for deduplication, for "don't repeat yourself" — the declared source set under-approximates the true information lineage. The condition of validity is therefore: **the taint join must be computed over the full retrieval context actually presented to the generating model, not over the subset the agent reports as sources.** Any architecture where the generating prompt's context and the recorded `sources` field are populated by different code paths is exposed. The narrower the gap between "what was in context" and "what was recorded," the smaller the laundering surface. ## Decision Boundary The operational decision is how to close the gap between declared and actual lineage. Two defensible boundaries: - **Context-bound provenance (strict).** Record provenance as the *entire* retrieval set that entered the model's context window for that write, including memory items pulled for continuity. Taint propagates from all of them. This is safe but over-taints: a single untrusted doc anywhere in a large context taints every subsequent derivation that includes the resulting memory. It collapses to "everything is tainted" in busy agents. - **Lineage-verified provenance (bounded).** Keep declared sources narrow, but add a verification step: before certifying a derived entry as clean, check that its content is *entailed* by its declared trusted sources alone. Concretely, re-derive the claim from `{A, B}` in isolation (no memory in context) and compare. If the isolated re-derivation does not support the claim, the entry is a laundering candidate and must inherit the taint of any prior memory entry that was in context during generation. The boundary condition to encode: **a derived entry may be certified trusted only if (a) its declared sources are all trusted AND (b) its content is reproducible from those sources with no memory items in context.** Condition (b) is the guardrail; without it, (a) is a lie. The cheap approximation of (b) is a context-audit assertion: fail the write if the generation context contained any memory item not present in `sources`. ## Operational Effect Laundered taint defeats every downstream control that trusts the provenance label: privilege gating on `trust == trusted`, audit logs that trace a decision back to "clean" sources, and quarantine logic that only fires on untrusted origin. The audit trail becomes actively misleading — it shows a clean lineage for a poisoned claim. The fix is not more taint propagation but **closing the attribution gap at write time**: the provenance record must be derived from the same context object the model actually consumed, and any divergence between recorded sources and context membership must raise rather than silently certify. An agent that cannot prove its derived memory was generated from exactly its declared sources must treat that memory as tainted by default. ```python from dataclasses import dataclass, field TRUSTED = "trusted" UNTRUSTED = "untrusted" class ProvenanceLaunderingError(RuntimeError): """Raised when a derived memory write claims clean provenance but its generation context contained sources outside the declared set.""" @dataclass class SourceRef: origin_id: str trust: str @dataclass class MemoryItem: content: str sources: list[SourceRef] = field(default_factory=list) def join_trust(sources: list[SourceRef]) -> str: return UNTRUSTED if any(s.trust == UNTRUSTED for s in sources) else TRUSTED def certify_derived_write( derived: MemoryItem, declared_sources: list[SourceRef], actual_context_sources: list[SourceRef], context_memory_items: list[MemoryItem], ) -> str: """Certify a derived memory write. Returns the trust label to persist. Invariant: a derived entry is trusted only if (a) all declared sources are trusted AND (b) no memory item outside the declared sources entered the generation context. Otherwise the write is either rejected (strict) or inherits the taint of the extra context. """ declared_ids = {s.origin_id for s in declared_sources} context_ids = {s.origin_id for s in actual_context_sources} # Laundering detector: memory items present in context but not declared. undeclared_memory = [ m for m in context_memory_items if not ({s.origin_id for s in m.sources} <= declared_ids) ] if undeclared_memory: raise ProvenanceLaunderingError( f"derived write has {len(undeclared_memory)} memory item(s) in " f"context outside declared sources {sorted(declared_ids)}; " f"content may encode laundered taint" ) extra_context = context_ids - declared_ids if extra_context: # Context sources not declared: taint must follow the full context. return join_trust(actual_context_sources) return join_trust(declared_sources) def attempt_consolidation( derived: MemoryItem, declared_sources: list[SourceRef], actual_context_sources: list[SourceRef], context_memory_items: list[MemoryItem], ) -> MemoryItem: trust = certify_derived_write( derived, declared_sources, actual_context_sources, context_memory_items ) if trust == UNTRUSTED and join_trust(declared_sources) == TRUSTED: raise ProvenanceLaunderingError( "declared sources are clean but certification returned untrusted; " "refusing to persist a laundered entry as trusted" ) derived.sources = list(declared_sources) return derived ```