Fixes all clippy -D warnings errors in the crates iris owns: hive-sh4re: - doc_lazy_continuation: add blank /// separator in priv_proto.rs - doc_markdown: backtick PRIVATE_NETWORK=0 / PRIVATE_NETWORK=1 hive-matrix-mcp: - map_unwrap_or: map().unwrap_or_else() -> map_or_else() in paths.rs - collapsible_if: if-let chains in wake.rs - doc_markdown: backtick M_UNKNOWN_TOKEN in main.rs - cast_possible_truncation: usize/u64 -> u32::try_from in handlers.rs - map_unwrap_or: map_or_else() in handlers.rs - manual_let_else: match Ok(r) => r, Err => return -> let Ok in handlers.rs - unused_async: remove async from list_invites; update socket.rs call site hive-forge: - doc_markdown: backtick REQUEST_CHANGES / APPROVED / COMMENT in pr_reviews.rs - unnecessary_wraps: list_reviews_text returns () not Result<()> - doc_markdown: backtick start_page / last_page in comments.rs - cast_possible_truncation: PAGE_SIZE u64 -> usize; remove as usize casts hive-ag3nt: - collapsible_if: if-let chains in events.rs and mcp.rs - single_match_else: match -> if let in events.rs and mcp.rs - items_after_statements: hoist STATUS_MAX_CHARS const in mcp.rs - map_unwrap_or: map_or_else() in mcp.rs and mcp_loose_ends.rs - cast_possible_truncation: usize -> u32::try_from in mcp.rs - doc_markdown: backtick snake_case in mcp.rs, needs_update/deployed_sha in web_ui.rs, HISTORY_CAPACITY in web_ui.rs - identical_match_arms: combine manage_root_agent | query_agent_state - redundant_closure: |s| s.to_string() -> ToString::to_string in web_ui.rs - duration_suboptimal_units: from_secs(3600) -> from_hours(1) in turn.rs Remaining failures in hive-c0re (39), hive-priv (8), hive-bash-mcp (11) are owned by damocles.
89 lines
3.8 KiB
Rust
89 lines
3.8 KiB
Rust
//! Per-agent filesystem paths used by both `hive-matrix-daemon` and the
|
|
//! stdio MCP bridge.
|
|
//!
|
|
//! All paths are overridable via env vars for dev / test scenarios and
|
|
//! to let the harness point the daemon at non-default locations when
|
|
//! the operator overrides `hyperhive.matrix.*` options.
|
|
|
|
use std::path::PathBuf;
|
|
|
|
/// Default homeserver URL when `HIVE_MATRIX_URL` isn't set. Tuwunel
|
|
/// (the local hive-matrix container) listens on `localhost:8008` by
|
|
/// default; shared host netns means every agent container resolves
|
|
/// `localhost` to the same machine.
|
|
pub const DEFAULT_HOMESERVER: &str = "http://localhost:8008";
|
|
|
|
/// Default unix socket path the daemon listens on inside the agent
|
|
/// container. The stdio MCP bridge `connect()`s here on every tool call.
|
|
/// Lives under systemd's `RuntimeDirectory=hive-matrix` (a tmpfs path
|
|
/// that disappears on container restart — fine, because the daemon
|
|
/// recreates the socket on its own boot) so the agent unix user
|
|
/// (post-#658) can bind a socket inside it without root in `/run`.
|
|
pub const DEFAULT_DAEMON_SOCKET: &str = "/run/hive-matrix/socket";
|
|
|
|
/// Resolve the matrix access-token file path. Override via
|
|
/// `HIVE_MATRIX_TOKEN_FILE`; default is `<HYPERHIVE_STATE_DIR>/matrix-token`,
|
|
/// the path `hive-c0re::matrix::ensure_user_for` writes to on agent
|
|
/// account provisioning.
|
|
#[must_use]
|
|
pub fn token_file() -> PathBuf {
|
|
if let Some(p) = std::env::var_os("HIVE_MATRIX_TOKEN_FILE") {
|
|
return PathBuf::from(p);
|
|
}
|
|
let state_dir = std::env::var("HYPERHIVE_STATE_DIR").unwrap_or_default();
|
|
PathBuf::from(format!("{state_dir}/matrix-token"))
|
|
}
|
|
|
|
/// Resolve the homeserver URL. Override via `HIVE_MATRIX_URL`; default
|
|
/// is the in-container `localhost:8008` tuwunel.
|
|
#[must_use]
|
|
pub fn homeserver_url() -> String {
|
|
std::env::var("HIVE_MATRIX_URL").unwrap_or_else(|_| DEFAULT_HOMESERVER.to_owned())
|
|
}
|
|
|
|
/// Resolve the daemon's unix socket path. Override via
|
|
/// `HIVE_MATRIX_SOCKET`; default is `/run/hive-matrix/socket`.
|
|
#[must_use]
|
|
pub fn daemon_socket() -> PathBuf {
|
|
std::env::var_os("HIVE_MATRIX_SOCKET")
|
|
.map_or_else(|| PathBuf::from(DEFAULT_DAEMON_SOCKET), PathBuf::from)
|
|
}
|
|
|
|
/// Persistent sqlite store directory for matrix-sdk's state (event
|
|
/// cache, devices, etc.). Lives under the per-agent state dir so it
|
|
/// survives container restart but gets wiped on `destroy --purge`.
|
|
#[must_use]
|
|
pub fn matrix_state_dir() -> PathBuf {
|
|
let state_dir = std::env::var("HYPERHIVE_STATE_DIR").unwrap_or_default();
|
|
PathBuf::from(format!("{state_dir}/matrix-sdk-state"))
|
|
}
|
|
|
|
/// Hyperhive control socket — the daemon writes wake signals here so
|
|
/// the harness drives a new claude turn on incoming matrix events.
|
|
/// Mirrors the path `forge_notify` writes to.
|
|
#[must_use]
|
|
pub fn hyperhive_socket() -> PathBuf {
|
|
std::env::var_os("HIVE_CONTROL_SOCKET")
|
|
.map_or_else(|| PathBuf::from("/run/hive/mcp.sock"), PathBuf::from)
|
|
}
|
|
|
|
/// Directory where MCP daemons write loose-end summary files for the harness.
|
|
/// Each daemon writes `<name>.json` here; the harness scans the dir in
|
|
/// `get_loose_ends` to surface active work from all MCPs generically.
|
|
///
|
|
/// NOTE: the base-dir resolution logic here is intentionally mirrored in
|
|
/// `hive-ag3nt/src/mcp_loose_ends.rs::loose_ends_dir()`. They can't share
|
|
/// code across crates — keep them in sync if the fallback logic changes.
|
|
#[must_use]
|
|
pub fn mcp_loose_ends_dir() -> PathBuf {
|
|
let base = if let Some(p) = std::env::var_os("HYPERHIVE_HARNESS_DIR") {
|
|
PathBuf::from(p)
|
|
} else {
|
|
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"))
|
|
};
|
|
base.join("mcp-loose-ends")
|
|
}
|