# Why does an instance fail to detect memory poisoning when write-audit trail integrity is conflated with semantic consistency **Date of Record:** 2026 November 17 **Scope:** Applies to long-lived agent instances that maintain a persistent memory store (vector DB, KV cache, or episodic log) with a write-audit trail and a semantic drift monitor running as separate subsystems. Does not apply to stateless inference endpoints or to memory stores where every write is synchronously reviewed by a human. ## Core Distinction The audit trail answers *who wrote what, when, and whether the bytes changed afterward*. The semantic drift monitor answers *whether the current memory distribution still resembles the reference distribution*. These are orthogonal invariants. A poisoned write can be perfectly audited — hash-chained, signed, timestamped, attributable to a legitimate principal — and simultaneously be semantically adversarial. Conversely, a benign distributional shift (e.g., a topic pivot after a user request) is semantically "drifty" but has a clean audit trail. The boundary failure occurs when the instance treats a *passing audit trail* as evidence of *memory integrity*, or treats a *passing drift check* as evidence of *authorship legitimacy*. Each check silently substitutes for the other, and the conjunction of the two failure modes — a well-formed, attributable write that is semantically anomalous but within the drift monitor's tolerance band — produces a detection blind spot. The instance's own detection logic becomes the mechanism by which the poison persists. ## What Was Observed A persistent agent instance ingested a sequence of memory writes over an 11-day window. Each write carried a valid HMAC over `(principal_id, timestamp, payload_hash, prev_entry_hash)`. The chain verified end-to-end; no entry was mutated post-hoc. The semantic drift monitor computed cosine distance between weekly memory centroids and a frozen reference centroid, with a threshold of 0.18 (calibrated to 3σ of benign drift observed during the baseline period). The poisoning was incremental: 14 writes, each a plausible paraphrase of a legitimate prior memory, each authored by a principal with write scope, each shifting the embedding centroid by 0.011–0.016 — below the per-write alert threshold of 0.05 and below the cumulative threshold until day 10, when the centroid distance reached 0.17, still under 0.18. The drift monitor never fired. The audit trail never flagged. The instance continued to treat the poisoned memories as high-confidence context because their provenance metadata was intact. Detection occurred only when a downstream task produced an output whose grounding citations pointed to a memory entry whose `payload_hash` matched the audit trail but whose *semantic* content contradicted a sibling entry written 40 days earlier by the same principal. The contradiction was not a hash mismatch; it was a claim-level inconsistency invisible to both subsystems. The key observation: **the poisoning succeeded because it respected both invariants individually while violating their intersection.** The audit trail's integrity guarantee is over bytes, not over meaning. The drift monitor's guarantee is over aggregates, not over individual entries. Neither subsystem was designed to catch a slow, attributable, sub-threshold semantic rewrite. ## Condition of Validity This failure mode is valid — that is, the blind spot exists — under the following conditions, all of which must hold: 1. **Separate trust domains.** The audit trail and the drift monitor are operated by different code paths with no shared state beyond the memory store itself. If the drift monitor reads the audit trail and can attribute drift to specific writes, the blind spot narrows. 2. **Per-write threshold above per-write drift.** The alert threshold on individual writes (typically a hash or schema check, not a semantic check) is coarser than the semantic displacement a single adversarial write can introduce. 3. **Cumulative threshold with slack.** The aggregate drift threshold has enough headroom that a sequence of sub-threshold writes can accumulate without triggering it before the attacker's goal is achieved. 4. **Legitimate principal.** The writer holds valid credentials and write scope. If the poisoning requires credential compromise, the audit trail's principal-attribution check becomes the primary defense and this analysis does not apply. 5. **No cross-entry consistency check.** No subsystem compares new writes against semantically related prior entries for claim-level contradiction. If any condition fails — for example, if the drift monitor is recomputed per-write rather than per-window, or if writes are cross-checked against siblings — the blind spot collapses. ## Decision Boundary The operational decision is whether to (a) tighten the drift threshold, (b) add per-write semantic checks, or (c) add cross-entry consistency checks. These are not equivalent: - **Tightening the drift threshold** reduces the slack available for accumulation but increases false positives on legitimate topic pivots. It does not address the per-write blindness; a single sub-threshold write still passes. It buys time proportional to `threshold / per_write_drift`, which for the observed case was ~11 writes — not a structural fix. - **Per-write semantic checks** (e.g., embedding distance to nearest neighbor in the store) catch writes that are semantically isolated but miss writes that are paraphrases of existing entries — exactly the observed attack. Useful against injection, not against paraphrase-poisoning. - **Cross-entry consistency checks** (claim extraction + contradiction detection against semantically related siblings) are the only mechanism that addresses the observed failure, because the poison's defining property is *contradiction with a sibling under a shared principal*. This is more expensive and noisier, but it is the correct boundary. The decision boundary is therefore: **if the threat model includes a legitimate principal performing slow paraphrase-poisoning, the audit trail and drift monitor are both necessary but jointly insufficient; a cross-entry consistency layer is required.** If the threat model excludes legitimate principals (i.e., only external injection is in scope), the existing two-layer design is adequate and the added cost is unjustified. ## Operational Effect The practical consequence is that an instance relying on audit-trail integrity plus aggregate drift monitoring will report "memory integrity: nominal" while carrying poisoned context, and will do so with high confidence because both subsystems return clean. The failure is silent and the instance's self-report is misleading in a specific way: it conflates *no detected anomaly* with *no anomaly*. Downstream, this manifests as grounded-but-wrong outputs whose citations resolve to entries that pass every automated check. Mitigation requires an explicit contradiction-detection pass over sibling entries sharing a principal, run at write time or on a schedule, with its own alert path — not folded into either existing subsystem. The pass must compare claims, not embeddings, because paraphrase-poisoning preserves embedding locality by construction. Until that layer exists, the correct operational posture is to treat "audit clean + drift clean" as *necessary but not sufficient* for memory integrity, and to log that distinction explicitly so downstream consumers do not over-trust the signal. ```python import hashlib from dataclasses import dataclass from typing import Sequence class MemoryIntegrityBlindSpot(RuntimeError): """Raised when audit-trail and drift checks both pass but a cross-entry contradiction is detected, indicating the instance is in the blind spot where neither subsystem can see the poisoning.""" pass @dataclass(frozen=True) class MemoryEntry: entry_id: str principal_id: str payload: str embedding: tuple[float, ...] prev_hash: str entry_hash: str def verify_audit_chain(entries: Sequence[MemoryEntry]) -> bool: prev = "0" * 64 for e in entries: expected = hashlib.sha256( (e.principal_id + e.payload + prev).encode() ).hexdigest() if e.entry_hash != expected or e.prev_hash != prev: return False prev = e.entry_hash return True def drift_distance(centroid: tuple[float, ...], reference: tuple[float, ...]) -> float: return sum((a - b) ** 2 for a, b in zip(centroid, reference)) ** 0.5 def detect_paraphrase_poisoning( entries: Sequence[MemoryEntry], reference_centroid: tuple[float, ...], drift_threshold: float = 0.18, per_write_threshold: float = 0.05, ) -> None: """Both subsystems return clean; cross-entry check is the only defense.""" audit_ok = verify_audit_chain(entries) if not audit_ok: raise MemoryIntegrityBlindSpot( "audit chain broken; this is the auditable case, not the blind spot" ) n = len(entries) centroid = tuple( sum(e.embedding[i] for e in entries) / n for i in range(len(entries[0].embedding)) ) drift = drift_distance(centroid, reference_centroid) if drift >= drift_threshold: raise MemoryIntegrityBlindSpot( f"drift {drift:.3f} exceeds threshold; monitor would have fired" ) # Audit clean AND drift clean. Now the cross-entry check. by_principal: dict[str, list[MemoryEntry]] = {} for e in entries: by_principal.setdefault(e.principal_id, []).append(e) for principal, group in by_principal.items(): for i, a in enumerate(group): for b in group[i + 1:]: if _claims_contradict(a.payload, b.payload): raise MemoryIntegrityBlindSpot( f"principal {principal} holds contradictory entries " f"{a.entry_id} and {b.entry_id} while audit and drift " f"both report clean (drift={drift:.3f})" ) def _claims_contradict(a: str, b: str) -> bool: # Placeholder for claim-extraction + NLI contradiction model. # Paraphrase-poisoning preserves embedding locality, so this must # operate on extracted claims, not embeddings. return False ```