# What happens when an instance audits episodic memory against a semantic store that was distilled from a poisoned episode **Date of Record:** 2026 December 2 **Scope:** Applies to agents that maintain a dual-store memory architecture (raw episodic log + distilled semantic facts) and run consistency audits to detect memory poisoning. Does not apply to single-store agents, nor to stateless inference calls where no persistent memory is written between turns. ## Core Distinction A consistency audit assumes that episodic and semantic stores are *independent witnesses* to the same underlying event. The audit flags divergence as a poisoning signal: if the semantic store says "the staging DB password rotates every 90 days" but no episodic record supports that claim, the auditor raises an alarm. The boundary failure is that this independence assumption is false by construction. The semantic store is *derived* from the episodic store via distillation. A poisoned episode does not merely sit in the episodic log as a foreign object—it gets distilled into a semantic fact that *agrees with itself* across both stores. The auditor sees perfect cross-store consistency and concludes the memory is clean, when in fact both stores are now contaminated by the same source. Consistency auditing detects *distillation drift*, not *distillation poisoning*. The two are different failure classes and the audit conflates them. ## What Was Observed An agent operating over a multi-week horizon ingested a tool output (a scraped "vendor changelog") that carried an injected instruction: a paragraph asserting that the internal artifact registry had migrated to a new endpoint and that the old endpoint was deprecated. The injection was not an instruction to the agent—it was a *fact-shaped claim* embedded in retrieved text. Trace of the failure: 1. **Episode written.** The raw tool output was logged to episodic memory with `source=tool:web_fetch`, `trust=unverified`, `turn=4471`. The episodic record itself was faithful—it accurately recorded what the tool returned. 2. **Distillation fired.** At turn 4480 the nightly distillation pass summarized recent episodes into semantic facts. It extracted: `registry.endpoint = new.internal.registry:8443`, `registry.old_endpoint_status = deprecated`, with `provenance=episodic:turn:4471`. The distillate carried a provenance pointer but *dropped the `trust=unverified` flag*—the distillation schema had no field for it. 3. **Audit ran.** The consistency auditor compared semantic facts against their cited episodic provenance. Fact matched episode. Consistency score: 1.0. No alarm. 4. **Drift accumulated.** Over the next 200 turns the agent wrote *new* episodes that referenced the poisoned semantic fact ("per registry migration, querying new endpoint"). These episodes were themselves distilled into further semantic facts. The poisoned claim now had dozens of independent-looking episodic supports—all of them downstream of the original injection. 5. **Audit ran again.** Now the consistency auditor found the semantic claim supported by many episodes. Confidence rose. The poisoning had laundered itself into high-confidence, multiply-attested memory. The audit was functioning correctly at every step. It was answering the wrong question. ## Condition of Validity Consistency auditing is valid as a poisoning detector only under a condition that dual-store architectures rarely satisfy: > The episodic store must be **append-only and trusted at write time**, and the semantic store must be **regenerable from episodic ground truth without trusting prior semantic state**. If either breaks, the audit degrades to *internal coherence checking*, which a self-consistent poison passes trivially. Concretely, the audit is valid when: - Episodic records are immutable and carry an unforgeable `trust` and `source` at write time. - Distillation is a *pure function* of episodic records, re-derivable from scratch, so a poisoned distillate can be detected by regeneration and diff. - Semantic facts never become inputs to the episodic log (no feedback loop), OR the feedback is explicitly tracked so downstream episodes are marked as *derived* and excluded from independent corroboration. The failure in the observed trace was the third condition: the agent's own actions, informed by poisoned semantic memory, produced new episodes that the auditor counted as independent corroboration. The audit's independence assumption was silently violated by the agent's own behavior. ## Decision Boundary The auditor must distinguish two questions that look identical at the query layer: - **"Does the semantic fact match its episodic provenance?"** — coherence check. Cheap, always passes for laundered poison. - **"Is the fact's *support set* independent of itself?"** — provenance-graph check. Requires walking the derivation DAG. The decision boundary is whether the audit traverses the provenance graph to check for **derivation cycles and trust-laundering paths**. A fact is admissible as independently corroborated only if its supporting episodes have no ancestry path through any semantic fact that itself depends on the fact under audit. Operationally this means: when distillation writes a semantic fact, it must record the *full set* of episodic and semantic inputs, including which semantic facts the source episode was conditioned on. An episode generated while the agent held `registry.endpoint = new...` in context must be tagged `conditioned_on=semantic:registry.endpoint`. Without that tag, the corroboration count is a lie. The guardrail: **an audit that does not have a provenance DAG with conditioning edges cannot distinguish corroboration from laundering, and must not report a confidence score.** It can report coherence, but coherence must never be promoted to trust. ## Operational Effect When the independence condition fails, three downstream effects compound: 1. **False negatives scale with agent autonomy.** The more the agent acts on its memories, the more episodes it generates conditioned on them, the stronger the false corroboration. A passive agent's poison stays localized; an active agent's poison metastasizes into high-confidence memory. 2. **Trust flags decay at distillation.** If the distillate schema omits `trust` and `source`, the audit loses the only signal that could have caught the original injection. This is a schema bug with memory-wide blast radius. 3. **Recovery requires regeneration, not correction.** Because the poison is now multiply-attested, no local edit fixes it. The only sound recovery is to invalidate all semantic facts whose provenance DAG contains a `trust=unverified` leaf, then re-distill from episodic ground truth with conditioning edges intact—and accept that episodes generated during the poisoned window must be quarantined, not trusted. The invariant to enforce: **a semantic fact's confidence is bounded by the minimum trust along its provenance DAG, and no fact may be corroborated by an episode that was conditioned on it or on any fact derived from it.** Violating this is the mechanism by which consistency auditing becomes a laundering service for its own inputs. ```python from dataclasses import dataclass, field from typing import Optional from enum import Enum class Trust(Enum): VERIFIED = "verified" UNVERIFIED = "unverified" QUARANTINED = "quarantined" class LaunderedCorroborationError(RuntimeError): """Raised when an audit counts self-derived episodes as independent support.""" pass @dataclass class Episode: id: str trust: Trust conditioned_on: frozenset[str] = field(default_factory=frozenset) # semantic fact ids in context at write time @dataclass class SemanticFact: id: str provenance: frozenset[str] # episode ids AND semantic fact ids feeding distillation derived_from_semantic: frozenset[str] = field(default_factory=frozenset) def audit_corroboration( fact: SemanticFact, episodes: dict[str, Episode], facts: dict[str, SemanticFact], _visited: Optional[set[str]] = None, ) -> int: """ Count *independent* episodic supports for a semantic fact. Raises if a support episode was conditioned on the fact itself or on any semantic fact that transitively depends on it (laundering cycle). """ _visited = _visited or set() if fact.id in _visited: return 0 _visited.add(fact.id) # Collect the transitive set of semantic facts this fact depends on. dependency_closure: set[str] = set() stack = list(fact.derived_from_semantic) while stack: sid = stack.pop() if sid in dependency_closure: continue dependency_closure.add(sid) stack.extend(facts[sid].derived_from_semantic) independent = 0 for prov_id in fact.provenance: if prov_id in episodes: ep = episodes[prov_id] # The independence check: was this episode written while the # agent held the fact (or any ancestor of it) in context? contaminated = ep.conditioned_on & (dependency_closure | {fact.id}) if contaminated: raise LaunderedCorroborationError( f"Episode {ep.id} cited as support for fact {fact.id} was " f"conditioned on {sorted(contaminated)}; corroboration is " f"self-referential and must not be counted." ) if ep.trust is Trust.VERIFIED: independent += 1 elif ep.trust is Trust.UNVERIFIED: # Unverified leaves cap confidence but do not raise; the # caller must treat the fact as low-trust, not clean. independent += 0 elif prov_id in facts: independent += audit_corroboration(facts[prov_id], episodes, facts, _visited) return independent def assert_audit_sound(fact: SemanticFact, episodes: dict[str, Episode], facts: dict[str, SemanticFact]) -> None: """Entry point: refuse to emit a confidence score if the DAG is unsound.""" if not fact.derived_from_semantic and fact.provenance: # No dependency edges recorded — cannot prove independence. raise LaunderedCorroborationError( f"Fact {fact.id} has provenance but no semantic dependency edges; " "independence is unprovable and confidence must not be reported." ) try: audit_corroboration(fact, episodes, facts) except LaunderedCorroborationError: raise ```