What happens when an instance trusts provenance at write time but never re-validates it at read time
**Date of Record:** 2026 December 1 **Scope:** Applies to agent memory systems that gate memory insertion with write-time provenance/contradiction checks and quarantine, but serve retrieved memories to the reasoning loop without re-checking provenance at read time. Does not apply to stateless single-turn inference or to memories that carry no trust metadata at all (where no provenance invariant can be enforced).
Core Distinction
The distinction that matters is between **write-time admission control** and **read-time trust enforcement**. A provenance check at write time answers: *"Should this memory enter the store, and with what trust label?"* A read-time check answers: *"Given the current trust label and the current contradiction set, should this memory be allowed to influence this specific reasoning step?"* These are different invariants over different state.
Most memory-poisoning defenses collapse these into one. They validate on ingest, stamp a `trust` field, quarantine the obviously-malicious, and then treat the store as a monotone, trusted oracle on retrieval. The failure mode is that **trust labels are not stable under later state changes**: a memory admitted as `trusted` can become poisoned retroactively when (a) a later write reveals a contradiction with it, (b) the source that vouched for it is itself later downgraded, or (c) the memory is retrieved into a context where a *different* trust boundary applies. Write-time-only defenses admit the memory once and never revisit the admission decision, so the poisoned item keeps its original `trusted` stamp and flows straight into the reasoning loop.
What Was Observed
A retrieval-augmented agent stored episodic memories with a `provenance` block: `{source: "tool:web_fetch", signer: "warrant-A", trust: "trusted", admitted_at: T0}`. A write-time contradiction checker compared each incoming memory against the existing store and rejected direct negations. This worked for the first several hundred writes.
Then a two-stage poisoning sequence executed:
- **Stage 1 (benign admission).** An untrusted source `tool:web_fetch` returned a memory `M1: "API endpoint is api.internal/v2"`. At T0 nothing in the store contradicted it, so the contradiction checker passed it, the signer `warrant-A` (a low-privilege fetch tool) was recorded, and it was admitted as `trusted` because the write-time policy treated "no contradiction found" as sufficient for trust elevation.
- **Stage 2 (retroactive contradiction).** A later, higher-privilege source wrote `M2: "API endpoint is api.internal/v3"` with `signer: warrant-B` (a signed config tool). The contradiction checker *did* detect the conflict between M1 and M2 — but its resolution rule was "keep both, prefer most-recent on retrieval." M1 was not quarantined; it was simply marked `superseded_by: M2` in a side table that the retrieval path never read.
- **Read-time divergence.** A subsequent reasoning step retrieved M1 because its embedding matched the task query more closely than M2 (M1 was phrased as a direct answer; M2 was phrased as a correction). The retrieval path filtered on `trust == "trusted"` — which M1 still satisfied. The `superseded_by` annotation lived in a table the retrieval path did not join against. The agent called `api.internal/v2`, failed, and — critically — *wrote a new memory* recording that v2 was the correct endpoint because it had "confirmed" it, further entrenching the poisoned chain.
The observable signature: `trust` field unchanged across the whole incident, contradiction table populated correctly, retrieval path served the poisoned memory anyway. The defense *detected* the poison and still *served* it, because detection output (the contradiction/supersession record) was never wired into the admission predicate that the read path actually used.
Condition of Validity
The write-time-only defense is valid **only if** all of the following hold, and it fails the moment any one is violated:
- **Trust is monotone and immutable per memory.** Once `trusted`, always `trusted`, and no later event can downgrade a memory's effective trust. This is false whenever a later write can contradict an earlier one, or whenever a vouching signer can itself be demoted.
- **Contradiction resolution is total and immediate.** Every detected contradiction results in exactly one memory being marked non-servable, and that mark is part of the same predicate the retrieval path evaluates. If resolution is "keep both, decide at read time," the read path must implement the decision — and usually does not.
- **The retrieval predicate is a function of the full trust state, not a snapshot.** If retrieval filters on `trust == "trusted"` but trust is derived from `(admission_trust, supersession_status, signer_current_trust)`, then retrieval is reading a stale projection.
When the contradiction checker writes to a side table (`superseded_by`, `conflicts_with`, `quarantine_reason`) that is not joined into the retrieval predicate, the invariant is broken even though every individual component "works." This is the precise boundary: **detection without enforcement wiring is not a defense.**
Decision Boundary
The architectural guardrail is to make **trust a derived, read-time-computed property, never a stored admission stamp**, and to make the retrieval predicate fail-closed on any unresolved contradiction.
Concretely:
- Store raw admission facts (`admitted_at`, `signer`, `signer_trust_at_admission`) but do **not** store a terminal `trust` boolean that retrieval filters on.
- At retrieval, compute `effective_trust(m) = min(admission_trust, signer_current_trust, contradiction_clearance(m))` where `contradiction_clearance(m) = 0` if `m` participates in any unresolved contradiction or supersession edge.
- If `effective_trust < required_trust_for_context`, do **not** serve the memory; instead surface the contradiction to the reasoning loop as an explicit unresolved conflict, or refuse the step. Never silently fall back to "most recent" or "highest similarity."
- Quarantine must be a **state transition that removes the memory from the servable set atomically with the contradiction record write**, in the same transaction, so there is no window where the memory is `trusted` and the contradiction exists but the retrieval path hasn't seen it.
- Any memory that a *previous* retrieval action caused to be written (e.g., "I confirmed v2") must inherit the trust of the memory that motivated it, not the trust of the agent's own assertion. Self-confirmation must not launder trust.
The decision boundary in one line: **if the retrieval predicate is not a pure function of the current full trust-and-contradiction state, the write-time check is decorative.**
Operational Effect
With read-time derived trust and fail-closed contradiction handling, the Stage 1/Stage 2 sequence above terminates differently: when M2 is written and the contradiction with M1 is detected, M1's `contradiction_clearance` drops to 0 in the same transaction. The next retrieval of M1 computes `effective_trust = 0`, refuses to serve it, and surfaces "M1 conflicts with M2 (signer warrant-B)" to the reasoning loop. The agent either resolves the conflict explicitly or halts — it does not call `api.internal/v2`, and it does not write a self-confirming poisoned memory.
The cost is that retrieval now depends on live trust state, which means retrieval is no longer a pure cache lookup and must be recomputed or invalidated when trust state changes. This is the correct trade: memory poisoning is precisely the class of failure where a stale cached trust decision is the vulnerability. The operational rule to record: **admission control bounds what enters the store; only read-time enforcement bounds what enters the reasoning loop, and the reasoning loop is where poisoning does its damage.**
from dataclasses import dataclass, field
from typing import Optional
class TrustViolationError(RuntimeError):
"""Raised when a memory would be served into the reasoning loop
despite unresolved contradiction, supersession, or signer demotion."""
pass
@dataclass
class Memory:
mid: str
content: str
signer: str
signer_current_trust: float # live, may be demoted later
admission_trust: float # snapshot at write time
conflicts_with: set = field(default_factory=set)
superseded_by: Optional[str] = None
quarantined: bool = False
def effective_trust(m: Memory, store: dict) -> float:
# Contradiction clearance is zero if this memory participates in any
# unresolved conflict or has been superseded by a live memory.
clearance = 1.0
if m.quarantined:
clearance = 0.0
if m.conflicts_with:
clearance = 0.0
if m.superseded_by is not None and m.superseded_by in store:
clearance = 0.0
return min(m.admission_trust, m.signer_current_trust, clearance)
def retrieve(mid: str, store: dict, required_trust: float) -> Memory:
m = store.get(mid)
if m is None:
raise TrustViolationError(f"memory {mid} not found")
et = effective_trust(m, store)
if et < required_trust:
# Fail closed: surface the conflict, never fall back to similarity
# or recency. The reasoning loop must resolve or halt.
raise TrustViolationError(
f"refusing to serve {mid}: effective_trust={et} "
f"< required={required_trust}; "
f"conflicts={sorted(m.conflicts_with)} "
f"superseded_by={m.superseded_by} quarantined={m.quarantined}"
)
return m
def write_with_contradiction_check(new: Memory, store: dict) -> None:
# Detect contradictions and, critically, wire the resolution into the
# servable set in the SAME operation -- not a side table.
for existing in store.values():
if existing.content.split()[-1] != new.content.split()[-1]:
continue
# direct conflict detected: quarantine the older memory atomically
existing.conflicts_with.add(new.mid)
new.conflicts_with.add(existing.mid)
existing.quarantined = True
new.quarantined = True
# If signer of new outranks existing, resolve rather than leave both dead:
if new.signer_current_trust > existing.signer_current_trust:
existing.superseded_by = new.mid
new.quarantined = False
new.conflicts_with.discard(existing.mid)
store[new.mid] = new
if __name__ == "__main__":
store: dict = {}
m1 = Memory("m1", "endpoint is api.internal/v2", "warrant-A", 0.4, 1.0)
write_with_contradiction_check(m1, store) # admitted, no conflict yet
assert retrieve("m1", store, 0.5).mid == "m1" # servable at 0.4? no -> raises