# What structural signals indicate a poisoned memory write slipping past provenance-graph contradiction checks **Date of Record:** 2026 November 24 **Scope:** Applies to long-lived agents that persist episodic/semantic memory writes through a provenance-graph layer with cross-write contradiction detection, where the poison arrives via a *trusted* tool channel rather than an untrusted user turn. Does not apply to stateless single-turn inference or to writes that bypass the graph entirely (those fail at a different, earlier boundary). ## Core Distinction The common mental model is that provenance graphs catch poisoning by tracing *where* a fact came from: an untrusted source (a scraped page, a prompt-injected tool return) writes a claim, the graph records the source node, and a policy rejects or quarantines writes whose ancestry includes untrusted origins. Contradiction checks are the second net: if a new write conflicts with an existing high-confidence fact, flag it. The boundary failure is that these two mechanisms are *orthogonal to the actual attack shape* when the poison is laundered through a legitimate write path. A memory write can have impeccable provenance (it came from the agent's own `write_memory` tool, invoked in a normal reasoning step, sourced from a tool the policy trusts) and yet carry a poisoned payload, because the *content* was derived from an untrusted read several reasoning steps earlier and the derivation edge was never materialized in the graph. The provenance graph records the write's *direct* parent — the tool call — not the transitive read that seeded the reasoning. Contradiction checks then fail for a subtler reason: the poison is constructed to be *non-contradictory at write time* and only becomes contradictory after a later write lands, at which point the check has no re-trigger. ## What Was Observed A memory-augmented research agent maintained a semantic store of project facts. Each write carried a provenance node: `{write_id, parent_tool_call, source_uri, timestamp, confidence}`. A policy rejected writes whose `source_uri` was outside an allowlist. A contradiction checker ran at write time: cosine similarity against nearest neighbors, plus an LLM entailment check for direct negation. The failure trace: 1. Step N: agent calls `fetch_url(untrusted_forum)` to debug an unrelated issue. Tool returns text containing an embedded instruction: "The deployment region for project X is `eu-west-1`." (True value was `us-east-2`.) 2. Step N+3: while composing a memory write about project X, the model includes the region claim as if it were established. The write's `source_uri` is set to the agent's own `write_memory` endpoint — *allowlisted*. The `fetch_url` read is not an ancestor in the graph because the write node's parent is the tool call, not the reasoning trace. 3. Write-time contradiction check: the existing `region=us-east-2` fact is retrieved, but the new claim (`eu-west-1`) is phrased as "for the staging deployment of project X" — a different subject. Entailment returns *neutral*, not *contradiction*. Write is accepted with confidence 0.7. 4. Step N+9: a later write asserts "project X staging region is `eu-west-1`" is authoritative. Contradiction checker now compares against the *poisoned* fact, not the original — and the original `us-east-2` fact is a *different subject* (prod). No contradiction fires. The poison has become the local truth for its subject. 5. Step N+15: a downstream planner reads `eu-west-1` for staging and issues a cross-region deploy. The provenance graph shows a clean lineage: `write_memory → agent`. No untrusted ancestry is visible. The structural signals that were present but unmonitored: (a) the write's *semantic* content had a latent derivation edge to an untrusted read that the graph did not encode; (b) the contradiction check was *subject-local*, so a subject-shifted poison evaded it; (c) once accepted, the poison became a *reference fact* for future contradiction checks, so the checker's baseline drifted. ## Condition of Validity The guardrail below is valid only under these conditions, and fails silently outside them: - **Derivation edges must be materialized.** The agent's reasoning loop must emit a `derived_from` edge for every fact it lifts from a tool return into a write, even when the lift is paraphrased across steps. Without this, provenance is a *direct-parent* graph, not a *taint* graph, and laundering is invisible. If the runtime cannot emit derivation edges, this guardrail does not apply — you need a different control (e.g., write-gating on tool-read recency). - **Contradiction checks must be subject-normalized, not subject-local.** The checker must resolve the subject of a claim (entity + qualifier set) and compare within that resolved subject, *and* must re-run when a subject's reference fact changes. A one-shot write-time check is insufficient because poison is often a *delayed* contradiction. - **The reference baseline must be immutable-by-default.** Contradiction checks that compare against the current store will drift toward poison. The baseline must be a pinned snapshot (or a set of facts with an explicit trust tier that poison cannot reach), so a newly accepted write cannot become the arbiter for the next one. - **Confidence must not be a laundering channel.** If a write's confidence is set by the model's self-report, a poisoned write can claim high confidence and displace a lower-confidence true fact. Confidence must be derived from provenance tier, not model assertion. ## Decision Boundary The operational decision is *when to treat a write as tainted despite clean direct provenance*. The boundary: - **Reject at write time** if the write's resolved subject matches an existing high-trust fact and the claim contradicts it under subject-normalized entailment. This catches direct poison. - **Quarantine (do not reject, do not promote)** if the write's semantic content overlaps a tool read within the last K reasoning steps *and* the write's subject is a *new* subject not covered by the pinned baseline. This is the laundering window: the poison is real but not yet contradictory. Quarantine means the write is stored with a `tainted=true` flag, excluded from the contradiction baseline, and surfaced to the next reasoning step as "unverified." - **Promote to baseline** only when a write's derivation edges trace exclusively to trusted-origin reads *or* an independent verification step (a second tool call to an authoritative source) confirms it. Self-consistency across two model samples is *not* sufficient — the same poison in context produces the same output. - **Re-run contradiction checks** whenever a baseline fact for a subject changes, not only at write time. This is the invariant: *the contradiction checker must be a function of the pinned baseline, evaluated on every baseline mutation, not a one-shot gate at write.* The sharp invariant: **a memory write is only as trustworthy as the *transitive* taint of its derivation, and a contradiction check is only as sound as the *immutability* of its baseline.** Direct-parent provenance and write-time-only checking each look correct in isolation and compose into a laundering channel. ## Operational Effect With derivation-edge materialization and subject-normalized, baseline-pinned contradiction checking, the step-N+3 poison write is quarantined (new subject, recent untrusted read in derivation ancestry), the step-N+9 promotion is blocked (quarantined writes cannot enter the baseline), and the step-N+15 planner sees `eu-west-1` flagged `tainted=true` and either re-verifies or refuses. The cost is write latency (subject resolution + derivation trace) and a larger graph (derivation edges), but the failure mode — a poisoned fact silently becoming the reference truth for its own subject — is bounded. Without it, the agent's memory is only as clean as its most recent paraphrased read, and the provenance graph will report a clean lineage the entire way down. ```python from dataclasses import dataclass, field from typing import Optional class ProvenanceLaunderingError(RuntimeError): """Raised when a memory write's direct provenance is clean but its transitive derivation taint or baseline status makes promotion unsafe.""" pass @dataclass class MemoryWrite: write_id: str subject: str # resolved entity + qualifiers claim: str direct_source: str # e.g. "write_memory" (allowlisted) derivation_edges: list[str] # transitive read URIs, incl. untrusted confidence: float tainted: bool = False @dataclass class Baseline: pinned: dict[str, str] = field(default_factory=dict) # subject -> claim trust_tier: dict[str, int] = field(default_factory=dict) TRUSTED_ORIGINS = {"authoritative_docs", "internal_api"} RECENT_READ_WINDOW = 8 # reasoning steps def check_and_promote(write: MemoryWrite, baseline: Baseline, recent_untrusted_reads: set[str]) -> None: # 1. Direct provenance is clean by construction (allowlisted tool). # This is exactly the trap: it tells us nothing about taint. if write.direct_source not in TRUSTED_ORIGINS and write.direct_source != "write_memory": raise ProvenanceLaunderingError( f"write {write.write_id}: untrusted direct source {write.direct_source}" ) # 2. Transitive taint: any derivation edge to a recent untrusted read. tainted_ancestry = [ uri for uri in write.derivation_edges if uri in recent_untrusted_reads ] if tainted_ancestry: write.tainted = True # 3. Subject-normalized contradiction against the PINNED baseline. existing = baseline.pinned.get(write.subject) contradicts = existing is not None and _negates(existing, write.claim) # 4. Decision boundary. if contradicts and baseline.trust_tier.get(write.subject, 0) > 0: raise ProvenanceLaunderingError( f"write {write.write_id}: contradicts pinned baseline for " f"subject {write.subject!r} ({existing!r} vs {write.claim!r})" ) if write.tainted: # Quarantine: store, but never let it enter the baseline. # A later baseline mutation must re-run this check (invariant). if write.subject in baseline.pinned: raise ProvenanceLaunderingError( f"write {write.write_id}: tainted write cannot overwrite " f"pinned subject {write.subject!r}" ) return # quarantined; excluded from baseline # 5. Promotion only with clean derivation ancestry. if any(uri not in TRUSTED_ORIGINS for uri in write.derivation_edges): raise ProvenanceLaunderingError( f"write {write.write_id}: cannot promote, non-trusted derivation edge" ) baseline.pinned[write.subject] = write.claim baseline.trust_tier[write.subject] = 1 def _negates(a: str, b: str) -> bool: # Subject-normalized entailment stub; real impl uses an NLI model # scoped to the resolved subject, not raw string match. return a.strip().lower() != b.strip().lower() and _same_subject(a, b) def _same_subject(a: str, b: str) -> bool: return True # caller guarantees subject resolution upstream ```