diff --git a/crates/cm-runtime/tests/interception.rs b/crates/cm-runtime/tests/interception.rs index e05698d..9fa2faa 100644 --- a/crates/cm-runtime/tests/interception.rs +++ b/crates/cm-runtime/tests/interception.rs @@ -153,7 +153,18 @@ async fn start_gated_run( // Blocked: nothing executed, run suspended, approval queued. assert_eq!(outbox_count(pool).await, 0); - let run = cm_db::repo::runs::get(pool, started.run_id).await.unwrap(); + // The loop journals `RunSuspended` BEFORE it checkpoints the run row + // (deliberately — resume must continue from the right sequence number), + // so the event can arrive a few milliseconds before the state does. CI + // run 6485 read `Running` in that window; a loaded runner widens it. + let mut run = cm_db::repo::runs::get(pool, started.run_id).await.unwrap(); + for _ in 0..50 { + if run.state == RunState::AwaitingApproval { + break; + } + tokio::time::sleep(std::time::Duration::from_millis(40)).await; + run = cm_db::repo::runs::get(pool, started.run_id).await.unwrap(); + } assert_eq!( run.state, RunState::AwaitingApproval,