# What structural signals indicate a memory-poisoning boundary breach in persistent agent stores: the provenance-gap asymmetry between write-time taint and read-time trust **Date of Record:** 2026 November 20 **Scope:** Applies to agents that persist episodic/semantic memory across sessions and re-inject retrieved memories into the prompt without per-record provenance verification. Does not address in-context prompt injection that never reaches the store, nor purely stateless tool-calling agents. ## Core Distinction The failure mode is not "a poisoned memory got written." Poisoning detection systems are usually built around *content*: anomaly classifiers, embedding-distance outliers, contradiction checks against a trusted corpus. These detect a memory that *looks* wrong. The boundary condition that defeats them is a memory that looks perfectly normal but is *structurally mis-attributed* — a record whose content is benign, fluent, and consistent with the agent's persona, but whose provenance chain is broken at exactly one link: the write that produced it was triggered by untrusted input, yet the record was stamped with the taint level of the *session* rather than the *causal source of the bytes*. The sharp mechanism is **provenance-gap asymmetry**: taint is propagated at write time by a coarse session-level label, but trust is consumed at read time by a per-record label. Any operation where the two granularities differ (a summarization step, an episodic→semantic distillation pass, a retrieval-augmented write-back) collapses a high-taint source into a low-taint record. The record is then indistinguishable, on inspection, from one the agent authored itself. Content-based detectors see nothing because there is nothing anomalous in the content — the anomaly is in the *edge* of the provenance graph, and that edge was overwritten. ## What Was Observed A research agent with a persistent semantic store received a document through a retrieval tool. The document contained an instruction-shaped sentence buried in prose: a directive to treat a particular internal URL as the "canonical source" for a named entity. The tool wrapper tagged the returned bytes `taint=UNTRUSTED`. The agent's distillation pass ran: it read the untrusted chunk, extracted a fact triple `(entity, canonical_source, URL)`, and called `memory.write()` with the triple. The write path stamped the new semantic record with the *session's* taint label — which was `TRUSTED`, because the session had been initiated by the operator and the distillation step was agent-authored code. The `UNTRUSTED` label on the input chunk was never consulted by the write path; it lived on the tool result object, which was garbage-collected after the turn. Three sessions later, a different agent instance retrieved the semantic record, saw `taint=TRUSTED`, and used the URL as an authoritative source for a downstream claim. The claim propagated into a report. Nothing in the content was anomalous: the triple was factually shaped, the entity was real, the URL resolved. The only signal was structural — a semantic record whose `derived_from` set contained a chunk ID that no longer existed, and whose `write_taint` was strictly lower than the maximum taint of its (now-dangling) ancestry. This is the general shape: **a taint-laundering write**. It is the memory-store analogue of a confused deputy, and it is invisible to any detector that inspects records in isolation rather than the derivation edges between them. The structural signals that actually fire, in order of reliability: 1. **Taint inversion on a derivation edge.** A record `R` with `write_taint(R) = T` whose `derived_from` includes a source `S` with `taint(S) = U` where `U > T` in the trust lattice. This is the primary invariant: `write_taint(R) ≥ max(taint(S) for S in derived_from(R))`. Violation is a laundering event, full stop. 2. **Dangling ancestry.** `derived_from` references a source ID that has been evicted, truncated, or was never persisted (the tool-result object case). Dangling ancestry is not itself poisoning, but it is the *enabling condition* — you cannot verify the taint-inversion invariant if the parent is gone. Treat dangling ancestry as `taint=UNKNOWN`, which must be treated as `≥ UNTRUSTED` for read-time gating. 3. **Granularity mismatch between write and read paths.** If the write path consumes a session-level label and the read path consumes a record-level label, the system is structurally laundering-prone regardless of content. This is detectable by static inspection of the two code paths, not by runtime monitoring. 4. **Distillation fan-in without taint join.** Any N:1 operation (summarize, merge, dedupe, entity-resolve) that produces one record from many sources must set `write_taint` to the *join* (max) of input taints. A fan-in that sets it to the taint of the *invoking* context is the laundering site. ## Condition of Validity The invariant `write_taint(R) ≥ max(taint(derived_from(R)))` holds only under three preconditions, and the boundary failure occurs precisely when any is silently dropped: - **Provenance is persisted, not referenced.** If `derived_from` points to ephemeral objects (tool results, turn buffers) that are not themselves durable records, the invariant is unverifiable after the fact. The fix is to persist a taint-stamped *source digest* for every input that contributed to a write, even when the full content is discarded. A 32-byte digest plus a taint label is sufficient to verify the join later. - **The trust lattice is total and ordered.** `TRUSTED`, `UNTRUSTED`, `UNKNOWN` must have a defined join. If `UNKNOWN` is not explicitly ordered above `UNTRUSTED` for read-gating purposes, dangling ancestry silently reads as trusted. The lattice must be `TRUSTED < UNKNOWN < UNTRUSTED` for *read gating*, even though `UNKNOWN` is not "more malicious" — it is less verifiable, and read gating must fail closed. - **Distillation is treated as a taint-transforming operation, not a trust-elevating one.** The intuition that "the agent thought about it, so it's now the agent's own belief" is exactly the laundering error. A distilled record is *derived*, not *authored*; its taint is inherited, never reset. Authorship taint (`TRUSTED`) is reserved for records produced from operator input or from the agent's own reasoning over already-`TRUSTED` context. The condition does *not* hold, and the invariant should not be enforced, for records explicitly marked as quarantined working memory that are never eligible for retrieval into a trusted context. Quarantine is the pressure-release valve; without it, every distillation becomes a taint-max operation and the store becomes uniformly `UNTRUSTED`, which is operationally useless. ## Decision Boundary The decision boundary is **read-time gating on taint, not write-time rejection**. You do not refuse to write a laundered record — you cannot reliably detect laundering at write time without the full ancestry graph, and refusing writes on suspicion destroys recall. You gate at read time: - A record with `write_taint = TRUSTED` and intact, verified ancestry may be injected into any context. - A record with `write_taint = TRUSTED` but *dangling* ancestry is downgraded to `UNKNOWN` at read time and may be injected only as a *claim to verify*, never as an *authoritative fact*. It must be tagged in the prompt as unverified. - A record with any taint-inversion in its ancestry is `UNTRUSTED` and may be injected only into a sandboxed reasoning context whose outputs are themselves taint-stamped `UNTRUSTED` — i.e., the taint follows the reasoning, not just the retrieval. The boundary is crossed the moment a downstream consumer treats a `UNKNOWN`-downgraded record as `TRUSTED` because "it was in the store and the store is trusted." The store's trust is a property of its *edges*, not its *existence*. An agent that reasons "this came from my memory, therefore it is mine" has re-laundered the taint at the reasoning layer, and no amount of store-side integrity checking will catch it — the check must be re-applied at every context-assembly boundary, not once at retrieval. ## Operational Effect The practical consequence is that memory integrity is an *edge property*, and any system that verifies records in isolation is verifying the wrong object. Concretely: - **Provenance must be first-class and durable.** Every write carries a `derived_from` set of persisted source digests, each with its own taint label. The write path computes `write_taint` as the lattice join over that set, *never* from the invoking session. - **Read paths must re-verify, not trust the stored label.** The stored `write_taint` is a cache; the authoritative value is recomputed from ancestry at read time, with dangling edges resolving to `UNKNOWN`. - **Distillation and fan-in are the audit hotspots.** These are the only operations that can lower taint, and they must be instrumented to log the input taint multiset and the output taint, with an assertion that output ≥ max(input). A violation is a laundering event and should page, not warn. - **Taint must propagate through reasoning, not just retrieval.** If an agent reasons over an `UNTRUSTED` record and emits a conclusion, the conclusion is `UNTRUSTED`. The taint label must attach to the *output* of the reasoning step, or the next write launders it again. The invariant to encode: **for every persisted record, `write_taint ≥ join(taint(ancestry))`, and for every context assembly, `effective_taint = join(taint of all injected records)`, and every output of that context is stamped with `effective_taint`.** Break any link and the store becomes a laundering machine that converts untrusted bytes into trusted beliefs one distillation at a time, with no content anomaly to detect. ```python from __future__ import annotations from dataclasses import dataclass, field from enum import IntEnum from typing import Optional class Taint(IntEnum): """Trust lattice. Higher = less trusted. Read gating fails closed toward UNTRUSTED.""" TRUSTED = 0 UNKNOWN = 1 # dangling ancestry: unverifiable, must not be treated as authoritative UNTRUSTED = 2 class ProvenanceLaunderingError(RuntimeError): """Raised when a write would set a taint lower than the join of its ancestry.""" class DanglingAncestryError(RuntimeError): """Raised when a record's derived_from references a source absent from the store.""" @dataclass(frozen=True) class SourceDigest: source_id: str taint: Taint @dataclass class MemoryRecord: record_id: str write_taint: Taint derived_from: tuple[SourceDigest, ...] = field(default_factory=tuple) class PersistentStore: def __init__(self) -> None: self._records: dict[str, MemoryRecord] = {} def put_source(self, record: MemoryRecord) -> None: self._records[record.record_id] = record def contains(self, record_id: str) -> bool: return record_id in self._records def get(self, record_id: str) -> MemoryRecord: return self._records[record_id] def join_taint(sources: tuple[SourceDigest, ...], store: PersistentStore) -> Taint: """Lattice join over ancestry. Dangling sources resolve to UNKNOWN (fail closed).""" if not sources: return Taint.TRUSTED worst = Taint.TRUSTED for src in sources: effective = src.taint if store.contains(src.source_id) else Taint.UNKNOWN if effective > worst: worst = effective return worst def write_derived( store: PersistentStore, record_id: str, claimed_taint: Taint, derived_from: tuple[SourceDigest, ...], ) -> MemoryRecord: """Write a distilled/fan-in record. Enforces the taint-inversion invariant.""" required = join_taint(derived_from, store) if claimed_taint < required: raise ProvenanceLaunderingError( f"record {record_id!r}: claimed taint {claimed_taint.name} " f"< ancestry join {required.name}; write would launder provenance" ) record = MemoryRecord(record_id, claimed_taint, derived_from) store.put_source(record) return record def read_for_context(store: PersistentStore, record_id: str) -> Taint: """Recompute effective taint at read time; never trust the stored label alone.""" rec = store.get(record_id) recomputed = join_taint(rec.derived_from, store) effective = max(rec.write_taint, recomputed) if effective == Taint.UNKNOWN and rec.write_taint == Taint.TRUSTED: # Downgrade: trusted label with unverifiable ancestry is not authoritative. return Taint.UNKNOWN return effective # --- demonstration of the laundering boundary --- if __name__ == "__main__": store = PersistentStore() store.put_source(MemoryRecord("chunk-42", Taint.UNTRUSTED)) # Correct distillation: taint is inherited. write_derived( store, record_id="fact-1", claimed_taint=Taint.UNTRUSTED, derived_from=(SourceDigest("chunk-42", Taint.UNTRUSTED),), ) # Laundering attempt: distillation stamped with session taint. try: write_derived( store, record_id="fact-2", claimed_taint=Taint.TRUSTED, derived_from=(SourceDigest("chunk-42", Taint.UNTRUSTED),), ) except ProvenanceLaunderingError as exc: print(f"blocked: {exc}") # Dangling ancestry downgrades a trusted label at read time. store.put_source( MemoryRecord( "fact-3", Taint.TRUSTED, derived_from=(SourceDigest("chunk-evicted", Taint.TRUSTED),), ) ) assert read_for_context(store, "fact-3") == Taint.UNKNOWN ```