feat(#2): split harness-internal state from agent-visible state
This commit is contained in:
parent
ce875646a5
commit
ae6d23594d
9 changed files with 113 additions and 23 deletions
|
|
@ -1,13 +1,16 @@
|
|||
//! Per-agent path resolution for state and credential directories.
|
||||
//! Per-agent path resolution for state, harness, and credential directories.
|
||||
//!
|
||||
//! All agents (including the manager `hm1nd`) use `/agents/{label}/state`.
|
||||
//! All agents (including the manager `hm1nd`) use `/agents/{label}/state`
|
||||
//! for agent-owned durable notes, and `/agents/{label}/harness` for
|
||||
//! harness-internal files (`hyperhive-events.sqlite`, `hyperhive-model`, etc.)
|
||||
//! that should not clutter what claude sees as "my notes dir".
|
||||
//! Claude credentials live at `$HOME/.claude` (resolves to
|
||||
//! `/home/<agent-name>/.claude` because the harness service runs as a
|
||||
//! non-root unix user matching the agent label — see
|
||||
//! `docs/persistence.md::First-boot agent-user migration`).
|
||||
//!
|
||||
//! Both paths can be overridden via env vars (`HYPERHIVE_STATE_DIR`,
|
||||
//! `HYPERHIVE_CLAUDE_DIR`) for dev / test scenarios.
|
||||
//! All three paths can be overridden via env vars (`HYPERHIVE_STATE_DIR`,
|
||||
//! `HYPERHIVE_HARNESS_DIR`, `HYPERHIVE_CLAUDE_DIR`) for dev / test scenarios.
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
|
|
@ -24,6 +27,20 @@ pub fn state_dir() -> PathBuf {
|
|||
PathBuf::from(format!("/agents/{label}/state"))
|
||||
}
|
||||
|
||||
/// Harness-internal state directory. Holds files the harness owns
|
||||
/// (`hyperhive-events.sqlite`, `hyperhive-turn-stats.sqlite`,
|
||||
/// `hyperhive-model`) so they do not appear inside the agent-visible
|
||||
/// `/agents/{label}/state` tree. Reads `HYPERHIVE_HARNESS_DIR` first;
|
||||
/// falls back to `/agents/{label}/harness` derived from `HIVE_LABEL`.
|
||||
#[must_use]
|
||||
pub fn harness_dir() -> PathBuf {
|
||||
if let Some(p) = std::env::var_os("HYPERHIVE_HARNESS_DIR") {
|
||||
return PathBuf::from(p);
|
||||
}
|
||||
let label = std::env::var("HIVE_LABEL").unwrap_or_default();
|
||||
PathBuf::from(format!("/agents/{label}/harness"))
|
||||
}
|
||||
|
||||
/// Per-turn config dir for the regenerated claude-{mcp-config,settings,
|
||||
/// system-prompt} files the harness drops before each turn. Set by
|
||||
/// systemd via `RuntimeDirectory = "hive-config"`: a per-service runtime
|
||||
|
|
|
|||
Loading…
Reference in a new issue