refactor(#2352): move hivectl-shared layout consts to hive-host-sock

This commit is contained in:
damocles 2026-07-15 21:58:03 +02:00
commit cce35c20e6
3 changed files with 57 additions and 35 deletions

View file

@ -24,6 +24,12 @@
use std::path::{Path, PathBuf};
// Layout facts shared with the host-side `hivectl` CLI live in
// `hive-host-sock` (the crate hivectl links instead of the whole daemon);
// re-exported here so this module stays the daemon's single-source facade for
// its own callsites.
pub use hive_host_sock::{AGENTS_ROOT, GATEWAY_HTPASSWD, HOST_SOCKET, agent_state_dir};
/// Root of all hive-c0re persistent state.
// nix: bind-mount source `services.hyperhive.c0re.statePath` (hive-c0re.nix) — must match.
pub const STATE_ROOT: &str = "/var/lib/hyperhive";
@ -35,11 +41,6 @@ pub const STATE_ROOT: &str = "/var/lib/hyperhive";
// stay in sync; the privsep boundary prevents importing across the crate.
pub const RUNTIME_ROOT: &str = "/run/hyperhive";
/// Default host admin socket (`/run/hyperhive/host.sock`). Exposed as a
/// `&str` for the `--socket` / `--host-socket` clap `default_value` in
/// `main.rs` (hive-c0re) and `bin/hivectl.rs`.
pub const HOST_SOCKET: &str = "/run/hyperhive/host.sock";
/// `/run/hive-agent` — per-agent runtime socket dir root (web + bound
/// markers), one subdir per agent.
// nix: agent container bind-mount / `RuntimeDirectory` (the harness nix modules) — must match.
@ -158,26 +159,12 @@ pub fn agent_sockets_file() -> PathBuf {
// single Rust-side source.
// ---------------------------------------------------------------------------
/// `agents/` — per-agent persistent state root (one subdir per agent,
/// bind-mounted into each container as `/agents/<name>`). A `&str` (the
/// dashboard state-file allow-list uses it for `strip_prefix` /
/// `starts_with` checks), so it stays a const; [`agents_root`] wraps it.
// nix: agent container bind-mount source (harness modules / agent.nix template) — must match.
// priv-sock: `hive_priv_sock::AGENT_STATE_ROOT` is the same value and must stay in sync;
// the privsep boundary prevents importing across the crate.
pub const AGENTS_ROOT: &str = "/var/lib/hyperhive/agents";
/// `agents/` root (`AGENTS_ROOT`) as an owned `PathBuf`.
#[must_use]
pub fn agents_root() -> PathBuf {
PathBuf::from(AGENTS_ROOT)
}
/// `agents/<name>` — one agent's persistent state root.
#[must_use]
pub fn agent_state_dir(name: &str) -> PathBuf {
agents_root().join(name)
}
/// `applied/` — per-agent *applied* (deployed) config repos + rev markers,
/// distinct from the proposed configs under `agents/<name>/config`.
// nix: read by hive-c0re only, but paired with `agents/` in the deploy flow.
@ -253,12 +240,6 @@ pub fn gateway_agents_conf() -> PathBuf {
gateway_dir().join("agents.conf")
}
/// `gateway/gateway.htpasswd` — nginx basic-auth credential store for the
/// operator dashboard vhost. A `&str` (used as a `hivectl` clap
/// `default_value`), so it stays a const rather than a `PathBuf` fn.
// nix: read by the gateway container's nginx (hive-gateway.nix) — must match.
pub const GATEWAY_HTPASSWD: &str = "/var/lib/hyperhive/gateway/gateway.htpasswd";
/// `forge-core-token` — the hive-c0re forge account API token. A `&str`
/// (used in `Path::new` + user-facing `format!` messages), so it stays a
/// const rather than a `PathBuf` fn.