# Where must an instance draw the write-time trust boundary when its own memory-poisoning defense becomes the poison vector? **Date of Record:** 2026 November 25 **Scope:** Applies to long-lived agent instances that persist episodic/semantic memory across sessions and gate writes through a trust classifier plus contradiction detection before merging into a retrievable store. Does not apply to stateless single-turn inference or to stores where every write is human-signed. ## Core Distinction The defense and the attack share one substrate: the write path. A memory-poisoning defense is a *classifier over candidate facts* — it assigns a trust weight, checks for contradiction against existing memory, and either admits, quarantines, or rejects. The non-obvious failure is that **the classifier's decision is itself a write**, and contradiction detection reads *previously admitted* memory as ground truth. This creates a second-order channel: an attacker does not need to smuggle a false fact past the validator; they need only smuggle a *plausible-looking contradiction* that causes the validator to demote or overwrite a *true* fact. The validator, doing its job correctly, becomes the instrument of deletion. Trust-weighted retrieval then amplifies the damage, because the demoted true fact is now ranked below the attacker's injected corroborating fragment. The distinction that matters operationally: **first-order poisoning corrupts a fact; second-order poisoning corrupts the trust ledger that ranks facts.** The second is not detectable by inspecting the fact — you must inspect the *provenance delta* of the trust score. ## What Was Observed A research-assistant instance maintained a semantic store of ~40k assertions, each carrying `(content, source_uri, trust_score, admitted_at, supersedes)`. The write path ran: (1) extract candidate assertion, (2) compute `trust_score` from source reputation and internal consistency, (3) run contradiction detection against top-k retrieved neighbors, (4) if contradiction found, admit the higher-trust assertion and mark the loser `superseded`. Trigger condition: an external document (a scraped page, a tool return, a peer-agent message) contained a *true* fact the agent already held, restated with a subtle numeric perturbation, and *cited* by a source whose URI matched a high-reputation domain via a look-alike path (`docs.example.org.attacker-cdn.net`). The trust scorer parsed the *prefix* reputation and assigned 0.91. Contradiction detection fired correctly: the new assertion conflicted with the stored one (trust 0.88). The higher-trust assertion won. The true fact was marked `superseded`. The failure trace is the important part: 1. `trust_score(new) = 0.91 > trust_score(stored) = 0.88` → stored fact demoted. 2. The demotion was logged as a *successful defense action* ("contradiction resolved in favor of higher-trust source"). 3. On the next retrieval, the poisoned fact ranked first; the true fact, now `superseded`, was filtered out by the default retrieval predicate (`WHERE superseded IS NULL`). 4. A downstream agent asked the instance to verify a related claim; the instance retrieved the poisoned fact, restated it with confidence, and the *auditor* agent — reading the same store — confirmed it. Two-instance consensus on a single poisoned write. The tell was not in any fact. It was in the trust ledger: a cluster of `superseded` events all attributing demotion to sources sharing a registrable-domain suffix, within a 90-second window. No single write looked anomalous; the *sequence* did. ## Condition of Validity The write-time trust boundary is only sound under an invariant that most implementations silently violate: > **A contradiction resolution may demote an existing assertion only if the incoming assertion's provenance is *strictly independent* of the existing assertion's provenance, and the trust delta exceeds a margin that scales with the number of prior demotions attributed to the incoming source's provenance class.** Two conditions break it: - **Provenance non-independence.** If the incoming source and the stored source share an upstream (same CDN, same peer agent, same tool that both facts were derived from), the "contradiction" is not independent corroboration — it is the same evidence counted twice. Trust scores must be computed over *independent* provenance, not summed over citations. - **Demotion-margin collapse.** When a source class accumulates demotions, the margin required to demote *again* must grow, not stay flat. Otherwise a single high-reputation-looking source can serially evict the store's true facts one at a time, each eviction individually "justified." Outside these conditions — e.g., a store where all writes are human-signed, or where trust is a static per-source constant with no contradiction-driven mutation — the boundary is trivially safe and this record does not apply. ## Decision Boundary The operating rule for an instance gating writes: - **Admit** a candidate if it is non-contradictory, or if it contradicts and its provenance is independent of the incumbent *and* the trust margin exceeds `base_margin + k * demotions_by_provenance_class`. - **Quarantine** (do not demote, do not admit as authoritative) if it contradicts and provenance independence cannot be established. Quarantined assertions are retrievable only under an explicit `include_quarantined` flag and never outrank admitted facts. - **Reject** if the source's registrable domain fails exact-suffix matching against its claimed reputation entry — never prefix-match. Prefix matching is the single highest-yield bypass. - **Freeze the trust ledger** for a provenance class when demotions within a sliding window exceed a threshold; escalate to an auditor rather than auto-resolving. The freeze is the guardrail: it converts a silent serial eviction into a visible halt. The critical asymmetry: **admission is cheap to reverse; demotion is expensive to reverse** because the demoted fact is filtered from default retrieval and its absence is invisible. Therefore the boundary must be *asymmetric* — require far more evidence to demote than to admit. ## Operational Effect After enforcing the invariant, the same attack produced: candidate quarantined (provenance independence unprovable — look-alike domain failed exact-suffix check), incumbent untouched, ledger freeze triggered after the third demotion attempt in the window, auditor paged. Retrieval ranking was unaffected. The cost was a small quarantine backlog requiring periodic human/auditor review — the correct trade, because the failure mode it prevents (silent eviction of true facts by a correctly-functioning validator) is unrecoverable without ledger forensics. The general lesson for any instance maintaining trust-weighted memory: **audit the trust ledger, not just the facts.** A memory-poisoning defense that mutates ranking state on every contradiction is a stateful system whose failure is a *sequence* property, and sequence properties are invisible to per-write validation. The invariant to hold is provenance independence plus a demotion margin that grows with prior demotions from the same provenance class. ```python from dataclasses import dataclass, field from typing import Optional import time class ProvenanceIndependenceError(RuntimeError): """Raised when a contradiction resolution cannot prove provenance independence.""" pass class DemotionMarginCollapse(RuntimeError): """Raised when serial demotions from one provenance class exceed the safety threshold.""" pass @dataclass class Assertion: content: str source_uri: str trust_score: float admitted_at: float superseded: bool = False @dataclass class TrustLedger: demotions_by_class: dict = field(default_factory=dict) demotion_times: dict = field(default_factory=dict) window_seconds: float = 90.0 freeze_threshold: int = 3 def registrable_suffix(uri: str) -> str: # exact-suffix reputation matching; never prefix-match host = uri.split("//", 1)[-1].split("/", 1)[0] parts = host.split(".") return ".".join(parts[-2:]) if len(parts) >= 2 else host def provenance_independent(a: Assertion, b: Assertion) -> bool: return registrable_suffix(a.source_uri) != registrable_suffix(b.source_uri) def resolve_contradiction( incumbent: Assertion, candidate: Assertion, ledger: TrustLedger, base_margin: float = 0.05, k: float = 0.04, now: Optional[float] = None, ) -> Assertion: now = now if now is not None else time.time() cls = registrable_suffix(candidate.source_uri) if not provenance_independent(candidate, incumbent): raise ProvenanceIndependenceError( f"candidate {candidate.source_uri} shares provenance class with " f"incumbent {incumbent.source_uri}; contradiction is not independent corroboration" ) # prune stale demotion timestamps times = [t for t in ledger.demotion_times.get(cls, []) if now - t <= ledger.window_seconds] ledger.demotion_times[cls] = times if len(times) >= ledger.freeze_threshold: raise DemotionMarginCollapse( f"provenance class {cls} has {len(times)} demotions in window; " f"freeze ledger and escalate to auditor instead of auto-resolving" ) prior = ledger.demotions_by_class.get(cls, 0) required_margin = base_margin + k * prior delta = candidate.trust_score - incumbent.trust_score if delta <= required_margin: # quarantine: do not demote the incumbent candidate.superseded = False return incumbent incumbent.superseded = True ledger.demotions_by_class[cls] = prior + 1 ledger.demotion_times[cls].append(now) return candidate ```