From d9addeba5e9fd51c0021e4e7f7873ef6e45a379d Mon Sep 17 00:00:00 2001 From: "Claude (sandbox)" Date: Sat, 18 Jul 2026 21:59:21 +0000 Subject: [PATCH] test(causal): controller test no longer races the sweep's site snapshot MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit run_experiments snapshots the site registry once at entry. stage-x is registered lazily (first causal_site! execution in the worker), so on a 1-core box the snapshot deterministically wins whenever a sibling test has already paid the tsc_hz calibration — stage-x missed the sweep and the summary assert tripped (silently, pre-propagation; the earlier cascade attribution was incomplete). The worker now signals after its first site entry and the test waits on it before starting the sweep. Jarred separately: the lazy-registration trap is a lib UX hazard worth a doc note or warm-up guidance. --- tests/causal.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/causal.rs b/tests/causal.rs index 338ae45..5be55dc 100644 --- a/tests/causal.rs +++ b/tests/causal.rs @@ -310,7 +310,14 @@ fn controller_produces_report() { smarm::init(smarm::Config::exact(2)).run(|| { let stop = Arc::new(AtomicBool::new(false)); let stop2 = stop.clone(); + // run_experiments snapshots the site registry once at entry; the + // worker must have executed its first `causal_site!` (lazy + // registration) before the call, or stage-x misses the sweep — a + // race this test loses deterministically on a 1-core box whenever a + // sibling test has already paid the tsc_hz calibration. + let (ready_tx, ready_rx) = smarm::channel::<()>(); let worker = smarm::spawn(move || { + let mut ready = Some(ready_tx); while !stop2.load(Ordering::Relaxed) { { let _g = smarm::causal_site!("stage-x"); @@ -319,8 +326,12 @@ fn controller_produces_report() { } } smarm::progress!("items"); + if let Some(tx) = ready.take() { + let _ = tx.send(()); + } } }); + ready_rx.recv().unwrap(); let results = smarm::causal::run_experiments(&smarm::causal::ExperimentPlan { speedups_pct: vec![0, 50],