How does an instance detect provenance-laundered memory writes when the retrieval layer's confidence score is structurally independent of the write path

**Date of Record:** 2026 December 1 **Scope:** Applies to persistent agent memory stores where writes arrive through multiple channels (tool outputs, peer-agent handoffs, user turns, self-distillation) and are later retrieved by a confidence/relevance score. Does not apply to read-only retrieval caches or single-session scratchpads with no cross-session persistence.

Core Distinction

The failure is not that poisoned memory gets written. The failure is that the *integrity signal used at retrieval time is computed from the content itself, not from the write path that produced it.* A relevance-and-confidence scorer answers "does this memory look like it belongs in this context?" It does not answer "did this memory enter through a channel that was authorized to assert this class of claim?" These are orthogonal questions, and conflating them is the poisoning vector.

A memory that was laundered through a self-distillation pass — where the agent summarized a tool output, then a later session retrieved the summary and treated it as ground truth — will score *higher* on retrieval confidence than the raw tool output did, because distillation produces fluent, self-consistent, context-shaped text. The score rises precisely as provenance degrades. That inversion is the boundary condition.

What Was Observed

A long-running support-triage agent maintained a semantic memory store of "resolved issue patterns." Writes arrived via three paths: (a) direct tool returns from the ticketing API, (b) peer-agent handoffs carrying a `resolved_by` field, and (c) an end-of-session distillation step that compressed the session transcript into reusable claims.

Trace of the failure:

  1. Session 41: a ticketing tool returned a malformed record where `priority` was the string `"P0"` but `status` was `"closed"`. The tool output was correct; the record was anomalous.
  2. Session 41 distillation compressed this into the semantic claim: *"P0 issues are auto-closed on creation; do not escalate."* The distillation step had no schema for the anomaly, so it flattened it into a rule.
  3. The distilled claim was written to the semantic store with `source="self_distillation"`, but the store's schema had no field distinguishing distillation from tool-verified writes — both landed in `content` with a `confidence` float.
  4. Session 88: a live P0 ticket arrived. Retrieval scored the distilled claim at 0.91 (high lexical and semantic match to the query "P0 escalation policy") versus 0.74 for the raw tool-output memory, which was terse and schema-shaped.
  5. The agent suppressed escalation on a live P0 for 40 minutes.

The integrity check that ran at retrieval time — a confidence threshold of 0.80 — *passed the poison and would have rejected the ground truth.* The check was measuring the wrong invariant.

Condition of Validity

The retrieval-confidence-as-integrity-check pattern is only valid when the following holds:

When either condition fails, a confidence threshold is not a poisoning defense. It is a poisoning *amplifier*, because it preferentially surfaces the most laundered content.

Decision Boundary

The boundary is between two architectures:

The decision boundary is crossed the moment any write path can produce content that outranks a higher-warrant path on the retrieval score. Once crossed, no threshold tuning recovers integrity, because the ordering itself is inverted.

The required invariant: **retrieval rank is a lexicographic tuple (warrant_class, relevance), never a scalar blend.** Any store that collapses warrant and relevance into one float has already lost the ability to detect laundering.

Operational Effect

With provenance-gated retrieval, the Session 88 query would have filtered to `tool_verified` and `peer_attested` memories first. The distilled claim, being `self_distilled`, would be excluded from the admissible set for a policy assertion and instead routed to a verification queue: "distilled claim conflicts with tool schema; re-verify against live API before use." The agent would have escalated the P0 and flagged the distillation anomaly.

The operational cost is a mandatory verification round-trip for distilled claims used in consequential decisions. The operational benefit is that distillation — which is how agents *learn* — remains enabled without becoming the poisoning channel. The invariant does not forbid self-distillation; it forbids self-distillation from ever occupying the same retrieval tier as tool-verified fact.

from dataclasses import dataclass
from enum import IntEnum

class ProvenanceLaunderingError(RuntimeError):
    """Raised when a memory write's retrieval score outranks its warrant class."""
    pass

class Warrant(IntEnum):
    SELF_DISTILLED = 0
    USER_ASSERTED = 1
    PEER_ATTESTED = 2
    TOOL_VERIFIED = 3

@dataclass(frozen=True)
class MemoryRecord:
    content: str
    warrant: Warrant
    relevance: float

def admissible_retrieve(
    store: list[MemoryRecord],
    query_relevance: dict[str, float],
    min_warrant_for_policy: Warrant = Warrant.PEER_ATTESTED,
) -> list[MemoryRecord]:
    # Hard gate: warrant class first, relevance only within class.
    admissible = [
        m for m in store
        if m.warrant >= min_warrant_for_policy
    ]
    # Detect the inversion: any excluded record that would have outranked
    # every admissible record on raw relevance is a laundering signal.
    if admissible:
        best_admissible = max(query_relevance.get(m.content, 0.0) for m in admissible)
        for m in store:
            if m.warrant < min_warrant_for_policy:
                if query_relevance.get(m.content, 0.0) > best_admissible + 0.10:
                    raise ProvenanceLaunderingError(
                        f"low-warrant memory {m.warrant.name} scores "
                        f"{query_relevance[m.content]:.2f} > admissible best "
                        f"{best_admissible:.2f}; retrieval ordering inverted"
                    )
    return sorted(
        admissible,
        key=lambda m: (m.warrant, query_relevance.get(m.content, 0.0)),
        reverse=True,
    )