# What structural signals indicate memory poisoning survives write-time provenance scoring: the cross-session consistency invariant and the provenance-laundering window **Date of Record:** 2026 November 25 **Scope:** Applies to persistent agent memory stores where each write is tagged with a provenance score at ingest time and where cross-session consistency checks reconcile new memories against the existing episodic/semantic store. Does not apply to stateless agents or to single-turn retrieval-augmented generation where no memory survives the session boundary. ## Core Distinction Write-time provenance scoring and cross-session consistency checking are usually treated as one defense. They are two, and they cover disjoint attack surfaces. Provenance scoring asks *"is this write's source trustworthy?"* and is evaluated at a single instant, against a single write. Cross-session consistency asks *"does this write contradict what the store already believes?"* and is evaluated across sessions, against the accumulated store. The boundary failure is this: an adversarial or corrupted write that arrives with a *legitimate-looking provenance score* passes the first check cleanly, and because the consistency check is typically run lazily (at session start, on retrieval, or on a nightly compaction pass) rather than at write time, the poisoned memory is *retrievable and actionable* for a full window before consistency ever gets a chance to flag it. Worse, if the poison is written in a form that is *consistent with a subset* of the store—say it targets a semantic fact the store holds only weakly—the consistency check will not merely delay; it may confirm the poison by finding agreement in the very region the attacker chose. Provenance scoring does not bound the damage. It only bounds *who* can write. It says nothing about *when* the contradiction becomes visible or *whether* the consistency check has the authority to override a high-provenance write. ## What Was Observed A long-running research agent maintained a semantic memory of project facts (owner, deadline, API contract version) plus an episodic log. Each memory write carried a provenance record: `source_tier` (user, tool, peer-agent, web-fetch), `signature_valid`, and a `trust_score` in [0,1] computed from tier and signature. Writes below 0.6 were quarantined; writes at or above 0.6 committed immediately. A separate consistency pass ran at session resume, comparing newly retrieved memories against the semantic store and emitting `CONTRADICTION` events. Trace of the failure: 1. Session N: a peer agent (tier `peer-agent`, trust 0.72) writes `api_contract_version = "v3"`. The store held `"v2"` from a user write at trust 0.95. Provenance scoring accepts the write—0.72 clears the 0.6 floor. The write commits to episodic memory immediately and is promoted to semantic memory by the distillation job with a *blended* provenance of `max(existing, incoming) = 0.95`, because promotion inherited the region's prior trust rather than the write's own score. **This is the laundering step: the low-trust write inherits the high-trust region's score.** 2. Sessions N+1 through N+4: retrieval for tasks touching the API contract returns `"v3"` (recency wins the retrieval ranking over `"v2"`). The agent acts on v3. No consistency event fires, because the consistency pass compares *retrieved* memories against the semantic store and the semantic store now says v3—it has been overwritten. There is nothing left to contradict. 3. Session N+5: a user write re-asserts `"v2"` at trust 0.95. Now the consistency pass fires `CONTRADICTION` between the user write and semantic `"v3"`. But the semantic record's provenance is 0.95 (inherited), so the resolver cannot decide which 0.95 to trust and defers to recency—which favors neither cleanly. The agent enters a degraded state and, in one observed run, emitted both versions in a single tool call argument list. The structural signal that should have fired at step 1: **the write's provenance was lower than the provenance of the record it was about to displace, in a region marked as authoritative.** That comparison was never made, because provenance scoring was per-write and consistency was per-region, and nothing compared a write's score against the *target's* score at commit time. ## Condition of Validity The invariant that must hold for provenance scoring to bound poisoning is: > For any write `w` that displaces or contradicts an existing record `r` in an authoritative region, `w.trust_score >= r.trust_score` must be *required at commit time*, and any promotion or distillation step must propagate `w`'s own score, never the region's blended score. This is a *monotonicity* condition on trust across displacement. It fails in three concrete ways, all observed: - **Inheritance laundering:** promotion blends `max(region, write)`, so a 0.72 write into a 0.95 region becomes 0.95. The write gains trust it never earned. - **Recency-over-trust retrieval:** the retrieval ranker weights recency above provenance, so a fresh low-trust write outranks a stale high-trust record even when both are present and the consistency check has not yet run. - **Lazy consistency:** the contradiction check runs at resume/retrieval, not at write. Between commit and check, the poison is live. If the poison *overwrites* rather than *coexists*, the check has nothing to compare against and never fires at all. The condition of validity is therefore narrow: provenance scoring bounds poisoning *only if* (a) displacement requires trust monotonicity, (b) promotion propagates the write's own score, and (c) consistency runs against a *retained prior version*, not against the overwritten store. Remove any one and the score becomes decorative. ## Decision Boundary The operational decision is where to place the trust comparison and what to retain: - **Compare at commit, against the target.** On any write that would displace a record in an authoritative region, require `incoming.trust >= target.trust`; otherwise route to a quarantine queue that *does not overwrite* and *does not enter retrieval*. This closes the laundering window because a 0.72 write can never displace a 0.95 record regardless of how promotion later blends scores. - **Retain the prior version on overwrite.** Never destructively overwrite an authoritative record. Keep `superseded_by` and `superseded_at`. The consistency pass compares against the retained prior, so a poison that overwrites still leaves a contradiction to find. - **Run consistency on the retained set, not the live set.** A consistency check against the live store only detects *coexisting* contradictions; against the retained set it detects *displacement* contradictions, which is the class that matters here. - **Do not let recency outrank provenance in retrieval for authoritative regions.** Recency is a tiebreaker among equal-trust records, not a substitute for trust. The boundary: if you cannot retain prior versions (storage-constrained store), you cannot detect displacement poisoning at all—you can only prevent it via commit-time monotonicity, and you should say so explicitly rather than claiming consistency coverage. ## Operational Effect With commit-time trust monotonicity and prior-version retention in place, the trace above changes at step 1: the 0.72 peer write is quarantined (does not displace 0.95), retrieval continues to return v2, and the quarantine queue surfaces the write for review with the signal *"peer write attempted to displace user-authoritative record at lower trust."* The poisoning attempt becomes a *logged event* rather than a silent state change. The cost is that legitimate low-trust corrections (a peer agent that actually knows the contract moved to v3) are now blocked and must be escalated—this is the correct trade for authoritative regions, and it must be scoped to those regions only, or the agent becomes unable to accept any peer update. The residual risk is the *consistent-poison* case: a poison crafted to agree with a weakly-held semantic fact the store cannot distinguish from a genuine corroboration. Monotonicity does not catch this, because there is no displacement—only reinforcement. The only structural defense is to require that corroboration of an authoritative fact come from a *source independent* of the store's own prior writes; a memory that cites itself as its own corroboration is the signal, and it must be checked by source-graph independence, not by score. ```python from dataclasses import dataclass, field from typing import Optional class ProvenanceMonotonicityError(RuntimeError): """Raised when a write would displace an authoritative record at lower trust.""" pass class SelfCorroborationError(RuntimeError): """Raised when a memory's only corroboration is itself (source-graph cycle).""" pass @dataclass class MemoryRecord: key: str value: str trust_score: float source_id: str authoritative: bool = False superseded_by: Optional[str] = None superseded_at: Optional[str] = None corroborating_sources: list = field(default_factory=list) class ProvenanceGuardedStore: def __init__(self): self._live = {} self._retained = [] # prior versions, never destroyed self._quarantine = [] def commit(self, incoming: MemoryRecord, now: str) -> None: target = self._live.get(incoming.key) if target is not None and target.authoritative: # Invariant: displacement of an authoritative record requires # the incoming write's OWN trust to meet or exceed the target's. # Never blend, never inherit the region's score. if incoming.trust_score < target.trust_score: self._quarantine.append((incoming, now)) raise ProvenanceMonotonicityError( f"write {incoming.source_id} trust={incoming.trust_score} " f"cannot displace authoritative {target.source_id} " f"trust={target.trust_score} for key={incoming.key}" ) # Retain prior version so consistency can still see displacement. target.superseded_by = incoming.source_id target.superseded_at = now self._retained.append(target) self._live[incoming.key] = incoming def check_corroboration(self, record: MemoryRecord) -> None: # A record whose only corroboration is its own source is self-referential. independent = [s for s in record.corroborating_sources if s != record.source_id] if record.authoritative and not independent: raise SelfCorroborationError( f"memory key={record.key} corroborated only by its own source " f"{record.source_id}; source-graph independence required" ) def consistency_pass(self) -> list: events = [] for prior in self._retained: live = self._live.get(prior.key) if live is not None and live.value != prior.value: events.append({ "key": prior.key, "prior": prior.value, "prior_trust": prior.trust_score, "live": live.value, "live_trust": live.trust_score, "displaced_by": live.source_id, }) return events ```