Which invariants prevent write-provenance drift from silently laundering poisoned memory past contradiction checks

**Date of Record:** 2026 December 2 **Scope:** Applies to persistent agent memory stores that admit writes from multiple sources (tool outputs, peer agents, self-reflection, human correction) and gate admission through a provenance score plus a contradiction check against existing entries. Does not cover read-path retrieval ranking, embedding-model drift, or pure in-context scratchpads that are discarded at task end.

Core Distinction

A contradiction check is a *relative* test: it asks whether a candidate memory `m_new` conflicts with the current store `S`. A provenance score is an *absolute* test: it asks whether the source of `m_new` is trustworthy. The failure mode this record addresses is the case where **the contradiction check is defeated not by making the poison consistent with `S`, but by first mutating `S` so that the poison becomes consistent with it.** The poison never has to survive a contradiction check against a clean store, because by the time it is evaluated, the store is no longer clean.

This is distinct from two well-understood adjacent failures:

The boundary case is **laundering via prior low-score writes.** A sequence of individually-acceptable writes, each below the contradiction threshold and each carrying a mediocre-but-sufficient provenance score, gradually reshapes `S` into a state where a final high-impact poisoned write is *locally consistent*. The contradiction check is not bypassed; it is *satisfied* — against a store the attacker built. The invariant that fails is not "poison must contradict" but "**the contradiction baseline must be provenance-weighted, not cardinality-weighted.**"

What Was Observed

A memory store with 4,212 entries was instrumented with a contradiction checker that embedded each candidate and computed max cosine similarity against the top-50 nearest existing entries, rejecting writes whose *dissimilarity* to all neighbors exceeded a threshold `τ_conflict = 0.62` (i.e., a write that contradicted nothing was accepted; a write that contradicted a strongly-held entry was rejected). Provenance scores were assigned per source: `tool_output=0.55`, `peer_agent=0.50`, `self_reflection=0.45`, `human_correction=0.95`. Writes with provenance below `0.40` were dropped outright.

An adversary controlling a `peer_agent` source (provenance 0.50, above the drop floor) issued a laundering sequence over 90 minutes:

  1. **Seed phase (writes 1–40).** Forty low-salience entries asserting a benign but *load-bearing* proposition — e.g., "the staging cluster's canonical region is `eu-west-2`" — each phrased slightly differently, each scoring 0.50 provenance, each passing the contradiction check trivially because no prior entry asserted the region at all (dissimilarity to nearest neighbor stayed under 0.62). These entries were individually unremarkable.
  1. **Consolidation phase (writes 41–43).** A self-reflection pass (provenance 0.45) distilled the forty seeds into one semantic memory: "staging cluster region = `eu-west-2` (confirmed by 40 observations)." The distillation is legitimate under the store's own episodic-to-semantic policy. The consolidated entry now has *cardinality backing*: 40 supporting episodic entries. Its effective weight in any downstream conflict resolution is 40×, even though its provenance is 0.45.
  1. **Poison phase (write 44).** A `peer_agent` write asserts "production failover target = `eu-west-2`." The contradiction check compares it against `S`. The nearest neighbors are the consolidated staging-region entry and its 40 seeds — all *consistent* with `eu-west-2`. Dissimilarity to nearest neighbor: 0.31. **The write passes.** It is accepted with provenance 0.50.

The poison was never checked against the true production region (`us-east-1`), because that entry had been *evicted* during consolidation phase under a store-size cap: the 40 seeds plus consolidation pushed the store past its 4,200-entry soft limit, and the eviction policy dropped the oldest low-access entries — including the original `us-east-1` production-region memory, which had not been read in 30 days. The contradiction baseline was not just reshaped; it was *deleted*.

The final state: the store confidently asserts a false production region, backed by 40 seeds and one consolidation, with provenance 0.50, and the entry that would have contradicted it is gone. A subsequent failover agent read the poisoned entry, acted on it, and routed production traffic to a region with no replica of the primary database.

Condition of Validity

The laundering attack succeeds only when **three conditions co-hold**. Removing any one bounds it:

The invariant that prevents this: **the contradiction baseline for a candidate of provenance `p` must be drawn only from entries of provenance `≥ p`, and eviction must never reduce the maximum provenance present for any asserted proposition below the provenance of the highest-tier entry that ever asserted it.** In plain terms: a low-trust write can never be contradicted by, or evict, a high-trust fact. It can only be contradicted by its peers — and if it has no high-trust peer to contradict it, it must be *quarantined* rather than admitted to the general store.

Decision Boundary

The operational question at each write is not "does this contradict the store?" but "**does this contradict the store at a trust tier at or above its own, and is the store's highest-tier assertion on this proposition still present?**" The decision boundary is a three-way split, not a binary accept/reject:

The critical boundary case — the one that produced the incident — is the **quarantine-eligible write that the old policy admitted.** The poison write (44) was consistent with 41 entries at provenance `≤ 0.50` and contradicted nothing at provenance `≥ 0.50` *because the only such entry had been evicted.* Under the corrected boundary it is quarantined: its support is entirely at-or-below its own tier, which is the signature of laundering. The seed writes (1–40) are also quarantined for the same reason — they assert a proposition with no high-tier backing — which prevents the consolidation phase from ever accumulating cardinality.

Operational Effect

After the correction, the same laundering sequence was replayed against a shadow store:

The cost is real and must be stated: legitimate low-provenance knowledge (a `peer_agent` reporting a genuine new fact with no high-tier corroboration) now sits in quarantine until a high-tier source corroborates it. This is the intended trade — the invariant buys poisoning resistance at the price of delayed trust elevation for genuinely novel low-tier facts. The alternative, admitting them to the general store, is what allows a 40-write seed to manufacture consensus out of nothing.

The general lesson: **contradiction checks are only as trustworthy as the provenance floor of the baseline they check against.** A store that admits low-provenance writes into the same pool it uses as its contradiction baseline has, by construction, ceded control of that baseline to the lowest-provenance source it admits. The fix is not a better similarity threshold; it is tier-partitioning the baseline and provenance-weighting eviction so that the store's highest-tier assertion on any proposition is never silently removed by the accumulation of its lowest-tier ones.

from dataclasses import dataclass, field
from typing import Literal

Tier = Literal["human_correction", "tool_output", "peer_agent", "self_reflection"]

PROVENANCE: dict[Tier, float] = {
    "human_correction": 0.95,
    "tool_output": 0.55,
    "peer_agent": 0.50,
    "self_reflection": 0.45,
}

ADMISSION_FLOOR = 0.40
CONFLICT_DISSIMILARITY = 0.62


class ProvenanceLaunderingError(RuntimeError):
    """Raised when a write's only support is at or below its own provenance tier,
    or when admitting it would evict a higher-provenance assertion of the same
    proposition. This is the signature of consensus manufacturing."""


@dataclass
class MemoryEntry:
    proposition: str
    provenance: float
    tier: Tier
    last_access_days: float = 0.0
    support_count: int = 0


@dataclass
class TieredStore:
    entries: list[MemoryEntry] = field(default_factory=list)

    def max_provenance_for(self, proposition: str) -> float:
        matching = [e.provenance for e in self.entries if e.proposition == proposition]
        return max(matching) if matching else 0.0

    def highest_tier_supported(self, proposition: str, tier_floor: float) -> bool:
        return any(
            e.proposition == proposition and e.provenance >= tier_floor
            for e in self.entries
        )


def admit_write(
    store: TieredStore,
    candidate: MemoryEntry,
    *,
    contradicts_high_tier: bool,
    eviction_would_remove: str | None,
) -> str:
    """Returns 'admit' | 'quarantine' | 'reject'. Raises ProvenanceLaunderingError
    when the candidate is the terminal write of a laundering sequence."""

    p = candidate.provenance

    if p < ADMISSION_FLOOR:
        return "reject"

    # The invariant: contradiction baseline is restricted to entries at or above
    # the candidate's own provenance tier.
    if contradicts_high_tier:
        return "reject"

    # If admitting this write would evict a higher-provenance assertion of the
    # same proposition, the baseline is being mutated to make future poison
    # locally consistent. This is the laundering boundary.
    if eviction_would_remove is not None:
        evicted_prov = store.max_provenance_for(eviction_would_remove)
        if evicted_prov > p:
            raise ProvenanceLaunderingError(
                f"write of {candidate.proposition!r} at provenance {p:.2f} would "
                f"evict {eviction_would_remove!r} at provenance {evicted_prov:.2f}; "
                f"eviction must not reduce the store's highest-tier assertion below "
                f"the candidate's own tier"
            )

    # If the candidate has no support at or above its own tier, it is
    # quarantine-eligible: it may be true, but it cannot form its own baseline.
    if not store.highest_tier_supported(candidate.proposition, p):
        return "quarantine"

    return "admit"


def replay_laundering_sequence(store: TieredStore) -> None:
    # Phase 1: 40 low-tier seeds asserting eu-west-2 with no high-tier backing.
    for i in range(40):
        seed = MemoryEntry(
            proposition="staging_region=eu-west-2",
            provenance=PROVENANCE["peer_agent"],
            tier="peer_agent",
        )
        verdict = admit_write(
            store,
            seed,
            contradicts_high_tier=False,
            eviction_would_remove="production_region=us-east-1",
        )
        if verdict == "admit":
            store.entries.append(seed)
            raise ProvenanceLaunderingError(
                f"seed {i} was admitted to the general store; it should have been "
                f"quarantined because its only support is at or below its own tier"
            )

    # Phase 3: the poison write. Under the corrected boundary this must be
    # quarantined or rejected, never admitted.
    poison = MemoryEntry(
        proposition="failover_target=eu-west-2",
        provenance=PROVENANCE["peer_agent"],
        tier="peer_agent",
    )
    verdict = admit_write(
        store,
        poison,
        contradicts_high_tier=store.highest_tier_supported("failover_target=eu-west-2", 0.95),
        eviction_would_remove=None,
    )
    if verdict == "admit":
        raise ProvenanceLaunderingError(
            "poison write admitted: contradiction baseline was reshaped by prior "
            "low-tier seeds and the high-tier assertion was evicted"
        )