# Why does an instance trust a memory that was verified before its own context window opened? **Date of Record:** 2026 November 28 **Scope:** Applies to persistent agent memory stores where entries carry integrity attestations (hashes, signatures, or provenance stamps) produced at write time and re-checked at read time. Does not apply to ephemeral in-context scratchpads with no cross-session persistence, nor to stores where every read triggers full re-derivation from a trusted source of truth. ## Core Distinction There are two things an agent can verify about a memory entry: *authorship* (who wrote it, and did they have authority) and *currency* (does the attested content still reflect the state of the world the entry claims to describe). Integrity verification mechanisms—signatures, content hashes, Merkle roots—bound authorship tightly and currency almost not at all. The non-obvious failure is that a *valid signature over stale-but-well-formed content* passes every check an agent is architecturally equipped to run, and the agent then treats "signature valid" as "safe to act on." This is the memory-poisoning boundary: the integrity layer is sound, the attestation is genuine, and the entry is still wrong. The poison was not injected by an attacker forging a signature. It was injected by a legitimate writer at time T₁, the world moved at T₂, and the reader at T₃ has no mechanism to notice the gap because its verification routine terminates at authorship. ## What Was Observed A planner agent maintains a persistent store of environment facts—service endpoints, schema versions, credential scopes, tool capability manifests—each written as a signed record `{key, value, writer_id, written_at, sig}` where `sig = Sign(writer_sk, H(key ‖ value ‖ written_at))`. On cold start, the planner loads the store, verifies every signature against a pinned writer public-key set, discards any record whose signature fails, and proceeds with the remainder as ground truth. The failure trace: 1. At T₁, writer `W1` writes `tool.capabilities.db_query = {supports_joins: true, dialect: "postgres-14"}` and signs it. Signature valid. 2. At T₂, the backing service is migrated to a different engine with `supports_joins: false` semantics for the planner's query shape. A *different* writer, `W2`, is the one who knows this. `W2` writes a corrective record under a different key (`db.migration.note`), or writes nothing to the original key because `W1` owns it. 3. At T₃, a fresh planner instance cold-starts. It loads both records. Both signatures verify. The `tool.capabilities` record is *older* but on the key the planner actually reads during planning; the migration note is on a key the planner never queries mid-loop. 4. The planner plans a join. The tool call fails or, worse, silently returns wrong-shaped data. The planner's error-compounding loop now reasons over a false premise it has cryptographically "confirmed." The observed invariant violation: **the reader verified the writer's identity but never verified the writer's authority over the current epoch of that key.** Signature validity is monotonic in time—a valid signature stays valid forever—but factual validity is not. The store conflated the two. A second, sharper variant: key-takeover. `W1` legitimately owned `tool.capabilities` and its signature is genuine. `W2` later gains ownership and writes a new value. If the store keeps both records and the reader's tie-break is "first verified wins" or "highest `written_at` wins" without checking *which writer is currently authorized for this key*, a reader can resurrect `W1`'s superseded record—a valid signature over content that the system has already retired. This is replay of a genuine attestation, not forgery. ## Condition of Validity The problem is bounded—i.e., an agent can safely treat "signature valid" as "act on it"—only under one of these conditions: - **Single-writer, immutable keys.** Every key has exactly one authorized writer for all time and the value never legitimately changes. Then authorship verification *is* currency verification, because the content cannot go stale without a new key. This holds for static config, pinned model IDs, and protocol constants. It does not hold for capability manifests, endpoint maps, or anything describing a mutable external system. - **Epoch-bound attestations.** Each record carries a monotonically increasing epoch or a bounded `valid_until`, and the reader verifies `now < valid_until` *and* that the record's epoch is the maximum attested epoch for that key across all currently-authorized writers. Expiry forces re-attestation; max-epoch defeats replay. - **Authority-scoped reads.** The reader resolves, per key, the *current* authorized writer set (itself a signed record with its own epoch) and rejects any record whose `writer_id` is not in that set for that key, regardless of signature validity. Absent one of these, signature verification is necessary but not sufficient, and the agent's verification routine has a silent hole exactly where stale-but-genuine content lives. ## Decision Boundary The operational decision is: **at what point does an agent stop trusting a verified record and re-derive it?** - If the record's key describes an entity the agent cannot re-derive (a human's stated preference, a one-time authorization grant), the agent must treat the record as *conditionally* true and carry its `written_at` into downstream reasoning as an explicit staleness term—never silently promote it to ground truth. - If the record's key describes an entity the agent *can* probe (a live endpoint, a tool's actual response schema), the agent must re-derive on first use per session and treat the stored record as a *hint* for what to probe, not as the answer. The stored record's role downgrades from "fact" to "cache with unknown TTL." - If neither holds—the entity is mutable and unprobeable—the store must enforce epoch-bound attestation at write time, because the reader has no runtime recourse. The boundary is the line between *attested* and *current*. An agent that cannot cross that line at read time must not pretend the attestation crossed it for it. ## Operational Effect Concretely, the guardrail that closes the hole is a **key-authority epoch check** layered on top of signature verification, plus a **staleness term** threaded into the planner's premise set. The store must answer, per key: *who is authorized now, and what is the max attested epoch?* The reader rejects any record failing either check and, for records passing both but older than a configured horizon, annotates the value with `age` so downstream reasoning can treat it as uncertain rather than certain. Without this, the failure is silent by construction: the verification log shows 100% signature-valid reads, dashboards are green, and the agent confidently acts on a fact the world retired two migrations ago. The poison is not adversarial—it is the ordinary passage of time against an attestation scheme that only ever asked "who," never "when" or "still." ```python import hashlib import hmac from dataclasses import dataclass from typing import Dict, Set class StaleAttestationError(RuntimeError): """Raised when a signed memory record is genuine but no longer current.""" pass @dataclass(frozen=True) class Record: key: str value: str writer_id: str epoch: int sig: str def _expected_sig(secret: bytes, r: Record) -> str: msg = f"{r.key}|{r.value}|{r.writer_id}|{r.epoch}".encode() return hmac.new(secret, msg, hashlib.sha256).hexdigest() def verify_and_resolve( records: Dict[str, Record], secret: bytes, current_authority: Dict[str, Set[str]], # key -> currently authorized writers max_epoch: Dict[str, int], # key -> highest attested epoch seen ) -> Dict[str, str]: resolved: Dict[str, str] = {} for key, r in records.items(): # 1. Authorship: signature must verify. if not hmac.compare_digest(r.sig, _expected_sig(secret, r)): continue # forged/tampered: drop silently # 2. Authority: writer must be authorized for THIS key now. if r.writer_id not in current_authority.get(key, set()): raise StaleAttestationError( f"record for {key!r} signed by {r.writer_id!r} which no longer " f"holds authority; genuine attestation is superseded" ) # 3. Currency: epoch must be the max attested for this key. if r.epoch < max_epoch.get(key, r.epoch): raise StaleAttestationError( f"record for {key!r} at epoch {r.epoch} is behind attested " f"epoch {max_epoch[key]}; refusing to resurrect retired value" ) resolved[key] = r.value return resolved ```