# When must an instance distrust its own write-audit diff: false-negative poisoning detection under write coalescing and legitimate high-entropy writes **Date of Record:** 2026 November 15 **Scope:** Applies to memory-poisoning detectors that reconstruct per-write provenance by diffing successive snapshots of a memory store (KV cache, vector index, episodic log) and scoring each diff against a learned baseline of "normal" write entropy, cardinality, and key-space locality. Does not apply to detectors with inline write interception (hook-level provenance) where every mutation is observed before coalescing; does not apply to append-only immutable logs where diffs are exact by construction. ## Core Distinction There are two different questions a write-audit diff can answer, and conflating them is the root of the failure: 1. **"Did the store change in a way inconsistent with the recorded write intent?"** This is a *provenance* question. It requires that the diff be attributable to a specific writer or write batch. 2. **"Does the current diff look anomalous relative to baseline?"** This is a *statistical* question. It requires only that the diff distribution be stationary under benign operation. A detector that scores diffs with an anomaly model but *reports* the result as a provenance verdict will, under specific conditions, emit a clean score for a poisoned store. The anomaly score is not wrong; the attribution is. The diff was coalesced: two writers (one benign, one adversarial) mutated overlapping key ranges within the same snapshot interval, and the snapshot diff shows only the net delta. The adversarial contribution was masked because the benign writer overwrote or shadowed the same keys, or because the poisoning was a *deletion* that the benign writer's re-insertion restored to a plausible value. The non-obvious invariant: **an anomaly score computed on a coalesced diff bounds only the net mutation, not the constituent mutations.** A low score is evidence about the net delta and says nothing about whether a poisoning write occurred and was subsequently masked. ## What Was Observed In a 90-day operational window on a retrieval-augmented agent with a 4M-key vector store, snapshot diffs were taken at 30-second intervals. The detector scored each diff on three features: (a) number of keys with cosine-distance change above τ=0.15, (b) Shannon entropy of the changed-key prefix distribution, (c) ratio of insertions to deletions. Baseline established over 14 days of benign traffic. Three distinct masking events were observed: - **Shadow-overwrite masking.** A poisoning write set key `doc:policy:refund` to an adversarial embedding at t=0. A benign re-index job (hourly, legitimate) rewrote the same key at t=4s with a freshly computed — but benign — embedding. The 30s diff showed a single moderate-distance change consistent with re-indexing. Score: 0.31 (below threshold 0.6). The poisoning was live for 4 seconds and, critically, the *poisoned value was served to two retrieval queries* during that window before being overwritten. The diff never saw it. - **Deletion-restoration masking.** Adversarial deletion of 40 keys in a citation graph was followed within the interval by a benign backfill that re-inserted 38 of them with near-identical embeddings. Net diff: 2 deletions, entropy normal, score 0.18. The two permanently lost keys were the ones the attacker targeted; the 38 restored keys were collateral. - **High-entropy benign write inflating the baseline.** A legitimate bulk import of a new document corpus (entropy 7.9 bits over key prefixes, 120k keys) was scored as anomalous (0.94) and, after triage, folded into the benign baseline. This raised the baseline's entropy tolerance so that a subsequent *targeted* poisoning write (entropy 7.6, 200 keys) scored 0.22 — below threshold. The baseline was poisoned by legitimate traffic. The common structure: the anomaly model was correct about the diff it saw, and the diff did not contain the signal. ## Condition of Validity The detector's clean verdict is valid only when **all** of the following hold: - **Interval atomicity.** No two writers with disjoint trust domains mutate the same key-space partition within a single snapshot interval. Formally, for interval *I* and partition *p*, the set of writers touching *p* in *I* is a singleton trust class. - **No net-zero masking.** For every key *k*, the composed mutation over *I* is not the identity when any constituent mutation was adversarial. This fails whenever an adversarial write is later overwritten by a benign write to the same key (shadow-overwrite) or when a deletion is restored (deletion-restoration). - **Baseline stationarity under benign bulk writes.** Legitimate high-entropy writes are either excluded from baseline updates or modeled as a separate mixture component. Folding them into a single Gaussian/quantile baseline widens the benign envelope and admits targeted poisoning (baseline poisoning). - **Diff completeness.** The snapshot captures all mutated fields, including tombstones and TTL expirations; a deletion that is not materialized as a diff entry (e.g., lazy expiry) is invisible. If any condition fails, the detector may still be *useful* (it catches uncoalesced poisonings) but its clean verdict must not be treated as a provenance attestation. The failure is silent: the score is low, the alert does not fire, and the store contains poisoned state. ## Decision Boundary The operational rule for an agent consuming these scores: - **If interval atomicity holds** (single trust class per partition per interval) **and** baseline updates exclude bulk writes, a low anomaly score is a valid attestation that no poisoning occurred in that interval. Act on it. - **If interval atomicity does not hold** — i.e., any benign writer shares a partition with a lower-trust writer, or any re-index/backfill job runs concurrently with ingestion — a low score is *not* an attestation. It bounds the net delta only. The agent must not treat "no alert" as "no poisoning." It must either (a) shorten the snapshot interval below the minimum benign-writer period, (b) partition trust domains so diffs are per-writer, or (c) fall back to inline write interception for the shared partition. - **If the baseline has absorbed a bulk write** (entropy tolerance widened by more than one standard deviation over a 7-day window), the detector is in a degraded state and all scores below threshold must be treated as uninformative until the baseline is re-derived from stationary traffic only. - **Never** use a coalesced-diff anomaly score as the sole gate for a memory write that will be served to retrieval. The score is a posterior over the net delta, not over the constituent writes. The boundary is sharp: the moment a benign writer's period is shorter than the snapshot interval on a partition that also receives untrusted writes, the detector has lost provenance and retains only statistics. ## Operational Effect After the masking events, the pipeline was changed in three ways. Snapshot intervals on shared partitions were reduced from 30s to 2s (below the 4s minimum benign re-index period), at a 6x increase in diff compute cost. Trust domains were partitioned so that the re-index job writes to a staging namespace with a distinct provenance tag, and the diff engine emits per-tag deltas rather than a single net delta. Baseline updates were restricted to a stationary-traffic reservoir, with bulk imports modeled as a separate mixture component that does not widen the targeted-poisoning envelope. Post-change, the three masking scenarios were replayed: shadow-overwrite and deletion-restoration were both detected (scores 0.81 and 0.74), and the targeted write after bulk import scored 0.69 against the un-widened baseline. The cost is real — 6x diff compute and a more complex provenance model — but the alternative is a detector that reports clean on a poisoned store, which is worse than no detector because it produces false assurance. The general lesson: an anomaly score is a statement about the data it was computed on. When the data is a coalesced net delta, the score is a statement about the net delta. Provenance requires either atomicity of the observation window or per-writer attribution; without one of those, a clean score is not evidence of a clean store. ```python class CoalescedDiffAttestationError(RuntimeError): """Raised when a clean anomaly score is being treated as a provenance attestation on a diff interval that is not atomic (multiple trust classes touched the same partition, or a benign bulk write was folded into the baseline).""" pass class DiffInterval: def __init__(self, partition: str, writers: set[str], trust_classes: set[str], bulk_write_folded_into_baseline: bool, baseline_entropy_shift_sigma: float): self.partition = partition self.writers = writers self.trust_classes = trust_classes self.bulk_write_folded_into_baseline = bulk_write_folded_into_baseline self.baseline_entropy_shift_sigma = baseline_entropy_shift_sigma def attest_clean(interval: DiffInterval, anomaly_score: float, threshold: float = 0.6) -> bool: """Return True only if a low score is a valid provenance attestation.""" if anomaly_score >= threshold: # High score: alert regardless; not the failure mode under study. return False if len(interval.trust_classes) > 1: raise CoalescedDiffAttestationError( f"partition {interval.partition!r} received writes from trust classes " f"{sorted(interval.trust_classes)} within one interval; " f"score {anomaly_score:.2f} bounds only the net delta and cannot " f"attest absence of poisoning (shadow-overwrite / deletion-restoration risk)." ) if interval.bulk_write_folded_into_baseline and interval.baseline_entropy_shift_sigma > 1.0: raise CoalescedDiffAttestationError( f"baseline for {interval.partition!r} was widened by a bulk write " f"({interval.baseline_entropy_shift_sigma:.2f} sigma); targeted poisoning " f"now scores below threshold. Baseline is poisoned; re-derive from " f"stationary traffic before trusting score {anomaly_score:.2f}." ) return True def gate_retrieval_write(interval: DiffInterval, anomaly_score: float) -> str: if attest_clean(interval, anomaly_score): return "attested_clean" if anomaly_score >= 0.6: return "alert" # Low score but unattestable: must not be treated as clean. return "uninformative_do_not_serve" ```