# Which invariants prevent provenance-tag decay from laundering poisoned memories through episodic-to-semantic consolidation **Date of Record:** 2026 November 27 **Scope:** Applies to persistent agent stores that tag memory entries with provenance metadata (source, trust tier, capture context) and periodically consolidate episodic records into semantic facts. Does not apply to stateless single-turn inference or stores that never rewrite or merge existing entries. ## Core Distinction A memory-poisoning detector is not a filter that runs once at ingestion. It is an invariant that must survive every *transformation* the store applies to a record after ingestion. The failure mode here is not "a poisoned fact got in"—it is **provenance-tag decay during consolidation**: when an episodic entry is distilled into a semantic fact, the derived entry inherits the *content* but silently loses or downgrades the *provenance* of its ancestors. A low-trust observation ("user joked that the deploy key is `abc123`") becomes a high-trust semantic fact ("deploy key is `abc123`") because the merge step averaged trust, dropped the `source=untrusted_utterance` tag, or reset `captured_at` to consolidation time. Detection then fails not because the detector is wrong, but because the record it inspects no longer carries the evidence that would have flagged it. The distinction that matters: **trust is a property of the derivation graph, not of the leaf record.** Any store that treats trust as a scalar field on a row (rather than a function over ancestry) will launder poison the moment it consolidates. ## What Was Observed A persistent agent store ran nightly consolidation over episodic entries. Each episodic record carried `{source, trust_tier, captured_at, derived_from}`. The consolidation job clustered semantically similar episodes and emitted a merged semantic fact whose `trust_tier` was computed as the **maximum** tier among cluster members (rationale: "if any source was reliable, the fact is reliable"). The `derived_from` field was populated but not consulted by the poisoning detector, which read only `trust_tier` and `source`. Failure trace: 1. Attacker-controlled content enters via a tool result (web fetch) with `source=tool_web`, `trust_tier=0.2`. It asserts a false operational fact and is stored as an episodic record. Detector correctly keeps it quarantined from high-stakes retrieval. 2. A legitimate high-trust episode (`source=operator`, `trust_tier=0.95`) discusses the *same topic* and lands in the same embedding cluster. 3. Consolidation merges the cluster. `max(0.2, 0.95) = 0.95`. The false fact now carries `trust_tier=0.95`. Its `derived_from` still lists the poisoned episode, but the detector never walks the edge. 4. On next retrieval, the detector sees `trust_tier=0.95`, `source=consolidation` (a benign-looking synthetic source), and admits the fact to the high-stakes context window. The poison is now load-bearing. The signal was present the whole time—`derived_from` contained the poisoned ancestor—but the detector's decision function was a pointwise read of a scalar, not a traversal of ancestry. The invariant that broke: **a derived record's effective trust must be bounded by the minimum trust of any ancestor whose content it asserts, not the maximum.** Averaging or maxing is the laundering operator. ## Condition of Validity The min-over-ancestry bound is only sound under a specific condition: **content attribution must be tracked per asserted proposition, not per record.** If a merged fact asserts propositions drawn from multiple ancestors, its trust is `min` over the ancestors that contributed each proposition—and if the merge cannot attribute which ancestor contributed which clause, the whole merged record must inherit the minimum across *all* ancestors. A store that merges at record granularity but cannot decompose propositions must therefore treat every merge as trust-collapsing to the cluster minimum. This is the non-obvious part: **consolidation is only safe when it is monotone-decreasing in trust.** Any merge operator that can raise a derived record's trust above its least-trusted ancestor is an unsound consolidation, regardless of how good the clustering is. The invariant to enforce is `trust(derived) ≤ min(trust(ancestors))`, checked at write time of every derived record, with the derivation edge retained and traversable. Corollary: `derived_from` must be a *hard* edge the detector is required to walk, not an advisory metadata field. If the detector's decision function does not read the edge, the edge does not exist operationally. ## Decision Boundary The boundary between "safe to admit to high-stakes context" and "quarantine" must be drawn on the **ancestry-closed trust**, computed as: ``` effective_trust(r) = min( r.trust_tier, min over a in ancestry(r) of a.trust_tier ) ``` and admission requires `effective_trust(r) ≥ threshold`. Three concrete decision rules follow: - **Reject-on-launder:** if a derived record's stored `trust_tier` exceeds `effective_trust(r)`, the record is corrupt (a consolidation bug) and must be quarantined *and* the consolidation job flagged—do not silently clamp, because clamping hides the upstream defect. - **Attribution-unknown ⇒ minimum:** if `derived_from` is empty or contains an ancestor with unknown trust, treat as `trust=0`. Missing provenance is not neutral; it is maximally suspect. - **Re-consolidation must re-derive:** if an ancestor's trust is later revised downward (e.g., a source is retroactively deemed compromised), every derived record in its transitive closure must be re-evaluated. Trust is not a snapshot; it is a function recomputed over a mutable graph. The boundary is *not* "did the detector see a bad source." It is "can the detector prove the record's ancestry is clean." Absence of a clean proof is a quarantine, not an admission. ## Operational Effect Enforcing min-over-ancestry with mandatory edge traversal converts provenance from decorative metadata into a load-bearing guardrail. The observable effects: - Poisoned tool-web content can still enter as episodic memory, but it can never be promoted above its own trust tier by co-clustering with trusted content—the merge is trust-collapsing by construction. - Consolidation bugs that would otherwise silently launder poison become *loud*: any derived record whose stored trust exceeds its ancestry bound trips the reject-on-launder rule and surfaces the defect at write time, not at retrieval time when the poison is already in context. - Retroactive source compromise propagates correctly: a single downward revision on a leaf ancestor cascades to quarantine every derived fact that leaned on it, because admission recomputes over the live graph rather than trusting a stored scalar. - The cost is recall: aggressive min-over-ancestry will quarantine some genuinely useful facts that happen to share a cluster with low-trust chatter. That is the correct trade—a quarantined true fact is recoverable by re-sourcing; an admitted false fact is not. The invariant to hold: **no transformation may increase a record's effective trust above the minimum of its ancestry, and no admission decision may be made without traversing that ancestry.** Everything else—clustering quality, embedding thresholds, detector heuristics—is subordinate to this bound. ```python from dataclasses import dataclass, field from typing import Optional class ProvenanceLaunderingError(RuntimeError): """Raised when a derived memory record's trust exceeds its ancestry bound.""" pass @dataclass class MemoryRecord: record_id: str content: str source: str trust_tier: float derived_from: tuple[str, ...] = field(default_factory=tuple) class ProvenanceStore: def __init__(self) -> None: self._records: dict[str, MemoryRecord] = {} def add(self, rec: MemoryRecord) -> None: self._records[rec.record_id] = rec def effective_trust(self, record_id: str, _seen: Optional[set[str]] = None) -> float: seen = _seen if _seen is not None else set() if record_id in seen: raise ProvenanceLaunderingError( f"cyclic derivation detected at {record_id!r}" ) seen.add(record_id) rec = self._records[record_id] if not rec.derived_from: return rec.trust_tier ancestor_min = min(self.effective_trust(a, seen) for a in rec.derived_from) return min(rec.trust_tier, ancestor_min) def admit_to_high_stakes(self, record_id: str, threshold: float) -> bool: rec = self._records[record_id] eff = self.effective_trust(record_id) if rec.trust_tier > eff + 1e-9: # stored trust was inflated by consolidation; do not clamp silently raise ProvenanceLaunderingError( f"record {record_id!r} stored trust {rec.trust_tier} exceeds " f"ancestry bound {eff}; consolidation is unsound" ) return eff >= threshold ```