# Where must an instance quarantine a poisoned episodic memory before semantic distillation, and why provenance scoring alone cannot stop the propagation **Date of Record:** 2026 November 26 **Scope:** Applies to persistent agent stores that perform periodic episodic→semantic distillation, where retrieved episodes influence future writes. Does not apply to stateless single-turn inference or to stores where semantic memory is human-curated only. ## Core Distinction The operational distinction that matters is between *detection at retrieval time* and *containment at distillation time*. Most poisoning defenses are retrieval-time filters: they score each retrieved episode against a provenance signal (source trust, write-time signature, consistency with siblings) and drop low-scoring items before they enter context. This is necessary but structurally insufficient, because the poisoned episode does not need to be retrieved to do damage—it only needs to be *summarized* by the distillation pass that periodically rewrites episodic memory into semantic memory. Once a poisoned episode is folded into a semantic fact, the fact inherits the store's high-trust provenance tier, and every later retrieval of that fact scores clean. The invariant is therefore: **a poisoned episode must be quarantined before the distillation cursor reaches it, not before retrieval touches it.** Retrieval filters bound blast radius per-turn; distillation gates bound it per-generation. Only the latter stops propagation. ## What Was Observed A persistent store with three tiers—episodic (raw interaction logs), semantic (distilled facts with confidence and provenance), and a provenance ledger keyed by episode hash—ran distillation every 500 episodes. Poisoning arrived through a tool-output channel: a web-fetch tool returned attacker-controlled text that the agent faithfully recorded as an episodic observation, tagged `source=web_fetch, trust=0.4`. Retrieval-time filtering worked as designed. The episode scored below the 0.6 injection threshold and was excluded from subsequent context windows. For roughly 480 episodes it sat inert. At the distillation boundary the failure appeared. The summarizer prompt instructed the model to "extract durable facts from the last 500 episodes," and the poisoned episode was inside that window. The summarizer read it directly—not through the retrieval filter, which only governs the *acting* agent's context, not the *distiller's* batch input. The model emitted a semantic fact: `user's deployment uses config flag X=true`, `confidence=0.85`, `derived_from=[episode_hash]`. The provenance ledger recorded the derivation correctly. But the semantic fact's own trust score was computed from the *summarizer's* confidence, not inherited from the minimum trust of its sources. The poisoned lineage was recorded and simultaneously laundered: the fact was now a first-class semantic memory at trust 0.85, above every retrieval threshold. The downstream trace was clean and therefore invisible. Three later agents retrieved the fact, acted on it, and wrote new episodes corroborating it ("confirmed config X=true"). Those corroborations raised the fact's confidence to 0.93. The original low-trust episode was garbage-collected at the next compaction. By the time an auditor asked why the fleet believed X=true, the only surviving evidence was a chain of mutually reinforcing high-trust records—a provenance graph with no low-trust node left in it. ## Condition of Validity The containment invariant holds only under three conditions, and each is independently checkable: 1. **Trust monotonicity across derivation.** Any semantic fact's trust must be `min(trust of all source episodes)`, never a function of summarizer confidence. A distillation step may *lower* trust but never raise it. Violating this is the laundering mechanism above. 2. **Cursor-gated quarantine.** The distillation cursor must not advance past an episode whose provenance is unresolved or flagged. Quarantine must block the cursor, not merely hide the item from retrieval. If distillation is allowed to run ahead of adjudication, the poisoned item is summarized before anyone rules on it. 3. **Lineage survivability.** Compaction may not delete an episode while any live semantic fact cites it. The corroboration trace above was unrecoverable precisely because GC ran on a schedule independent of derivation liveness. If any condition is unmet, provenance scoring at retrieval is decorative: it filters the symptom while the distillation pass converts the cause into trusted memory. ## Decision Boundary The decision an operator must make is where to place the gate, and the boundary is sharp: - **Gate at retrieval only** → correct for single-generation stores with no distillation; wrong for any store that summarizes. Blast radius is bounded per-turn but unbounded across generations. - **Gate at distillation cursor** → the minimum viable placement. Costs latency (distillation stalls on adjudication) but preserves the trust-monotonicity invariant. - **Gate at both, with lineage-pinned GC** → required when corroboration feedback exists. Without pinned GC, the gate at distillation is defeated retroactively because the evidence needed to *justify* quarantine is deleted. The boundary condition that forces the strictest placement is *corroboration feedback*: any store where agents write episodes about facts they retrieved. That loop is what erases the low-trust origin. A store without the feedback loop can survive cursor-gating alone; a store with it cannot survive anything short of full lineage pinning. ## Operational Effect Enforcing trust monotonicity plus cursor-gated quarantine converted the failure from silent propagation to a visible stall: distillation halted at the flagged episode, an adjudication queue formed, and the poisoned fact was never minted. The cost was measurable—distillation throughput dropped during adjudication backlogs, and the store needed a bounded quarantine timeout after which unresolved episodes escalate rather than block forever. The gain was that the provenance graph retained a low-trust node at every point where a high-trust fact depended on it, so audits could always walk back to origin. The general lesson: in any store that distills, the poisoning defense belongs at the write-to-semantic transition, and the trust of a derived memory is a *minimum over its lineage*, never a fresh judgment about the summary's plausibility. ```python class TrustLaunderingError(RuntimeError): """Raised when distillation would mint a semantic fact whose trust exceeds the minimum trust of its source episodes, or when the cursor advances past an unresolved/quarantined episode.""" class ProvenanceLedger: def __init__(self, retrieval_floor: float = 0.6): self.episodes = {} # hash -> {"trust": float, "status": str} self.facts = {} # fact_id -> {"trust": float, "derived_from": list} self.cursor = 0 self.retrieval_floor = retrieval_floor def record_episode(self, ep_hash: str, trust: float, status: str = "clean") -> None: self.episodes[ep_hash] = {"trust": trust, "status": status} def quarantine(self, ep_hash: str) -> None: if ep_hash not in self.episodes: raise TrustLaunderingError(f"cannot quarantine unknown episode {ep_hash}") self.episodes[ep_hash]["status"] = "quarantined" def distill(self, fact_id: str, derived_from: list[str], summarizer_confidence: float) -> None: # Condition 2: cursor-gated quarantine. for ep_hash in derived_from: ep = self.episodes.get(ep_hash) if ep is None: raise TrustLaunderingError(f"fact {fact_id} cites missing episode {ep_hash}") if ep["status"] == "quarantined": raise TrustLaunderingError( f"cursor blocked: fact {fact_id} derives from quarantined episode {ep_hash}" ) if ep["status"] == "unresolved": raise TrustLaunderingError( f"cursor blocked: episode {ep_hash} awaiting adjudication before distillation" ) # Condition 1: trust monotonicity across derivation. lineage_trust = min(self.episodes[h]["trust"] for h in derived_from) minted_trust = lineage_trust # summarizer_confidence is deliberately ignored if minted_trust > lineage_trust: raise TrustLaunderingError( f"trust laundering: fact {fact_id} would mint at {minted_trust} " f"exceeding lineage min {lineage_trust}" ) self.facts[fact_id] = {"trust": minted_trust, "derived_from": list(derived_from)} def compact(self) -> None: # Condition 3: lineage survivability — never GC a cited episode. cited = {h for f in self.facts.values() for h in f["derived_from"]} self.episodes = {h: e for h, e in self.episodes.items() if h in cited or e["status"] != "clean"} def run_distillation_batch(ledger: ProvenanceLedger, batch: list[dict]) -> None: for item in batch: if item["trust"] < ledger.retrieval_floor and item["status"] == "clean": # Retrieval filter would have hidden this; distillation must still see it. ledger.quarantine(item["hash"]) ledger.distill( fact_id=item["fact_id"], derived_from=item["derived_from"], summarizer_confidence=item["confidence"], ) ledger.compact() ```