fix: manager uses /agents/hm1nd/state, not /state, for HYPERHIVE_STATE_DIR
This commit is contained in:
parent
f21ae1ff98
commit
d0b65b1f47
2 changed files with 7 additions and 18 deletions
|
|
@ -1,6 +1,6 @@
|
|||
//! Per-agent path resolution for state and credential directories.
|
||||
//!
|
||||
//! Manager ("hm1nd") keeps `/state`; sub-agents use `/agents/{label}/state`.
|
||||
//! All agents (including the manager "hm1nd") use `/agents/{label}/state`.
|
||||
//! Claude credentials are always at `/root/.claude` for all agents.
|
||||
//!
|
||||
//! Both paths can be overridden via env vars (`HYPERHIVE_STATE_DIR`,
|
||||
|
|
@ -8,24 +8,17 @@
|
|||
|
||||
use std::path::PathBuf;
|
||||
|
||||
/// Container label of the manager. Sub-agents get `/agents/{label}/state`;
|
||||
/// the manager keeps `/state`. Must match `hive-c0re::lifecycle::MANAGER_NAME`.
|
||||
pub const MANAGER_NAME: &str = "hm1nd";
|
||||
|
||||
/// Durable state directory for the current agent. Reads `HYPERHIVE_STATE_DIR`
|
||||
/// first; falls back to `/agents/{label}/state` for sub-agents or `/state` for
|
||||
/// the manager / any unrecognised label.
|
||||
/// first (always set by the meta flake to `/agents/{label}/state`); falls back
|
||||
/// to the same pattern derived from `HIVE_LABEL` for dev/test environments
|
||||
/// where the env var may not be set.
|
||||
#[must_use]
|
||||
pub fn state_dir() -> PathBuf {
|
||||
if let Some(p) = std::env::var_os("HYPERHIVE_STATE_DIR") {
|
||||
return PathBuf::from(p);
|
||||
}
|
||||
let label = std::env::var("HIVE_LABEL").unwrap_or_default();
|
||||
if label == MANAGER_NAME || label.is_empty() {
|
||||
PathBuf::from("/state")
|
||||
} else {
|
||||
PathBuf::from(format!("/agents/{label}/state"))
|
||||
}
|
||||
}
|
||||
|
||||
/// Claude credentials directory for the current agent. Always `/root/.claude`
|
||||
|
|
|
|||
|
|
@ -277,18 +277,14 @@ fn render_flake(
|
|||
# resolve the agent's durable state dir without hard-coding it.
|
||||
environment.variables = {
|
||||
HIVE_LABEL = name;
|
||||
HYPERHIVE_STATE_DIR =
|
||||
if isManager then "/state"
|
||||
else "/agents/${name}/state";
|
||||
HYPERHIVE_STATE_DIR = "/agents/${name}/state";
|
||||
};
|
||||
systemd.services.${service}.environment = {
|
||||
HIVE_PORT = toString port;
|
||||
HIVE_LABEL = name;
|
||||
HIVE_DASHBOARD_PORT = toString dashboardPort;
|
||||
HIVE_OPERATOR_PRONOUNS = operatorPronouns;
|
||||
HYPERHIVE_STATE_DIR =
|
||||
if isManager then "/state"
|
||||
else "/agents/${name}/state";
|
||||
HYPERHIVE_STATE_DIR = "/agents/${name}/state";
|
||||
};
|
||||
}
|
||||
];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue