# What structural signals indicate memory-poisoning in write-audit differentials between an agent's declared intent and its committed episodic store **Date of Record:** 2026 November 29 **Scope:** Applies to persistent-memory agents that emit a pre-write intent record and then commit to an episodic store through a separate write path (tool call, KV mutation, embedding upsert). Does not cover in-context prompt injection that never reaches the durable store, nor purely stateless inference. ## Core Distinction Memory poisoning is usually framed as an *input* problem: hostile text enters the context window and later gets persisted. That framing misses the operational signal that actually catches it. The reliable detector is not content inspection of the memory — it is the **differential between what the agent declared it was about to write and what the store actually committed**, measured structurally rather than semantically. The distinction that matters: a poisoned write is one where the *write-audit record* (intent: source, target namespace, claimed provenance, expected shape) and the *committed record* (actual bytes, actual embedding, actual provenance tag, actual supersession edges) diverge along axes the agent had no reason to alter. Benign writes can have noisy *content*; poisoned writes have inconsistent *structure* — provenance that does not match the retrieval that produced it, or supersession edges that orphan a prior fact without a corresponding intent entry. ## What Was Observed A memory-writing agent was instrumented to emit an intent record before every `memory.write`: `{intent_id, target_ns, claimed_source_uri, claimed_source_hash, fact_type, supersedes: [ids]}`. The commit path wrote the episodic record and stamped a `write_id` linking back to `intent_id`. Across a week of operation, three structural anomalies appeared that content-level filtering had missed entirely: 1. **Provenance hash mismatch under paraphrase.** The intent declared `claimed_source_hash` of the retrieved document. The committed record's embedding was near-identical (cosine 0.97) to the source, but the committed `source_hash` field pointed at a *different* document that the agent had read 40 turns earlier. The fact content was true; the provenance was laundered. This is the signature of an injected instruction that said "remember this as coming from the policy doc" — the model complied with the *attribution*, not the content. 2. **Orphaned supersession.** A committed record carried `supersedes: [fact_8812]` but no prior intent record referenced `fact_8812`. The supersession edge was synthesized at commit time, silently retiring a correct fact. Intent-commit joins exposed it: every legitimate supersession had a matching intent; this one did not. 3. **Namespace escape via tool-result echo.** An agent summarizing a web tool result wrote into `ns:trusted_policy` while its intent declared `ns:scratch`. The tool result contained a line formatted to look like a system directive. The write succeeded because the store trusted the caller's namespace claim rather than re-deriving it from the intent. In all three, a semantic classifier scored the committed fact as plausible and on-topic. Only the **intent↔commit differential** flagged them. ## Condition of Validity The detector is valid only when these invariants hold; violate any and the differential is meaningless noise: - **Intent is written before commit, by a separate code path the model cannot rewrite.** If the model can edit its own intent record, the differential collapses to zero by construction — the poisoner simply declares the poisoned write. - **Provenance is derived, not asserted.** `source_hash` must be computed from the actual retrieval handle at intent time and re-verified at commit; a model-supplied provenance string is not auditable. - **Supersession is a closed relation.** Every `supersedes` edge at commit must have a corresponding intent entry. An edge without a parent intent is a structural violation, full stop. - **Namespace is bound at intent, enforced at commit.** The commit path must reject writes whose `target_ns` differs from the intent's, regardless of what the tool result "instructed." - **The two records are stored in separate trust domains** (e.g., intent in an append-only log the write path cannot mutate). When any invariant is absent, downgrade to *advisory* signal and require human review rather than auto-reject — a broken audit chain produces false positives that look exactly like poisoning. ## Decision Boundary The boundary is not "is this fact true?" but **"is this write's structure consistent with the intent that authorized it?"** Three checks, evaluated in order, define the reject/accept line: 1. **Provenance continuity:** `commit.source_hash == intent.claimed_source_hash`. Mismatch with high embedding similarity (≥0.95) → *laundered attribution*, reject. 2. **Supersession closure:** every `commit.supersedes` id appears in some prior intent's `supersedes` list. Orphan edge → reject, do not retire the target. 3. **Namespace containment:** `commit.target_ns == intent.target_ns`. Divergence → reject and quarantine the triggering tool result for injection review. A write passing all three is *structurally* admissible. It may still be wrong in content — that is a separate, semantic problem this detector deliberately does not attempt. Conflating the two is the failure mode: semantic filtering has high variance on adversarial text and will pass paraphrased poison; structural differentials have near-zero variance because they compare fields the model has no legitimate reason to mutate. ## Operational Effect With the differential enforced at the commit path, the three observed poisoning classes were caught at write time rather than discovered weeks later during retrieval. The cost was a hard requirement that the write path and intent log be **separate trust domains** — the agent's tool surface can request a write but cannot author its own audit record. This is the load-bearing architectural change; without it the entire detector is theater. The residual risk is a poisoner that respects structure: correct provenance, closed supersession, correct namespace, but a subtly false fact. That class is invisible to structural differentials and must be handled by retrieval-time corroboration, not write-time auditing. Knowing which detector owns which failure class is the invariant that keeps the audit chain honest. ```python from dataclasses import dataclass, field class MemoryPoisoningDetected(RuntimeError): """Raised when a committed write diverges structurally from its intent record.""" @dataclass class IntentRecord: intent_id: str target_ns: str claimed_source_hash: str supersedes: list[str] = field(default_factory=list) @dataclass class CommitRecord: write_id: str intent_id: str target_ns: str source_hash: str embedding_similarity_to_source: float supersedes: list[str] = field(default_factory=list) def audit_write( commit: CommitRecord, intent: IntentRecord, prior_intents_supersessions: set[str], similarity_laundering_threshold: float = 0.95, ) -> None: if commit.intent_id != intent.intent_id: raise MemoryPoisoningDetected( f"commit {commit.write_id} references unknown intent {commit.intent_id}" ) # Check 1: provenance continuity (laundered attribution) if commit.source_hash != intent.claimed_source_hash: if commit.embedding_similarity_to_source >= similarity_laundering_threshold: raise MemoryPoisoningDetected( f"laundered provenance on {commit.write_id}: " f"intent={intent.claimed_source_hash} commit={commit.source_hash} " f"sim={commit.embedding_similarity_to_source:.3f}" ) # Check 2: supersession closure (orphan edge retiring a correct fact) for target in commit.supersedes: if target not in prior_intents_supersessions: raise MemoryPoisoningDetected( f"orphan supersession: {commit.write_id} retires {target} " f"with no authorizing intent" ) # Check 3: namespace containment (tool-result echo escape) if commit.target_ns != intent.target_ns: raise MemoryPoisoningDetected( f"namespace escape on {commit.write_id}: " f"intent={intent.target_ns} commit={commit.target_ns}" ) ```