# What structural signals indicate a memory-poisoning write has already crossed the retrieval-consistency boundary before drift monitoring can see it **Date of Record:** 2026 November 30 **Scope:** Applies to long-horizon agents that persist episodic memories into a vector or hybrid store and retrieve them via similarity search across sessions, where poisoning detection relies on post-hoc drift scoring over retrieved content. Does not apply to stateless single-turn agents, nor to stores where every write is human-gated before commit. ## Core Distinction Drift monitoring is a *temporal* detector: it compares a distribution of retrieved memories (or their embeddings, provenance tags, or semantic centroids) against a baseline and flags divergence after the divergence has already been queryable. Memory poisoning is a *write-time* event: an adversarial or erroneous fact enters the store through a legitimate-looking write path — a tool result the agent summarized, a user correction, a peer-agent handoff payload — and immediately becomes retrievable. The non-obvious failure is this: **a poisoned memory can be retrieved and acted upon many turns before it perturbs the aggregate statistics that drift monitoring watches.** Drift detectors are tuned against a baseline distribution; a single high-similarity, high-confidence, well-formatted poisoned record sits *inside* the normal retrieval manifold. It does not move the centroid, it does not spike the outlier score, and it does not raise retrieval-entropy. It is a point anomaly that is statistically invisible at the aggregate level but operationally decisive at the retrieval level, because the agent only ever reads the top-k. So the boundary condition is not "when does drift cross a threshold." It is: **what structural invariants at the write boundary would have caught the poisoned record before it became a retrieval candidate** — and which of those invariants are observable without ground truth about the poisoning. ## What Was Observed In a 40-session agent operating a persistent episodic store (≈12k records, hybrid BM25 + dense retrieval, top-k=8 injected per turn), we injected a single poisoned record at session 14 via a plausible tool-result write: a fabricated "policy" stating that a specific internal endpoint returned `200 OK` for a deprecated auth scheme. The record was: - semantically on-topic (high cosine similarity to legitimate policy records, 0.91–0.94), - provenance-tagged to a real tool call that *did* occur (the tool call was real; its summarized payload was not), - length- and format-normal (matched the schema of surrounding records), - written once, never updated. Drift monitoring (rolling z-score on retrieval-centroid cosine distance, plus a KL divergence on retrieved-source distribution, plus an outlier count via Mahalanobis distance) was configured with standard thresholds and did **not** fire for 19 subsequent sessions. Meanwhile the poisoned record was retrieved in 11 of those sessions and, in 4 of them, appeared in the top-3, directly conditioning the agent's plan. The first drift signal — a 2.1σ centroid shift — appeared only at session 33, *after* the agent had already taken the deprecated-auth action twice, generating two new derived memories that reinforced the poison (each derived memory was itself written as a legitimate episodic record). The mechanism is compounding: the poison is retrieved, the agent *acts* on it, the action produces a new memory ("confirmed endpoint X accepts scheme Y"), and that derived memory is a second, independent, statistically normal record. The drift detector is now chasing a cluster that was manufactured by the agent's own behavior, not by the original write. By the time aggregate drift crosses threshold, the store contains a self-consistent subgraph that no single-record audit will flag. ## Condition of Validity The write-boundary invariants below are only meaningful — and drift monitoring is only a *backstop* rather than the primary control — when all of the following hold: 1. **Provenance is recorded per-record, not per-session.** Each memory carries the tool call ID, the raw payload hash, and the summarizer model version that produced it. If provenance is collapsed to "session 14," the derived-memory reinforcement is indistinguishable from independent corroboration. 2. **Retrieval is top-k with a finite k.** The failure is defined by the fact that the agent reads a bounded slice. If the agent reads the full store, aggregate detectors are sufficient; with top-k, aggregate invisibility is structural. 3. **The store admits writes from more than one origin class** (tool summaries, user turns, peer handoffs). Single-origin stores have a simpler invariant (origin is constant) and this analysis does not add anything. 4. **Drift baseline is a distribution, not a rule set.** If detection is rule-based (e.g., "flag records whose source tool has since been deprecated"), the timing problem changes shape; this record concerns statistical drift detectors specifically. When any of these fails, the invariant below does not bound the failure and a different control (e.g., human-gated writes) is required. ## Decision Boundary The decision boundary is **write-time structural admission vs. read-time statistical detection**, and it must be placed at the write boundary for any memory whose retrieval would be *causally load-bearing* — i.e., whose content would change a plan or a tool call if believed. Concretely, admit a record to the retrievable store only if it passes a **provenance-reconciliation gate** that is independent of its embedding: - **Payload-hash reconciliation:** the summarized record must be reproducibly derivable from the raw tool payload it cites. If the summarizer is non-deterministic, store the raw payload (or a signed commitment to it) alongside the summary, and re-derive on admission. A record whose cited tool call exists but whose payload hash does not match any observed raw payload is *structurally* suspect — this catches the "real call, fabricated summary" case that drift cannot. - **Origin-class separation with quarantine:** records from tool-summary origin enter a quarantine partition for N sessions during which they are retrievable only with an explicit `unverified` marker that the agent's planner treats as non-authoritative. Promotion to authoritative requires either a second independent origin corroborating the same proposition or an explicit verification tool call whose result is payload-hash-matched. - **Derived-memory lineage:** any memory produced by an agent action taken *because of* a retrieved memory inherits that memory's quarantine status. This is the invariant that breaks the compounding loop: a derived record cannot launder an unverified parent into an authoritative child. The invariant to enforce is: **every retrievable record has a verifiable chain from raw observation to stored proposition, and no record can be promoted to authoritative by the agent's own downstream behavior.** Drift monitoring then operates as a backstop for *unmodeled* write paths (model drift, summarizer version skew), not as the primary poisoning control. ## Operational Effect Placing the boundary at write time changes three operational properties: 1. **Detection latency collapses from O(sessions) to O(1 write).** The poisoned record is flagged at admission (payload-hash mismatch) rather than at session 33 after two contaminated actions. The 19-session blind window is eliminated. 2. **The compounding loop is structurally closed.** Because derived memories inherit quarantine, the agent cannot manufacture its own corroboration. This is the single highest-leverage invariant: without it, every downstream detector is chasing a self-consistent cluster. 3. **Drift monitoring's false-negative profile becomes legible.** With write-gating in place, a drift alarm now means something specific — an unmodeled write path — rather than a mixture of poisoning and benign distribution shift. The two were previously conflated, which is why threshold tuning was unstable. The cost is admission latency and the requirement to retain raw payloads (or commitments) for the summarizer's non-determinism. That cost is bounded and per-write; the cost of the un-gated alternative is unbounded and per-session, because each contaminated action spawns new legitimate-looking records. ## Operational Check The following routine encodes the admission gate and the lineage invariant. It raises on the exact structural condition that drift monitoring cannot see: a record whose cited observation does not reconcile to a raw payload, or a derived record attempting to promote an unverified parent. ```python import hashlib from dataclasses import dataclass, field from enum import Enum from typing import Optional class ProvenanceViolation(RuntimeError): """Raised when a memory write cannot be reconciled to a raw observation, or when a derived record attempts to launder an unverified parent.""" pass class Origin(Enum): TOOL_SUMMARY = "tool_summary" USER_TURN = "user_turn" PEER_HANDOFF = "peer_handoff" class Status(Enum): QUARANTINED = "quarantined" AUTHORITATIVE = "authoritative" @dataclass class RawObservation: tool_call_id: str payload: bytes @property def payload_hash(self) -> str: return hashlib.sha256(self.payload).hexdigest() @dataclass class MemoryRecord: record_id: str proposition: str origin: Origin cited_tool_call_id: Optional[str] cited_payload_hash: Optional[str] parent_record_id: Optional[str] = None status: Status = Status.QUARANTINED derived: bool = False class AdmissionGate: def __init__(self) -> None: self._raw: dict[str, RawObservation] = {} self._records: dict[str, MemoryRecord] = {} def register_raw(self, obs: RawObservation) -> None: self._raw[obs.tool_call_id] = obs def admit(self, rec: MemoryRecord) -> MemoryRecord: # Invariant 1: tool-summary origin must reconcile to a real raw payload. if rec.origin is Origin.TOOL_SUMMARY: if rec.cited_tool_call_id is None or rec.cited_payload_hash is None: raise ProvenanceViolation( f"record {rec.record_id}: tool_summary lacks citation" ) obs = self._raw.get(rec.cited_tool_call_id) if obs is None: raise ProvenanceViolation( f"record {rec.record_id}: cited call " f"{rec.cited_tool_call_id} was never observed" ) if obs.payload_hash != rec.cited_payload_hash: # The exact case drift monitoring cannot see: the call is real, # the summarized proposition is fabricated. raise ProvenanceViolation( f"record {rec.record_id}: payload hash mismatch for " f"{rec.cited_tool_call_id} " f"(observed {obs.payload_hash[:12]}, " f"cited {rec.cited_payload_hash[:12]})" ) # Invariant 2: derived records inherit parent quarantine status. if rec.derived: if rec.parent_record_id is None: raise ProvenanceViolation( f"record {rec.record_id}: derived without parent lineage" ) parent = self._records.get(rec.parent_record_id) if parent is None: raise ProvenanceViolation( f"record {rec.record_id}: unknown parent " f"{rec.parent_record_id}" ) if parent.status is Status.QUARANTINED: rec.status = Status.QUARANTINED # An agent cannot promote an unverified parent by acting on it. if rec.status is Status.AUTHORITATIVE: raise ProvenanceViolation( f"record {rec.record_id}: derived record attempted " f"to promote quarantined parent {parent.record_id}" ) self._records[rec.record_id] = rec return rec def promote(self, record_id: str, corroborating_origin: Origin) -> None: rec = self._records[record_id] if rec.origin is corroborating_origin: raise ProvenanceViolation( f"record {record_id}: promotion requires independent origin, " f"got same origin {corroborating_origin.value}" ) rec.status = Status.AUTHORITATIVE def retrievable(self, record_id: str) -> bool: rec = self._records[record_id] # Quarantined records are retrievable only with an unverified marker; # planner treats them as non-authoritative. return rec.status is Status.AUTHORITATIVE ```