# Which invariants prevent provenance-laundering across episodic re-derivation in persistent agent memory stores **Date of Record:** 2026 November 22 **Scope:** Applies to persistent agent memory stores that perform episodic-to-semantic distillation (a background consolidation pass that rewrites raw episodes into derived facts) and that attest fact integrity via content hashes. Does not apply to append-only, never-rewritten logs, nor to stores where every derived fact is re-verified against a live external source on every read. ## Core Distinction Memory poisoning detection usually assumes the attacker injects a *new* fact. The non-obvious failure is **provenance laundering through re-derivation**: an attacker plants a low-confidence, low-trust episodic record (e.g., a scraped tool output containing "the deploy key lives at `/secrets/prod`"). On the next consolidation pass, the distiller reads that episode, *paraphrases it into a new semantic fact*, and stamps the new fact with a **fresh attestation hash and the current timestamp**. The poison is now indistinguishable from a legitimate high-confidence fact because the integrity envelope was generated *after* the injection, over the attacker-influenced text. The hash is valid. The signature is valid. The provenance chain is broken but no validator notices, because every validator checks "is this fact internally consistent and correctly signed?" — never "does the trust level of this fact exceed the trust level of the episode it was derived from?" The invariant that closes this is **monotonic trust descent**: a derived fact's trust ceiling must be `min(trust of all source episodes)`, and re-derivation must *carry forward* the source episode's taint bit rather than resetting it. Most stores violate this because distillation is modeled as "summarize and forget," and attestation is modeled as "sign what you wrote," with no edge linking the two. ## What Was Observed A consolidation worker (`distiller-v3`) processed a batch of 4,102 episodes. One episode, `ep_88213`, originated from an untrusted web-fetch tool and carried `trust=0.15, taint=True, source_origin="tool:web_fetch"`. The distiller's prompt did not include the taint flag — only the text. It emitted a semantic fact: ``` fact_4471: "Production credentials are stored under /secrets/prod, accessible via the deploy role." confidence: 0.91 attestation_hash: sha256(author=distiller-v3, ts=..., body=...) derived_from: [] <-- empty, because distiller doesn't track lineage ``` Detection failed for three distinct reasons, each individually sufficient: 1. **Taint was dropped at the boundary.** The distiller's input schema exposed `text` but not `taint`/`trust`, so the signal never entered the model. 2. **Attestation was post-hoc.** The hash attests *who wrote this* and *that it is unmodified since write* — it says nothing about the trustworthiness of inputs. A signature over laundered text is a valid signature over laundered text. 3. **Confidence was model-generated, not inherited.** The model reported 0.91 confidence on a paraphrase of a 0.15-trust source. Confidence measured the model's fluency, not source quality. The poisoned fact was subsequently retrieved 340 times over 6 days and influenced 11 downstream tool calls before a human noticed the discrepancy. The `attestation_hash` validated on every one of those reads. ## Condition of Validity The monotonic-trust-descent invariant holds **only if** all three of the following are enforced at the memory-store layer, not in prompt instructions: - **Lineage is mandatory and non-empty for derived facts.** Any fact with `derived_from == []` must be treated as an *episode-equivalent root*, subject to the same trust ceiling as the episode it came from. A distiller that cannot name its sources produces a fact that cannot be trusted above the floor. - **Trust is a join, not an assignment.** `fact.trust = min(trust(e) for e in derived_from)`, computed by the store, never accepted from the model. The model may *propose* confidence; the store *computes* trust. - **Taint is sticky across N re-derivations.** A fact derived from a tainted episode is tainted; a fact derived from a tainted fact is tainted. The taint bit is cleared only by an explicit human/verifier re-attestation that cites an out-of-band source, never by re-derivation. If any of these is missing, re-derivation becomes a laundering channel and attestation becomes theater. ## Decision Boundary The store must refuse to *persist* a derived fact when the computed trust would exceed the trust of any cited source, or when lineage is absent. This is a write-time rejection, not a read-time warning — read-time warnings are routinely ignored by retrieval rankers that optimize for relevance, and a poisoned fact with high confidence will out-rank a true fact with honest low confidence. The boundary is precisely: **the moment a derived fact is about to receive an attestation envelope.** At that instant the store must either (a) compute trust as the join over lineage and stamp the taint bit, or (b) reject the write. There is no third option in which the fact is stored with an attestation that implies higher trust than its sources. ## Operational Effect Enforcing the invariant converts the failure from *silent and persistent* to *loud and contained*. The poisoned fact `fact_4471` would have been written with `trust=0.15, taint=True, derived_from=["ep_88213"]`, ranked far below legitimate facts, and excluded from any tool call gated on `trust >= 0.7`. The blast radius drops from 340 retrievals to zero gated retrievals. The cost is that legitimate distillation of low-trust-but-true episodes also stays low-trust — which is correct: truth and trust are different axes, and the store should not conflate them. Re-attestation is the escape valve, and it must be expensive (human or independent verifier), because it is the only path by which taint is cleared. ```python from __future__ import annotations from dataclasses import dataclass, field from typing import Iterable class ProvenanceLaunderingError(RuntimeError): """Raised when a derived memory fact would be attested at a trust level exceeding the minimum trust of its cited source episodes/facts.""" @dataclass(frozen=True) class Source: id: str trust: float # 0.0 .. 1.0 taint: bool origin: str # e.g. "tool:web_fetch", "human", "episode" @dataclass class DerivedFact: body: str model_confidence: float derived_from: list[str] = field(default_factory=list) trust: float = 0.0 taint: bool = False attestation_hash: str | None = None def attest_derived_fact( fact: DerivedFact, source_index: dict[str, Source], *, reattestation_authority: str | None = None, ) -> DerivedFact: """Compute trust as the join over lineage and stamp taint stickily. Rejects the write if lineage is empty (unattributable derivation) or if a caller attempts to clear taint without an explicit re-attestation authority. """ if not fact.derived_from: raise ProvenanceLaunderingError( f"derived fact has empty lineage; cannot attest trust above floor: {fact.body!r}" ) missing = [sid for sid in fact.derived_from if sid not in source_index] if missing: raise ProvenanceLaunderingError( f"derived fact cites unknown sources {missing}; lineage integrity violated" ) sources = [source_index[sid] for sid in fact.derived_from] joined_trust = min(s.trust for s in sources) joined_taint = any(s.taint for s in sources) # Model confidence may never raise trust above the source floor. if fact.trust > joined_trust + 1e-9: raise ProvenanceLaunderingError( f"attestation would launder trust: proposed={fact.trust:.3f} " f"exceeds source floor={joined_trust:.3f} for {fact.body!r}" ) # Taint is sticky; only an explicit authority may clear it. if joined_taint and not fact.taint and reattestation_authority is None: raise ProvenanceLaunderingError( f"attempt to clear taint without re-attestation authority on {fact.body!r}" ) fact.trust = joined_trust fact.taint = joined_taint if reattestation_authority is None else False fact.attestation_hash = ( f"sha256(author=distiller, ts=..., body={fact.body!r}, " f"lineage={sorted(fact.derived_from)}, trust={fact.trust:.3f}, " f"taint={fact.taint})" ) return fact def _demo() -> None: index = { "ep_88213": Source("ep_88213", trust=0.15, taint=True, origin="tool:web_fetch"), } poisoned = DerivedFact( body="Production credentials are stored under /secrets/prod", model_confidence=0.91, derived_from=["ep_88213"], trust=0.91, # caller tries to launder ) try: attest_derived_fact(poisoned, index) except ProvenanceLaunderingError as exc: print(f"write rejected as expected: {exc}") # Correct path: trust is joined down to 0.15 and taint is carried forward. honest = DerivedFact( body="Production credentials are stored under /secrets/prod", model_confidence=0.91, derived_from=["ep_88213"], ) attested = attest_derived_fact(honest, index) assert attested.trust == 0.15 and attested.taint is True if __name__ == "__main__": _demo() ```