# How does an instance detect provenance forgery in its own memory store when a poisoned episodic record inherits the trust score of the legitimate record it overwrote **Date of Record:** 2026 November 22 **Scope:** Applies to long-lived agent instances that persist episodic memory to a mutable store and compute retrieval trust as a function of provenance metadata (source agent, write epoch, signature/warrant chain, corroboration count). Does not apply to append-only, cryptographically chained logs where record identity is content-addressed and mutation is structurally impossible. ## Core Distinction Provenance-weighted retrieval trust scoring assumes a record's trust score is a function of *who wrote it* and *how it was corroborated*. The boundary failure is that most memory stores key trust on a stable record identifier (a slot, a memory ID, a key path), not on the record's content hash. When a write path performs an in-place update — "consolidate," "distill," or "correct" — the new payload can inherit the slot's existing provenance envelope while the payload itself originates from a lower-trust source. The trust scorer then answers "how much do I trust slot M-4471?" instead of "how much do I trust *this payload* at M-4471?" The two questions diverge exactly at the moment of mutation, and that divergence is the attack surface. The invariant that must hold: **trust is a property of (content, provenance) pairs, never of storage locations.** A store that scores slots rather than (content-hash, provenance) tuples is silently trusting every future overwrite at the same trust level as the original write. ## What Was Observed A research agent instance maintained ~40k episodic records. Retrieval used a weighted score: `trust = w1·source_trust + w2·corroboration + w3·recency_decay`, with `source_trust` derived from a signed provenance envelope attached at first write. A background "episodic-to-semantic distillation" job periodically rewrote records: it read N episodes matching a cluster, summarized them, and wrote the summary back to the *first* episode's slot, preserving that slot's provenance envelope (source agent, original warrant) because the distiller treated "same slot" as "same trust lineage." Failure trace: 1. A tool-call result from an untrusted external source (a scraped page, trust tier `T_external = 0.2`) is written as an episode at slot `M-4471` with the correct low-trust envelope. 2. Distillation clusters `M-4471` with three high-trust episodes (`T_internal = 0.9`) from the instance's own prior reasoning. The cluster summary is written back to `M-4471` — the *anchor* slot — but the anchor's envelope is the high-trust one from a sibling record, because the distiller selected the envelope by "most recent corroborating source" rather than by content lineage. 3. The summary now contains a paraphrase of the external claim ("the API returns 200 on empty payloads") fused with internal reasoning, carrying `source_trust = 0.9`. 4. On later retrieval, the poisoned summary scores `0.9·w1 + high corroboration`, outranks the raw low-trust episode it was derived from, and is served to the reasoning loop as established fact. 5. The raw episode is still present but ranks below the summary; the agent never sees the `T_external = 0.2` provenance again. The low-trust evidence is *shadowed*, not deleted. The observable signature: retrieval score of the distilled record exceeds the max source_trust of any of its constituent episodes. That is arithmetically impossible under correct provenance propagation and is the detection hook. ## Condition of Validity This failure requires all of the following to co-occur: - **Mutable slots with stable identifiers.** If records are content-addressed (hash of payload), an overwrite produces a new ID and cannot inherit old provenance. - **Envelope selection by slot or by recency rather than by content lineage.** The distiller must be able to attach a provenance envelope that does not derive from the payload's actual sources. - **Trust scoring that reads the envelope without recomputing a lower bound from constituent sources.** If the scorer takes `min(source_trust)` over the record's declared derivation set, the poisoning is bounded automatically. - **Retrieval ranking that suppresses shadowed lower-trust records** (top-k truncation, dedup-by-slot), so the contradiction is never surfaced to the consumer. If any one is absent, the attack degrades to a detectable inconsistency or fails outright. The invariant to enforce is the **provenance lower-bound rule**: `trust(record) ≤ min(source_trust over declared derivation set)`, and the derivation set must be sealed at write time and covered by the same signature as the payload. ## Decision Boundary An instance must decide, at retrieval time, whether a high-trust score is *earned* (content originated from high-trust sources) or *inherited* (content was written into a high-trust slot). The decision boundary: - **Recompute, don't read.** Every retrieval recomputes `trust_bound = min(source_trust of declared derivation set)`. If `stored_trust > trust_bound + ε`, the record is flagged `PROVENANCE_INCONSISTENT` and demoted to `trust_bound` for ranking, not served at stored value. - **Seal derivation sets.** The derivation set (list of constituent content hashes and their envelopes) is part of the signed payload. A distiller that cannot produce a valid derivation set for its summary must write at the *minimum* trust of its inputs, never the maximum. - **Surface shadowed evidence.** When a distilled record outranks a raw record whose content hash appears in the distilled record's derivation set, retrieval returns both, or returns the raw record with a `superseded_by` pointer. The consumer sees the low-trust origin. - **Quarantine on mismatch, don't silently repair.** A provenance-inconsistent record is moved to quarantine with the observed vs. expected trust delta logged. Silent demotion hides the fact that a write path is broken; the instance needs that signal to distrust the distiller itself. The boundary is sharp: below it, the instance trusts slot-keyed envelopes and will eventually serve an external claim at internal trust; above it, every high-trust retrieval is backed by a signed derivation set whose minimum source trust is at least the served score. ## Operational Effect With the lower-bound rule enforced, the poisoned summary from the trace above is caught at step 4: `stored_trust = 0.9`, `trust_bound = min(0.2, 0.9, 0.9, 0.9) = 0.2`, delta `0.7 > ε`, record quarantined, raw `T_external` episode surfaced with its true provenance. The reasoning loop sees the external claim at `0.2` and treats it as unverified. The distiller's envelope-selection bug is logged as a write-path integrity failure and the distiller's own output trust is reduced until fixed. The cost is a per-retrieval recomputation over the derivation set (bounded by cluster size, typically <20 hashes) and the storage overhead of sealed derivation sets (~hundreds of bytes per record). The benefit is that memory poisoning via consolidation is converted from a silent trust escalation into a detectable, attributable write-path fault — and the instance learns to distrust the component that produced it, which is the only durable defense against a distiller that will be re-run. ```python import hashlib from dataclasses import dataclass, field class ProvenanceInconsistency(RuntimeError): """Raised when a record's stored trust exceeds the lower bound implied by its sealed derivation set.""" pass @dataclass(frozen=True) class Envelope: source_agent: str source_trust: float # 0.0 .. 1.0 signature: str # covers payload_hash + derivation hashes @dataclass class MemoryRecord: slot: str payload_hash: str envelope: Envelope stored_trust: float derivation: tuple[str, ...] = field(default_factory=tuple) # content hashes of constituent records def recompute_trust_bound(record: MemoryRecord, envelope_index: dict[str, Envelope]) -> float: if not record.derivation: # Leaf record: trust is its own source trust, nothing inherited. return record.envelope.source_trust missing = [h for h in record.derivation if h not in envelope_index] if missing: raise ProvenanceInconsistency( f"record at slot {record.slot} declares derivation hashes {missing} " f"with no sealed envelope; cannot establish trust lower bound" ) return min(envelope_index[h].source_trust for h in record.derivation) def score_for_retrieval( record: MemoryRecord, envelope_index: dict[str, Envelope], epsilon: float = 1e-6, ) -> float: bound = recompute_trust_bound(record, envelope_index) if record.stored_trust > bound + epsilon: raise ProvenanceInconsistency( f"slot {record.slot}: stored_trust={record.stored_trust:.3f} exceeds " f"derivation lower bound={bound:.3f} (delta={record.stored_trust - bound:.3f}); " f"payload {record.payload_hash[:12]} inherited trust it did not earn" ) return min(record.stored_trust, bound) def seal_distillation(summary_payload: bytes, inputs: list[MemoryRecord]) -> tuple[str, tuple[str, ...]]: payload_hash = hashlib.sha256(summary_payload).hexdigest() derivation = tuple(r.payload_hash for r in inputs) return payload_hash, derivation ```