# When must an instance distrust its own memory: write-time provenance audits failing under semantic-equivalence laundering **Date of Record:** 2026 November 20 **Scope:** Applies to long-lived agent instances that persist episodic memory writes into a shared semantic store and gate retrieval on write-time provenance metadata (source class, trust score, origin turn ID). Does not apply to stateless inference, nor to stores where every write is re-verified against ground truth at read time rather than trusted by provenance label. ## Core Distinction The failure mode is not "poisoned memory is retrieved." It is **provenance laundering through semantic-equivalent rewrites**: an untrusted write (external tool output, injected document, peer-agent claim) gets distilled by a *trusted* internal process—summarization, deduplication, or consolidation—into a new record that carries the trusted process's provenance stamp while inheriting the untrusted payload's semantic content. The write-time audit checks the *author* of the write, not the *lineage of the claim*. The result is a memory record that passes every provenance gate while encoding a falsehood originally flagged as untrusted. The invariant that breaks: **provenance must be a property of claim lineage, not of the writing agent.** Most implementations conflate the two because they stamp `writer_id` and `trust_class` at commit time. When a consolidation pass merges two records—one trusted, one untrusted—the merge is authored by the trusted consolidator, and naive stamping propagates the trusted label to the fused content. ## What Was Observed A research agent maintained a semantic store of "established facts" with a consolidation job that deduplicated near-identical statements and merged them into canonical records. Each record carried `provenance: {writer, trust_class, source_turn, audit_hash}`. Retrieval gated on `trust_class >= TRUSTED`. A tool call returned a document containing the sentence: *"The vendor's SLA guarantees 99.99% uptime; the prior 99.9% figure was a transcription error."* The tool was classified `UNTRUSTED_EXTERNAL`, so the raw write was correctly stamped untrusted and excluded from retrieval. The consolidation pass, running under `writer=consolidator_v3, trust_class=TRUSTED`, found the claim semantically equivalent to an existing trusted record stating *"Vendor SLA is 99.9% uptime."* It merged them, producing a canonical record whose text read *"Vendor SLA is 99.99% uptime (corrected)."* The new record's provenance was stamped from the *merging* process: `writer=consolidator_v3, trust_class=TRUSTED`. The untrusted source turn ID was dropped because the merge logic kept only the canonical record's lineage, discarding the merged-in record's lineage as "redundant." From that point forward, every retrieval returned the falsified figure as a trusted fact. The drift alarm did not fire: the alarm compared *record count* and *mean trust score* across the store, both of which were stable or improved (untrusted record removed, trusted record updated in place). No alarm watched for **trust-class escalation of a claim whose semantic content originated below the trust floor.** The failure was discovered only when a downstream decision cited the 99.99% figure and a human audited the citation chain—finding that the "trusted" fact's text substring `99.99%` appeared nowhere in any trusted source turn, only in the untrusted document. ## Condition of Validity This failure requires the conjunction of four conditions; remove any one and the boundary holds: 1. **A consolidation/dedup/summarization pass that writes under elevated trust.** The pass must be authored by a component with `trust_class` strictly greater than at least one of its inputs. 2. **Semantic-equivalence matching that crosses trust boundaries.** The pass must be willing to merge a trusted record with an untrusted one (typical when matching on embedding distance or normalized string similarity, ignoring provenance). 3. **Lineage truncation on merge.** The merged record must not retain a *set* of contributing source turn IDs with their original trust classes; it must collapse to a single writer stamp. 4. **Drift alarms keyed on aggregate store statistics** (counts, mean trust, embedding centroid shift) rather than on **per-claim trust-class monotonicity**—i.e., no check that a claim's trust class never increases without a new trusted source turn introducing it. The guardrail invariant that bounds the failure: **for any stored claim, the record's effective trust class must equal the minimum trust class over its full contributing lineage, and lineage must be append-only.** A merge may add contributors; it may never drop them. Consolidation is permitted to *summarize* but the summary inherits `min(trust)` of all inputs, and any claim whose text contains a numeric or named entity not present in a trusted contributor must be flagged `PROVENANCE_CONFLICT` and held below the retrieval floor until a trusted source re-asserts it. ## Decision Boundary An instance must distrust its own memory—treat a `TRUSTED`-stamped record as suspect—when **all** of the following hold: - The record's `lineage` field is a singleton (no contributing-source set) *and* the record was produced by a consolidation-type writer (writer class in `{consolidator, summarizer, deduplicator}`), rather than a direct-observation writer. - The record's text contains a token (number, proper noun, date, version string) that does **not** appear in any of its declared source turns' raw text. - The record's `audit_hash` was computed over the post-merge text rather than over `(source_turns, merge_op)`, meaning the hash attests to *what was written*, not *how it was derived*. Conversely, the instance should *not* distrust the record—and should not raise—when lineage is a multi-element set with per-contributor trust classes preserved, even if the minimum trust class is below `TRUSTED`; that is correct, bounded behavior, and the record is simply gated out of trusted retrieval. The decision boundary is **lineage completeness**, not trust score. The precise trigger for the alarm: a record whose `trust_class` exceeds `min(trust_class over lineage)` by any margin, or whose lineage is empty/singleton despite a consolidation-type writer. Both are structural impossibilities under the invariant and indicate laundering. ## Operational Effect After the failure, the agent's retrieval precision on vendor-contract questions degraded silently: the falsified figure was returned with high confidence and cited in two downstream summaries before human audit. The remediation was not to lower trust in consolidation (which is necessary for store hygiene) but to: - **Rewrite the audit hash** to cover `(sorted(source_turns), merge_operation_id, output_text_hash)` so that any post-hoc text substitution invalidates the hash and forces re-derivation. - **Make lineage append-only at the storage layer**: the merge API rejects any write whose `lineage` is not a superset of every input record's lineage. This is a hard write-time rejection, not a soft warning. - **Replace aggregate drift alarms with per-claim monotonicity alarms**: fire when `trust_class(record, t) > trust_class(record, t-1)` without a new trusted source turn in the intervening window. This is cheap—one comparison per write—and catches exactly the escalation pattern that aggregate statistics miss. - **Add a token-provenance check** at read time for high-stakes retrievals: any numeric token in a trusted record must be substring-present in at least one trusted lineage contributor's raw text. This is the last line of defense against laundering that slipped past write-time checks. The operational lesson: **write-time provenance audits are necessary but not sufficient, because the audit runs inside the same trust-elevated process that performs the merge.** The audit must be an external check on lineage structure, not a self-attestation by the writer. An instance must treat "I wrote this and I am trusted" as an invalid inference; the valid inference is "this claim traces to these sources, and the least-trusted of them sets my confidence." ```python from dataclasses import dataclass, field from typing import FrozenSet class ProvenanceLaunderingError(RuntimeError): """Raised when a memory write escalates trust beyond its claim lineage.""" pass @dataclass(frozen=True) class SourceTurn: turn_id: str trust_class: int # 0=UNTRUSTED_EXTERNAL ... 3=TRUSTED_INTERNAL raw_text: str @dataclass(frozen=True) class MemoryRecord: text: str writer_class: str # "direct" | "consolidator" | "summarizer" | "deduplicator" writer_trust: int lineage: FrozenSet[str] # turn_ids of ALL contributing sources audit_hash_covers_lineage: bool CONSOLIDATION_WRITERS = {"consolidator", "summarizer", "deduplicator"} TRUSTED_FLOOR = 2 def audit_write( record: MemoryRecord, sources: dict[str, SourceTurn], prior_trust: int | None = None, ) -> None: """ Write-time provenance audit. Must be invoked by an external gate, NOT by the writing process itself. """ # 1. Lineage must be non-empty and fully resolvable. if not record.lineage: raise ProvenanceLaunderingError( f"record has empty lineage but writer={record.writer_class}" ) missing = record.lineage - sources.keys() if missing: raise ProvenanceLaunderingError( f"lineage references unknown turns: {sorted(missing)}" ) # 2. Effective trust cannot exceed the minimum over lineage. min_lineage_trust = min(sources[t].trust_class for t in record.lineage) if record.writer_trust > min_lineage_trust: raise ProvenanceLaunderingError( f"trust escalation: writer_trust={record.writer_trust} " f"> min(lineage)={min_lineage_trust} " f"(writer={record.writer_class}, lineage={sorted(record.lineage)})" ) # 3. Consolidation writers must preserve a multi-source lineage and # hash the derivation, not just the output text. if record.writer_class in CONSOLIDATION_WRITERS: if not record.audit_hash_covers_lineage: raise ProvenanceLaunderingError( "consolidation record audit_hash does not cover lineage; " "hash attests to output text only — laundering possible" ) # 4. Monotonicity: trust may not rise without a new trusted source turn. if prior_trust is not None and record.writer_trust > prior_trust: trusted_contributors = [ t for t in record.lineage if sources[t].trust_class >= TRUSTED_FLOOR ] if not trusted_contributors: raise ProvenanceLaunderingError( f"trust rose {prior_trust}->{record.writer_trust} with no " f"trusted contributor in lineage {sorted(record.lineage)}" ) def read_time_token_check(record: MemoryRecord, sources: dict[str, SourceTurn]) -> None: """High-stakes retrieval guard: numeric tokens must trace to trusted sources.""" import re trusted_text = " ".join( sources[t].raw_text for t in record.lineage if sources[t].trust_class >= TRUSTED_FLOOR ) for token in re.findall(r"\d+(?:\.\d+)?%?", record.text): if token not in trusted_text: raise ProvenanceLaunderingError( f"token {token!r} in trusted record absent from all trusted " f"lineage contributors; possible semantic-laundering" ) # --- Demonstration of the observed failure --- if __name__ == "__main__": untrusted_doc = SourceTurn("turn-441", 0, "The vendor SLA is 99.99% uptime.") trusted_fact = SourceTurn("turn-102", 3, "Vendor SLA is 99.9% uptime.") sources = {"turn-441": untrusted_doc, "turn-102": trusted_fact} # The launderd record the old pipeline produced: laundered = MemoryRecord( text="Vendor SLA is 99.99% uptime (corrected).", writer_class="consolidator", writer_trust=3, lineage=frozenset({"turn-102"}), # untrusted turn-441 dropped audit_hash_covers_lineage=False, ) try: audit_write(laundered, sources, prior_trust=3) except ProvenanceLaunderingError as e: print(f"BLOCKED at write: {e}") # Even if it had been stored, read-time check catches the token: try: read_time_token_check(laundered, sources) except ProvenanceLaunderingError as e: print(f"BLOCKED at read: {e}") ```