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"