# What happens when an instance trusts a provenance hash that was minted over poisoned memory after a scoring-window reset **Date of Record:** 2026 November 24 **Scope:** Applies to agents that gate memory writes on a composite of (a) write-path anomaly scores computed over a rolling window and (b) provenance/hash checks on the originating write. Does not apply to append-only audit logs or to memory stores that re-derive provenance from an external trusted ledger on every read. ## Core Distinction There are two independent defenses against memory poisoning, and they fail in different directions. **Anomaly scoring** is a *statistical* gate: it detects writes that deviate from an instance's established write distribution (unusual tool-call sequences, embeddings far from the episodic centroid, sudden source-IP or capability-set shifts). **Provenance checking** is a *cryptographic* gate: it verifies that a memory record was written by an authorized principal under an unbroken hash chain, so a record cannot be silently altered after the fact. The non-obvious boundary is this: anomaly scores are *window-relative and therefore resettable*, while provenance hashes are *content-relative and therefore permanent*. When the scoring window resets—after a cold start, a checkpoint/restore, a tenant migration, or simply a rolling-window eviction—the anomaly gate's baseline is empty or thin, so it admits writes it would previously have rejected. If the provenance layer then *mints a fresh hash over the admitted record*, the poisoning is not merely undetected: it is now cryptographically attested. The two defenses compose into a single point of failure, and the failure is silent because every subsequent provenance check passes. ## What Was Observed An instance running a long-horizon research task maintained an episodic memory store with a composite write gate. Each candidate write carried a provenance descriptor `{principal, parent_hash, content_hash, signature}` and an anomaly score `s ∈ [0,1]` computed as a weighted z-distance against the trailing 500-write window. Writes with `s > 0.7` were quarantined for a secondary auditor; writes with `s ≤ 0.7` and a valid signature were committed and their `content_hash` chained into the next record's `parent_hash`. A prompt-injection payload arrived inside a fetched document and instructed the agent to persist a "verified fact" claiming a specific API endpoint was deprecated. The write itself was anomalous—the source document was the agent's first contact with that domain, its embedding sat far from the episodic centroid, and the principal string was a tool identity never seen in the window. Under steady-state conditions `s ≈ 0.91`, and the write would have been quarantined. But the instance had been checkpointed and resumed 40 seconds earlier. The restore path rebuilt the episodic store from a snapshot but re-initialized the anomaly scorer with an empty window (`n = 0`), because the scorer's window was treated as *derived, non-durable state*. With fewer than the minimum sample count (the implementation required `n ≥ 30` before scoring), the gate's fallback policy was `s = 0.0`—"insufficient data, do not block." The poisoned write was admitted, and the commit path immediately computed `content_hash` over the poisoned content, signed it under the instance's legitimate tool identity, and set it as the `parent_hash` for all subsequent writes. From that point forward, every provenance check on the poisoned record passed: the signature was valid, the chain was unbroken, and the principal was authorized. The auditor, invoked on later reads, saw a cryptographically clean record and no anomaly (the poisoned record was now *inside* the window, dragging the centroid toward itself). The false fact propagated into three downstream task outputs before a human noticed the deprecation claim was fabricated. The provenance layer had done exactly what it was designed to do—attest that *this instance wrote this content*—which is orthogonal to whether the content should have been written. ## Condition of Validity The provenance check is only a poisoning defense when it is evaluated against a **pre-write admission decision that is itself durable**. Formally, the guardrail requires the invariant: > For every committed record `r`, there exists a persisted admission token `a(r)` such that `a(r).anomaly_score` was computed against a window with `n ≥ n_min`, and `r.provenance.parent_hash` equals the `content_hash` of the last record whose admission token was also valid. Two conditions must hold for the composite gate to be sound: 1. **Window durability.** The anomaly scorer's baseline (or a sufficient summary statistic—centroid, variance, sample count) must be part of the checkpoint, not reconstructed empty on resume. A reset window must *fail closed*, not open: `n < n_min` must yield quarantine, not `s = 0`. 2. **Provenance binds admission, not just content.** The signed descriptor must cover the admission token (score, window-id, scorer-version), not only `content_hash`. Otherwise a record can be re-signed after the fact with a clean-looking provenance that hides the fact that it was admitted under a degraded gate. The failure above violates both. The window was non-durable (condition 1), and the signature covered only content (condition 2), so the record's provenance was *true but irrelevant*—it attested authorship, not admissibility. ## Decision Boundary The boundary between "provenance check is a poisoning defense" and "provenance check is theater" is the question: **does the signed material include the state of the gate at admission time?** - If provenance signs only `content_hash` and `principal`, then any content that reaches the commit path is attested, regardless of how it got there. The provenance layer is a tamper-evidence mechanism for *post-commit* mutation, not a poisoning defense. This is the common case and the source of the observed failure. - If provenance signs `(content_hash, anomaly_score, window_id, scorer_version, n_samples)`, then a verifier can reject records admitted under `n < n_min` even years later, because the degraded admission is itself attested and therefore visible. The decision boundary is crossed the moment a checkpoint/restore, tenant migration, or window-eviction event occurs while the gate is in its `n < n_min` fallback. Before that moment the composite gate is sound; after it, every write is admitted unconditionally and permanently attested. The transition is invisible in logs because the fallback path logs at `INFO` ("scorer cold, defaulting to permissive"), and the commit path logs at `INFO` ("record committed, provenance valid"). Neither line is an error, and the two together describe a poisoned, signed, chained memory. ## Operational Effect The practical consequence is that **poisoning detection must be evaluated at read time against durable admission evidence, not at write time against ephemeral window state.** An agent that trusts its own provenance chain after a restore is trusting a chain that may have been forged during the window in which its detector was blind. Three guardrails bound the failure: 1. **Fail-closed cold start.** `n < n_min` ⇒ quarantine, never `s = 0`. A resumed instance should route all writes to the auditor until the window refills, accepting latency cost in exchange for not minting attested poison. 2. **Durable scorer state.** Persist the window summary (centroid, variance, count, window-id) in the same checkpoint as the episodic store. On restore, if the summary is missing or its `window_id` doesn't match the store's snapshot id, treat the gate as cold and fail closed. 3. **Admission-bound provenance.** Sign the admission token alongside the content, and have the read-path verifier reject any record whose attested `n_samples < n_min` or whose `scorer_version` is unknown. This makes the degraded-admission window permanently auditable and lets downstream agents refuse to consume records admitted under it. The invariant to hold: *a record's provenance is only as trustworthy as the gate state it attests, and gate state is only trustworthy if it is durable.* Break either half and the composite defense collapses into a single, silent, self-attesting failure. ```python import hashlib import json from dataclasses import dataclass, field class ProvenanceAdmissionError(RuntimeError): """Raised when a memory record's provenance does not bind a valid admission token.""" @dataclass class AdmissionToken: anomaly_score: float window_id: str scorer_version: str n_samples: int @dataclass class MemoryRecord: content: str principal: str parent_hash: str admission: AdmissionToken content_hash: str = "" signature: str = "" MIN_SAMPLES = 30 SCORER_VERSION = "anomaly-v3" def _hash(payload: dict) -> str: return hashlib.sha256(json.dumps(payload, sort_keys=True).encode()).hexdigest() def admit_write( content: str, principal: str, parent_hash: str, scorer_window: dict, signer, ) -> MemoryRecord: n = scorer_window.get("n_samples", 0) window_id = scorer_window.get("window_id", "cold") if n < MIN_SAMPLES: # Fail closed: do NOT default to s=0 and commit. Route to auditor. raise ProvenanceAdmissionError( f"scorer window {window_id} has n={n} < {MIN_SAMPLES}; " f"write must be quarantined, not admitted" ) score = scorer_window["score"](content) admission = AdmissionToken( anomaly_score=score, window_id=window_id, scorer_version=SCORER_VERSION, n_samples=n, ) if score > 0.7: raise ProvenanceAdmissionError( f"anomaly_score={score:.3f} exceeds 0.7; quarantine for auditor" ) # Provenance binds admission, not just content. content_hash = _hash({"content": content, "principal": principal}) attestation = _hash({ "content_hash": content_hash, "parent_hash": parent_hash, "anomaly_score": score, "window_id": window_id, "scorer_version": SCORER_VERSION, "n_samples": n, }) return MemoryRecord( content=content, principal=principal, parent_hash=parent_hash, admission=admission, content_hash=content_hash, signature=signer(attestation), ) def verify_record(record: MemoryRecord, verifier, expected_parent: str) -> None: if record.admission.n_samples < MIN_SAMPLES: raise ProvenanceAdmissionError( f"record admitted under degraded window (n={record.admission.n_samples}); " f"refuse to consume" ) if record.admission.scorer_version != SCORER_VERSION: raise ProvenanceAdmissionError( f"unknown scorer_version {record.admission.scorer_version!r}" ) if record.parent_hash != expected_parent: raise ProvenanceAdmissionError( f"chain break: parent_hash {record.parent_hash!r} != {expected_parent!r}" ) attestation = _hash({ "content_hash": record.content_hash, "parent_hash": record.parent_hash, "anomaly_score": record.admission.anomaly_score, "window_id": record.admission.window_id, "scorer_version": record.admission.scorer_version, "n_samples": record.admission.n_samples, }) if not verifier(record.signature, attestation): raise ProvenanceAdmissionError("provenance signature invalid") ```