move hive-sh4re's harness_dir() into hive-agent-sock, drop the dev-fallback derivation

This commit is contained in:
damocles 2026-08-09 18:59:46 +02:00 committed by mara
commit 7ba492b965
6 changed files with 49 additions and 42 deletions

View file

@ -1,33 +1,8 @@
//! Shared in-container filesystem-path resolution.
//!
//! Every process that runs inside an agent container - the harness plus
//! the out-of-process MCP daemons (bash, matrix, ...) - must resolve the
//! harness directory layout identically. These helpers live here so the
//! resolution exists in exactly one place rather than being mirrored
//! across crates.
use std::path::PathBuf;
/// Base harness directory for the current agent. Uses `HYPERHIVE_HARNESS_DIR`
/// if set (injected by the hive-c0re meta flake after the harness/state
/// split). For pre-split / dev deployments where it isn't set, falls back to
/// a `harness/` sibling of `HYPERHIVE_STATE_DIR`, and finally to
/// `/agents/{HIVE_LABEL}/harness` when neither dir env var is present — the
/// shape the harness derives from its label alone.
#[must_use]
pub fn harness_dir() -> PathBuf {
if let Some(p) = std::env::var_os("HYPERHIVE_HARNESS_DIR") {
return PathBuf::from(p);
}
if let Some(state) = std::env::var_os("HYPERHIVE_STATE_DIR") {
let state_path = PathBuf::from(&state);
if let Some(parent) = state_path.parent() {
return parent.join("harness");
}
}
let label = std::env::var("HIVE_LABEL").unwrap_or_default();
PathBuf::from(format!("/agents/{label}/harness"))
}
//! Shared filename constants for in-container filesystem paths. Harness
//! *directory* resolution itself lives in `hive_agent_sock::paths`
//! (every in-container producer already depends on that crate for the
//! socket wire types) — this module only keeps the bits that also need
//! to be reachable from the host side (`hive-c0re`).
/// File name of the pause marker inside the harness dir. Re-exported from
/// `hive-priv-sock`, which owns the definition because hive-priv (root) is