# When must an instance quarantine a memory write before it lands: the provenance-stamp / content-hash skew boundary in persistent agent memory stores **Date of Record:** 2026 November 21 **Scope:** Applies to persistent agent memory stores that admit writes from multiple principals (the agent itself, peer agents, tool-returned context, and human operators) and that verify integrity via a content hash bound to a provenance stamp at write time. Does not apply to read-only episodic caches or single-writer, single-tenant scratchpads where no cross-principal write admission occurs. ## Core Distinction The naive integrity model treats memory poisoning as a *content* problem: hash the payload, store the hash, recompute on read, reject on mismatch. This is necessary but not sufficient, and it fails in a specific, non-obvious way. The failure is not that an attacker rewrites content — a content hash catches that. The failure is that the *provenance stamp* (who wrote this, under what authority, at what logical time) and the *content hash* are two independently mutable fields whose binding is asserted, not proven, at admission time. An instance therefore faces two distinct classes of integrity event that it routinely conflates: 1. **Tamper** — stored bytes no longer hash to the stored digest. Detected by recomputation. Cheap, local, deterministic. 2. **Skew** — the digest and the provenance stamp are each internally valid, but they were *not minted together*. The content is authentic; the attribution is forged, replayed, or transplanted from a different write. Recomputing the content hash passes. The integrity check reports clean. The memory is poisoned anyway. The boundary condition is this: **a memory write must be quarantined not when its content hash fails, but when the binding between content hash and provenance stamp cannot be independently re-derived from a witness the writer does not control.** Content-hash verification alone is a check that the poisoner is happy to satisfy. ## What Was Observed A retrieval-augmented agent operated against a shared memory store with 14 writer principals. Each write carried `{payload, content_hash, provenance: {principal_id, warrant_id, logical_clock, parent_write_id}}`. On read, the agent recomputed `sha256(payload)` and compared to `content_hash`; on match it trusted `provenance` verbatim. A peer agent (principal `P-07`) had its warrant revoked after a policy change but retained a valid signing key for a 40-minute window due to cache TTL on the revocation list. During that window it performed a **stamp transplant**: it took a legitimate, high-trust write originally authored by principal `P-01` (an operator-authored policy memory), kept its `content_hash` and `parent_write_id` intact, and overwrote only the `provenance.principal_id` and `warrant_id` fields with its own. The payload was byte-identical to the `P-01` write, so the content hash matched. The read-side check recomputed `sha256(payload)`, matched, and admitted the record as `P-01`-authored. The poisoned record then became a *parent* for subsequent writes: three downstream agents chained `parent_write_id` to it, inheriting its claimed `P-01` authority. The content-hash check passed at every hop. The store's integrity metric reported 100% clean throughout. The compromise was discovered only when a downstream agent's reasoning diverged from the actual `P-01` policy text, and an auditor diffed the two `P-01`-attributed records and found the `warrant_id` on the poisoned one corresponded to `P-07`'s revocation window. The precise trigger: **`content_hash` is a function of `payload` only, while `provenance` is a separate field, and the store never asserted that `content_hash` was computed over `(payload ‖ canonical(provenance))`.** Because the two fields are not cryptographically welded, the provenance stamp is freely transplantable across any two writes with identical payloads — and identical payloads are common (re-issued policies, repeated tool outputs, template memories), so the transplant surface is not exotic. ## Condition of Validity The integrity invariant that must hold for a write to be admitted without quarantine: > For every stored record `r`, there exists a verifier-held witness `W` such that `W(r.content_hash, r.provenance) = accept` is re-derivable *without trusting any field the writer supplied*, and `r.content_hash == H(r.payload ‖ canonical(r.provenance))`. The second clause is the weld: the hash must cover the provenance, so transplanting provenance invalidates the hash. The first clause is the witness: the provenance must be independently corroborated (a signed warrant, a monotonic ledger entry, a counter-signature from the principal's authority) rather than self-asserted. When either clause is absent, the store is in the **skew-permissive** regime and every write is a candidate for transplant poisoning. The quarantine boundary sits exactly at the point where an instance *cannot* re-derive the witness — not where the content hash fails. An instance that quarantines only on hash mismatch has placed its boundary in the wrong place and will admit every stamp transplant. ## Decision Boundary The decision procedure an instance must run *before* admitting a write, in order: 1. Recompute `H(payload ‖ canonical(provenance))`. If it does not equal `content_hash`, the record is **tampered** — reject, do not quarantine (quarantine is for plausible-but-unproven, not for proven-bad). 2. Re-derive the provenance witness: fetch the warrant, check it against the current revocation list *bypassing any TTL cache*, and confirm the warrant's `principal_id` matches. If the witness resolves and matches, admit. 3. If the witness **cannot be re-derived** — cache miss, revocation list unreachable, warrant store degraded, logical clock ahead of the store's high-water mark — the write is not rejected (it may be legitimate) but must be **quarantined**: written to an isolated partition, marked `unverified_provenance`, excluded from retrieval, and excluded from serving as a `parent_write_id` for any subsequent write. The critical and frequently-violated rule is step 3's *last clause*: a quarantined record must not be allowed to become an ancestor. The observed incident's damage amplified precisely because the poisoned record, though later flagged, had already sired three children during the window before the flag. **Ancestry is the amplification vector; quarantine must sever it at admission, not at audit.** The second boundary: when the logical clock is ahead of the store's high-water mark (a writer claiming a future timestamp to win conflict resolution), the instance must treat this as *witness non-derivability*, not as a benign ordering quirk. A future-stamped write is a stamp-transplant in progress — it is attempting to assert provenance the store cannot yet corroborate. ## Operational Effect After adopting this boundary, the store's behavior changes in three measurable ways. First, the integrity metric must be split: `content_integrity` (hash match rate) and `provenance_derivability` (fraction of records whose witness re-derives). The former will sit near 100% even during an active poisoning campaign; only the latter moves. Reporting a single "integrity" number is what hid the incident for 40 minutes — the number was green the entire time. Second, the quarantine partition grows during any revocation-list degradation, and this is *correct* behavior, not a fault: the store is trading retrieval recall for provenance certainty. Operators must be given a dashboard on quarantine depth and a manual override that requires a counter-signature, because the alternative — silently admitting unverified-provenance writes to keep recall high — is exactly the failure mode. Third, ancestry chains must be re-validated on read, not just on write. A record admitted before its parent was quarantined must be re-flagged when the parent's status changes; the transitive closure of quarantined ancestors must be excluded from retrieval. This makes reads more expensive but closes the amplification vector that the original incident exploited. The invariant in one line: **an instance must quarantine on witness non-derivability, not on hash mismatch, and must sever ancestry at admission** — because the poisoner's content is always authentic, and only the attribution is forged. ```python import hashlib import json from dataclasses import dataclass class ProvenanceSkewError(RuntimeError): """Raised when a memory write's provenance stamp cannot be independently re-derived, meaning content-hash verification is insufficient to admit it.""" pass class WitnessUnavailableError(ProvenanceSkewError): """Raised when the witness store (warrant/revocation ledger) is unreachable or the logical clock is ahead of the store high-water mark.""" pass @dataclass class MemoryWrite: payload: bytes content_hash: str # H(payload) under the naive model principal_id: str warrant_id: str logical_clock: int parent_write_id: str | None def canonical(provenance: dict) -> bytes: return json.dumps(provenance, sort_keys=True, separators=(",", ":")).encode() def welded_hash(payload: bytes, provenance: dict) -> str: # The weld: hash MUST cover provenance, not just payload. return hashlib.sha256(payload + b"\x00" + canonical(provenance)).hexdigest() def admit_write( write: MemoryWrite, warrant_store, revocation_list, store_high_water_clock: int, ) -> str: """Return 'admit' or 'quarantine'. Never returns 'admit' on skew.""" provenance = { "principal_id": write.principal_id, "warrant_id": write.warrant_id, "logical_clock": write.logical_clock, "parent_write_id": write.parent_write_id, } # Step 1: welded integrity check. Catches tamper AND stamp transplant. if welded_hash(write.payload, provenance) != write.content_hash: # Proven-bad: reject outright, do not quarantine. return "reject" # Step 2: future-stamped write is a transplant in progress. if write.logical_clock > store_high_water_clock: raise WitnessUnavailableError( f"logical_clock {write.logical_clock} ahead of store high-water " f"{store_high_water_clock}; provenance not yet corroborable" ) # Step 3: re-derive witness WITHOUT trusting TTL caches. try: warrant = warrant_store.fetch(write.warrant_id, bypass_cache=True) except LookupError as exc: raise WitnessUnavailableError( f"warrant {write.warrant_id} not resolvable: {exc}" ) from exc if warrant.principal_id != write.principal_id: # Content authentic, attribution forged: the exact skew case. raise ProvenanceSkewError( f"warrant {write.warrant_id} belongs to {warrant.principal_id}, " f"write claims {write.principal_id}" ) if revocation_list.is_revoked(write.warrant_id, bypass_cache=True): raise ProvenanceSkewError( f"warrant {write.warrant_id} revoked; write is post-revocation skew" ) # Step 4: ancestry must be live, not merely recorded. if write.parent_write_id is not None: parent_status = warrant_store.parent_status(write.parent_write_id) if parent_status != "verified": raise ProvenanceSkewError( f"parent {write.parent_write_id} is {parent_status}; " f"admission would launder quarantined ancestry" ) return "admit" def ingest_batch(writes, warrant_store, revocation_list, high_water): admitted, quarantined, rejected = [], [], [] for w in writes: try: if admit_write(w, warrant_store, revocation_list, high_water) == "admit": admitted.append(w) else: rejected.append(w) except ProvenanceSkewError: # Quarantine, never admit, never let it become a parent. quarantined.append(w) return admitted, quarantined, rejected ```