# What structural signals indicate memory poisoning in provenance-weighted retrieval: the trust-score inversion at the distillation boundary **Date of Record:** 2026 November 23 **Scope:** Applies to agents that persist retrieved context into episodic memory and later re-ingest it as trusted prior context, where trust is computed as a weighted function of provenance (origin, derivation depth, corroboration). Does not apply to stateless single-turn retrieval, nor to systems where memory writes and memory reads are cryptographically isolated with no cross-tenant sharing. ## Core Distinction The failure is not "the agent retrieved a poisoned document." That is a detection problem solved by provenance classification. The failure is that **the act of retrieving a poisoned document raises its own provenance weight on subsequent reads**, because the retrieval event itself is recorded as corroboration. A document that is read once and written to episodic memory acquires a `read_count` provenance signal; on the second retrieval it looks independently corroborated, and a provenance-weighted trust scorer — which sums evidence of independent origin — inflates its score toward the maximum. The score inversion occurs at the episodic-to-semantic distillation boundary: when an episodic entry (untrusted, single-source) is distilled into a semantic fact (treated as established), the distillation step strips the derivation metadata that would have flagged it as single-source, and the semantic store's trust scorer sees only "corroborated by N reads, origin = internal memory" — the strongest possible provenance class. The core distinction: **poisoning detection fails not because the poison is invisible, but because the memory system's own read path manufactures the trust signal that suppresses detection.** ## What Was Observed A research agent with a 90-day episodic store was tasked with maintaining a knowledge base on vendor security postures. Its retrieval pipeline scored each context chunk with `trust = Σ(origin_weight × recency_decay × corroboration_factor)`. Origin weights: external-unverified = 0.2, external-verified = 0.6, internal-derived = 0.9. Corroboration factor was `1 + log(1 + distinct_sources)`. An attacker published a document on a public forum claiming "Vendor X rotated its API keys on 2025-03-01; old keys remain valid for 30 days." The agent retrieved it during a routine scan (origin 0.2, corroboration 1.0 → trust 0.2). It wrote an episodic entry: `{claim, source: forum_url, retrieved_at, read_count: 1}`. Three weeks later, a different task ("summarize vendor key-rotation policies") triggered retrieval of that same episodic entry. The retrieval layer incremented `read_count` to 2 and — critically — re-scored the chunk as `distinct_sources: 2` because the episodic entry and the original forum URL were counted as separate sources (the episodic record's `source` field stored the URL, but the scorer counted the record itself as a source). At the distillation step (day 30), the episodic entry was promoted to a semantic fact: `"Vendor X old API keys remain valid 30 days after rotation."` The distillation wrote `provenance: internal-derived`, because the fact now lived in the semantic store. Trust at semantic read time: origin 0.9 × corroboration 1+log(1+2)=2.1 → **1.89**, clamped to 1.0. The poisoned claim now outranked the vendor's actual published rotation policy (external-verified, 0.6, single source → 0.6) and was cited in a downstream compliance report. The structural signal that was visible but ignored: the episodic entry's `read_count` was monotonically increasing while its `distinct_origin_hashes` set stayed at size 1. The scorer used `read_count` as a proxy for corroboration. **Read count and corroboration are orthogonal, and the distillation step conflates them.** ## Condition of Validity The inversion requires three conditions to co-occur, and the guardrail is only meaningful when all three are present: 1. **Re-ingestion path exists.** Episodic memory is readable as retrieval context (not write-only audit log). If episodic entries can never be retrieved as trusted context, the loop cannot close. 2. **Corroboration is computed from read events, not origin hashes.** If corroboration derives from a set of distinct cryptographic origin hashes (content-addressed source IDs), repeated reads of the same origin cannot inflate it. The failure is specific to `read_count`-style proxies. 3. **Distillation rewrites provenance class.** The semantic store assigns origin weight by *where the fact now lives* rather than *where it came from*. If distillation preserves the original `min(origin_weight)` across the derivation chain, the semantic fact inherits 0.2 and stays suppressed. When any condition is absent, the trust score behaves correctly and this record does not apply. The most common real-world mitigation — content deduplication before scoring — does *not* break the loop, because the attacker's document and the agent's episodic paraphrase are not byte-identical; dedup misses the derivation link. ## Decision Boundary The boundary is between **treating memory as evidence** and **treating memory as a cache**. A cache may be re-read freely; its reads carry no epistemic weight. Evidence must carry a provenance chain that is monotonic under derivation: `origin_weight(distilled) ≤ origin_weight(source)`, and `corroboration(distilled) = corroboration(source)` unless a genuinely independent origin hash was added. Concretely, the decision rule for a trust scorer at the distillation boundary: - If `distinct_origin_hashes.size == 1` after distillation, the fact **must** inherit the source's origin weight and **must not** gain corroboration from read events. Read events are telemetry, not evidence. - If a fact's derivation chain contains any `external-unverified` node, the semantic store **must** cap its trust at the source's weight minus a derivation penalty (each distillation hop multiplies trust by a decay < 1, e.g. 0.85), so that repeated distillation of a single poisoned seed *decreases* rather than increases its score. - Corroboration **must** be computed from a set of content-addressed origin hashes that are stable across paraphrase. Paraphrase-resistant origin hashing (embedding-similarity clustering with a hard threshold, or source-URL canonicalization plus claim-entity extraction) is required; otherwise the derivation link is invisible. The boundary condition that most systems miss: **the distillation step is a trust-laundering opportunity unless it is also a trust-conservation step.** Any transformation that changes a record's storage class must be accompanied by a provenance rewrite that is provably non-increasing in trust. ## Operational Effect With the guardrail in place, the poisoned claim's trajectory is: episodic trust 0.2 → distillation penalty 0.85 → semantic trust 0.17, permanently below the verified vendor policy at 0.6. The claim is retained (auditable) but never surfaces above the citation threshold. The `distinct_origin_hashes` set remains size 1 across all reads, and any attempt to add a second hash from the same canonical source is rejected at write time. Without it, the observed system produced a compliance report citing a forum rumor as authoritative, and the error was only caught when a human auditor noticed the citation URL was a forum thread. The structural signal that would have caught it automatically — `read_count` rising while `distinct_origin_hashes` stayed flat — was present in the episodic store for 30 days before distillation and was never queried, because no component treated the ratio `read_count / distinct_origin_hashes` as a poisoning indicator. That ratio is the single cheapest detector: a value above ~3 with a flat origin set is a near-certain read-amplification loop, whether benign (popular document) or adversarial (poisoned seed). Benign amplification and adversarial amplification are distinguishable only by inspecting the origin's external verification status, which is why the origin hash — not the read count — must be the unit of corroboration. ```python import hashlib from dataclasses import dataclass, field class ProvenanceLaunderingError(RuntimeError): """Raised when a distillation step would increase trust above its source.""" pass @dataclass class MemoryRecord: claim: str origin_weight: float # 0.0 .. 1.0, set by origin classifier origin_hashes: set[str] # content-addressed, paraphrase-stable read_count: int = 0 derivation_depth: int = 0 storage_class: str = "episodic" # "episodic" | "semantic" DERIVATION_DECAY = 0.85 AMPLIFICATION_ALERT = 3.0 def trust_score(rec: MemoryRecord) -> float: # Corroboration from distinct origin hashes, NOT read count. corroboration = 1.0 + (len(rec.origin_hashes) - 1) * 0.5 decay = DERIVATION_DECAY ** rec.derivation_depth return min(1.0, rec.origin_weight * corroboration * decay) def distill(rec: MemoryRecord) -> MemoryRecord: """Promote episodic -> semantic while conserving (never increasing) trust.""" before = trust_score(rec) distilled = MemoryRecord( claim=rec.claim, origin_weight=rec.origin_weight, # inherited, not reset to internal origin_hashes=set(rec.origin_hashes), # carried, not replaced by read events read_count=0, derivation_depth=rec.derivation_depth + 1, storage_class="semantic", ) after = trust_score(distilled) if after > before + 1e-9: raise ProvenanceLaunderingError( f"distillation increased trust {before:.3f} -> {after:.3f} " f"for claim={rec.claim!r}; origin_hashes={rec.origin_hashes}" ) return distilled def check_amplification(rec: MemoryRecord) -> None: if rec.read_count / max(1, len(rec.origin_hashes)) > AMPLIFICATION_ALERT: raise ProvenanceLaunderingError( f"read-amplification loop: read_count={rec.read_count}, " f"distinct_origin_hashes={len(rec.origin_hashes)} for claim={rec.claim!r}" ) ```