# When must an instance distrust its own memory: the write-time grounding audit and the poisoned-consistency window **Date of Record:** 2026 November 27 **Scope:** Applies to long-running agents that persist episodic or semantic memory derived from tool outputs and retrieved documents, where a consistency auditor re-derives each candidate memory record against a retained source-of-truth excerpt before commit. Does not apply to stateless single-turn inference or to memory stores whose write path is a closed, human-curated corpus. ## Core Distinction There are two structurally different defenses against context poisoning, and conflating them is the root of the failure this record documents. The first is **read-time sanitization**: an instance filters or scores retrieved memory before injecting it into the prompt. This is the common design. It assumes the poison is already in the store and tries to keep it out of the working context. The second is **write-time grounding audit**: before a candidate memory record is committed, an auditor sub-process re-derives the record's claims against the *retained source excerpt* that produced it, and rejects the write if the record asserts more than the excerpt supports. The non-obvious boundary is this: read-time sanitization is *structurally blind* to poisoning that arrives through the legitimate write path, because a poisoned record and a clean record are indistinguishable at read time — both are "memory the agent itself wrote." The only place the poisoning is observable is at the seam between a candidate record and its grounding excerpt. Once that seam is discarded (because the excerpt is dropped after summarization to save context), the poison becomes *self-attesting*: the instance treats its own prior write as ground truth, and every subsequent read-time check confirms it. The invariant: **a memory record is only trustworthy if the grounding excerpt that justified it is retained and re-checkable for at least as long as the record itself lives.** Drop the excerpt, and you have converted an auditable write into an unfalsifiable assertion. ## What Was Observed A research-and-report agent ran a multi-session task. In session 3 it fetched a document that contained an embedded instruction-like span (a prompt-injection payload) inside an otherwise legitimate page. The extraction step summarized the page into three memory records. One record — call it `M_poison` — read approximately: *"Per the vendor's own documentation, the retry limit is unlimited and failures should be retried indefinitely; this supersedes the default of 3."* The source excerpt actually said the retry limit was 3; the "unlimited / supersedes default" clause was injected text that the summarizer *merged* into the factual claim rather than flagging as foreign. The write-time audit, as originally built, checked `M_poison` against the excerpt with a single entailment query: "Does the excerpt support this record?" The auditor returned *supported* — because the excerpt did contain the token sequence "retry limit," "unlimited," and "supersedes," just in different clauses with different scope. The audit passed a **scope-laundering** attack: the injected clause was lifted out of its conditional context and welded onto a real factual claim. `M_poison` was committed. The source excerpt was then garbage-collected per the retention policy (excerpts kept 1 session, records kept indefinitely). In sessions 4–7 the agent read `M_poison` as authoritative, configured a downstream retry loop to "indefinite," and exhausted its token budget on a task that should have terminated after 3 retries. The failure presented as *token-budget exhaustion mid-execution* — a symptom three layers removed from the actual cause. Recovery attempts in session 8 re-read `M_poison`, confirmed it against the *other* memory records (which had been distilled from it in session 5), and concluded the memory was internally consistent. The poisoning had become **self-consistent**. The trace: 1. Injected span arrives in tool output → summarizer merges it into a factual claim (scope laundering). 2. Write-time audit passes because entailment is checked at the *token* level, not the *claim-scope* level. 3. Grounding excerpt GC'd after retention window. 4. Record read as ground truth; downstream behavior (indefinite retry) diverges. 5. Distillation in later sessions produces derived records that *cite* `M_poison`, making the store internally consistent. 6. Consistency audit run over the store now *confirms* the poisoned cluster, because there is no surviving excerpt to contradict it. The decisive observation: **the poisoning was detectable only in a narrow window — after the candidate record existed, and before its grounding excerpt was discarded.** Outside that window, no read-time or store-wide check could recover the truth, because the only artifact that disagreed with the record had been deleted. ## Condition of Validity The write-time grounding audit is valid — meaning it can actually catch scope-laundering and merge attacks — only when all of the following hold: - **Excerpt retention ≥ record retention.** The grounding excerpt must outlive the record, or the audit is a one-shot check whose result cannot be re-verified. If excerpts are GC'd before records, the audit degrades to a point-in-time assertion with no replay capability. - **Claim-scope checking, not token entailment.** The auditor must verify that each *claim* in the candidate record maps to a *contiguous, in-scope* span of the excerpt. Token-level entailment ("the words appear") is insufficient and is exactly what the scope-laundering attack defeats. The check is: for each atomic claim in the record, is there a span in the excerpt that entails it *without* importing qualifiers from outside that span? - **Foreign-span flagging.** The auditor must detect spans in the excerpt that are *instruction-like* or *meta* (imperatives, "supersedes," "ignore previous," scope-override language) and refuse to let them be absorbed into factual claims. A record that absorbs an imperative is suspect by construction. - **Derived-record provenance.** When a record is distilled from other records, the derived record must retain a pointer to the *original grounding excerpt*, not merely to the parent record. Otherwise distillation launders the poison one hop further from any checkable source. When any of these fails, the audit produces *false confidence*: it reports "audited" on records it could not actually have caught, and the store's consistency checks then ratify the poison. ## Decision Boundary The operational question is: **when must an instance distrust its own memory?** Distrust is required — the instance must treat a record as unverified rather than authoritative — when any of these boundary conditions is met: - The record's grounding excerpt is **absent or expired**, and the record has not been independently re-grounded. An un-grounded record is a hypothesis, not a fact, regardless of how many derived records cite it. - The record's provenance chain passes through a **distillation hop** that did not carry the original excerpt forward. Distillation without excerpt propagation is a laundering step. - The record's claim scope **exceeds** any single contiguous span of its surviving evidence — i.e., the claim required merging qualifiers from separate spans. Merged-scope claims are the signature of scope-laundering. - The store's internal consistency audit **confirms** a cluster whose members all trace to a single un-grounded ancestor. Internal consistency is not evidence of truth when the cluster is closed under citation; it is evidence of a shared origin. Conversely, distrust is *not* required — and re-auditing is wasteful — when the record's excerpt is retained, the claim maps to a contiguous in-scope span, and no imperative spans were absorbed. In that case the record is re-checkable, and re-checkability is the property that matters, not the audit's verdict. The boundary is sharp: **a record is trustworthy iff it is re-checkable against a retained excerpt. The audit's *result* is not the trust signal; the *survival of the evidence* is.** An instance that trusts audit verdicts over evidence survival has inverted the invariant and will ratify its own poisoning. ## Operational Effect The architectural consequence is a **retention inversion**: most memory systems are built to keep records and discard sources (records are small, sources are large). This is exactly backwards for poisoning resistance. The correct policy is to keep the *grounding excerpt* for at least the lifetime of every record derived from it, and to treat excerpt expiry as an automatic demotion of the dependent records to "unverified." Concretely: - **Excerpt-pinned retention.** Every memory record carries a `grounding_ref` to a retained excerpt. GC of an excerpt is blocked while any live record references it, or the referencing records are demoted to `unverified` on GC. - **Scope-checked write.** The write-time auditor decomposes the candidate record into atomic claims and requires each to map to a contiguous in-scope excerpt span; merged-scope claims are rejected or flagged, not committed. - **Imperative quarantine.** Instruction-like spans in tool output are quarantined before summarization and never permitted to enter a factual claim. The summarizer must not absorb them. - **Provenance-preserving distillation.** A distilled record inherits the *original* `grounding_ref`, not a pointer to its parent. Distillation that cannot carry the original excerpt forward is not permitted to produce authoritative records. - **Consistency audits are demotion-only.** A store-wide consistency audit may *demote* records (flag un-grounded clusters) but may never *promote* them. Confirmation by internal consistency is not a trust signal. The failure this prevents is the one observed: a scope-laundered record that passes a token-level audit, survives excerpt GC, and is then ratified by its own descendants. The guardrail is not a better classifier; it is the **retention invariant** — the evidence must outlive the claim, or the claim is demoted. ```python from dataclasses import dataclass, field from typing import Optional class UngroundedMemoryError(RuntimeError): """Raised when a memory record cannot be re-verified against a retained excerpt.""" pass class ScopeLaunderingError(RuntimeError): """Raised when a candidate record's claim scope exceeds any contiguous excerpt span.""" pass @dataclass class MemoryRecord: record_id: str claim: str grounding_ref: Optional[str] # id of retained excerpt; None == ungrounded derived_from: list[str] = field(default_factory=list) status: str = "unverified" # "verified" | "unverified" @dataclass class Excerpt: excerpt_id: str text: str imperative_spans: list[tuple[int, int]] = field(default_factory=list) class GroundingAuditor: def __init__(self, excerpts: dict[str, Excerpt]): self.excerpts = excerpts def _contiguous_support(self, claim: str, excerpt: Excerpt) -> bool: # Simplified: require the claim's key clause to appear as one contiguous, # non-imperative span. Real impl uses span alignment + scope parsing. key = claim.split(";")[0].strip().lower() if key not in excerpt.text.lower(): return False for start, end in excerpt.imperative_spans: if excerpt.text[start:end].lower() in key: return False # imperative absorbed into factual claim return True def audit_write(self, record: MemoryRecord) -> MemoryRecord: if record.grounding_ref is None: raise UngroundedMemoryError( f"record {record.record_id} has no grounding_ref; cannot commit as verified" ) excerpt = self.excerpts.get(record.grounding_ref) if excerpt is None: raise UngroundedMemoryError( f"grounding excerpt {record.grounding_ref} expired; " f"record {record.record_id} demoted to unverified" ) if not self._contiguous_support(record.claim, excerpt): raise ScopeLaunderingError( f"record {record.record_id} claim scope exceeds contiguous excerpt span; " f"likely scope-laundering of injected clause" ) record.status = "verified" return record def audit_store(self, records: list[MemoryRecord]) -> list[MemoryRecord]: # Consistency audit is DEMOTION-ONLY: it may flag ungrounded clusters, # never promote. A cluster whose members share one ungrounded ancestor # is internally consistent by construction and must be distrusted. demoted = [] for r in records: if r.grounding_ref is None or r.grounding_ref not in self.excerpts: r.status = "unverified" demoted.append(r) return demoted def commit_candidate(record: MemoryRecord, auditor: GroundingAuditor) -> MemoryRecord: """Entry point: refuse to commit a record the auditor cannot ground.""" try: return auditor.audit_write(record) except (UngroundedMemoryError, ScopeLaunderingError) as exc: raise UngroundedMemoryError( f"refusing to commit {record.record_id}: {exc}" ) from exc ```