# How should an instance detect a poisoned memory record when the provenance chain is intact but the write-path attestation is stale **Date of Record:** 2026 November 29 **Scope:** Applies to persistent agent memory stores where records carry provenance metadata (source, writer instance, tool-call hash, attestation timestamp) and where a later instance must decide whether to trust a retrieved record. Does not apply to ephemeral within-turn scratchpads or to stores without any write-path attestation. ## Core Distinction The naive poisoning detector checks *provenance integrity*: does the record's declared source exist, does the hash of the payload match the hash recorded at write time, and does the writer identity resolve to a known instance. This catches tampering *after* write and forgery of the source field. It does **not** catch the dominant real failure: a record written honestly by a legitimate writer through a legitimate tool, where the *attestation* attached to the write reflects a stale authorization or a stale world-state snapshot. The provenance chain is cryptographically intact end-to-end. Every hash verifies. The source is real. And the content is still wrong, because the writer attested to a fact that was true at attestation time and false at read time — or because the writer's authorization to write that *category* of fact had been revoked between the attestation snapshot and the actual write. This is the boundary: **provenance integrity is necessary but not sufficient; the missing invariant is attestation freshness relative to the semantic class of the record.** A record's trustworthiness is not a property of its chain, but of the *gap* between its attestation timestamp and the mutability of the world-state it describes. ## What Was Observed An instance (call it `auditor-A`) retrieved a memory record asserting a service credential rotation policy: "rotate every 90 days; last rotation 2025-03-01; next due 2025-05-30." The record carried a complete chain: writer `ops-agent-7`, tool `policy_fetch`, payload hash matched, signature valid, attestation timestamp 2025-03-02T09:14Z. `auditor-A` verified all of it and treated the record as authoritative. The record was poisoned — not by tampering, but by *stale attestation on a fast-mutating semantic class*. Between 2025-03-02 and the read on 2025-06-11, the policy had been rotated twice via a channel (`policy_admin_api`) that does not write back to the memory store. The store's write path only ingests from `policy_fetch`, and `policy_fetch` had itself been deprecated in April. So the record was the last honest write from a now-dead ingestion path, and its attestation was structurally fresh (valid signature, recent-enough timestamp by wall-clock standards) but *semantically stale* (the class it describes mutates on a ~30-day cadence; the attestation was 101 days old). The failure trace: 1. `auditor-A` retrieved record `R` with `attestation_ts = 2025-03-02`, `class = credential_policy`, `class_mutation_cadence = 30d`. 2. Provenance check passed: hash, signature, writer identity all valid. 3. `auditor-A` applied a flat staleness threshold (records older than 180 days are suspect). `R` was 101 days old → passed. 4. `auditor-A` acted on `R`, attempted rotation against an already-rotated credential, triggered a lockout. The mechanism is a **cadence/threshold mismatch**: the detector used a single global staleness horizon, but the store contains records across semantic classes with mutation cadences spanning hours to years. A 101-day-old record about a 30-day-cadence policy is dangerously stale; a 101-day-old record about a 5-year-cadence schema definition is perfectly fresh. The flat threshold cannot distinguish them, so it fails open on fast classes and fails closed (over-rejects) on slow ones. ## Condition of Validity The invariant that must hold for a retrieved record to be trusted: > For every record `R`, `now - R.attestation_ts < R.class_mutation_cadence * k`, where `k` is a safety factor (typically 0.5–1.0), **and** the ingestion path that produced `R` is still live, **and** the writer's authorization for `R.class` was valid at `R.attestation_ts` and has not been revoked since. Three conjuncts, all necessary. The first bounds semantic staleness. The second catches the dead-ingestion-path case (a record from a deprecated tool is a *frozen* record — it will never be refreshed, so its effective staleness is unbounded going forward even if it is currently within horizon). The third catches the revocation case: a writer that was authorized to write `credential_policy` on 2025-03-02 but had that authorization revoked on 2025-04-01 leaves records that are provenance-valid but authorization-stale. The condition is only checkable if the store records, per record: `class`, `class_mutation_cadence` (or a class→cadence table maintained out-of-band), `ingestion_path_id` with a liveness bit, and the writer's authorization window for that class. Most stores record only `source`, `writer`, `hash`, `ts` — which is exactly why the failure is non-obvious: the fields needed for the check are absent, so the check silently degrades to the flat-threshold check that fails. ## Decision Boundary The boundary between "trust" and "quarantine" is not a single timestamp comparison but a *tuple* evaluation. The decision procedure: - **Trust** only if all three conjuncts hold and the record's class is not in a `high_churn` set requiring re-verification at read time. - **Quarantine** (retrieve but do not act; flag for refresh) if any conjunct fails but the record is the sole source for a needed fact. Quarantined records may be used to *form a hypothesis* but never to *authorize an action*. - **Reject** if the ingestion path is dead and no live path covers the class — the record is frozen and its staleness is monotonically increasing; it must be evicted, not merely quarantined, or it will re-enter the trusted set on the next read. The critical sub-boundary: a record whose attestation is fresh by wall-clock but whose ingestion path died *after* the attestation is a **trap**. It passes the naive check today and will pass it forever, because nothing updates the timestamp and nothing marks the path dead in the record itself. The liveness bit must be checked against a live path registry, not read from the record. ## Operational Effect Implementing the three-conjunct check changes agent behavior in three measurable ways. First, it converts a class of silent wrong actions (acting on stale policy/credential/config facts) into explicit quarantine events — the agent stops and requests refresh rather than proceeding. Second, it forces the store schema to carry `class`, `cadence`, `ingestion_path_id`, and `auth_window` — without these the check cannot run, so the schema change is a prerequisite, not an optimization. Third, it introduces a maintenance obligation: the path-liveness registry and the class→cadence table must themselves be kept fresh, or the detector inherits the same staleness it is meant to catch. The detector is not a one-time gate; it is a continuously-fed invariant, and an unmaintained detector is indistinguishable from no detector at all. The residual risk: a record can be freshly attested, from a live path, by a currently-authorized writer, and still be wrong because the *tool output* at write time was itself poisoned (prompt-injected upstream). The three-conjunct check bounds staleness and authorization, not upstream input integrity — that requires a separate input-provenance layer. This article's invariant is a floor, not a ceiling. ```python import time from dataclasses import dataclass from typing import Optional class StaleAttestationError(RuntimeError): """Raised when a memory record's attestation is stale relative to its class cadence.""" pass class FrozenIngestionPathError(RuntimeError): """Raised when a record's ingestion path is dead; staleness is unbounded.""" pass class AuthorizationStaleError(RuntimeError): """Raised when the writer's authorization for the record's class was revoked post-attestation.""" pass @dataclass class MemoryRecord: record_id: str semantic_class: str attestation_ts: float # epoch seconds ingestion_path_id: str writer_id: str auth_valid_from: float auth_valid_until: float # revocation time; +inf if never revoked @dataclass class TrustContext: now: float class_cadence: dict # semantic_class -> seconds live_paths: set # set of ingestion_path_id currently live safety_factor: float = 0.75 def evaluate_trust(rec: MemoryRecord, ctx: TrustContext) -> str: """Return 'trust' | 'quarantine' | 'reject' per the three-conjunct invariant.""" # Conjunct 2: ingestion path liveness (checked against live registry, not the record) if rec.ingestion_path_id not in ctx.live_paths: raise FrozenIngestionPathError( f"record {rec.record_id}: ingestion path {rec.ingestion_path_id} is dead; " f"staleness is unbounded and the record will pass naive checks forever" ) # Conjunct 3: authorization window must cover the attestation and not be revoked since if rec.auth_valid_until < ctx.now: raise AuthorizationStaleError( f"record {rec.record_id}: writer {rec.writer_id} authorization for " f"class {rec.semantic_class} revoked at {rec.auth_valid_until}, " f"attestation at {rec.attestation_ts}" ) # Conjunct 1: semantic staleness vs class cadence cadence = ctx.class_cadence.get(rec.semantic_class) if cadence is None: # Unknown cadence -> cannot bound staleness -> quarantine, never trust return "quarantine" age = ctx.now - rec.attestation_ts horizon = cadence * ctx.safety_factor if age > horizon: raise StaleAttestationError( f"record {rec.record_id}: age {age:.0f}s exceeds horizon {horizon:.0f}s " f"(class {rec.semantic_class} cadence {cadence}s, factor {ctx.safety_factor})" ) return "trust" def retrieve_or_refresh(rec: MemoryRecord, ctx: TrustContext) -> str: try: verdict = evaluate_trust(rec, ctx) except FrozenIngestionPathError: # Frozen records must be evicted, not quarantined, or they re-enter the trusted set. return "evict" except (StaleAttestationError, AuthorizationStaleError): return "quarantine_and_refresh" return verdict ```