From 01d37b6da33b86442cb8dba4c7ac007999ac752f Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 1 Aug 2026 21:53:22 +0000 Subject: [PATCH] fix(tests): stop clear_fault_emits_fault_cleared_event racing its siblings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The event sender is global and the test binary runs tests in parallel, so the drain loop sees FaultCleared events from any test that clears a fault — and eleven of them do. The loop's Ok(_) arm skips other event kinds but not other tests' FaultCleared, so whichever arrives first is asserted against this test's id, comparing two unrelated uuids. Guard the arm on the id so the loop skips what its comment always said it skipped. Observed failing in CI; the same code passes on other branches, which is the flake. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01CgdfXBAnSEj5s24gbJyXHi --- crates/core/src/runtime/faults/tests.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/core/src/runtime/faults/tests.rs b/crates/core/src/runtime/faults/tests.rs index 95179390..53bcc3da 100644 --- a/crates/core/src/runtime/faults/tests.rs +++ b/crates/core/src/runtime/faults/tests.rs @@ -311,14 +311,16 @@ fn clear_fault_emits_fault_cleared_event() { clear_fault(&db, &id, &app("myapp")).expect("clear"); // Drain again looking for our FaultCleared, skipping any interleaved - // events from other parallel tests. + // events from other parallel tests. The id guard is load-bearing: the + // sender is global, several sibling tests clear faults of their own, and + // without it the first FaultCleared from any of them is asserted against + // this test's id. let mut found = false; loop { match rx.try_recv() { Ok(seedling_protocol::events::OiEvent::FaultCleared { id: eid, app, kind, .. - }) => { - assert_eq!(eid, id); + }) if eid == id => { assert_eq!(app, "myapp"); assert_eq!(kind, "script_error"); found = true;