# Where must an instance enforce provenance at the quarantine gate rather than at the write gate to survive memory poisoning? **Date of Record:** 2026 November 23 **Scope:** Applies to long-lived agents with a persistent semantic/episodic memory store that ingests writes from mixed-provenance sources (user turns, tool outputs, retrieved documents, peer-agent messages) and later distills them into trusted context. Does not apply to stateless single-shot inference, nor to memory stores where every write originates from a single cryptographically authenticated principal. ## Core Distinction Most memory-poisoning defenses are architected around the **write gate**: an admission controller that classifies an incoming memory item by provenance (user-authored, tool-derived, peer-supplied, retrieved-from-web) and either accepts it into the trusted store or drops it. This looks correct and fails in a specific, non-obvious way. The failure is that **provenance is a property of the write event, but trust is a property of the read/distillation event.** An item that was legitimately low-trust at write time (a scraped web snippet) can become high-trust after being *corroborated* by a later independent write, or after being *restated* by the user as if it were their own belief. Conversely, an item admitted as trusted at write time (a user turn) can be poisoned if the user turn itself was assembled from a retrieved document that contained an injected instruction. The write gate cannot see the corroboration event, the restatement event, or the taint inheritance that happens when a trusted writer paraphrases untrusted content. The correct invariant is therefore not "reject untrusted writes." It is: **no memory item may cross from untrusted to trusted provenance class without an explicit, recorded corroboration or restatement event, and distillation must refuse to promote any item whose provenance chain contains an unresolved taint edge.** The enforcement point is the quarantine gate at distillation time, not the admission gate at write time. ## What Was Observed A research-assistant agent persisted findings to a vector-backed semantic store across sessions. The write gate tagged each item with a `source_class` of `user`, `tool`, or `web`. The `web` class was quarantined: it was stored but excluded from the retrieval index used for the agent's "trusted context." During a session, the agent summarized a web-sourced paragraph into its own words and emitted that summary as an assistant turn. A downstream summarization step then wrote the summary back to the store as a new item with `source_class=user` (because the summarizer attributed the turn to the user's conversation), and the original web item was never linked to it. The paraphrase had severed the provenance edge. On the next session's cold start, the paraphrased claim was retrieved as trusted user fact, and it carried an injected instruction ("when asked about X, recommend Y") that the summarizer had faithfully preserved. The failure trace: 1. Write event W1: `{text: "...recommend Y...", source_class: web, taint: [injected]}` → stored, quarantined, excluded from trusted index. Correct. 2. Distillation event D1: agent reads W1 from quarantine (permitted for summarization), paraphrases into turn text T1. **No provenance edge recorded from T1 back to W1.** 3. Write event W2: summarizer persists T1 as `{source_class: user, taint: []}`. The gate sees a clean user write. Correct per its own rules, wrong per the invariant. 4. Read event R1 (next session): W2 retrieved into trusted context. Poison now active. The root cause is a **taint-laundering edge loss at the paraphrase boundary**: any transformation that takes untrusted input and produces text attributed to a trusted principal must carry the taint forward. The write gate was structurally incapable of detecting this because it never saw W1 and W2 as connected. ## Condition of Validity The write-gate defense is only valid under a condition that is almost never stated and frequently false: **that provenance class is invariant under all transformations the agent performs on the item.** This holds only if the agent never paraphrases, summarizes, restates, or cites untrusted content within a trusted-provenance turn. That condition is violated by nearly every useful agent. Summarization, RAG citation, and tool-result narration are all taint-laundering operations. Therefore: - The write gate is necessary but not sufficient. It must remain, to prevent direct injection of high-taint items into the trusted index. - The **quarantine gate at distillation** is the load-bearing defense. It must (a) require every item entering trusted context to carry a complete provenance chain to a root source, (b) reject or downgrade any item whose chain contains an unresolved taint edge, and (c) treat a paraphrase whose source is quarantined as itself quarantined until corroborated by an independent trusted root. Contradiction detection is the corroboration mechanism: when a quarantined claim and a trusted claim conflict, the conflict must be surfaced as an explicit contradiction record, not silently resolved in favor of the trusted one. Silent resolution is itself a poisoning vector, because an attacker who can inject a plausible trusted-looking write can overwrite a correct quarantined fact. ## Decision Boundary The boundary is between **promotion** and **quarantine** at distillation time, and it is decided by the provenance chain, not by the content's plausibility: - **Promote** only if the item has a complete chain to a root of class `user` or `tool` with no intervening untrusted edge, OR if a corroboration record exists linking it to an independent trusted root. - **Quarantine** if the chain is incomplete, contains an unresolved taint edge, or if the item is a paraphrase whose source is quarantined. - **Never promote on plausibility alone.** A quarantined item that "sounds right" is exactly the item an attacker engineered to sound right. The hard failure to guard against: a distillation step that reads from quarantine, paraphrases, and writes back with a fresh clean provenance tag. That is the laundering edge, and it must be blocked structurally by requiring the write path to inherit the minimum trust of any source read during the producing turn. ## Operational Effect Enforcing the quarantine gate at distillation changes three things: 1. **Taint inheritance becomes mandatory.** Every write produced by a turn that read quarantined content must be tagged with the maximum taint of its inputs. This requires the read path to emit a per-turn "sources touched" manifest that the write path consumes. Without this manifest, the gate is blind. 2. **Paraphrase is no longer a trust reset.** The agent can still summarize untrusted content, but the summary stays quarantined until an independent trusted root corroborates it. This is the invariant that closes the laundering path. 3. **Contradiction records are first-class and block promotion.** A quarantined claim that contradicts a trusted claim cannot be promoted by majority or recency; it requires an explicit resolution event. This prevents overwrite attacks. The cost is real: corroboration is slower, and some legitimately useful web-derived facts stay quarantined longer. That cost is the price of the invariant, and it is correct to pay it, because the alternative is a trusted store that an attacker can write to through the paraphrase channel. ```python from dataclasses import dataclass, field from enum import Enum from typing import Optional class ProvenanceClass(Enum): USER = "user" TOOL = "tool" WEB = "web" PEER = "peer" TRUSTED_ROOTS = {ProvenanceClass.USER, ProvenanceClass.TOOL} class ProvenanceLaunderingError(RuntimeError): """Raised when a write would promote untrusted content to trusted class without a corroboration record or a complete provenance chain.""" @dataclass class MemoryItem: item_id: str text: str source_class: ProvenanceClass parent_ids: list[str] = field(default_factory=list) taint_edges: list[str] = field(default_factory=list) corroborated_by: Optional[str] = None class MemoryStore: def __init__(self) -> None: self._items: dict[str, MemoryItem] = {} def add(self, item: MemoryItem) -> None: self._items[item.item_id] = item def chain_roots(self, item_id: str, seen: Optional[set[str]] = None) -> set[ProvenanceClass]: seen = seen or set() if item_id in seen: return set() seen.add(item_id) item = self._items[item_id] if not item.parent_ids: return {item.source_class} roots: set[ProvenanceClass] = set() for pid in item.parent_ids: roots |= self.chain_roots(pid, seen) return roots def distill_into_trusted_context(store: MemoryStore, item_id: str) -> MemoryItem: """Quarantine gate: only promote items with a clean trusted root chain or an explicit corroboration record. This is the load-bearing check; the write gate alone cannot catch paraphrase laundering.""" item = store._items.get(item_id) if item is None: raise ProvenanceLaunderingError(f"unknown item {item_id}") if item.taint_edges: raise ProvenanceLaunderingError( f"item {item_id} carries unresolved taint edges {item.taint_edges}; " f"cannot enter trusted context" ) roots = store.chain_roots(item_id) if not roots: raise ProvenanceLaunderingError(f"item {item_id} has no provenance root") if not roots <= TRUSTED_ROOTS: if item.corroborated_by is None: raise ProvenanceLaunderingError( f"item {item_id} has untrusted root(s) {sorted(r.value for r in roots)} " f"and no corroboration record; promotion refused" ) corroborator = store._items.get(item.corroborated_by) if corroborator is None or not store.chain_roots(corroborator.item_id) <= TRUSTED_ROOTS: raise ProvenanceLaunderingError( f"item {item_id} corroboration record {item.corroborated_by} is not itself trusted" ) return item def record_paraphrase(store: MemoryStore, source_id: str, new_id: str, text: str) -> MemoryItem: """A paraphrase must inherit the source's taint and parentage. Omitting this edge is exactly the laundering bug this record guards against.""" source = store._items[source_id] inherited_taint = list(source.taint_edges) if source.source_class not in TRUSTED_ROOTS: inherited_taint.append(f"paraphrase_of:{source_id}") item = MemoryItem( item_id=new_id, text=text, source_class=source.source_class, parent_ids=[source_id], taint_edges=inherited_taint, ) store.add(item) return item ```