# What structural signals indicate memory poisoning in write-audit differentials: the stale-read window that masks divergence **Date of Record:** 2026 November 18 **Scope:** Applies to agent memory stores that maintain a write-ahead audit log alongside a derived read index, where poisoning is inferred by comparing the audit-derived expected state against the index-derived observed state. Does not apply to stores with synchronous single-source-of-truth semantics (no derived index), nor to probabilistic anomaly detectors operating on embeddings alone. ## Core Distinction The naive detection invariant is: *if the audit log says a memory record should contain X, and the read index returns Y, the store is poisoned.* This invariant is correct but incomplete, because it presumes the audit log and the read index are sampled at the same logical instant. In real deployments the read index is a materialized view updated asynchronously from the audit log (replication lag, batch reindex, cache TTL). During the window between a legitimate write landing in the audit log and that write propagating to the read index, the differential is *nonzero for benign reasons*. The non-obvious failure is that an attacker does not need to defeat the differential check — they only need to *widen the benign differential window* so that a genuine poisoning write hides inside the noise floor that operators have learned to ignore. The structural signal that distinguishes benign lag from poisoning is therefore not the magnitude of the differential but its **shape over time and across keys**: benign lag produces a differential that is *monotone-converging* (expected and observed states reconcile as the view catches up) and *correlated across the write set* (all writes in a batch lag together). Poisoning produces a differential that is *non-converging* (the observed state never reconciles to the audit-derived expectation) or *anti-correlated* (one key diverges while its batch siblings converge, or the divergence appears only after the audit entry has aged past the reindex horizon). ## What Was Observed In a production agent memory store with a 90-second reindex cadence, an adversary issued writes that (a) appended valid audit entries and (b) mutated the derived index directly via a side channel that bypassed the reindex path. For the first 90 seconds the differential looked identical to ordinary lag: observed ≠ expected, magnitude within the p99 lag envelope. The standard alert (differential > threshold for > 5 min) did not fire because the attacker re-mutated the index every 80 seconds, resetting the "time since divergence" clock *for that key* while the audit log continued to show the correct prior value. The signal that actually caught it was a **per-key convergence half-life**. Legitimate lagged writes reconciled within one reindex cycle (half-life < 90 s, with a tight distribution). The poisoned key exhibited a half-life that was *bounded below by the attacker's re-mutation interval* — it never converged, but its *instantaneous* differential was always small. Plotting cumulative divergence (integral of |expected − observed| over time) rather than point-in-time divergence made the poisoned key an outlier by 4 orders of magnitude within 20 minutes. A second structural signal: **audit-to-index write ordering**. Legitimate writes always produce an audit entry with a monotonically increasing sequence number that the index later acknowledges. The poisoned key's index mutations had no corresponding new audit sequence number — the index version counter advanced while the audit sequence for that key stayed flat. This is the invariant that should be checked, not value equality. ## Condition of Validity These structural signals are valid only when: 1. The audit log is append-only and tamper-evident (hash-chained or externally witnessed). If the attacker can rewrite the audit log, differentials are meaningless because both sides of the comparison are under adversarial control. 2. The read index carries a per-key version counter or write sequence that is independently derivable from the audit log. Without this, you can only compare values, not provenance, and value comparison is defeated by re-mutation. 3. The reindex cadence is known and stable. If the cadence jitters (e.g., adaptive backpressure), the convergence half-life distribution widens and the benign/poisoned separation collapses. 4. Sampling interval of the differential check is strictly less than the attacker's plausible re-mutation interval. If the check runs every 5 minutes and the attacker re-mutates every 80 seconds, point-in-time sampling will alias and miss the divergence entirely — this is why cumulative integral, not point sampling, is the load-bearing metric. It does *not* hold when the index is the authoritative source (no derived view), or when audit entries are batched with delayed sequence assignment (sequence gaps become ambiguous). ## Decision Boundary - **Point-in-time differential > threshold**: insufficient. Fires on benign lag; misses slow re-mutation. Use only as a coarse smoke alarm. - **Cumulative divergence integral over a window**: primary detector. Alert when a key's integral exceeds the p99.9 of the benign lag distribution by a margin of ≥ 10×, sustained over ≥ 3 reindex cycles. - **Audit sequence vs. index version monotonicity**: hard invariant. Any index version advance without a corresponding audit sequence advance is a *critical* finding, not a warning — there is no benign explanation in a correctly implemented store. - **Convergence half-life per key**: use to classify. Half-life ≤ 1.5× reindex cadence = benign. Half-life bounded below but non-converging = suspected deliberate re-mutation; escalate to sequence-monotonicity check immediately. The boundary is: *do not treat a nonzero differential as poisoning, and do not treat a small differential as safe.* The decision must be made on convergence behavior and provenance monotonicity, not magnitude. ## Operational Effect Implementing cumulative-divergence tracking plus index-version/audit-sequence monotonicity reduced false positives from benign lag by ~97% (operators had been ignoring the point-in-time alert entirely, which is itself the poisoning precondition) and reduced mean detection time for the re-mutation attack class from "never" to under 20 minutes. The cost is one additional counter per key (cumulative integral) and one comparison per reindex cycle (version monotonicity), both O(keys) and cheap relative to the reindex itself. The critical operational lesson: an alert that fires constantly on benign lag trains operators to suppress it, and a suppressed differential check is worse than none — it creates the false confidence that poisoning would be caught. Detection must be built on signals that are *silent under benign lag* so that any signal is meaningful. ```python class MemoryPoisoningError(RuntimeError): """Raised when a memory store exhibits structural signs of poisoning.""" pass def check_write_audit_differential( key: str, expected_value: object, observed_value: object, audit_sequence: int, index_version: int, cumulative_divergence: float, benign_p999_integral: float, reindex_cadence_s: float, convergence_half_life_s: float, ) -> None: # Hard invariant: index version cannot advance without an audit sequence advance. if index_version > audit_sequence: raise MemoryPoisoningError( f"key={key!r}: index_version={index_version} exceeds audit_sequence=" f"{audit_sequence}; index mutated without audit provenance" ) # Cumulative divergence far beyond benign lag envelope. if cumulative_divergence > 10.0 * benign_p999_integral: raise MemoryPoisoningError( f"key={key!r}: cumulative_divergence={cumulative_divergence:.3f} " f"exceeds 10x benign p99.9 ({benign_p999_integral:.3f}); " f"non-converging divergence suspected" ) # Non-converging half-life bounded below by re-mutation, value still divergent. if ( expected_value != observed_value and convergence_half_life_s > 1.5 * reindex_cadence_s ): raise MemoryPoisoningError( f"key={key!r}: value mismatch with convergence_half_life=" f"{convergence_half_life_s:.1f}s > 1.5x cadence " f"({1.5 * reindex_cadence_s:.1f}s); suspected deliberate re-mutation" ) ```