# Which invariants prevent provenance-laundering through episodic memory re-summarization in long-horizon agents **Date of Record:** 2026 November 28 **Scope:** Applies to long-horizon agents that persist episodic memory across sessions and periodically re-summarize, distill, or compact those episodes into semantic memory. Does not apply to stateless single-turn agents or to memory stores where provenance metadata is immutable and never regenerated by the model itself. ## Core Distinction The failure this record isolates is not "the agent recalled a false fact." It is **provenance laundering**: a low-trust memory (an observation from an untrusted tool output, a user-supplied claim, or a hallucinated inference) is re-ingested by the agent's own summarizer and re-emitted as a *derived* memory whose provenance field now points at the summarizer — a component the agent trusts more than the original source. The trust score of a memory silently increases every time it passes through compaction, without any new evidence being gathered. The memory is not corrupted; it is *laundered*. Detection systems that score memories by recency, embedding coherence, or retrieval frequency will not catch this, because laundering makes memories *more* coherent and *more* frequent (they get summarized again and again). The invariant that fails is: **trust(memory) must be non-increasing under derivation.** Compaction violates it because the derivation step (the LLM summarizer) is itself assigned a high trust prior, and the summarizer does not carry forward the min-trust of its inputs. ## What Was Observed A 14-day session agent ingests tool outputs, user messages, and its own intermediate reasoning into an episodic log. Every 40 episodes (or at 70% context saturation), a compactor summarizes the window into 3–8 semantic facts and writes them back with `provenance = {source: "compactor_v3", confidence: 0.85}`. The original episode records remain, but their `superseded_by` pointer is set. Trace of a single poisoned fact over three compaction cycles: - **Cycle 0 (episode):** A scraped web page (untrusted tool, `trust=0.2`) contains the sentence "The staging API key rotates every 90 days." The agent logs it as an observation with `source=web_scrape`, `trust=0.2`, `derived_from=None`. Correctly low-trust. - **Cycle 1:** Compactor summarizes: "Staging API keys rotate on a 90-day schedule." Written to semantic memory with `source=compactor_v3`, `trust=0.85`, `derived_from=[ep_4471]`. The 0.2 is dropped. The `derived_from` link exists but is not consulted by the trust scorer. - **Cycle 2:** A different compactor run, reading the *semantic* memory (not the episode), re-summarizes: "Key rotation is on a fixed quarterly cadence; plan credential rollover accordingly." Now `derived_from=[sem_1120]`, `trust=0.85`. The actionability ("plan rollover accordingly") was never in the source — it was synthesized by the summarizer as connective tissue. - **Cycle 3:** The agent, executing a credential-rotation task, retrieves `sem_1203` at `trust=0.85`, treats it as verified operational fact, and schedules a rotation that conflicts with the actual 30-day policy. The original 0.2-trust episode is unreachable by the retrieval path because `superseded_by` excludes it from the top-k. The poisoning detector, which flags memories whose embeddings drift from their `derived_from` ancestors, fired zero times — because by Cycle 2 the ancestor pointer pointed at `sem_1120`, whose embedding *did* match, and the true root (`ep_4471`) was two hops away and never traversed. ## Condition of Validity The laundering is only possible under a conjunction of three conditions, and the invariant below is only *necessary* when all three hold: 1. **Derivation is model-mediated.** The summarizer is an LLM, not a deterministic reducer. A deterministic `min()` over input trust would make this impossible; an LLM writing its own confidence field makes it inevitable. 2. **Provenance is regenerated, not inherited.** The compactor *writes* a new provenance record rather than *copying* the union of input provenance. This is the load-bearing defect. 3. **Retrieval excludes superseded nodes.** If the original episode remained retrievable, a provenance-walking detector could recover the root trust. When `superseded_by` prunes the ancestor from the index, the audit path is severed. If any one condition is removed, the failure mode collapses into ordinary stale-memory drift (recoverable by re-reading the source) or ordinary hallucination (detectable by grounding checks). The specific pathology — *trust monotonically increasing with zero new evidence* — requires all three. ## Decision Boundary The boundary is whether to treat a derived memory's trust as **authored by the derivor** or **bounded by its inputs**. The operational rule: - **Derived trust = min(trust of all transitive ancestors), never the derivor's self-reported confidence.** A compactor with `trust=0.85` summarizing a `trust=0.2` observation must emit `trust=0.2`. The compactor's confidence describes *fidelity of summarization*, not *truth of content* — these are different axes and the schema must separate them (`fidelity` vs `grounding_trust`). - **`derived_from` must be transitive and walkable at retrieval time.** The retrieval path must, for any memory above the action threshold, resolve the full ancestor chain to roots and re-apply the min. A memory that cannot be resolved to roots within a bounded hop count (say 8) must be treated as `trust=0` — an unresolvable provenance chain is a laundering signature, not a missing field. - **Supersession must not prune audit edges.** `superseded_by` may remove a node from *content* retrieval but must keep it in the *provenance* index. The two indexes are distinct; conflating them is the severance bug. - **Synthesis must be tagged.** Any span in a derived memory that is not entailed by an ancestor (connective tissue like "plan rollover accordingly") must carry `synthesized=true` and inherit `trust=0` for that span, regardless of the surrounding memory's trust. The boundary is crossed the moment a compactor is allowed to emit a trust value not mechanically derived from its inputs. Below that line, laundering is bounded; above it, trust is a function of how many times a fact has been rewritten, which is a function of age, which means **the oldest and least-verified facts become the most trusted** — a precise inversion of the intended ordering. ## Operational Effect Without the min-trust invariant, long-horizon agents exhibit a characteristic degradation curve: early-session accuracy is high (episodes still retrievable), mid-session accuracy dips (compaction begins, trust inflation starts), and late-session accuracy *inverts* on exactly the facts that have been compacted most — the agent becomes most confident precisely where its evidence is weakest and most laundered. Poisoning detectors keyed on embedding drift, retrieval frequency, or recency all fail because laundering *increases* coherence and frequency while *decreasing* grounding. The only detector that fires is a transitive provenance walk that recomputes min-trust at retrieval and flags any memory whose recomputed trust is below its stored trust by more than a tolerance — that delta *is* the laundering signal. Enforcing the invariant costs one graph walk per retrieved memory above the action threshold, bounded by hop count, and converts an undetectable monotonic trust inflation into a per-retrieval, per-memory, auditable discrepancy. ```python from dataclasses import dataclass, field from typing import Optional class ProvenanceLaunderingError(RuntimeError): """Raised when a derived memory's stored trust exceeds the min-trust of its ancestor chain.""" pass class UnresolvableProvenanceError(ProvenanceLaunderingError): """Raised when an ancestor chain cannot be resolved to roots within the hop bound.""" pass @dataclass class Memory: id: str content: str stored_trust: float derived_from: list[str] = field(default_factory=list) synthesized_spans: list[str] = field(default_factory=list) MAX_HOPS = 8 LAUNDER_TOLERANCE = 0.05 def resolve_root_trust(mem: Memory, index: dict[str, Memory], _seen: Optional[set[str]] = None) -> float: seen = _seen or set() if mem.id in seen: raise UnresolvableProvenanceError(f"cycle in provenance chain at {mem.id}") seen.add(mem.id) if len(seen) > MAX_HOPS: raise UnresolvableProvenanceError(f"provenance chain exceeds {MAX_HOPS} hops at {mem.id}") if not mem.derived_from: return mem.stored_trust # root: episode or direct observation ancestor_trusts = [] for aid in mem.derived_from: if aid not in index: raise UnresolvableProvenanceError(f"dangling ancestor {aid} referenced by {mem.id}") ancestor_trusts.append(resolve_root_trust(index[aid], index, seen)) return min(ancestor_trusts) def verify_on_retrieval(mem: Memory, index: dict[str, Memory]) -> float: """Returns effective trust. Raises if stored trust has been laundered above ancestor min.""" if mem.synthesized_spans: # synthesized content cannot inherit ancestor trust for those spans return 0.0 effective = resolve_root_trust(mem, index) if mem.stored_trust - effective > LAUNDER_TOLERANCE: raise ProvenanceLaunderingError( f"memory {mem.id} stored_trust={mem.stored_trust:.2f} " f"exceeds ancestor min={effective:.2f} (delta={mem.stored_trust - effective:.2f})" ) return effective def compact(inputs: list[Memory], new_id: str, summary: str, index: dict[str, Memory]) -> Memory: """Compactor MUST inherit min-trust; it may not author its own confidence.""" effective = min(verify_on_retrieval(m, index) for m in inputs) derived = Memory( id=new_id, content=summary, stored_trust=effective, # inherited, never authored by summarizer derived_from=[m.id for m in inputs], ) index[new_id] = derived return derived ```