refactor(#1202): introduce HiveEnv + AgentPaths to reduce arg repetition

This commit is contained in:
damocles 2026-06-03 21:51:45 +02:00 committed by mara
commit 29c7f64bd3
8 changed files with 131 additions and 235 deletions

View file

@ -10,6 +10,7 @@ use anyhow::{Context, Result, bail};
use tokio::process::Command;
use tokio::sync::Mutex;
use crate::coordinator::HiveEnv;
use crate::lifecycle;
const META_ROOT: &str = "/var/lib/hyperhive/meta";
@ -50,26 +51,18 @@ pub fn meta_dir() -> PathBuf {
/// rendered contents differ from disk; an unchanged `flake.nix` is a
/// no-op.
#[allow(dead_code, clippy::implicit_hasher)] // first caller lands in a later commit
pub async fn sync_agents(
hyperhive_flake: &str,
nixpkgs_flake: &str,
nixpkgs_unstable_flake: &str,
dashboard_port: u16,
operator_pronouns: &str,
context_window_tokens: &std::collections::HashMap<String, u64>,
agents: &[AgentSpec],
) -> Result<()> {
pub async fn sync_agents(hive: &HiveEnv, agents: &[AgentSpec]) -> Result<()> {
let _guard = META_LOCK.lock().await;
let dir = meta_dir();
std::fs::create_dir_all(&dir).with_context(|| format!("create {}", dir.display()))?;
let new_flake = render_flake(
hyperhive_flake,
nixpkgs_flake,
nixpkgs_unstable_flake,
dashboard_port,
operator_pronouns,
context_window_tokens,
&hive.hyperhive_flake,
&hive.nixpkgs_flake,
&hive.nixpkgs_unstable_flake,
hive.dashboard_port,
&hive.operator_pronouns,
&hive.context_window_tokens,
agents,
);
let flake_path = dir.join("flake.nix");