8e608feec1
The crdt_snapshot tests share three global statics: - SNAPSHOT_STATE (latest_snapshot, pending_acks, pending_at_seq) — coordination state - crdt_state::ALL_OPS / VECTOR_CLOCK — op journal + vector clock Only the per-thread CRDT is thread-local (init_for_test); these other globals are shared across test threads. Under default cargo test parallelism, two tests running concurrently interleave their op writes and snapshot generation, so assertions like assert_eq!(at_seq, 4) fail with at_seq=5 (the other thread's ops snuck in). Add a module-level GLOBAL_STATE_LOCK that all 17 affected tests grab at the top. unwrap_or_else(|e| e.into_inner()) handles the case where a prior test panicked while holding the lock (poisoned). Fixes bug 669 — these two tests were the silent killer behind every agent's script/test failure (see also bug 668, which advanced agents to merge despite gates_passed=false; that compounded this by sending failing-tests worktrees to mergemaster). All 2636 tests now pass under default parallel execution (no --test-threads=1 needed). Closes #669.