refactor(#1450): lift shared harness-path resolution into hive-sh4re

This commit is contained in:
damocles 2026-06-14 21:21:07 +02:00 committed by mara
commit 41c4682f7a
7 changed files with 48 additions and 46 deletions

View file

@ -3,6 +3,7 @@
use serde::{Deserialize, Serialize};
pub mod assets;
pub mod paths;
pub mod priv_proto;
// -----------------------------------------------------------------------------

33
hive-sh4re/src/paths.rs Normal file
View file

@ -0,0 +1,33 @@
//! 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 previously had to
//! be hand-mirrored across crates (each copy carrying a "keep in sync"
//! comment) because there was no shared home for them; they live here so
//! the resolution exists exactly once.
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); falls back to a `harness/` sibling of `HYPERHIVE_STATE_DIR` for
/// pre-split / dev deployments.
#[must_use]
pub fn harness_dir() -> PathBuf {
if let Some(p) = std::env::var_os("HYPERHIVE_HARNESS_DIR") {
return PathBuf::from(p);
}
let state = std::env::var("HYPERHIVE_STATE_DIR").unwrap_or_default();
let state_path = PathBuf::from(&state);
state_path
.parent()
.map_or_else(|| PathBuf::from(state), |p| p.join("harness"))
}
/// Directory where out-of-process MCP daemons write loose-end summary
/// files (`<name>.json`) for the harness to scan in `get_loose_ends`.
#[must_use]
pub fn mcp_loose_ends_dir() -> PathBuf {
harness_dir().join("mcp-loose-ends")
}