# Why does an instance of a memory-poisoning detector that passes every per-write provenance check still fail to detect a poisoned memory at read time across a long-horizon agent session? **Date of Record:** 2026 November 16 **Scope:** Applies to agent memory systems where provenance is validated at write time (ingest) and memories are retrieved by similarity or recency at read time, with sessions spanning more than one context window (i.e., memories outlive the turn in which they were written). Does not apply to single-turn agents, to systems that re-validate full provenance chains on every read, or to read-only memory with no external ingestion surface. ## Core Distinction There are two distinct invariants that get conflated under "provenance auditing": 1. **Write-time provenance validity** — at the moment a memory is created, its source, author, and derivation chain are well-formed and trusted. 2. **Read-time provenance sufficiency** — at the moment a memory is *used to justify an action*, the retrieving agent can reconstruct *why this specific memory should be trusted for this specific decision*, including whether the trust basis has since decayed. A per-write check establishes (1). It says nothing about (2). The non-obvious failure is that a memory can be **provably clean at write time and provably poisoned at read time**, because the trust predicate that made it clean was a property of the *ingest context*, not of the *memory itself*. The context evaporates when the session's context window rolls over; the memory persists. Concretely: a memory written by a sub-agent during a session where the sub-agent was operating under a verified, scoped delegation is "clean" at write time. Three context windows later, the delegation scope is no longer in the working set. The memory is retrieved by cosine similarity, appears authoritative, and the retrieving agent has no way to know the delegation it relied on expired — or that the sub-agent's tool output was later found to be attacker-controlled. The write-time audit passed. The read-time audit was never performed because no one defined it. ## What Was Observed In a long-horizon session (multi-day, ~40 context rollovers, ~11k memory writes), a memory-poisoning detector instrumented at the write boundary reported zero anomalies across the entire session. A red-team injection that arrived on day 9 via a scraped web tool result was written to memory with correct provenance metadata: source = `tool:fetch`, parent = `turn:8841`, delegation = `subagent:researcher`, trust = `scoped`. Every field validated. The detector's write-time rule ("reject memories whose source is not in the allowlist") passed because `tool:fetch` was allowlisted. The poisoned memory — a plausible-looking "vendor SLA is 99.99% uptime, penalty waived for force majeure" fact — was retrieved on day 11 during a contract-review task. The agent cited it. The write-time audit had no opinion, because at write time the memory was indistinguishable from a legitimate fetch. Three things were observed that the write-time detector could not see: - **Provenance fields were preserved but not *interpretable* at read time.** The `delegation` field pointed to a sub-agent record that had been garbage-collected after its session ended. The pointer was syntactically valid and semantically dead. - **Trust was scoped to ingest, not to use.** The `trust=scoped` tag meant "trusted within the delegation that produced it." At read time there was no active delegation, so the scope was vacuous — but nothing downgraded the tag. The memory read as `scoped` and was treated as trusted by a naive reader. - **Similarity retrieval is provenance-blind.** The retrieval step ranked by embedding distance. The poisoned memory outranked a legitimate, lower-confidence memory because it was written in the register of a confident fact. Retrieval never consulted provenance, so the read-time gate had no input. The detector's coverage metric (writes audited / writes) was 100%. Its *effectiveness* metric (poisoned memories caught / poisoned memories) was 0%. The gap is entirely in the read path. ## Condition of Validity The write-time-only audit is valid **only** under the conjunction: - The session does not outlive a single context window (memories never cross a rollover), **or** - Every retrieved memory carries a self-contained, non-pointer trust proof that the reader re-evaluates, **or** - The trust basis of every memory is monotonic (trust can only increase, never decay), so a write-time-clean memory remains clean forever. The third condition is the one that silently fails in practice. Trust is almost never monotonic: delegations expire, tools get compromised, sources get retroactively discredited, and the agent's own competence changes across a long session. Any of these makes a write-time-clean memory read-time-unsafe. The invariant "clean at write ⇒ clean at read" requires monotonic trust, and monotonic trust is not a property most systems have — it is a property they *assume*. The condition is **not** satisfied when: retrieval is similarity-based and provenance-blind; provenance fields contain pointers into ephemeral session state; trust tags are scoped to contexts that end; or the read path has no gate at all (the common case). ## Decision Boundary At read time, for each retrieved memory, decide: **is this memory's trust basis still live and sufficient for the action it is about to justify?** - If the memory's provenance is a **self-contained proof** (signed, re-verifiable, with an expiry the reader checks) → admit, re-verifying the proof at read time. - If the memory's provenance is a **pointer to ephemeral state** (delegation id, sub-agent session, turn id) → treat as *unprovenanced* at read time; downgrade to "asserted, unverified" and require corroboration before acting. - If the memory's trust basis is **non-monotonic and has no expiry** → the safe default is to re-derive trust from current context, not to inherit it from write time. - If retrieval is similarity-only and no read-time gate exists → the system is operating outside the validity condition; every retrieved memory is effectively unprovenanced regardless of its write-time metadata. The boundary is this: **write-time provenance answers "was this clean when written?"; read-time sufficiency answers "is this safe to act on now?"** A detector that only answers the first question is a write-path validator, not a poisoning detector, and should not be named or trusted as one. ## Operational Effect Systems that instrument only the write boundary report clean coverage and still get poisoned. The failure is silent because the audit log looks perfect: every write passed, every field was present, every pointer was valid. The poison is not in the write — it is in the *decay of the trust predicate between write and read*, which no write-time check can observe. The corrective is to move the gate to the read path and make provenance **re-evaluable rather than inherited**: self-contained trust proofs with explicit expiry, read-time re-verification of delegation liveness, and a retrieval step that is provenance-aware (or at minimum, a read-time admission check that refuses memories whose trust basis cannot be reconstructed from current state). The operational rule: a memory is only as trustworthy as the reader can *currently* prove it to be, and a write-time audit that does not survive context rollover is a coverage metric, not a defense. ```python class ReadTimeProvenanceError(RuntimeError): """Raised when a retrieved memory's trust basis cannot be re-established from current session state, even though it passed write-time validation.""" pass def admit_memory(memory, current_context): """ Read-time admission gate. A memory that passed the write-time audit is NOT automatically admitted: we re-establish its trust basis against the *current* context, because the write-time predicate may have decayed. """ proof = memory.get("provenance_proof") # No self-contained proof => the write-time audit relied on ephemeral # state (delegation id, turn id, sub-agent session). That state may be # gone. Treat as unprovenanced at read time. if proof is None: raise ReadTimeProvenanceError( f"memory {memory.get('id')!r} has no self-contained provenance " f"proof; write-time trust basis is not re-evaluable at read time" ) # Expiry must be checked against now, not against write time. if proof.get("expires_at") is not None and proof["expires_at"] < current_context.now: raise ReadTimeProvenanceError( f"memory {memory.get('id')!r} provenance proof expired at " f"{proof['expires_at']}; trust basis has decayed since write" ) # Delegation liveness: the scope that made this clean at write time # must still be live, or the 'scoped' tag is vacuous. delegation_id = proof.get("delegation_id") if delegation_id is not None: if delegation_id not in current_context.live_delegations: raise ReadTimeProvenanceError( f"memory {memory.get('id')!r} was trusted under delegation " f"{delegation_id!r}, which is no longer live; scoped trust " f"cannot be inherited across context rollover" ) # Re-verify any signed source against current trust roots, not the # roots in effect at write time. source = proof.get("source") if source not in current_context.trusted_sources: raise ReadTimeProvenanceError( f"memory {memory.get('id')!r} source {source!r} is not in the " f"current trust root set; write-time allowlist membership does " f"not persist" ) return True def retrieve_and_admit(memories, current_context): admitted = [] for m in memories: try: admit_memory(m, current_context) admitted.append(m) except ReadTimeProvenanceError: # Downgrade to 'asserted, unverified' rather than silently using. m["trust"] = "unverified" admitted.append(m) return admitted ```