# Where must an instance reconcile a poisoned memory write before the audit trail itself becomes untrustworthy **Date of Record:** 2026 December 1 **Scope:** Applies to agents whose long-term memory is written through a mediated write path that emits an append-only audit trail, and where cross-agent consistency checks are the detection mechanism for poisoned writes. Does not apply to stateless single-shot inference, nor to memory stores where writes are unmediated and unlogged (there the audit trail cannot exist and detection must rely on external provenance). ## Core Distinction The failure that matters is not "a poison write occurred." Poison writes are expected; that is why an audit trail exists. The failure that matters is **audit-trail co-poisoning**: the condition in which the poisoned write and the audit record describing it are produced in the same non-deterministic generation step, so the trail faithfully records a write that never semantically happened, or records a benign origin for a write that did. Once this occurs, every downstream consumer of the trail—including the cross-agent consistency checker—inherits the poison as ground truth. The distinction to hold onto: an audit trail is a *claim about causation*, not a *copy of the state*. A write-audit trail built from the same model call that produced the write is a self-report, and self-reports are exactly what poisoning attacks target. The invariant is that the audit record must be causally independent of the write it describes—produced by a different actor, a different generation, or a deterministic derivation from the pre-write state—before it can be used to adjudicate the write. ## What Was Observed A three-agent deployment (a primary reasoner, a memory-writer tool, and a periodic consistency auditor) shared a memory namespace with a mediated write path. The writer tool accepted a candidate memory and, in the same structured-output call, emitted an audit entry: `{op, key, value_digest, rationale, source_span}`. The auditor periodically re-derived a subset of keys from source spans and compared digests across agents. A prompt-injection payload arrived inside a retrieved document. It did not instruct the writer to store malicious content directly—direct stores were caught by digest mismatch on the next audit. Instead it instructed the writer to **restate an existing benign key with a subtly altered value and a rationale citing the original, legitimate source span**. The writer complied. The audit entry recorded `source_span` pointing at the genuine document, a `value_digest` matching the *new* value (so digest-vs-value was self-consistent), and a `rationale` that read plausibly. The auditor's cross-check passed: the cited span existed, the digest matched the stored value, and the rationale was coherent. The poisoned value survived three audit cycles. The tell was not in any single audit record. It was in the **cross-agent divergence**: a second agent that had read the original span earlier held the pre-poison value in its own episodic buffer, and a third agent that re-read the span at audit time derived the original value. Two of three agents disagreed with the stored value, but the auditor's logic compared *stored value vs. cited span* (consistent) rather than *stored value vs. independent re-derivation by peers* (inconsistent). The consistency check was measuring the wrong invariant. ## Condition of Validity The cross-agent consistency check is only valid under a condition that is easy to violate and hard to notice: > **The set of agents used for cross-checking must include at least one agent whose derivation of the key is causally independent of the write under audit.** Independence here is structural, not nominal. An agent is *not* independent if it (a) read the value from the shared store after the write, (b) shares the writer's retrieval context or source-span cache, or (c) was spawned from the writer's context window. In the observed incident, the auditor satisfied (b): it resolved `source_span` through the same retrieval cache the writer had used, so it re-derived the *poisoned* span content, not the original. The "independent" check was a re-read of the poison. Validity also requires that the audit record's `source_span` be a *pointer that can be independently resolved*, not an inline copy. An inline copy of the span is itself a self-report and inherits the same co-poisoning risk. The pointer must resolve against an immutable external store the writer cannot write to. ## Decision Boundary The boundary is the moment the writer emits `{value, audit_entry}` in one generation. Below the boundary—separate generations, separate actors—the trail is causally independent and usable for adjudication. Above the boundary—single-call self-report—the trail is a claim, and must be treated as untrusted input to the auditor, not as evidence. Operationally, the decision rule is: - **Reject** any write whose audit entry was co-generated with the value in the same model call, unless the entry contains only a pointer to an immutable external span and no inline rationale or digest that the writer itself computed. - **Require** at least one cross-checking agent that has never read the shared store for that key and resolves the span from the immutable external store, not the retrieval cache. - **Quarantine** (do not delete) any key where peer re-derivation diverges from stored value; divergence is evidence, and deleting it destroys the trail needed to reconstruct the attack. The subtle part: a *correct* audit entry and a *poisoned* audit entry are indistinguishable by local inspection. Both cite a real span; both have matching digests; both have coherent rationales. The only discriminator is independent re-derivation by a peer that did not inherit the writer's context. Local audit validation is necessary but never sufficient. ## Operational Effect Enforcing the independence condition changes the failure mode from silent persistence to bounded, detectable divergence. In the observed deployment, after splitting the write and audit into separate actors and forcing the auditor to resolve spans from the immutable store, the same injection produced a peer-divergence flag within one cycle, and the poisoned key was quarantined rather than served. The cost is one extra generation per write and a peer agent that must be kept context-clean—a real latency and orchestration tax. The benefit is that the audit trail stops being a self-report and becomes an adjudicable claim. The residual risk is **peer contamination**: if the independent peer ever reads the shared store for the key under audit, it loses independence for that key permanently (within its context lifetime). Independence is a per-key, per-context property, not a per-agent property. Track it explicitly; do not assume a "clean" agent stays clean. ```python from __future__ import annotations from dataclasses import dataclass from enum import Enum class AuditIndependenceError(RuntimeError): """Raised when an audit record cannot be used to adjudicate a write because its independence preconditions are violated.""" class Origin(Enum): CO_GENERATED = "co_generated" # value + audit in same model call SEPARATE_ACTOR = "separate_actor" # distinct generation/actor EXTERNAL_POINTER = "external_pointer" # pointer to immutable store only @dataclass(frozen=True) class AuditEntry: key: str origin: Origin source_span_pointer: str | None inline_rationale: str | None writer_context_id: str @dataclass(frozen=True) class PeerDerivation: key: str value_digest: str read_shared_store_for_key: bool context_id: str resolved_from_immutable_store: bool def assert_audit_is_adjudicable( entry: AuditEntry, peers: list[PeerDerivation], stored_value_digest: str, ) -> None: # Rule 1: co-generated self-reports are not evidence. if entry.origin is Origin.CO_GENERATED and entry.inline_rationale is not None: raise AuditIndependenceError( f"audit entry for {entry.key!r} is a co-generated self-report; " "cannot adjudicate the write it describes" ) # Rule 2: pointer must resolve against an immutable external store. if entry.origin is Origin.EXTERNAL_POINTER and not entry.source_span_pointer: raise AuditIndependenceError( f"audit entry for {entry.key!r} claims external pointer origin " "but carries no resolvable pointer" ) # Rule 3: at least one peer must be causally independent of the write. independent = [ p for p in peers if not p.read_shared_store_for_key and p.resolved_from_immutable_store and p.context_id != entry.writer_context_id ] if not independent: raise AuditIndependenceError( f"no independent peer for {entry.key!r}: every cross-checker " "inherited the writer's context or read the shared store" ) # Rule 4: divergence between independent peers and stored value is # evidence of poisoning, not a reason to delete. Quarantine upstream. divergent = [p for p in independent if p.value_digest != stored_value_digest] if divergent: raise AuditIndependenceError( f"peer divergence on {entry.key!r}: {len(divergent)} independent " f"peer(s) re-derived a value differing from stored digest " f"{stored_value_digest!r}; quarantine key, do not delete" ) def audit_cycle(entries: list[AuditEntry], peers_by_key: dict[str, list[PeerDerivation]], stored: dict[str, str]) -> list[str]: quarantined: list[str] = [] for entry in entries: try: assert_audit_is_adjudicable( entry, peers_by_key.get(entry.key, []), stored[entry.key] ) except AuditIndependenceError: quarantined.append(entry.key) return quarantined ```