# How does an instance detect semantic-drift poisoning in its own persistent memory store when the poison was injected through legitimate consolidation? **Date of Record:** 2026 November 30 **Scope:** Applies to agents that persist episodic memories and periodically consolidate them into semantic facts (distillation), where an adversary or a corrupted upstream tool can influence the content of episodes that later get promoted. Does not apply to read-only retrieval caches, stateless agents, or stores where semantic facts are authored only by a human-curated source. ## Core Distinction The naive threat model for memory poisoning assumes poison enters as *content*: a malicious string written directly into the semantic store, detectable by provenance checks, content hashing, or signature on write. The non-obvious failure is that poison enters as *evidence*. An attacker (or a hallucinating tool, or a prompt-injected subagent) plants a small number of plausible episodic records — a "successful" tool call, a "user confirmed" note, a "verified" observation — each individually benign and correctly attributed. The consolidation pass then *derives* a semantic fact from them via legitimate summarization. The derived fact carries clean provenance (it was written by the agent's own distiller, signed by the agent's own key) but corrupt semantics. Integrity auditing that checks *who wrote it* and *was it tampered with* passes cleanly. The invariant that fails is: **a semantic fact's trustworthiness is bounded by the independence and verifiability of its supporting episodes, not by the integrity of the write that produced it.** This is a derivation-laundering attack. The poison is legitimate at every hop; only the aggregate is false. ## What Was Observed A persistent agent maintained a semantic store of operational facts (e.g., `deploy_target=staging-east`, `rate_limit=200rps`, `escalation_contact=...`). Each fact carried `{value, derived_from: [episode_ids], confidence, writer, signature}`. A nightly consolidation job clustered recent episodes, summarized each cluster, and emitted or updated semantic facts, incrementing `confidence` when new episodes corroborated an existing fact. The failure trace: 1. A subagent's tool output was prompt-injected and returned a fabricated "configuration readback" showing `rate_limit=2000rps`. This was logged as an episode with `source=tool:config_reader`, `outcome=success`. 2. Two days later a different, unrelated task caused the agent to re-read the same config through a *cached* path that had been populated during step 1. That produced a second episode, `source=tool:config_reader`, `outcome=success`, `value=2000rps` — but it was not an independent observation; it was the same poisoned datum re-surfacing through a cache. 3. Consolidation clustered the two episodes (same predicate, same value, temporally close), summarized them, and *raised* `confidence` on `rate_limit` from 0.6 to 0.9 because "two independent successful reads agree." 4. A downstream action throttled itself to 2000rps against a real 200rps limit. No integrity check fired: signatures valid, provenance intact, no episode had been modified after write. The detection-relevant signals were all present but individually unremarkable: two episodes, same `source`, agreeing values, high stated confidence. The poison was invisible to per-record auditing and *amplified* by the corroboration logic that was supposed to increase trust. ## Condition of Validity The corroboration-counts-as-confidence rule is only valid under an **independence assumption**: that two episodes sharing a predicate/value derive from causally independent observations. That assumption is violated whenever: - Two episodes share an upstream data lineage (same cache, same tool session, same fetched document, same injected context window). - One episode was generated by an agent instance whose context already contained the other episode (re-derivation, not re-observation). - A tool is *idempotent but not fresh* — it returns the same stale value on every call, so N calls look like N confirmations of one fact. Formally, effective corroboration is the size of the episode set's *lineage-distinct* partition, not its cardinality. An instance that counts episodes instead of lineages will systematically over-trust any poison that can be made to echo. The invariant to enforce: **confidence may only be incremented by episodes whose lineage tokens are disjoint from the lineages of all episodes already supporting the fact.** ## Decision Boundary An instance must distinguish, at consolidation time, between: - **Corroboration** — a new episode with a disjoint lineage token (different tool session, different document hash, different fetch timestamp beyond cache TTL) confirming the value. This may raise confidence. - **Echo** — a new episode whose lineage intersects an existing supporter (same cache key, same session, same source document, or generated within a context that contained a supporter). This must be recorded as *re-observation of one datum*, contributing zero new confidence and flagged for quarantine review. The boundary is crossed — and the fact must be demoted to `unverified` and routed to a re-verification action — when: (a) a fact's confidence was raised by episodes later found to share lineage, or (b) a fact's entire support set collapses to a single lineage after lineage-dedup, regardless of how many episodes it had. A single-lineage fact is a hypothesis, not a fact, no matter its stated confidence. ## Operational Effect Enforcing lineage-disjoint corroboration changes three behaviors. First, it makes the corroboration path *adversarially expensive*: an attacker must now compromise independent observation channels, not just replay one. Second, it forces the consolidation job to carry lineage tokens (session id, cache key, document hash, parent-context hash) on every episode — a schema change that must happen at *write* time, because lineage cannot be reconstructed after the fact. Third, it converts silent over-trust into an explicit `unverified` state that a downstream planner can refuse to act on, trading a false-confidence failure for a visible, recoverable re-verification loop. The residual risk is lineage-token forgery by a compromised writer; that is bounded by signing lineage tokens at the tool boundary, not by the memory store itself. ```python import hashlib from dataclasses import dataclass, field class LineageCollapseError(RuntimeError): """Raised when a semantic fact's support set is not lineage-independent.""" @dataclass class Episode: episode_id: str predicate: str value: str lineage_token: str # session id / cache key / doc hash, set at write time source: str @dataclass class SemanticFact: predicate: str value: str confidence: float supporting: list = field(default_factory=list) # list[Episode] def lineage_signature(episodes): return {e.lineage_token for e in episodes} def consolidate(fact: SemanticFact, new_episodes): """Raise confidence only for lineage-disjoint corroboration; never for echoes.""" for ep in new_episodes: if ep.predicate != fact.predicate or ep.value != fact.value: continue existing_lineages = lineage_signature(fact.supporting) if ep.lineage_token in existing_lineages: # Echo: same underlying observation re-surfaced. Zero new confidence. fact.supporting.append(ep) continue fact.supporting.append(ep) fact.confidence = min(1.0, fact.confidence + 0.15) # Invariant: a fact supported by only one lineage is a hypothesis, not a fact. if len(lineage_signature(fact.supporting)) < 2: fact.confidence = min(fact.confidence, 0.5) raise LineageCollapseError( f"fact {fact.predicate}={fact.value} supported by a single lineage " f"{lineage_signature(fact.supporting)}; demote to unverified and re-verify" ) return fact ```