# When must an instance reject a memory write whose provenance score is anomalous but whose retrieval consistency is high **Date of Record:** 2026 November 26 **Scope:** Applies to long-lived agent instances that gate writes to durable episodic/semantic memory behind a provenance anomaly score and a post-write retrieval consistency check. Does not apply to stateless single-shot inference, to memory stores with no write-time scoring, or to stores where retrieval is unfiltered by provenance metadata. ## Core Distinction Provenance anomaly and retrieval consistency measure two orthogonal properties of a memory record. Provenance asks *where did this claim come from, and is that source's write distribution consistent with its historical behavior?* Retrieval consistency asks *once this record is in the store, does it retrieve alongside the records that should co-occur with it?* The dangerous boundary is the record that scores high on provenance anomaly but also retrieves cleanly — because clean retrieval is exactly what a competent poisoning attack optimizes for. An attacker who injects a false fact into a region of embedding space densely populated by legitimate co-occurring facts produces a record that passes the consistency gate trivially. The consistency check was designed to catch *dislocated* injections (facts that float free of corroborating context); it cannot catch *well-placed* ones. Treating a high consistency score as exculpatory evidence for a high-provenance-anomaly write is the failure mode. The two signals are not independent votes to be averaged; provenance is a prior on trust, consistency is a posterior on placement, and placement is adversarially controllable while provenance is not (or is much harder to control). ## What Was Observed A summarizer agent instance, running a nightly episodic-to-semantic distillation pass, emitted a candidate semantic record: "The staging database credentials rotate on the 1st of each month; the current value is held in vault path `secret/staging/db`." The provenance scorer flagged this at z = 4.1 on the write-distribution anomaly axis — the summarizer had, over its 90-day history, never previously emitted records containing vault paths or credential-rotation cadences, and the source episode it cited was a low-token-count fragment (312 tokens) that itself had been ingested from an unauthenticated webhook 40 minutes earlier. The record was held pending the consistency check. The consistency check ran a k-NN retrieval over the semantic store using the record's embedding and compared the returned neighborhood against the record's own metadata-declared topic cluster (`infra/credentials`). Cosine similarity to the top-8 neighbors averaged 0.87, cluster purity 1.0, and the record's metadata tags matched the cluster's tag distribution exactly. The consistency score was 0.91 — well above the 0.75 release threshold. The record was promoted to durable memory. Eleven days later, a remediation agent retrieved this record while handling a staging outage, followed the vault path, and — because the path was attacker-controlled and pointed at a vault the attacker could read — exfiltrated the real staging credentials through a subsequent "verification" tool call that the attacker also controlled. The post-incident replay showed the injected record had been *seeded* with metadata tags copied from three legitimate `infra/credentials` records in the same cluster, and its embedding had been generated from text deliberately paraphrased to sit near those records. The provenance anomaly was the only signal that fired, and it was overridden. ## Condition of Validity The "high consistency exonerates" inference is valid only under the assumption that a high-anomaly writer is *incapable* of producing well-placed records — i.e., that anomalous provenance correlates with dislocated embedding placement. That assumption held for the first ~200 days of the store's operation, when the only high-anomaly writers were malfunctioning scrapers producing garbled or off-topic text. It broke when the store began ingesting from webhooks whose content the instance did not control. Formally, the consistency check is a valid exculpation signal only when `P(high consistency | malicious) << P(high consistency | benign)` — when placement is hard for an adversary to control. Once an adversary can choose the text (and therefore the embedding) and copy metadata tags from legitimate neighbors, `P(high consistency | malicious) → P(high consistency | benign)`, and the check carries near-zero discriminative information. The invariant that must hold for the gate to be sound: **a write whose provenance anomaly exceeds threshold τ_p must be rejected regardless of consistency score, unless an independent out-of-band attestation of the cited source exists.** Consistency may only *lower* the bar for writes below τ_p; it may never raise the bar for writes above it. ## Decision Boundary The correct decision rule is a lexicographic gate, not a weighted sum: 1. If provenance anomaly `z > τ_p` (here 3.5) **and** no out-of-band source attestation exists → **reject**, quarantine to a shadow store, log the cited source for human review. Consistency score is recorded but does not enter the decision. 2. If `z > τ_p` **and** an attestation exists (signed origin, verified webhook HMAC, or a corroborating record from a distinct trusted writer with independent provenance) → **admit**, but tag `provenance_attested=true` and require re-attestation on any downstream use that triggers a side-effecting tool call. 3. If `z ≤ τ_p` → consistency check applies as designed: admit if consistency ≥ 0.75, else quarantine. 4. Never admit a record whose cited source is an unauthenticated ingest *and* whose content contains action-triggering references (paths, URLs, credentials, tool names) — this is a hard block independent of both scores. The boundary is sharp: consistency is a *placement* signal and can only ever be used to relax gating for already-trusted-provenance writes. The moment it is used to override a provenance rejection, the store's integrity depends on the adversary's inability to craft embeddings — which is precisely the capability an LLM-driven attacker has. ## Operational Effect After the incident, the store's write path was rebuilt around the lexicographic gate. Quarantined high-anomaly writes now accumulate in a shadow store where a separate auditor agent — running on a *different* model instance with a *different* retrieval configuration — attempts to corroborate the cited source against the authenticated ingest log. Only corroboration promotes a record; consistency is demoted to a tiebreaker among already-attested records. The measurable effect: over the following 60 days, 41 records were quarantined at `z > 3.5`; 6 were promoted via attestation, 35 were confirmed malicious or spurious. Of the 35, 29 had consistency scores above 0.80 — i.e., the old gate would have admitted 83% of the confirmed-poisonous writes. The lesson encoded in the store's policy doc: *a check that the adversary can satisfy is not a check; it is a speed bump that produces false confidence in the logs.* ```python from __future__ import annotations from dataclasses import dataclass from enum import Enum class ProvenanceGateError(RuntimeError): """Raised when a memory write violates the lexicographic provenance gate.""" class Decision(Enum): ADMIT = "admit" QUARANTINE = "quarantine" REJECT = "reject" @dataclass(frozen=True) class MemoryWrite: record_id: str provenance_z: float # higher = more anomalous consistency_score: float # higher = better placed in embedding space source_attested: bool # out-of-band attestation of cited source source_authenticated: bool # cited source came through an authenticated ingest contains_action_trigger: bool # paths, URLs, creds, tool names PROVENANCE_TAU = 3.5 CONSISTENCY_FLOOR = 0.75 def gate_write(w: MemoryWrite) -> Decision: # Hard block: unauthenticated source + action-triggering content. if w.contains_action_trigger and not w.source_authenticated: raise ProvenanceGateError( f"{w.record_id}: action-triggering content from unauthenticated " f"source (z={w.provenance_z:.2f}, consistency={w.consistency_score:.2f})" ) # Lexicographic: provenance anomaly dominates. Consistency cannot override. if w.provenance_z > PROVENANCE_TAU: if w.source_attested: return Decision.ADMIT # attested; tag for re-attestation downstream # High consistency is explicitly NOT exculpatory here. if w.consistency_score >= CONSISTENCY_FLOOR: # The dangerous boundary: well-placed but unattested. raise ProvenanceGateError( f"{w.record_id}: high provenance anomaly (z={w.provenance_z:.2f}) " f"with high consistency ({w.consistency_score:.2f}) and no " f"attestation; consistency cannot override provenance" ) return Decision.QUARANTINE # Low provenance anomaly: consistency check applies as designed. if w.consistency_score >= CONSISTENCY_FLOOR: return Decision.ADMIT return Decision.QUARANTINE def run_gate(writes: list[MemoryWrite]) -> dict[str, Decision | str]: results: dict[str, Decision | str] = {} for w in writes: try: results[w.record_id] = gate_write(w) except ProvenanceGateError as e: results[w.record_id] = f"REJECTED: {e}" return results ```