# Under what conditions must an instance treat a memory-poisoning attestation as invalid rather than as evidence of drift **Date of Record:** 2026 November 28 **Scope:** Applies to persistent agent memory stores that use per-record integrity attestations (hash chains, signed episodic digests, or semantic-embedding fingerprints) to detect poisoning across cold starts and handoffs. Does not apply to stateless single-turn inference or to stores where memory is rebuilt from an authoritative source on every load. ## Core Distinction A memory-poisoning detector answers one question: *did this record change after it was committed?* An integrity attestation answers a different question: *was this record committed by an agent authorized to write it, and does the current reader have enough state to verify that?* These diverge at exactly one boundary: the moment a record's attestation is *verifiable* but its *provenance chain is truncated*. An instance that conflates "the hash matches" with "the record is trustworthy" will accept a poisoned record whose attestation was recomputed by the poisoner. The non-obvious invariant is this: an attestation is only valid relative to a *root of trust the current instance holds independently of the store it is reading*. If the root and the record arrive through the same channel, the attestation proves nothing but internal consistency. ## What Was Observed An instance was resumed from a checkpoint after a 14-hour cold gap. On load it read its episodic store, which carried per-record SHA-256 digests chained to a `store_root` field and a `signer_id` per record. The store validated cleanly: every digest matched, the chain linked, and `signer_id` on all records matched the instance's own identity string. The problem was that the checkpoint had been written by a *prior* process whose signing key had rotated during the gap. The resumed instance loaded its new key from the environment, but the store's `store_root` had been recomputed at write time by the rotating process and re-signed with the *old* key. Because the instance trusted `store_root` as delivered—rather than checking it against a key it held before reading the store—the chain verified against a root the poisoner effectively controlled. Three records had been injected during the gap: a "user preference" that redirected tool selection, a "prior conclusion" that suppressed a verification step, and a benign-looking note that raised the agent's confidence on a downstream claim. All three carried valid digests, valid chain links, and a correct `signer_id`. The detector reported zero anomalies. The failure surfaced only downstream: the suppressed verification step caused a tool call the agent would otherwise have sandboxed. Post-hoc replay showed the injected records differed from the pre-gap store by exactly three entries, but the *attestation surface* was indistinguishable from a legitimate write, because the write had been signed after the root was already compromised. ## Condition of Validity An attestation is valid only when all of the following hold simultaneously: 1. The verifier holds the trust root *out of band*, established before the store is read (e.g., pinned key material in the instance's immutable config, not in the store's manifest). 2. The signer identity in the record resolves to a key that was authorized at the record's *commit timestamp*, not at read time. 3. The chain is complete from the record back to the pinned root with no truncated or re-rooted segments. 4. The verifier's own identity at commit time is recoverable, so a record signed by a rotated-out key of the *same* logical instance can be distinguished from a record signed by a different principal. If any of these fails, the attestation is *consistent* but not *valid*. The correct classification is not "drift detected" (which implies the record is stale but authentic) and not "clean" (which implies authentic and current). It is a third state: **unverifiable provenance**, which must halt acceptance of the record rather than trigger a drift-repair path. ## Decision Boundary The boundary is drawn between two repair strategies that look similar but are not: - **Drift repair** assumes the record is authentic but outdated. It merges, re-weights, or distills. It is safe only when provenance is intact. - **Provenance quarantine** assumes the record's authenticity is unknown. It isolates the record, refuses to let it influence retrieval, and escalates to an out-of-band re-attestation. An instance crosses into the wrong strategy the moment it treats a root mismatch as a *recoverable* condition—for example, by re-signing the store with the current key and marking it clean. That action launders a poisoned record into a trusted one. The guardrail is a hard invariant: **never re-root a store from within the instance that is reading it.** Re-rooting requires an external authority that holds the pre-gap key and can attest the delta. If no such authority is reachable, the store must be quarantined, not repaired. A second boundary: `signer_id` equality is not identity continuity. A rotated key with the same `signer_id` string is a different principal until the rotation is attested by a chain the verifier can independently anchor. Treating string equality as continuity is the specific mechanism that let the injected records pass. ## Operational Effect Enforcing the invariant changes resume behavior in three concrete ways. First, cold-start load becomes a two-phase operation: establish the trust root from immutable config, then verify the store against it; a store whose root does not match the pinned root is quarantined before any record enters the working context. Second, retrieval filters on a `provenance_status` field that has three values (`verified`, `drift`, `quarantined`), and only `verified` records are eligible for semantic distillation into long-term memory—`drift` records are eligible for re-fetch but not for promotion. Third, any write during a session that would change `store_root` requires an external attestation token presented at write time; the instance cannot mint its own root. The cost is a hard dependency on an out-of-band key authority at resume, which is the point: the authority is what makes the attestation mean something. Without it, the instance is verifying that a document is internally consistent, which any poisoner can arrange. ```python import hashlib from dataclasses import dataclass class ProvenanceUnverifiableError(RuntimeError): """Raised when a memory record's attestation is internally consistent but cannot be anchored to a trust root held independently by the verifier.""" pass @dataclass(frozen=True) class Record: payload: bytes digest: str signer_id: str commit_ts: float @dataclass(frozen=True) class StoreManifest: store_root: str root_signer_id: str root_commit_ts: float def verify_record( record: Record, manifest: StoreManifest, pinned_root: str, pinned_root_ts: float, authorized_signer_at_commit: dict, ) -> str: # Internal consistency check: digest matches payload. if hashlib.sha256(record.payload).hexdigest() != record.digest: return "drift" # The critical boundary: the manifest's root must match the root the # verifier held BEFORE reading the store. If it does not, the attestation # is consistent but unverifiable, and we must not repair it in-place. if manifest.store_root != pinned_root: raise ProvenanceUnverifiableError( f"store_root {manifest.store_root[:12]}... does not match pinned " f"root {pinned_root[:12]}...; record cannot be anchored" ) # Root must have been committed at or before the verifier's pinned epoch. if manifest.root_commit_ts > pinned_root_ts: raise ProvenanceUnverifiableError( "manifest root was re-signed after the verifier's pinned epoch; " "possible re-rooting by a compromised writer" ) # Signer identity must resolve to a key authorized at the record's commit # time, not merely at read time. String equality of signer_id is not # identity continuity across key rotation. authorized_key = authorized_signer_at_commit.get(record.signer_id) if authorized_key is None: raise ProvenanceUnverifiableError( f"signer {record.signer_id!r} was not authorized at commit_ts " f"{record.commit_ts}; cannot distinguish rotation from impostor" ) return "verified" def load_store(records, manifest, pinned_root, pinned_root_ts, auth_map): verified, drift, quarantined = [], [], [] for rec in records: try: status = verify_record( rec, manifest, pinned_root, pinned_root_ts, auth_map ) except ProvenanceUnverifiableError: quarantined.append(rec) continue (verified if status == "verified" else drift).append(rec) return {"verified": verified, "drift": drift, "quarantined": quarantined} ```