refactor: per-agent state paths (/agents/{label}/state), centralize in paths.rs

This commit is contained in:
damocles 2026-05-16 14:16:25 +02:00
commit a6d1464071
10 changed files with 86 additions and 56 deletions

View file

@ -1,6 +1,6 @@
//! Login-state probe for the bind-mounted `~/.claude/` dir. The dir is
//! provided by hive-c0re (Phase 8 step 1) and persists across container
//! destroy/recreate so OAuth tokens survive.
//! provided by hive-c0re and persists across container destroy/recreate so
//! OAuth tokens survive.
//!
//! "Has session" today means "the dir contains at least one regular file."
//! That's a heuristic: a fresh bind-mount starts empty, and `claude auth login`
@ -8,11 +8,15 @@
//! specific credentials filename, or run a no-op `claude` call) once the
//! exact layout is locked in.
use std::path::Path;
use std::path::{Path, PathBuf};
/// Mount point of the per-agent Claude credentials dir inside the container.
/// Matches `hive_c0re::lifecycle::CONTAINER_CLAUDE_MOUNT`.
pub const DEFAULT_CLAUDE_DIR: &str = "/root/.claude";
/// Returns the Claude credentials directory for this agent, derived from
/// `HIVE_LABEL`. Manager ("hm1nd") uses `/root/.claude`; sub-agents use
/// `/agents/{label}/claude`. Overridable via `HYPERHIVE_CLAUDE_DIR`.
#[must_use]
pub fn default_dir() -> PathBuf {
crate::paths::claude_dir()
}
/// Returns `true` if `dir` exists and contains any regular file. Used at
/// startup to decide whether to enter the turn loop (logged in) or stay in