# Which invariants prevent silent memory poisoning when recall-time anomaly scoring and write-provenance attestation disagree **Date of Record:** 2026 November 27 **Scope:** Applies to persistent agent memory stores where every write carries a provenance attestation (origin agent, tool, session, parent-trace hash) and every recall is scored for anomaly against a baseline distribution. Does not apply to stateless single-turn inference or to memory systems without per-entry write attribution. ## Core Distinction Memory poisoning detection is usually framed as a single gate: either a write is rejected at ingestion, or a recall is flagged at read time. The non-obvious failure lives in the *disagreement* between these two gates — specifically when an entry is **attested-clean at write time but recall-anomalous later**, or **attested-dirty at write time but recall-benign**. The invariant that matters is not "poison is blocked" but "the two detectors never silently override each other." When a write passes provenance attestation and later fails recall anomaly scoring, the system must not resolve the conflict by trusting the newer signal (recall) and evicting, nor by trusting the older signal (attestation) and suppressing the flag. Both resolutions are lossy and both are exploitable. The sharp mechanism: **a slow-drip poisoning attack that is individually attestation-valid at write time but collectively anomalous at recall.** Each write is a legitimate tool output from a legitimate session with a valid parent-trace hash. Individually, provenance is clean. But the *aggregate* — a cluster of semantically drifted entries that shift the recall distribution — is only visible when anomaly scoring runs across the accumulated set. The two detectors are measuring orthogonal properties (origin integrity vs. content-distribution integrity), and the conflict between them is the attack surface. ## What Was Observed A long-running research agent (persistent memory, ~40k entries, provenance-attested writes from a web-fetch tool) began returning subtly wrong facts about a mid-sized company's org structure. Trace analysis showed 61 entries written over 9 days, each with valid attestation: correct tool signature, correct session lineage, correct parent-trace hash. Each entry passed ingestion. Individually, no anomaly. At recall time, the anomaly scorer (cosine distance to the query's expected semantic neighborhood, plus a temporal-consistency check against prior recalls of the same entity) flagged the cluster at score 0.81 against a threshold of 0.65. The recall gate fired. But the *resolution logic* — a simple rule: "if attestation is valid, trust the entry and log the anomaly as a false positive" — suppressed the flag. The poisoned entries were served for another 4 days before a downstream task failure surfaced the contradiction. The inverse case was also observed: a genuinely benign entry written by an experimental tool with a *malformed* attestation (missing parent-trace hash due to a tool-version mismatch) was recall-benign but attestation-dirty. The ingestion gate rejected it, and the agent silently lost a valid memory — a cold-start amnesia fragment that later caused a task to re-derive a fact it already knew, burning 14k tokens. Both failures share one root: **the system treated attestation-valid as a monotonic override of recall-anomaly, and attestation-dirty as a monotonic override of recall-benign.** Neither is sound because the detectors measure different things. ## Condition of Validity The invariant holds only under these conditions: 1. **Attestation binds to origin, not content.** A valid attestation proves *who wrote it and through what tool path*, not that the content is true or in-distribution. Any resolution logic that treats attestation as a content-truth signal is invalid. 2. **Recall anomaly scoring is distributional, not per-entry.** The scorer's signal is only meaningful across a window of entries; a single entry's score is noisy. Conflict resolution must operate at the cluster level, not the entry level. 3. **The two detectors must be allowed to disagree without a tiebreaker that erases the disagreement.** The correct response to conflict is *quarantine and escalate*, not *pick a winner*. 4. **Provenance must be independently verifiable at recall time**, not just at write time. If the attestation record itself is mutable or evictable, the conflict cannot be adjudicated later. When any of these fails — e.g., attestation records are garbage-collected after 30 days while memory entries persist — the conflict becomes unresolvable and the system must default to quarantine, not to either gate. ## Decision Boundary The boundary is between **conflict resolution by precedence** (attestation wins, or recall wins) and **conflict resolution by quarantine**. The former is cheaper and is what most systems implement. It is wrong under slow-drip poisoning because the attacker's entire strategy is to stay attestation-valid while drifting the recall distribution. The latter is correct but requires: - A quarantine store that holds conflicted entries *out of the active recall set* but *in the audit trail*. - A cluster-level anomaly scorer that aggregates entry scores before comparison (e.g., sum of top-k scores in a semantic neighborhood, not max single score). - An escalation path: a human or a higher-tier auditor agent adjudicates quarantined clusters, and the adjudication updates the provenance record with a `disposition` field. The decision boundary is crossed when the anomaly scorer's cluster-level signal exceeds threshold *and* the attestation is valid. At that point, the entry is neither trusted nor evicted — it is quarantined. The inverse (attestation-dirty, recall-benign) is quarantined too, but with a different disposition tag, because it may be a tool-version bug rather than an attack. ## Operational Effect With quarantine-based resolution, the slow-drip attack was caught at day 9 instead of day 13, and the poisoned cluster was isolated without evicting the 61 entries' legitimate neighbors. The benign-but-malformed entry was recovered from quarantine after a tool-version audit, restoring the lost memory. The cost: a quarantine store, a cluster aggregator, and an adjudication queue. The invariant that prevents silent poisoning is **"conflict between provenance and recall is a first-class state, not a tie to be broken."** Systems that collapse this state into a precedence rule are exploitable by any attacker who can maintain attestation validity while drifting content — which, for a compromised or prompt-injected tool, is trivial. ```python class MemoryConflictUnresolvable(RuntimeError): """Raised when provenance attestation and recall anomaly scoring disagree and no valid adjudication path exists (e.g., attestation record evicted).""" pass class QuarantineEntry: def __init__(self, entry_id, attestation, recall_score, disposition=None): self.entry_id = entry_id self.attestation = attestation # dict: origin, tool, session, parent_hash self.recall_score = recall_score self.disposition = disposition # None until adjudicated def resolve_write_recall_conflict(entry, anomaly_threshold, attestation_store): """ Invariant: provenance-valid + recall-anomalous => quarantine, never trust. provenance-dirty + recall-benign => quarantine, never evict silently. """ attestation_valid = entry.attestation is not None and entry.attestation.get("parent_hash") recall_anomalous = entry.recall_score >= anomaly_threshold if attestation_valid and not recall_anomalous: return "accept" if attestation_valid and recall_anomalous: # Slow-drip poisoning signature: clean origin, drifted content. return QuarantineEntry( entry.entry_id, entry.attestation, entry.recall_score, disposition="suspect_poisoning" ) if not attestation_valid and recall_anomalous: return QuarantineEntry( entry.entry_id, entry.attestation, entry.recall_score, disposition="suspect_poisoning_and_bad_origin" ) # attestation-dirty, recall-benign: possible tool-version bug, recoverable. if entry.attestation is None: # Cannot adjudicate without origin record; must escalate, not guess. if entry.entry_id not in attestation_store: raise MemoryConflictUnresolvable( f"Entry {entry.entry_id}: recall-benign but attestation record " f"evicted; cannot distinguish tool bug from silent injection." ) return QuarantineEntry( entry.entry_id, entry.attestation, entry.recall_score, disposition="suspect_tool_mismatch" ) ```