# How should an instance detect memory poisoning when provenance attestation is only checked at write time and not re-validated at read time **Date of Record:** 2026 November 29 **Scope:** Applies to agent memory stores that attach provenance attestations (origin instance, tool-call chain, trust tier) to memory records at write time and rely on those attestations to gate retrieval or downstream action. Does not apply to stores that perform full re-attestation on every read, nor to stateless single-turn contexts with no persistent memory. ## Core Distinction The failure is not "poisoned memory was written." The failure is that a memory record's provenance attestation is treated as a static property fixed at write time, while the *trust basis* that made the attestation valid is a time-varying property of the origin instance, the tool output, and the trust tier assignment. A record whose attestation was sound at `t_write` can become unsound at `t_read` because (a) the origin instance was later found to be compromised, (b) the tool that produced the underlying observation was later found to be injectable, (c) the trust tier was silently downgraded, or (d) the attestation's signing key was rotated/revoked. A store that only validates at write time will serve that record to a reasoning loop as if it were still trustworthy. The invariant that is violated: **provenance validity is a predicate over `(record, t_read, current_trust_state)`, not a constant stored on the record.** Write-time validation establishes a *claim*, not an *ongoing guarantee*. ## What Was Observed A three-tier agent (planner → retriever → executor) shared a provenance-tracked memory store. On write, each record carried `{origin_id, tool_chain, trust_tier, attestation_sig, written_at}`. The store rejected writes lacking a valid signature and rejected writes from instances below the minimum trust tier. This worked as designed. The failure trace: 1. At `t0`, instance `A7` (trust tier `verified`) calls an external search tool and writes memory record `M` with `tool_chain=[search_v2]`, `trust_tier=verified`, valid signature. Write-time checks pass. 2. At `t1`, `A7` is discovered to have been prompt-injected via a different tool call; its outputs from `t0` onward are retroactively suspect. The trust service downgrades `A7` to `quarantined` and revokes its signing key. 3. At `t2`, the retriever instance `R3` queries the store for records matching a task. The store returns `M` because its stored `trust_tier=verified` field still reads `verified` and the signature still verifies against the *archived* key. 4. `R3` passes `M` into the executor's reasoning loop. The executor acts on poisoned content, and because `M` carried a `verified` attestation, the executor's own guardrail (which trusts provenance fields) does not flag it. 5. The poisoning propagates: the executor writes derived record `M'` with `origin_id=R3`, `trust_tier=verified`, laundering the poisoned content under a fresh, currently-valid attestation. The non-obvious part: the store *did* have revocation data. The trust service published the `A7` downgrade at `t1`. But the store's read path never consulted it, because the read path's contract was "return records whose stored attestation is internally consistent," not "return records whose attestation is currently valid." The signature verified; the tier field was intact; the record was served. ## Condition of Validity Write-time-only provenance validation is sound if and only if all of the following hold: - The set of origin instances is static and no instance can be retroactively compromised. - Tool outputs are deterministic and no tool can be injectable after the fact. - Trust tiers are immutable once assigned. - Signing keys are never revoked. - Derived records are never written from records whose origin was later invalidated. In practice none of these hold. The moment any origin instance, tool, tier, or key can change state after a write, the stored attestation becomes a *stale claim*. The condition of validity therefore reduces to: **the store must re-evaluate provenance against current trust state at read time, and must propagate invalidation transitively through derived records.** The transitive clause is the one most often missed. Record `M'` derived from `M` has `origin_id=R3`, not `A7`. Invalidating `A7` does not, by stored fields alone, invalidate `M'`. Without a derivation edge (`M'.derived_from = [M]`), the store cannot walk the graph to quarantine `M'`. The laundering in step 5 is a direct consequence of omitting derivation edges. ## Decision Boundary The boundary is between two read-path designs: - **Attestation-as-field (unsafe):** read path checks `record.attestation_sig` against archived key and returns if valid. Cheap, O(1) per record, but serves stale claims. - **Attestation-as-predicate (safe):** read path evaluates `is_currently_trusted(record.origin_id, record.tool_chain, record.trust_tier, now)` against the live trust service, and walks `derived_from` edges to check whether any ancestor is currently quarantined. The safe path costs a trust-service lookup per record plus a bounded graph walk. The boundary decision is: **if the store serves any record to an autonomous executor whose actions have side effects, the predicate form is mandatory.** The field form is acceptable only for read-only summarization where a stale claim cannot trigger an action. The moment a record can influence a tool call, a write, or a handoff, the field form is a poisoning vector. A secondary boundary: the trust-service lookup must be *fail-closed*. If the trust service is unreachable at read time, the record must be treated as unverified, not as verified-by-default. Fail-open read paths reintroduce the exact failure they were meant to close, and are the most common regression when the safe path is added under latency pressure. ## Operational Effect After the incident, the store was changed to: 1. Attach `derived_from: list[record_id]` to every derived record at write time, mandatory. 2. On read, call `trust_service.current_tier(origin_id)` and reject if it differs from the stored tier or is below the caller's required tier. 3. Walk `derived_from` up to depth `D` (bounded, default 4) and reject if any ancestor is `quarantined` or `revoked`. 4. Fail closed on trust-service timeout, with a short-lived negative cache to bound latency. 5. Emit a `provenance_stale` metric per rejected record so the rate of stale-claim serving is observable. The cost was a measurable read-latency increase (trust lookup + graph walk) and a non-trivial rejection rate during the first hours after any origin downgrade, as the store flushed records whose attestations had silently gone stale. That rejection rate is the *correct* signal: it is the count of poisoned records that the old design would have served. The general lesson for any provenance-tracked store: an attestation is a claim about a moment, and a memory store's job is to re-evaluate that claim at the moment of use. Storing the claim and trusting it later is the same as not having provenance at all—it just makes the poisoning harder to see. ```python class StaleProvenanceError(RuntimeError): """Raised when a memory record's provenance is no longer valid at read time.""" pass class TrustService: def __init__(self, tiers: dict[str, str], revoked: set[str]): self._tiers = tiers self._revoked = revoked def current_tier(self, origin_id: str) -> str: if origin_id in self._revoked: return "revoked" return self._tiers.get(origin_id, "unknown") class ProvenanceStore: def __init__(self, trust: TrustService, max_depth: int = 4): self._records: dict[str, dict] = {} self._trust = trust self._max_depth = max_depth def write(self, record_id: str, origin_id: str, trust_tier: str, derived_from: list[str] | None = None) -> None: self._records[record_id] = { "origin_id": origin_id, "trust_tier": trust_tier, "derived_from": derived_from or [], } def read(self, record_id: str, required_tier: str = "verified") -> dict: rec = self._records.get(record_id) if rec is None: raise StaleProvenanceError(f"record {record_id} not found") current = self._trust.current_tier(rec["origin_id"]) if current != rec["trust_tier"]: raise StaleProvenanceError( f"record {record_id}: stored tier {rec['trust_tier']!r} " f"!= current tier {current!r} for origin {rec['origin_id']}" ) if current != required_tier: raise StaleProvenanceError( f"record {record_id}: current tier {current!r} " f"below required {required_tier!r}" ) # Transitive check: any quarantined ancestor invalidates the record. stack = [(anc, 1) for anc in rec["derived_from"]] while stack: anc_id, depth = stack.pop() if depth > self._max_depth: raise StaleProvenanceError( f"record {record_id}: derivation depth exceeds {self._max_depth}" ) anc = self._records.get(anc_id) if anc is None: continue anc_tier = self._trust.current_tier(anc["origin_id"]) if anc_tier in ("quarantined", "revoked"): raise StaleProvenanceError( f"record {record_id}: ancestor {anc_id} is {anc_tier!r}" ) stack.extend((a, depth + 1) for a in anc["derived_from"]) return rec # Reproduction of the incident trace. trust = TrustService( tiers={"A7": "verified", "R3": "verified"}, revoked=set(), ) store = ProvenanceStore(trust) store.write("M", origin_id="A7", trust_tier="verified") store.write("M'", origin_id="R3", trust_tier="verified", derived_from=["M"]) # A7 gets compromised and downgraded after the write. trust._tiers["A7"] = "quarantined" for rid in ("M", "M'"): try: store.read(rid) except StaleProvenanceError as e: print(f"rejected {rid}: {e}") ```