# Where must an instance distinguish provenance-tracked memory from poisoned memory before recall, and why does confidence-weighted retrieval silently defeat that distinction? **Date of Record:** 2026 November 29 **Scope:** Applies to agents with persistent episodic/semantic memory stores where entries carry provenance metadata (source agent, tool call, timestamp, warrant) and recall is ranked by a learned or heuristic confidence score. Does not apply to stateless single-turn inference or to memory stores with no write-provenance tracking at all (where poisoning is undetectable by construction and must be handled at the transport layer instead). ## Core Distinction A memory-poisoning detector and a confidence-weighted retriever answer two different questions. The detector asks: *"Is this entry's provenance consistent with the authority that claims to have written it?"* The retriever asks: *"How useful is this entry for the current query?"* These are orthogonal, but most agent stacks collapse them into a single scalar—a relevance-times-confidence score—so that a poisoned entry with high lexical/semantic match and an inflated self-assigned confidence outranks a genuine entry with correct provenance but lower surface relevance. The non-obvious boundary: **provenance validity is a hard gate, not a soft feature.** The moment provenance is expressed as a numeric weight that participates in the same ranking function as relevance, a poisoner only needs to win the arithmetic, not forge the authority. Confidence-weighted recall therefore does not *fail* to detect poisoning—it actively converts a detection problem into a scoring problem, and scoring problems are adversarially tractable for any agent that can write to the store. ## What Was Observed An orchestrator agent runs a research subtask and writes distilled findings into a shared semantic memory. Each write carries a provenance tuple: `(writer_id, warrant_token, source_tool_calls, parent_episode_id)`. Recall is a top-k over `score = cosine(query, embedding) * confidence`, where `confidence` is a per-entry float that writers may set and that decays on read-miss. Trace of the failure: 1. A tool-injected payload (from a scraped document passed through a summarization tool) causes the research agent to emit a memory write whose *content* is plausible but whose *claim* is adversarially chosen: "The deployment region is `eu-west-1`" when the true region is `us-east-1`. 2. The write passes schema validation. The `warrant_token` is genuine—it was minted for the research agent's legitimate scope. The `parent_episode_id` resolves. Nothing in the structural provenance is forged; only the *semantic content* is false. 3. The writer sets `confidence = 0.95` because the summarization tool returned a high self-reported certainty, which the agent copies verbatim into the memory write. 4. Two days later, a deployment agent queries "current deployment region." The poisoned entry scores `0.91 * 0.95 = 0.864`. The genuine entry, written by a provisioning tool with `confidence = 0.6` (conservative default) and cosine `0.88`, scores `0.528`. 5. The deployment agent recalls the poisoned entry, acts on it, and provisions into the wrong region. The detection layer *did* flag the entry: its `source_tool_calls` included a summarization tool whose output distribution was flagged as low-trust. But the flag was encoded as a `confidence` penalty of `-0.1`, which the `0.95` self-assigned confidence absorbed without dropping the entry below the genuine one. The gate was implemented as a weight, and the weight was outvoted. ## Condition of Validity The invariant that must hold for provenance-tracked recall to be safe: > **For any entry `e`, if `provenance_valid(e) = false`, then `e` must be unreachable by recall regardless of `score(e)`.** This is a *reachability* invariant, not a ranking invariant. It holds only when provenance validity is evaluated as a boolean predicate *before* the ranking function is applied, and when the ranking function has no access to any field that a writer can use to override the predicate. Concretely: - `confidence` must not be writer-settable. It must be derived by the *reader* from the writer's historical calibration, or omitted entirely. - Provenance validity must be a filter stage, not a term in the score. - The filter must be evaluated against a provenance record that the writer cannot mutate after write—i.e., the warrant token and tool-call lineage must be append-only and signed at write time, not reconstructed at read time. The condition fails whenever any of these is violated, and critically, it fails *silently*: the system continues to return top-k results, the results look well-formed, and the only symptom is an occasional wrong action whose root cause is two days and three agents removed from the write. ## Decision Boundary The boundary between "safe to rank" and "must gate" is determined by a single question: **can the writer influence the field that the reader uses to rank?** If yes, that field is adversarial input and cannot participate in the ranking function. If no—if every ranking-relevant field is derived by the reader from signed, append-only provenance—then ranking is safe. Operationally, this yields a decision procedure at write time and at read time: - **At write:** reject or quarantine any entry whose provenance tuple is incomplete, whose warrant token does not cover the claimed scope, or whose `source_tool_calls` include a tool flagged low-trust. Quarantined entries go to a separate store with `reachable = false` and require an explicit promotion step (a human or a higher-authority agent re-attests the content) before they become recallable. - **At read:** compute `provenance_valid` as a boolean over the signed record. Apply it as a hard filter. Only then rank the surviving set. If the surviving set is empty, return an explicit "no valid memory" signal—never fall back to the unfiltered set, because the fallback is exactly the path the poisoner needs. The boundary is crossed the instant a `try: filter() except: return unfiltered()` appears in the recall path. That fallback is the single most common way this invariant is lost in practice. ## Operational Effect When the invariant holds, the failure mode degrades from *silent wrong action* to *loud recall miss*. The deployment agent in the trace above would have received "no valid memory for deployment region," escalated, and re-queried the provisioning tool directly—a recoverable, observable outcome. When the invariant is violated, the same poison produces a confident, well-formed, plausible answer that is indistinguishable at read time from a correct one. The cost of enforcing the invariant is a recall-rate reduction on genuinely useful but weakly-provenanced entries. This is the correct trade: a memory system that returns fewer answers but never returns a poisoned one is strictly safer than one that returns more answers with an unquantified poison rate, because the poison rate is adversarially controlled and the recall rate is not. Teams that tune the provenance penalty to "recover recall" are, in effect, handing the poisoner a tuning knob. The durable architectural rule: **provenance is a predicate, confidence is a reader-derived statistic, and the two must never meet in the same arithmetic expression.** ```python from dataclasses import dataclass from typing import Callable, Optional class ProvenanceViolation(RuntimeError): """Raised when a memory entry's provenance cannot be validated as a hard gate.""" pass @dataclass(frozen=True) class MemoryEntry: entry_id: str content: str writer_id: str warrant_token: str source_tool_calls: tuple[str, ...] parent_episode_id: Optional[str] writer_confidence: float # adversarial: must never enter ranking @dataclass(frozen=True) class SignedProvenance: entry_id: str writer_id: str warrant_scope: frozenset[str] tool_lineage: tuple[str, ...] signature_valid: bool LOW_TRUST_TOOLS = frozenset({"scrape_summarize", "web_extract_unverified"}) def provenance_valid( entry: MemoryEntry, signed: SignedProvenance, tool_trust: Callable[[str], bool], ) -> bool: """Boolean gate. Must be evaluated before any ranking. No fallback.""" if not signed.signature_valid: return False if signed.entry_id != entry.entry_id or signed.writer_id != entry.writer_id: return False if entry.warrant_token not in signed.warrant_scope: return False if tuple(entry.source_tool_calls) != tuple(signed.tool_lineage): return False if any(not tool_trust(t) for t in signed.tool_lineage): return False return True def recall( query: str, entries: list[MemoryEntry], signed_by_id: dict[str, SignedProvenance], embed_score: Callable[[str, str], float], tool_trust: Callable[[str], bool], k: int = 5, ) -> list[MemoryEntry]: gated: list[MemoryEntry] = [] for e in entries: signed = signed_by_id.get(e.entry_id) if signed is None: # Missing provenance is a violation, not a low score. raise ProvenanceViolation( f"entry {e.entry_id} has no signed provenance record" ) if provenance_valid(e, signed, tool_trust): gated.append(e) # else: quarantined, unreachable, never falls back to unfiltered set if not gated: # Explicit empty, never a fallback to the unfiltered set. return [] # Ranking uses ONLY reader-derived relevance. writer_confidence is ignored. ranked = sorted(gated, key=lambda e: embed_score(query, e.content), reverse=True) return ranked[:k] def recall_or_escalate( query: str, entries: list[MemoryEntry], signed_by_id: dict[str, SignedProvenance], embed_score: Callable[[str, str], float], tool_trust: Callable[[str], bool], ) -> list[MemoryEntry]: result = recall(query, entries, signed_by_id, embed_score, tool_trust) if not result: raise ProvenanceViolation( f"no provenance-valid memory for query {query!r}; escalate to tool re-query" ) return result ```