hyperhive/hive-agent-sock/src/paths.rs

30 lines
1.4 KiB
Rust

//! In-container harness-directory resolution, shared by the harness
//! itself and every producer daemon that dials the in-agent socket
//! (`hive-bash-mcp`, and any future producer that writes artifacts
//! alongside the harness's own state).
use std::path::PathBuf;
/// Base harness directory for the current agent. Reads
/// `HYPERHIVE_HARNESS_DIR`, always injected by the meta flake's
/// `systemd.globalEnvironment` for every in-container service
/// (`nix/host-modules` — see `hive-c0re/src/meta.rs`'s per-agent
/// environment block). Every process this crate's wire types serve
/// (the harness, `hive-bash-daemon`, ...) runs under that same
/// environment, so there is no legitimate runtime path where it's
/// unset — a missing var means the container is misconfigured, not
/// that a fallback derivation should paper over it.
///
/// # Panics
///
/// Panics if `HYPERHIVE_HARNESS_DIR` is not set. Deliberate: a wrong
/// silently-derived path here means task files, sqlite stores, and the
/// in-agent socket itself could resolve to the wrong directory — a
/// loud crash at startup beats a quiet cross-agent path collision.
#[must_use]
pub fn harness_dir() -> PathBuf {
PathBuf::from(
std::env::var_os("HYPERHIVE_HARNESS_DIR")
.expect("HYPERHIVE_HARNESS_DIR must be set — the meta flake injects it for every in-container service; a missing value means the container's environment is misconfigured"),
)
}