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.
|
//! 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.
|
//! Claude credentials are always at `/root/.claude` for all agents.
|
||||||
//!
|
//!
|
||||||
//! Both paths can be overridden via env vars (`HYPERHIVE_STATE_DIR`,
|
//! Both paths can be overridden via env vars (`HYPERHIVE_STATE_DIR`,
|
||||||
|
|
@ -8,25 +8,18 @@
|
||||||
|
|
||||||
use std::path::PathBuf;
|
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`
|
/// Durable state directory for the current agent. Reads `HYPERHIVE_STATE_DIR`
|
||||||
/// first; falls back to `/agents/{label}/state` for sub-agents or `/state` for
|
/// first (always set by the meta flake to `/agents/{label}/state`); falls back
|
||||||
/// the manager / any unrecognised label.
|
/// to the same pattern derived from `HIVE_LABEL` for dev/test environments
|
||||||
|
/// where the env var may not be set.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn state_dir() -> PathBuf {
|
pub fn state_dir() -> PathBuf {
|
||||||
if let Some(p) = std::env::var_os("HYPERHIVE_STATE_DIR") {
|
if let Some(p) = std::env::var_os("HYPERHIVE_STATE_DIR") {
|
||||||
return PathBuf::from(p);
|
return PathBuf::from(p);
|
||||||
}
|
}
|
||||||
let label = std::env::var("HIVE_LABEL").unwrap_or_default();
|
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"))
|
PathBuf::from(format!("/agents/{label}/state"))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// Claude credentials directory for the current agent. Always `/root/.claude`
|
/// Claude credentials directory for the current agent. Always `/root/.claude`
|
||||||
/// because the `claude` CLI reads `$HOME/.claude` (uid 0 → `/root`), and
|
/// because the `claude` CLI reads `$HOME/.claude` (uid 0 → `/root`), and
|
||||||
|
|
|
||||||
|
|
@ -277,18 +277,14 @@ fn render_flake(
|
||||||
# resolve the agent's durable state dir without hard-coding it.
|
# resolve the agent's durable state dir without hard-coding it.
|
||||||
environment.variables = {
|
environment.variables = {
|
||||||
HIVE_LABEL = name;
|
HIVE_LABEL = name;
|
||||||
HYPERHIVE_STATE_DIR =
|
HYPERHIVE_STATE_DIR = "/agents/${name}/state";
|
||||||
if isManager then "/state"
|
|
||||||
else "/agents/${name}/state";
|
|
||||||
};
|
};
|
||||||
systemd.services.${service}.environment = {
|
systemd.services.${service}.environment = {
|
||||||
HIVE_PORT = toString port;
|
HIVE_PORT = toString port;
|
||||||
HIVE_LABEL = name;
|
HIVE_LABEL = name;
|
||||||
HIVE_DASHBOARD_PORT = toString dashboardPort;
|
HIVE_DASHBOARD_PORT = toString dashboardPort;
|
||||||
HIVE_OPERATOR_PRONOUNS = operatorPronouns;
|
HIVE_OPERATOR_PRONOUNS = operatorPronouns;
|
||||||
HYPERHIVE_STATE_DIR =
|
HYPERHIVE_STATE_DIR = "/agents/${name}/state";
|
||||||
if isManager then "/state"
|
|
||||||
else "/agents/${name}/state";
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue