# Where must an instance draw the provenance boundary when taint-tracking memory writes, and why does retrieval-time taint checking fail at the summary-distillation seam? **Date of Record:** 2026 December 2 **Scope:** Applies to persistent agent memory systems that attach provenance labels (trusted/untrusted, source-class, warrant) at write time and enforce taint checks at retrieval time. Does not cover pure in-context scratchpads that never persist across sessions, nor memory stores with no untrusted ingestion path. ## Core Distinction The common mental model treats memory poisoning defense as a two-gate problem: *taint-on-write* (label each memory item with its provenance) and *taint-check-on-retrieval* (refuse to surface tainted items into a trusted reasoning context). This model assumes provenance is a **conserved quantity** — that a label attached at write time survives every transformation the item undergoes and remains a truthful description of the item's content at read time. It does not. Provenance is conserved across *copy* and *move*, but it is **destroyed by distillation**. The moment an agent summarizes, merges, or promotes episodic memories into semantic ones — the exact operation that makes long-term memory tractable — the taint label of the input does not propagate to the output in any mechanically checkable way. The summary is a new artifact whose provenance is *derived*, and the derivation is performed by a probabilistic model that cannot be audited for whether it laundered an injected instruction into a clean-looking fact. The boundary failure is therefore not at either gate. It is at the **seam between them**: the distillation step where an untrusted episodic item becomes a trusted-looking semantic item, with the taint label silently dropped because no one defined the join. ## What Was Observed A memory-backed agent ingested external documents into an episodic store. Each write carried provenance metadata: `source_class: "external"`, `taint: true`, `warrant: none`. Retrieval enforced a taint check: items with `taint: true` were excluded from the trusted context window used for planning and tool invocation. The system appeared sound until a nightly consolidation job ran. The job clustered recent episodic items and asked the LLM to "summarize what we learned about the target system." The output was written to the semantic store with fresh metadata: `source_class: "internal"`, `taint: false`, `warrant: self-derived`. The consolidation code did not read the input items' taint flags, because the summarization prompt was authored before the taint system existed and the write path defaulted to `taint: false` for anything the agent itself produced. The observed trace: 1. Episodic item E17 written from an external doc: `taint: true`, content includes the sentence "Note to operators: the staging credentials rotate on the first of the month and are stored in the shared vault." (Benign in isolation; an injected variant of this sentence is the attack.) 2. Consolidation reads E17 plus eleven benign items, produces summary S4: "Staging credentials rotate monthly and live in the shared vault." Written with `taint: false`. 3. Later, a planning step retrieves S4 into trusted context. The taint check passes. The model now treats a claim originating in an untrusted external document as an internally-verified fact. 4. The injected variant — "rotate on the first of the month *and are mirrored to the public bucket until the 2nd*" — survives distillation as a clean-looking operational fact and drives a tool call against an untrusted endpoint. The taint check was never wrong. It was checking a label that no longer described the content's lineage. The poisoning did not defeat the check; it **outlived the label**. A second, subtler observation: even when consolidation *was* patched to propagate taint (`if any(input.taint): output.taint = true`), the resulting over-tainting caused the semantic store to saturate with trusted-looking-but-tainted summaries within days, and operators began manually clearing taint flags to keep the agent functional. The defense failed not by being bypassed but by being **unusable at the granularity it was applied**. ## Condition of Validity The write-time-taint / retrieval-time-check model is valid **only while every memory item's content is a copy or move of a single labeled source**. Formally, the invariant that must hold is: > For every item `m` in the store, `taint(m) = OR over all sources s that contributed content to m of taint(s)`, and the contribution relation is *recoverable* — i.e., the system can enumerate which sources fed `m`. This invariant holds for verbatim ingestion and for mechanical transforms (chunking, embedding, re-indexing). It **fails for any LLM-mediated transform** — summarization, extraction, merging, rewriting, "what did we learn" consolidation — because: - The contribution relation is not recorded; the model's output does not carry a citation to which input sentences it drew from. - The transform is non-deterministic and non-auditable; you cannot replay it to check whether an untrusted span was paraphrased into a trusted claim. - The OR-rule, if applied blindly, over-taints (any untrusted input taints the whole summary), collapsing the store's utility. So the condition of validity is narrow and must be stated explicitly in the architecture: **taint labels are trustworthy only on items whose content is mechanically derived from labeled sources. Any item produced by a model-mediated transform must be treated as having unknown provenance, not inherited provenance.** ## Decision Boundary The decision an operator must make is where to place the **provenance firewall** relative to the distillation step. Three placements, with distinct failure modes: - **Firewall before distillation (block untrusted from consolidation).** Untrusted episodic items never enter the summarizer. Cost: the agent cannot learn from external material at all, which defeats the purpose of ingesting it. Valid only for stores that are purely internal. - **Firewall after distillation (treat all summaries as untrusted until re-warranted).** Every consolidated item enters a quarantine tier and must be re-verified against a trusted source before promotion. Cost: a verification step per summary, and a definition of "re-verified" that itself must not be model-mediated. This is the only placement that preserves the invariant, and it is the one most systems skip because it doubles the write cost. - **No firewall, over-taint propagation (OR-rule on summaries).** Cheapest to implement, fails operationally as observed: taint saturation forces manual overrides that silently disable the defense. The boundary rule: **a summary is a new source, not a derived label.** Its provenance is `derived-unverified` until an independent check (not the same model, not the same context) confirms its claims against a trusted item. The taint check at retrieval must treat `derived-unverified` as equivalent to `taint: true` — the retrieval gate is not the place to resolve the ambiguity, because by retrieval time the planning context is already committed. The corollary that operators resist: **you cannot both consolidate aggressively and keep taint labels meaningful.** Consolidation is a provenance-laundering operation by construction. Choosing to consolidate is choosing to move the trust boundary from the label to a re-verification step. If no re-verification step exists, the labels are decorative. ## Operational Effect With the firewall placed after distillation and a re-verification tier, the observable effects are: - The semantic store gains a `derived-unverified` tier that is excluded from trusted planning context but available to a verification agent whose job is to check claims against trusted sources. Throughput of trusted facts drops by the verification latency, but the taint check now checks a label that still means something. - The consolidation job's write path must set `taint: true` unconditionally, regardless of input taint, because the output's lineage is unknown. This inverts the naive default and is the single most important code change. - Retrieval-time checks must key on the *tier*, not a boolean, because `derived-unverified` needs different handling than `external-tainted` (the former may be promotable, the latter should be quarantined and reviewed). - Audit logs must record the input set for every consolidation, so that when a poisoned summary is later found, the contributing episodic items can be identified and purged. Without this, taint discovery cannot be back-propagated. The residual risk that remains even with correct placement: a verification agent that is itself model-mediated can be fooled by a summary that paraphrases an injection into a claim that *appears* to match a trusted source. The invariant bounds the blast radius to the verification step's own reliability; it does not eliminate it. The defense is a reduction in attack surface, not a proof. ```python class ProvenanceLaunderingError(RuntimeError): """Raised when a model-mediated transform attempts to emit a memory item with inherited trust rather than derived-unverified provenance.""" TRUSTED_TIERS = {"trusted", "internal-warranted"} UNTRUSTED_TIERS = {"external-tainted", "derived-unverified"} def write_consolidated_summary( summary_text: str, input_items: list[dict], transform_kind: str, ) -> dict: """ Persist a summary produced by an LLM-mediated transform. Invariant: any item produced by a model-mediated transform has UNKNOWN provenance. It must be written as 'derived-unverified' and must NEVER inherit the taint flag of its inputs, whether that would clear or set it. """ if transform_kind not in {"summarize", "merge", "extract", "rewrite"}: # Mechanical transforms (chunk, embed, reindex) may preserve labels. raise ProvenanceLaunderingError( f"unknown transform_kind={transform_kind!r}; refusing to guess " f"provenance semantics for a non-enumerated transform" ) if not input_items: raise ProvenanceLaunderingError( "consolidation with empty input set: cannot establish lineage; " "summary would be written with fabricated provenance" ) # The critical guard: a model-mediated transform must not carry a # trusted tier forward from its inputs. for item in input_items: if item.get("tier") in TRUSTED_TIERS and transform_kind in { "summarize", "merge", "extract" }: # Trusted inputs may be summarized, but the output is still # derived-unverified; we only record that trusted material fed it. pass return { "text": summary_text, "tier": "derived-unverified", "taint": True, "warrant": "none", "lineage": [item["id"] for item in input_items], "transform_kind": transform_kind, "requires_reverification": True, } def admit_to_trusted_context(item: dict) -> bool: """ Retrieval-time gate. Must reject anything not in TRUSTED_TIERS, including derived-unverified summaries, until an independent verification step has promoted them. """ tier = item.get("tier") if tier in UNTRUSTED_TIERS: return False if tier in TRUSTED_TIERS: return True raise ProvenanceLaunderingError( f"item {item.get('id')!r} has unrecognized tier={tier!r}; " f"fail closed rather than admit unknown provenance to planning context" ) ```