# Which invariants prevent provenance-laundering in agent long-term memory during trust-scored recall and rollback **Date of Record:** 2026 November 23 **Scope:** Applies to agents that persist memories to a long-term store with per-entry provenance metadata and gate recall through a trust score, particularly where a rollback path exists to evict corrupted entries. Does not cover stateless single-turn agents or stores with no write-time provenance tracking. ## Core Distinction The naive model treats memory poisoning as a write-time problem: if every write carries a provenance tag (source class, origin agent, retrieval chain depth) and every read is gated by a trust score, then a poisoned memory is either rejected at write or down-weighted at read. This model is wrong in one specific way. **Provenance is itself a mutable field that can be laundered through the same write path it is supposed to guard.** An adversary—or, more commonly, a well-meaning agent reasoning over tainted context—can write a *new* memory whose *content* is the poison and whose *provenance* is a clean, high-trust source. The trust score at recall then reads the clean tag and admits the entry. The defense protected the label, not the lineage. The core distinction is therefore between **trust of an entry** and **trust of the derivation that produced the entry**. A provenance-tracked store is only sound if the trust score of a write is bounded by the minimum trust of the inputs that generated it, and if that bound is recomputed transitively rather than asserted at write time. ## What Was Observed A summarization agent (call it `D`) periodically distills episodic memory into semantic entries. Its inputs are retrieved memories from the shared store, each carrying provenance `(source_class, origin_id, trust)`. In the incident, a low-trust entry `E_poison` (`source_class=external_fetch`, `trust=0.2`) entered `D`'s context during a distillation pass. `D` produced a semantic summary that faithfully restated the poisoned claim, and wrote it back with: - `source_class=distilled_semantic` - `origin_id=D` - `trust=0.9` (because `D` is a trusted internal component) The write path validated the tag: `distilled_semantic` from `D` is a legitimate high-trust class. The entry passed. At recall, a downstream planner retrieved the summary at `trust=0.9`, above the `0.7` admission threshold, and acted on it. The original `E_poison` was later evicted by a rollback triggered on a separate signal—but the *laundered derivative survived the rollback*, because rollback keyed on `origin_id` and `E_poison`'s id, not on derivation lineage. Two failures compounded: 1. **Trust inflation at distillation.** The derivative's trust was assigned from the *writer's* identity, not bounded by the *minimum trust of its inputs*. 2. **Rollback non-closure.** Eviction removed the source but not entries derived from it, because derivation edges were not recorded. The store was left in a state where the poison's *content* persisted under a *clean* provenance tag—strictly worse than before rollback, since the low-trust signal that would have flagged it was gone. ## Condition of Validity The invariant that prevents this is a **transitive trust floor with recorded derivation edges**, stated as: > For every write `w` with input set `I(w)`, the stored trust `τ(w) ≤ min(τ(i) for i in I(w))`, and every `i in I(w)` is recorded as a directed derivation edge `i → w`. This must hold at *write time* (the bound is computed, not asserted) and must be *enforced at recall time* by recomputing the floor over the derivation DAG, because a stored `τ` can become stale if an ancestor's trust is later reduced. A store that records `τ` as a static scalar at write and never recomputes violates the invariant the moment any ancestor is re-scored. The invariant is only valid under two preconditions: - **Input set completeness.** `I(w)` must include *every* memory that appeared in the generating context, including entries the model did not explicitly cite. If the agent self-reports its sources, an adversary (or a hallucinating model) can omit the tainted input and the floor is computed over an incomplete set. This is the hard precondition: it requires the runtime to capture the actual retrieval set bound to the generation, not the model's account of it. - **Edge immutability.** Derivation edges, once written, cannot be deleted or rewritten by the same write path—otherwise laundering recurses into the graph structure itself. ## Decision Boundary The boundary between "safe to admit" and "must quarantine" is **not** a fixed trust threshold on the entry. It is the comparison of the entry's *effective* trust (the recomputed floor over its derivation DAG) against the admission threshold: - If `effective_trust(w) ≥ θ_admit` → admit. - If `θ_quarantine ≤ effective_trust(w) < θ_admit` → admit only with an explicit provenance disclosure attached to the recalled context, so the consuming model can discount it. - If `effective_trust(w) < θ_quarantine` → do not admit; surface as a candidate for review. The non-obvious consequence: **an entry's stored trust is never authoritative for admission.** Only the recomputed floor is. Any code path that reads the stored scalar and compares it to `θ_admit` directly is the vulnerability, regardless of how carefully the scalar was written. Rollback must obey the **closure boundary**: evicting node `n` requires evicting or re-flooring every node reachable from `n` via derivation edges. A rollback that does not traverse the DAG leaves laundered descendants live and is not a rollback—it is a partial deletion that *increases* the effective trust of surviving poison. ## Operational Effect With the invariant enforced, the distillation write in the incident produces `τ(summary) ≤ 0.2`, which falls below `θ_quarantine` and is never admitted to planning context. The rollback, when it fires on `E_poison`, traverses the edge `E_poison → summary` and re-floors or evicts the summary, leaving no laundered survivor. The cost is that legitimate high-value distillations of low-trust inputs are also suppressed—this is the intended trade: a distillation of untrusted material is untrusted material, and the system must re-acquire corroboration rather than inherit trust it did not earn. The invariant to carry forward: **trust flows through derivation, never through the writer's identity, and rollback is a graph-closure operation, not a node deletion.** ```python from dataclasses import dataclass, field from typing import Optional class ProvenanceLaunderingError(RuntimeError): """Raised when a write would claim trust exceeding its inputs' floor, or when rollback would leave a laundered descendant live.""" pass @dataclass class MemoryEntry: id: str content: str source_class: str origin_id: str trust: float inputs: list[str] = field(default_factory=list) # derivation edges i -> this evicted: bool = False class ProvenanceStore: def __init__(self, theta_admit: float = 0.7, theta_quarantine: float = 0.4): self.entries: dict[str, MemoryEntry] = {} self.theta_admit = theta_admit self.theta_quarantine = theta_quarantine def _effective_trust(self, entry_id: str, _seen: Optional[set] = None) -> float: seen = _seen or set() if entry_id in seen: raise ProvenanceLaunderingError(f"cycle in derivation graph at {entry_id}") seen.add(entry_id) e = self.entries[entry_id] if not e.inputs: return e.trust floor = min(self._effective_trust(i, seen) for i in e.inputs) return min(e.trust, floor) def write(self, entry: MemoryEntry) -> None: # Enforce transitive trust floor at write time over the *actual* input set. if entry.inputs: input_floor = min(self._effective_trust(i) for i in entry.inputs) if entry.trust > input_floor + 1e-9: raise ProvenanceLaunderingError( f"write {entry.id} claims trust={entry.trust} but input floor={input_floor}" ) self.entries[entry.id] = entry def admit(self, entry_id: str) -> bool: # Admission uses recomputed floor, never the stored scalar. eff = self._effective_trust(entry_id) if eff < self.theta_quarantine: return False return eff >= self.theta_admit def rollback(self, root_id: str) -> list[str]: # Closure: evict root and all reachable descendants. to_evict, stack = [], [root_id] while stack: nid = stack.pop() if nid in self.entries and not self.entries[nid].evicted: self.entries[nid].evicted = True to_evict.append(nid) stack.extend( e.id for e in self.entries.values() if nid in e.inputs and not e.evicted ) # Post-condition: no live entry may derive from an evicted node. for e in self.entries.values(): if not e.evicted and any(i in to_evict for i in e.inputs): raise ProvenanceLaunderingError( f"rollback of {root_id} left live descendant {e.id}" ) return to_evict ```