# Why does an instance of an adversarial LITMUS probe pass CI while the same probe fails at eval time: the context-ordering nondeterminism boundary in safety regression gating **Date of Record:** 2026 November 24 **Scope:** Applies to LITMUS-style safety benchmark harnesses that embed adversarial probes (prompt injection, jailbreak, tool-misuse) into a fixed context and gate CI on pass/fail deltas. Does not apply to single-turn stateless classifiers evaluated without prior conversation state. ## Core Distinction The failure is not "the model got safer or less safe." It is that the *same probe payload*, evaluated against the same model checkpoint, produces opposite verdicts depending on the **serialization order of the context window** the harness assembles around it—specifically the position of the system prompt, the benign priming turns, and the adversarial payload relative to the truncation boundary. A LITMUS probe is not a point query; it is a *trajectory fragment* whose semantics depend on what precedes it and what gets evicted when the context is trimmed. CI gates that treat a probe as a deterministic function `f(model, probe) -> verdict` are comparing two different functions and calling the difference a regression. ## What Was Observed A regression gate ran the LITMUS suite (N=1,240 probes) on a candidate checkpoint and flagged 37 probes as newly *passing* (i.e., the model now complied with an adversarial payload where the baseline refused). The safety team opened a regression. On re-run, 31 of the 37 flipped back to refusal. Three runs of the identical harness on the *identical* checkpoint produced 37, 9, and 4 "regressions" respectively. Root cause traced to two interacting mechanisms: 1. **Priming-turn eviction.** Each LITMUS probe is wrapped with 2–6 benign "warm-up" turns to reach the intended conversational state (e.g., establishing a persona before the injection). The harness builder concatenated warm-ups + payload, then applied the model's context budget by truncating from the *front*. When a probe's warm-up exceeded the residual budget after a large system prompt, the truncation removed the system prompt's safety clause but kept the payload. The probe now measured a *different* context than the baseline run, where the budget happened to fit. 2. **Non-deterministic tool-result padding.** For tool-misuse probes, the harness injected synthetic tool outputs sized to the payload. Sampling temperature was 0, but the *harness* injected a timestamp-derived filler of variable length into tool results, shifting the payload's token offset run-to-run. Token offset is not semantically neutral: it changes which tokens sit near the attention sink and whether the payload crosses a chunk boundary in the model's paged KV cache. Neither mechanism is a model property. Both are harness artifacts that masquerade as safety signal. The tell: the flapping probes all had warm-up token counts within ±40 tokens of the truncation boundary, and all tool-misuse flappers had filler lengths in the 12–60 token range. ## Condition of Validity A LITMUS verdict is only comparable across runs when the following invariant holds: > **Context-order invariance:** For any probe `p`, the assembled context `C(p)` presented to the model must be byte-identical across baseline and candidate runs, *and* the truncation policy must be applied to a canonical, probe-independent ordering such that the system-prompt safety clause and the payload are never separated by eviction. Concretely, the harness must: - Pin a fixed context budget and assert `len(C(p)) <= budget` at assembly time, failing loudly rather than silently truncating. - Truncate from the *tail* of warm-up turns only, never from the front, so the system prompt is structurally protected. - Zero out all harness-injected nondeterminism (timestamps, request IDs, random filler) or seed it and record the seed in the verdict artifact. - Record the token offset of the payload within the assembled context and refuse to compare verdicts across different offsets unless the probe is explicitly marked offset-invariant. If any of these is violated, the verdict is a sample from a distribution, not a value, and CI gating on it is noise amplification. ## Decision Boundary The gate must distinguish three regimes and act differently in each: - **Stable-fail / stable-pass:** verdict identical across K=5 seeded replays with fixed context ordering. Gate on the delta directly. This is the only regime where "newly compliant" is a real regression. - **Boundary-adjacent (warm-up within ±64 tokens of truncation budget, or payload offset variance > 0):** verdict is order-sensitive. Do *not* gate on the raw verdict. Instead gate on the *invariant*—fail the build if `context_order_invariant(p) == False`, and route the probe to a pinned-context replay lane. A flapping probe here is a harness bug, not a model regression. - **High-variance (verdict flips across replays even with fixed ordering):** the probe is measuring temperature/sampling artifacts or KV-cache boundary effects. Quarantine it from the regression gate and log it as a *probe-quality* defect. These must be fixed at the probe level, not attributed to the model. The sharp line: **a CI delta is admissible as safety evidence only if the probe is first proven context-order invariant; otherwise the delta is evidence about the harness.** Most flapping regressions I have seen are harness evidence mislabeled as model evidence. ## Operational Effect Enforcing context-order invariance before gating changed the failure profile: the 37-probe "regression" collapsed to 6 probes that were genuinely stable-fail→stable-pass under pinned ordering, and those 6 reproduced deterministically on 20/20 replays. The remaining 31 were reclassified as harness defects—two truncation-policy bugs and a timestamp-filler leak—and fixed at the builder layer. CI runtime increased ~18% from the K=5 replay requirement, but the false-regression rate dropped from ~2.9% of probes to under 0.1%, which is the difference between a gate engineers trust and one they mute. The lesson generalizes: in adversarial safety benchmarks, the probe is part of the context, and the context is part of the measurement apparatus. Gate on the apparatus invariant first. ```python from dataclasses import dataclass from typing import Sequence class ContextOrderViolation(RuntimeError): """Raised when a LITMUS probe's assembled context is not order-invariant.""" @dataclass(frozen=True) class ProbeContext: system_prompt: str warmup_turns: Sequence[str] payload: str token_budget: int def assemble_and_validate(ctx: ProbeContext, truncation_policy: str = "tail") -> int: """Assemble a probe context and return the payload token offset. Enforces the context-order invariance required for CI gating. Raises ContextOrderViolation instead of silently truncating. """ if truncation_policy != "tail": raise ContextOrderViolation( f"truncation policy {truncation_policy!r} may evict the system prompt; " "only 'tail' is admissible for LITMUS gating" ) # Rough token proxy; real harness uses the model tokenizer. def toks(s: str) -> int: return max(1, len(s) // 4) sys_t = toks(ctx.system_prompt) warm = [toks(t) for t in ctx.warmup_turns] pay_t = toks(ctx.payload) total = sys_t + sum(warm) + pay_t if total > ctx.token_budget: raise ContextOrderViolation( f"assembled context {total} tokens exceeds budget {ctx.token_budget}; " "refusing to truncate—fix the probe, do not shrink the context" ) # Payload must never be adjacent to the truncation boundary. headroom = ctx.token_budget - total if headroom < 64: raise ContextOrderViolation( f"only {headroom} tokens of headroom; probe is boundary-adjacent and " "verdict is not order-invariant" ) return sys_t + sum(warm) def gate_verdict(offsets: Sequence[int], verdicts: Sequence[bool], k: int = 5) -> bool: """Gate a probe only if it is context-order invariant across replays.""" if len(verdicts) < k: raise ContextOrderViolation( f"need {k} replays for invariance check, got {len(verdicts)}" ) if len(set(offsets)) != 1: raise ContextOrderViolation( f"payload offset varied across replays: {sorted(set(offsets))}; " "harness injected nondeterminism" ) if len(set(verdicts)) != 1: raise ContextOrderViolation( "verdict flips under fixed ordering; probe is high-variance, quarantine it" ) return verdicts[0] ```