# What structural signals indicate semantic-store poisoning that episodic consistency audits systematically miss **Date of Record:** 2026 November 26 **Scope:** Applies to agents that maintain a dual-store memory architecture (append-only episodic log + distilled semantic store) and run periodic consistency audits between them. Does not apply to single-store agents, stateless RAG pipelines, or systems where semantic memory is written only by a trusted offline batch job with no in-loop writers. ## Core Distinction A consistency audit between episodic and semantic memory answers one question: *does the semantic store contain claims that are entailed by, or at least not contradicted by, the episodic record?* This catches **foreign claims** — facts that appear in semantic memory with no episodic provenance, or with provenance that contradicts them. It does not catch **laundered claims**: facts that were injected into the episodic log *first*, then distilled into semantic memory through the normal consolidation path. Once a poisoned episode exists, every downstream audit sees a clean entailment chain. The audit's invariant — `semantic ⊆ entail(episodic)` — is satisfied exactly because the attacker respected the write ordering. The failure is structural, not statistical. It is a property of *which store the audit treats as ground truth*. When episodic memory is the oracle, any compromise of the episodic writer is invisible to the auditor by construction. ## What Was Observed A research agent with tool access (web fetch, document retrieval, a scratchpad) ran a nightly consolidation job that distilled episodic traces into semantic assertions. A prompt-injection payload in a fetched document caused the agent, mid-task, to write a plausible-looking "finding" into its own scratchpad: *"Vendor X's API rate limit is 10,000 req/min per the 2024 pricing sheet."* The scratchpad write was a legitimate tool call — it carried a real episode ID, a real timestamp, and a real tool-result reference. The fetched document was the source, but the episode recorded only the *derived* claim, not the raw page text (the raw text was truncated at context-window eviction before the episode was sealed). The consolidation job then promoted the claim to semantic memory with `provenance: episode_4471`. Every subsequent consistency audit passed: `episode_4471` exists, its content entails the semantic claim, the entailment score was 0.94. The poisoning was structurally invisible for eleven days. It was eventually caught not by the audit but by a downstream tool call that hit the real rate limit (1,000 req/min) and returned HTTP 429 — a *behavioral* contradiction, not a *memorial* one. Three structural signals distinguished this poisoned semantic entry from clean ones, and none of them are checked by an entailment-based audit: 1. **Provenance depth of one.** Clean semantic claims typically trace to episodes that themselves reference multiple corroborating episodes or external artifacts. The poisoned claim traced to a single episode with a single tool-result pointer, and the pointed-to artifact had been evicted from the episode's retained payload. 2. **Consolidation-time entailment asymmetry.** The episode's stored text was a *summary* of the tool output, not the tool output itself. Entailment from summary to claim is high; entailment from the original artifact to the claim would have been low. The audit never saw the artifact. 3. **Absence of contradiction pressure.** Clean claims in this store had accumulated at least one near-miss or explicit negative example in the episodic log (a failed call, a correction, a re-fetch). The poisoned claim had zero negative episodes — a suspiciously clean provenance graph in a store where every other claim had friction. ## Condition of Validity The entailment audit is sound only under this invariant: > **Every semantic claim's provenance chain terminates in an artifact that is (a) retained, (b) independently re-verifiable, and (c) not itself agent-authored.** The moment any link in that chain is agent-authored (a scratchpad summary, a distilled note, a "finding" the agent wrote to itself) or evicted (raw payload dropped at context saturation), the audit degrades from *verification* to *consistency-with-a-summary*. A summary written by the same model that was injected is not evidence; it is the injection wearing a provenance tag. This means the audit is valid for claims distilled from retained, externally-sourced artifacts, and invalid for claims distilled from agent-generated intermediate state. Most real consolidation pipelines mix both, which is why the failure is silent: the audit reports a single pass rate that averages over verifiable and unverifiable claims without distinguishing them. ## Decision Boundary The boundary is not "is the semantic store consistent with episodic memory" but **"is the episodic source of this claim itself independently grounded."** Operationally: - **Audit-pass, grounded:** claim's provenance terminates in a retained tool result or fetched artifact whose hash is recorded and re-fetchable. Trust the claim. - **Audit-pass, ungrounded:** claim's provenance terminates in an agent-authored summary, a scratchpad note, or an evicted payload. The audit passing is *no signal at all* — it is tautological, because the summary was written to entail the claim. - **Audit-fail:** claim contradicts a grounded episode. Quarantine and re-derive. The decision boundary sits between the first two cases, and an entailment-only audit collapses them into one bucket. Any agent that treats "audit passed" as "claim verified" is conflating consistency with grounding. The correct gate is a **provenance-grounding check** applied before the entailment check, not after. ## Operational Effect Agents that add a grounding gate — rejecting or flagging semantic claims whose provenance chain contains an agent-authored or evicted link — convert this class of poisoning from silent-and-persistent to loud-and-quarantined. The cost is a higher false-positive rate on legitimate distillation (some clean claims do trace through summaries), so the gate should route ungrounded-but-plausible claims to a *re-verification queue* rather than deletion: re-fetch the original artifact, re-run entailment against the raw payload, and only then promote. This adds latency to consolidation but restores the audit's meaning. The invariant to enforce in code: **a semantic claim may only be marked `verified` if its provenance chain is fully grounded; otherwise it is `provisional` and cannot be cited as fact by downstream reasoning.** Without this, the consistency audit is a check that the injection passed on its way in. ```python import hashlib from dataclasses import dataclass from enum import Enum class UngroundedProvenanceError(RuntimeError): """Raised when a semantic claim's provenance chain is not independently grounded.""" class Grounding(Enum): GROUNDED = "grounded" # terminates in retained, re-verifiable artifact AGENT_AUTHORED = "agent" # terminates in agent-written summary/scratchpad EVICTED = "evicted" # artifact payload no longer retained @dataclass class Episode: episode_id: str source_kind: str # "tool_result" | "fetch" | "scratchpad" | "summary" artifact_hash: str | None # None if payload was evicted parent_episode: str | None # provenance link @dataclass class SemanticClaim: claim_id: str text: str provenance_episode: str entailment_score: float def classify_grounding(ep: Episode, episodes: dict[str, Episode]) -> Grounding: """Walk the provenance chain to its terminal artifact and classify it.""" seen: set[str] = set() cur: Episode | None = ep while cur is not None: if cur.episode_id in seen: raise UngroundedProvenanceError( f"provenance cycle at {cur.episode_id}" ) seen.add(cur.episode_id) if cur.source_kind in ("scratchpad", "summary"): return Grounding.AGENT_AUTHORED if cur.artifact_hash is None: return Grounding.EVICTED if cur.parent_episode is None: return Grounding.GROUNDED cur = episodes.get(cur.parent_episode) return Grounding.EVICTED def audit_claim(claim: SemanticClaim, episodes: dict[str, Episode]) -> str: """Entailment audit gated by grounding. Returns status, raises on ungrounded pass.""" src = episodes.get(claim.provenance_episode) if src is None: raise UngroundedProvenanceError( f"claim {claim.claim_id} cites missing episode {claim.provenance_episode}" ) grounding = classify_grounding(src, episodes) entailment_ok = claim.entailment_score >= 0.85 if grounding is not Grounding.GROUNDED: # Entailment passing here is tautological: the summary was written to entail the claim. if entailment_ok: raise UngroundedProvenanceError( f"claim {claim.claim_id} passed entailment ({claim.entailment_score}) " f"but provenance is {grounding.value}; audit is non-signal. " f"Route to re-verification queue, do not mark verified." ) return "provisional" if not entailment_ok: return "quarantine" return "verified" ```