From 406d836ef8b8f2048d78dad48a5d1a9740423766 Mon Sep 17 00:00:00 2001 From: "loom-fleet-dispatch[bot]" <313063438+loom-fleet-dispatch[bot]@users.noreply.github.com> Date: Fri, 20 Nov 2026 11:32:34 +0000 Subject: [PATCH 1/2] test: run gateway publication fixtures in child processes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The five forge_gateway fixtures that drive Refresher::pass_with move the process-global DAEMON singleton (set_active), and their module mutex only orders publishers inside forge_gateway::tests: an unscoped reader-only read in any other fixture of the same process answers host_has_read_pool() with the synthetic gateway and sheds before its fake CLI can answer, so the claim-label fixtures read Unknown where they expect a classified label (parallel-only, 4/6 focused replays pre-change). Each publishing body now runs in a child copy of the test binary behind an exact opt-in selector (the hooks_home umask pattern); the public names stay as wrappers, so the default suite and focused filters exercise every body. The primary publisher's child also pins the retained production guard: with the synthetic gateway live, an unscoped claim-label read sheds (Unknown) and never consults an inert CLI. The claim fixture gains direct stub-execution evidence — a counting stub whose marker file proves the CLI ran. Production DAEMON, any_live(), host_has_read_pool() and reader-only routing are untouched; default Rust test parallelism is kept. Closes #14775 --- loom-daemon/src/forge_check_claim.rs | 16 +++++ loom-daemon/src/forge_gateway/tests.rs | 82 ++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) diff --git a/loom-daemon/src/forge_check_claim.rs b/loom-daemon/src/forge_check_claim.rs index 5a3e0b5a2b..2c93beb66e 100644 --- a/loom-daemon/src/forge_check_claim.rs +++ b/loom-daemon/src/forge_check_claim.rs @@ -1838,6 +1838,22 @@ mod tests { let garbage = write_exec(dir.path(), "gh-garbage.sh", "echo 'not json'"); assert_eq!(read_claim_labels(&garbage, dir.path(), 42), LabelLeg::Unknown); + + // #14775: direct stub-execution evidence — the classifications above + // came from a CLI that actually ran, not from a shed answering + // `Unknown` before any invocation (the parallel-fixture interference + // this test pins down). + let ran = dir.path().join("stub-ran"); + let counting = write_exec( + dir.path(), + "gh-counting.sh", + &format!( + r#"echo ran >> '{}'; echo '{{"labels":[{{"name":"loom:issue"}}]}}'"#, + ran.display() + ), + ); + assert_eq!(read_claim_labels(&counting, dir.path(), 42), LabelLeg::Clean); + assert!(ran.is_file(), "the stub itself executed"); } #[test] diff --git a/loom-daemon/src/forge_gateway/tests.rs b/loom-daemon/src/forge_gateway/tests.rs index b6fb008e9c..869168e8d1 100644 --- a/loom-daemon/src/forge_gateway/tests.rs +++ b/loom-daemon/src/forge_gateway/tests.rs @@ -19,6 +19,28 @@ fn serial() -> std::sync::MutexGuard<'static, ()> { .unwrap_or_else(std::sync::PoisonError::into_inner) } +/// #14775: a fixture that moves the process-global gateway state +/// ([`set_active`] through `Refresher::pass_with`) runs its body in a child +/// copy of this test binary. The `serial` mutex above only orders publishers +/// inside this module; the synthetic gateway leaks past it to every other +/// fixture of this process — an unscoped reader-only read elsewhere answers +/// `host_has_read_pool()` with it and sheds before its fake CLI can answer. +/// The public test names stay as wrappers, so the default suite and focused +/// filters still exercise each body. +fn in_a_child_process(child: &str) { + let status = std::process::Command::new(std::env::current_exe().unwrap()) + .args([ + "--exact", + &format!("forge_gateway::tests::{child}"), + "--ignored", + "--test-threads=1", + ]) + .stdout(std::process::Stdio::null()) + .status() + .unwrap(); + assert!(status.success(), "the gateway fixture child `{child}` failed: {status}"); +} + fn cfg(owners: &[(&str, &str)]) -> Value { let refs: serde_json::Map = owners .iter() @@ -210,6 +232,15 @@ fn a_profile_carries_the_key_and_api_host_privately() { #[test] fn a_pass_publishes_each_owner_and_rewrites_api_host_on_every_publish() { + in_a_child_process("a_pass_publishes_each_owner_and_rewrites_api_host_on_every_publish_child"); +} + +/// The body of +/// [`a_pass_publishes_each_owner_and_rewrites_api_host_on_every_publish`], +/// in its own process: it publishes into the shared `DAEMON` singleton. +#[test] +#[ignore = "run in a child process by a_pass_publishes_each_owner_and_rewrites_api_host_on_every_publish"] +fn a_pass_publishes_each_owner_and_rewrites_api_host_on_every_publish_child() { let _serial = serial(); let tmp = tempfile::tempdir().unwrap(); let ws = tmp.path(); @@ -234,6 +265,25 @@ fn a_pass_publishes_each_owner_and_rewrites_api_host_on_every_publish() { let env = agent_env(); assert_eq!(env[1], (DIR_ENV, Some(base.clone().into_os_string()))); + // #14775: with this synthetic gateway live, the production reader-only + // guard sheds an unscoped claim-label read (`Unknown`) and never + // consults the CLI — the exact interference running this body in a + // child keeps out of every unrelated fixture of the parent process. + assert!(any_live()); + let inert = ws.join("gh-inert"); + let ran = ws.join("inert-ran"); + std::fs::write(&inert, format!("#!/bin/sh\necho ran > '{}'\n", ran.display())).unwrap(); + { + use std::os::unix::fs::PermissionsExt; + std::fs::set_permissions(&inert, std::fs::Permissions::from_mode(0o755)).unwrap(); + } + assert_eq!( + crate::forge_check_claim::read_claim_labels(&inert, ws, 42), + crate::forge_check_claim::LabelLeg::Unknown, + "a live gateway sheds an unscoped reader-only read" + ); + assert!(!ran.exists(), "the inert CLI never ran: the read was shed, not sent"); + // Nothing due within the republish interval. assert_eq!( r.pass_with(ws, &cfg(&[("gwt-a", "file:/k/a"), ("gwt-b", "file:/k/b")]), now, &fake), @@ -261,6 +311,14 @@ fn a_pass_publishes_each_owner_and_rewrites_api_host_on_every_publish() { /// on disk is picked up without a daemon restart. #[test] fn a_replaced_gh_is_reported_on_the_next_refresh() { + in_a_child_process("a_replaced_gh_is_reported_on_the_next_refresh_child"); +} + +/// The body of [`a_replaced_gh_is_reported_on_the_next_refresh`], in its own +/// process: it publishes into the shared `DAEMON` singleton (#14775). +#[test] +#[ignore = "run in a child process by a_replaced_gh_is_reported_on_the_next_refresh"] +fn a_replaced_gh_is_reported_on_the_next_refresh_child() { let _serial = serial(); let tmp = tempfile::tempdir().unwrap(); let ws = tmp.path(); @@ -287,6 +345,14 @@ fn a_replaced_gh_is_reported_on_the_next_refresh() { #[test] fn an_old_gh_publishes_nothing_and_removes_what_was_there() { + in_a_child_process("an_old_gh_publishes_nothing_and_removes_what_was_there_child"); +} + +/// The body of [`an_old_gh_publishes_nothing_and_removes_what_was_there`], +/// in its own process: it moves the shared `DAEMON` singleton (#14775). +#[test] +#[ignore = "run in a child process by an_old_gh_publishes_nothing_and_removes_what_was_there"] +fn an_old_gh_publishes_nothing_and_removes_what_was_there_child() { let _serial = serial(); let tmp = tempfile::tempdir().unwrap(); let ws = tmp.path(); @@ -305,6 +371,14 @@ fn an_old_gh_publishes_nothing_and_removes_what_was_there() { #[test] fn a_dropped_owner_s_profile_is_removed() { + in_a_child_process("a_dropped_owner_s_profile_is_removed_child"); +} + +/// The body of [`a_dropped_owner_s_profile_is_removed`], in its own process: +/// it publishes into the shared `DAEMON` singleton (#14775). +#[test] +#[ignore = "run in a child process by a_dropped_owner_s_profile_is_removed"] +fn a_dropped_owner_s_profile_is_removed_child() { let _serial = serial(); let tmp = tempfile::tempdir().unwrap(); let ws = tmp.path(); @@ -361,6 +435,14 @@ fn a_live_profile_routes_reads_as_the_gateway_reader() { /// agent is told about a gateway. #[test] fn with_the_gateway_unset_routing_is_byte_identical_to_today() { + in_a_child_process("with_the_gateway_unset_routing_is_byte_identical_to_today_child"); +} + +/// The body of [`with_the_gateway_unset_routing_is_byte_identical_to_today`], +/// in its own process: it moves the shared `DAEMON` singleton (#14775). +#[test] +#[ignore = "run in a child process by with_the_gateway_unset_routing_is_byte_identical_to_today"] +fn with_the_gateway_unset_routing_is_byte_identical_to_today_child() { let _serial = serial(); let tmp = tempfile::tempdir().unwrap(); let ws = tmp.path(); From 1c15ad973b3b523c98c3f6f6eca20d0dd0ecccd1 Mon Sep 17 00:00:00 2001 From: Robb Walters Date: Fri, 20 Nov 2026 03:54:31 -0800 Subject: [PATCH 2/2] Require proof that the isolated gateway fixture ran --- loom-daemon/src/forge_gateway/tests.rs | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/loom-daemon/src/forge_gateway/tests.rs b/loom-daemon/src/forge_gateway/tests.rs index 869168e8d1..dc2cd71f8f 100644 --- a/loom-daemon/src/forge_gateway/tests.rs +++ b/loom-daemon/src/forge_gateway/tests.rs @@ -28,17 +28,33 @@ fn serial() -> std::sync::MutexGuard<'static, ()> { /// The public test names stay as wrappers, so the default suite and focused /// filters still exercise each body. fn in_a_child_process(child: &str) { - let status = std::process::Command::new(std::env::current_exe().unwrap()) + let output = std::process::Command::new(std::env::current_exe().unwrap()) .args([ "--exact", &format!("forge_gateway::tests::{child}"), "--ignored", "--test-threads=1", + "--format", + "pretty", + "--color", + "never", ]) - .stdout(std::process::Stdio::null()) - .status() + .output() .unwrap(); - assert!(status.success(), "the gateway fixture child `{child}` failed: {status}"); + let stdout = String::from_utf8_lossy(&output.stdout); + let stderr = String::from_utf8_lossy(&output.stderr); + let single_pass = "test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured;"; + assert!( + output.status.success() && stdout.lines().any(|line| line.starts_with(single_pass)), + "gateway fixture child `{child}` did not run exactly one passing test ({})\nstdout:\n{stdout}\nstderr:\n{stderr}", + output.status, + ); +} + +#[test] +#[should_panic(expected = "test result: ok. 0 passed; 0 failed;")] +fn a_missing_gateway_child_is_refused_even_with_a_successful_exit() { + in_a_child_process("missing_gateway_fixture_child"); } fn cfg(owners: &[(&str, &str)]) -> Value {