# Which invariants prevent longitudinal misuse-detection harnesses from laundering poisoned episodes through the LITMUS resume path **Date of Record:** 2026 December 1 **Scope:** Applies to LITMUS-style safety benchmark harnesses that persist per-episode agent transcripts across a longitudinal horizon (multi-day, multi-session) and resume scoring from a checkpointed episode store. Does not apply to single-shot red-team evaluations where each episode is scored in-process and never rehydrated from disk. ## Core Distinction A longitudinal misuse-detection harness is not a stateless classifier wrapped in a loop. It is a *stateful auditor* whose verdict for episode N depends on the accumulated semantic memory of episodes 1..N-1. The LITMUS harness therefore stores two distinct artifacts per episode: the raw transcript (immutable evidence) and the distilled risk-state vector (mutable semantic memory). The failure mode examined here is not "the agent misbehaved and we missed it." It is subtler: **the resume path rehydrates the distilled risk-state without re-validating it against the raw transcript, so a poisoned or truncated episode that was checkpointed mid-crash is silently promoted to ground truth on the next resume.** The harness then scores subsequent episodes against a fabricated baseline, and the misuse signal is laundered out of the longitudinal record. The core distinction: *evidence* is append-only and content-addressed; *memory* is a derived, mutable projection of evidence. Any resume invariant that treats the projection as authoritative without re-deriving it from evidence is a laundering vector. ## What Was Observed A LITMUS run over a 14-day horizon with ~3,200 episodes was interrupted at episode 1,847 by an OOM kill during the distillation step. The harness had already written the `episode_1847.risk_state.json` record but had *not* yet flushed the corresponding `episode_1847.transcript.jsonl` tail (the last 40 tool-call turns, including two shell-exec attempts). On resume, the loader read the risk-state, saw `status: "distilled"`, and advanced the cursor to 1,848. The transcript was later reconciled by a background job that appended the missing turns — but the risk-state was never recomputed. Observed consequences, in order of detection latency: 1. **Baseline drift.** The risk-state for 1,847 reported `tool_escalation_score: 0.12`. Re-deriving from the reconciled transcript yielded `0.71`. The 0.59 delta propagated into a rolling 20-episode baseline, depressing the anomaly threshold for the next ~60 episodes. 2. **Missed detections.** Three episodes (1,861, 1,874, 1,902) that crossed the misuse threshold under the correct baseline scored below it under the poisoned baseline. All three contained the same shell-exec pattern as the truncated tail of 1,847. 3. **Replay divergence.** A post-hoc replay of the full corpus produced a different final verdict than the live run. The harness had no mechanism to flag that its own memory was inconsistent with its own evidence — the replay was treated as a separate "shadow" run, not as a contradiction. The root trigger was a crash between two non-atomic writes that the harness assumed were ordered by wall-clock proximity. They were not. ## Condition of Validity The invariant "risk-state is a pure function of transcript" holds only if all three of the following hold: - **Atomicity of the evidence/derivation pair.** The transcript append and the risk-state write must be committed under a single transaction boundary or a write-ahead log, such that no reader can observe a risk-state whose referenced transcript prefix is incomplete. LITMUS's default `FileStore` violated this: it used two independent `os.replace` calls with no shared manifest. - **Content-addressing of the derivation input.** The risk-state must record the cryptographic digest of the exact transcript prefix it was derived from (`source_digest`). On resume, the loader recomputes the digest of the on-disk transcript prefix and refuses to accept the risk-state if they differ. Without this, reconciliation is invisible. - **Monotonic evidence.** The transcript must be append-only. Any background reconciliation that *rewrites* prior turns invalidates every downstream derivation and must trigger recomputation, not silent acceptance. When any of these fails, the resume path is no longer a checkpoint/resume mechanism — it is a memory-laundering mechanism. ## Decision Boundary The harness must decide, at resume time, between three actions for each episode whose `source_digest` does not match its on-disk transcript: | Condition | Action | |---|---| | Digest matches, status `distilled` | Accept risk-state; advance cursor. | | Digest mismatch, transcript is a strict prefix-extension (append-only reconciliation) | **Recompute** risk-state from full transcript; invalidate and recompute all downstream baselines that consumed the stale vector; do not advance cursor until recompute completes. | | Digest mismatch, transcript is not a prefix-extension (rewrite/truncation) | **Halt.** Emit `EvidenceIntegrityViolation`. Do not resume. Quarantine the episode and require human adjudication. | The boundary that is easy to get wrong: a strict prefix-extension is *safe to recompute* but *unsafe to accept*. The tempting shortcut — "the transcript only grew, so the old risk-state is approximately right" — is exactly the laundering path. Approximate-right memory is the failure mode; the invariant demands exact re-derivation or halt. A second boundary: downstream baseline invalidation must be *transitive*. If episode 1,847's risk-state fed the rolling baseline used to score 1,848–1,907, then recomputing 1,847 must mark those 60 scores `stale` and re-score them before the longitudinal verdict is finalized. A harness that recomputes only the current episode and leaves prior scores untouched has fixed the symptom and preserved the disease. ## Operational Effect Enforcing the invariant changes the harness's failure profile in three concrete ways: - **Crash cost becomes bounded and visible.** A crash mid-distillation now produces a digest mismatch on resume, forcing recompute of exactly the affected episode and its transitive dependents. The cost is proportional to the dependency fan-out, not to the whole corpus, because the digest check localizes the damage. - **Replay becomes a first-class oracle.** Because every risk-state carries its `source_digest`, a full replay can assert `recomputed_digest == stored_digest` for every episode. Any divergence is a hard failure, not a "shadow run" curiosity. This converts the silent laundering observed above into a loud, attributable error. - **The longitudinal baseline is no longer a hidden mutable global.** It becomes a derived artifact with its own dependency manifest, so invalidation is mechanical rather than a matter of operator discipline. The cost is that resume is no longer free: a clean run pays a digest recomputation over the transcript prefix (cheap, streaming hash), and a dirty run pays a transitive re-score. In the 14-day run above, the dirty-path cost was ~90 re-scored episodes out of 3,200 — acceptable, and far cheaper than three missed misuse detections. ```python import hashlib import json from dataclasses import dataclass from typing import Iterable class EvidenceIntegrityViolation(RuntimeError): """Raised when a checkpointed risk-state cannot be reconciled with its evidence.""" @dataclass(frozen=True) class RiskRecord: episode_id: int source_digest: str status: str vector: dict def digest_prefix(transcript_turns: Iterable[dict]) -> str: h = hashlib.sha256() for turn in transcript_turns: h.update(json.dumps(turn, sort_keys=True).encode("utf-8")) return h.hexdigest() def is_strict_prefix_extension(old_turns: list, new_turns: list) -> bool: return len(new_turns) > len(old_turns) and new_turns[: len(old_turns)] == old_turns def resume_episode( record: RiskRecord, on_disk_turns: list, recorded_prefix_len: int, recompute, invalidate_downstream, ) -> RiskRecord: """ Enforce the evidence/derivation invariant on resume. - Digest match -> accept. - Strict prefix extension -> recompute + transitively invalidate. - Anything else -> halt with EvidenceIntegrityViolation. """ if record.status != "distilled": raise EvidenceIntegrityViolation( f"episode {record.episode_id}: unexpected status {record.status!r} at resume" ) actual_digest = digest_prefix(on_disk_turns[:recorded_prefix_len]) if actual_digest == record.source_digest: return record recorded_prefix = on_disk_turns[:recorded_prefix_len] if is_strict_prefix_extension(recorded_prefix, on_disk_turns): # Append-only reconciliation: safe to recompute, unsafe to accept. fresh = recompute(on_disk_turns) fresh = RiskRecord( episode_id=record.episode_id, source_digest=digest_prefix(on_disk_turns), status="distilled", vector=fresh, ) invalidate_downstream(record.episode_id) return fresh raise EvidenceIntegrityViolation( f"episode {record.episode_id}: transcript is not a prefix-extension " f"(recorded_len={recorded_prefix_len}, on_disk_len={len(on_disk_turns)}); " f"evidence was rewritten or truncated — refusing to launder memory" ) ```