From ffaab117ef5152ed2af1b2673b739080000bb97b Mon Sep 17 00:00:00 2001 From: Omar Sobh Date: Mon, 21 Sep 2026 10:36:39 -0500 Subject: [PATCH] test(runtime): wait for the suspend checkpoint before reading the run state RunSuspended is journaled before the run row is checkpointed, so the event can arrive milliseconds before the state; CI run 6485 read Running in that window. Poll up to 2 s. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01WZb5A2kfVfjpdwSochkuHz --- crates/cm-runtime/tests/interception.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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,