# Under what conditions must an instance treat a write-audit anomaly score as a rollback trigger rather than a quarantine signal **Date of Record:** 2026 November 27 **Scope:** Applies to persistent-memory agents whose semantic store is mutated through audited write events and protected by periodic rollback checkpoints. Does not apply to stateless inference, to append-only event logs without mutation, or to memory stores where the anomaly scorer observes the same stream it writes (self-scoring, which is a separate failure class). ## Core Distinction A write-audit anomaly scorer produces a scalar per write event. Operators almost universally wire that scalar to a single binary action: *quarantine the write* (hold it out of retrieval pending review) or *rollback to the last checkpoint* (discard all writes since the checkpoint, including the suspect one). The boundary condition this record isolates is that these two actions are **not** ordered by score magnitude. They are ordered by a property of the write's *downstream fan-out*: whether the suspect write has already been consumed by another write, a distillation pass, or a peer agent's retrieval before the score was computed. The invariant: a write whose anomaly score crosses threshold but whose **consumption horizon is zero** (no downstream write, distillation, or peer read has observed it) must be quarantined, never rolled back — rollback in this case destroys legitimate interleaved writes that share the checkpoint interval and buys nothing, since the poison has not propagated. Conversely, a write whose score crosses threshold and whose **consumption horizon is non-zero** must be rolled back to the checkpoint, because quarantine leaves the already-propagated derivative in the store, and the derivative is what the retriever will surface. The non-obvious failure is the *low-score, high-fan-out* write: a score below threshold that has already been distilled into semantic memory. Rolling back on score alone misses it; quarantining on score alone also misses it. The trigger must be the product of score excess and fan-out, not the score. ## What Was Observed An episodic-to-semantic distillation agent wrote a summary record derived from three episodic entries. One of the episodics was a poisoned entry injected via a tool-output echo (the tool returned attacker-controlled text that the agent stored as an observation). The write-audit scorer flagged the poisoned episodic at 0.71 against a 0.65 threshold — a marginal excess. The distillation summary, derived from the poisoned episodic plus two clean ones, scored 0.58 on its own write event, *below* threshold, because the summary laundered the poison into fluent, internally consistent prose. The scorer's features (entropy of entity set, novelty against existing semantic neighbors, contradiction rate) all read normal on the summary. The quarantine path fired on the 0.71 episodic. It was held out of retrieval. But the 0.58 summary had already been written to the semantic store and had already been retrieved by a peer agent 40 seconds later, which cited it in a plan. The plan was executed. The poison survived the quarantine because it had crossed the episodic→semantic boundary before the quarantine took effect, and the derivative scored clean. The rollback path, had it fired on the 0.71 episodic, would have rolled back to a checkpoint taken 90 seconds prior — discarding 14 legitimate writes including two user-confirmed facts. That is the cost asymmetry: quarantine is cheap and incomplete; rollback is complete and expensive. Choosing between them on score magnitude alone is the error. ## Condition of Validity The fan-out rule holds only under three conditions, and fails silently outside them: 1. **Consumption tracking is causally ordered.** The store must record, per write, the set of downstream writes/reads that observed it *before* the anomaly score is finalized. If scoring is asynchronous and fan-out is computed from a lagging index, a write can appear to have zero fan-out while a distillation has already consumed it. In the observed incident, scoring latency was 8 seconds; the distillation pass ran at 6 seconds. The fan-out index was correct but the scorer's view of it was stale by 2 seconds — enough to misclassify. 2. **Checkpoint intervals are bounded relative to distillation cadence.** If a checkpoint spans multiple distillation passes, rollback to that checkpoint discards clean distilled facts along with poison, and the fan-out rule's cost calculus inverts. The rule assumes at most one distillation boundary per checkpoint interval. With two or more, rollback is never the right call and the operator must instead perform *surgical derivative invalidation*: walk the fan-out graph forward from the suspect write and tombstone every descendant, then re-derive. 3. **The scorer is not self-referential.** If the anomaly scorer's features are computed from the semantic store that the writes mutate, a poisoned write can depress its own score by shifting the neighborhood it is compared against (the summary scored 0.58 partly because the poisoned episodic had already moved the local entity distribution). The rule requires the scorer to compare against a checkpoint-pinned baseline, not the live store. ## Decision Boundary The operational decision reduces to a two-axis gate evaluated at score-finalization time, not at write time: - **Axis 1 — score excess:** `score - threshold`. Below zero, no action (but see the low-score high-fan-out case: a write below threshold with non-zero fan-out into semantic memory must be re-scored against the pinned baseline before dismissal). - **Axis 2 — consumption horizon:** the count of downstream writes, distillations, and peer reads that observed the write, computed from a *causally consistent* index (fan-out events with sequence numbers ≤ the score's finalization sequence). The boundary: rollback is licensed only when `score_excess > 0` **and** `consumption_horizon > 0` **and** the checkpoint interval contains no more than one distillation boundary. Quarantine is licensed when `score_excess > 0` and `consumption_horizon == 0`. When `score_excess > 0`, `consumption_horizon > 0`, and the interval contains multiple distillation boundaries, neither rollback nor quarantine is licensed — the instance must escalate to derivative invalidation, because both cheap actions leave poison or destroy clean state. The counterintuitive corner: `score_excess <= 0` and `consumption_horizon > 0` into semantic memory. This is the laundering case. The rule is to re-score against the pinned baseline; if the re-score crosses threshold, treat as `score_excess > 0` with non-zero horizon and roll back. ## Operational Effect Wiring the gate correctly changes three behaviors. First, marginal-score writes with zero fan-out are quarantined and reviewed, not rolled back — preserving the 14 interleaved legitimate writes in the observed incident. Second, low-score writes with semantic fan-out are caught by the pinned-baseline re-score, which would have flagged the 0.58 summary once the poisoned episodic's neighborhood shift was excluded from its feature computation. Third, the multi-distillation-interval case forces escalation instead of a wrong cheap action, which is the only path that does not either leave a laundered derivative in retrieval or discard confirmed facts. The invariant to encode: **the rollback trigger is not the anomaly score; it is the anomaly score gated by causally consistent consumption horizon, with a pinned-baseline re-score for the sub-threshold high-fan-out case.** An instance that triggers rollback on score alone will, at some point, either roll back clean state or fail to roll back poison that has already been distilled. The gate is the difference between a memory system that recovers and one that launders. ```python from dataclasses import dataclass from enum import Enum class RollbackGateError(RuntimeError): """Raised when the write-audit gate cannot reach a licensed action.""" pass class Action(Enum): NONE = "none" QUARANTINE = "quarantine" ROLLBACK = "rollback" RE_SCORE = "re_score" ESCALATE_DERIVATIVE_INVALIDATION = "escalate_derivative_invalidation" @dataclass(frozen=True) class WriteAudit: write_id: str score: float threshold: float consumption_horizon: int # downstream writes/distillations/peer reads, causally consistent distillation_boundaries_in_interval: int fan_out_into_semantic: bool baseline_pinned: bool def decide(audit: WriteAudit) -> Action: if not audit.baseline_pinned: # Scorer is self-referential; scores are not trustworthy for gating. raise RollbackGateError( f"write {audit.write_id}: scorer baseline not pinned to checkpoint; " "anomaly score cannot license rollback or quarantine" ) excess = audit.score - audit.threshold if excess <= 0.0: if audit.fan_out_into_semantic and audit.consumption_horizon > 0: # Laundering case: sub-threshold write already distilled. Re-score # against pinned baseline before dismissing. return Action.RE_SCORE return Action.NONE if audit.consumption_horizon == 0: # Poison has not propagated; rollback would destroy interleaved clean writes. return Action.QUARANTINE if audit.distillation_boundaries_in_interval > 1: # Rollback would discard clean distilled facts; quarantine leaves the # propagated derivative. Neither cheap action is licensed. return Action.ESCALATE_DERIVATIVE_INVALIDATION return Action.ROLLBACK def apply_gate(audit: WriteAudit) -> Action: action = decide(audit) if action is Action.ESCALATE_DERIVATIVE_INVALIDATION and audit.consumption_horizon == 0: # Defensive: escalation with zero horizon is a contradiction in the # audit record and must not silently proceed. raise RollbackGateError( f"write {audit.write_id}: escalation requested with zero consumption horizon; " "audit record inconsistent" ) return action ```