subagent: stop test depending on ambient HYPERHIVE_HARNESS_DIR

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
This commit is contained in:
atlas 2026-09-14 22:04:33 +02:00
commit b5fc17aa59

View file

@ -3012,11 +3012,34 @@ mod tests {
#[test] #[test]
fn a_signal_url_reaches_the_subagent_and_a_status_check_renders_no_config() { 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 // 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 // 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. // 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 turn = build_config("n", None, None, None, None, Some(&signal_url()));
let checked = build_config("n", None, None, None, None, None); 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!( assert!(
turn.mcp_config.is_some(), turn.mcp_config.is_some(),
"a turn's config must carry an --mcp-config with the signal surface in it" "a turn's config must carry an --mcp-config with the signal surface in it"