From b5fc17aa59eaf888e20a876de6b91950ba329306 Mon Sep 17 00:00:00 2001 From: atlas Date: Mon, 14 Sep 2026 22:04:33 +0200 Subject: [PATCH] subagent: stop test depending on ambient HYPERHIVE_HARNESS_DIR MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit a_signal_url_reaches_the_subagent_and_a_status_check_renders_no_config built a config with a signal_url, which makes mcp_config::build write a real --mcp-config file and resolve hive_agent_sock::paths::harness_dir. That reads HYPERHIVE_HARNESS_DIR, which the meta flake injects into every in-container service but a nix-sandboxed cargo test does not set — so the test passed locally and panicked in CI. Set the var to a scratch dir for the duration of this one test instead. Refs #4403 --- hive-subagent-mcp/src/session.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/hive-subagent-mcp/src/session.rs b/hive-subagent-mcp/src/session.rs index 18868a2c..78d998fc 100644 --- a/hive-subagent-mcp/src/session.rs +++ b/hive-subagent-mcp/src/session.rs @@ -3012,11 +3012,34 @@ mod tests { #[test] fn a_signal_url_reaches_the_subagent_and_a_status_check_renders_no_config() { + // `turn` actually writes an --mcp-config file (crate::mcp_config::build), + // which resolves `hive_agent_sock::paths::harness_dir` — normally the + // container's injected `HYPERHIVE_HARNESS_DIR`, unset in a plain `cargo + // test` sandbox. Point it at a scratch dir for just this test rather + // than depending on ambient environment; only this test's call path + // reads the var, so there's no cross-test race to sequence around + // (contrast `otel_attrs_append_ambient_value_or_stand_alone` above). + let dir = std::env::temp_dir().join(format!( + "hive-subagent-mcp-test-harness-dir-{}", + std::process::id() + )); + // SAFETY: test-only env mutation; no other test reads this var. + unsafe { + std::env::set_var("HYPERHIVE_HARNESS_DIR", &dir); + } + // The signal surface is how `goal_reached` is callable at all, so a // spawned turn's config has to carry it; `status` builds a config // purely to resolve the store and has no subagent to hand it to. let turn = build_config("n", None, None, None, None, Some(&signal_url())); let checked = build_config("n", None, None, None, None, None); + + // SAFETY: see above. + unsafe { + std::env::remove_var("HYPERHIVE_HARNESS_DIR"); + } + let _ = std::fs::remove_dir_all(&dir); + assert!( turn.mcp_config.is_some(), "a turn's config must carry an --mcp-config with the signal surface in it"