hive-c0re: in-memory broker + per-agent sockets + coordinator state

This commit is contained in:
müde 2026-05-14 21:42:51 +02:00
parent 4545c08908
commit d79b5a39a1
6 changed files with 220 additions and 9 deletions

View file

@ -1,18 +1,24 @@
//! Thin async wrappers over `nixos-container`.
use std::path::Path;
use anyhow::{Context, Result, bail};
use tokio::process::Command;
pub const AGENT_PREFIX: &str = "hive-agent-";
pub const HIVE_PREFIX: &str = "hive-";
/// Mount point of the per-agent runtime directory inside the container.
pub const CONTAINER_RUNTIME_MOUNT: &str = "/run/hive";
pub fn container_name(name: &str) -> String {
format!("{AGENT_PREFIX}{name}")
}
pub async fn spawn(name: &str, agent_flake: &str) -> Result<()> {
pub async fn spawn(name: &str, agent_flake: &str, agent_dir: &Path) -> Result<()> {
let container = container_name(name);
run(&["create", &container, "--flake", agent_flake]).await?;
let bind = format!("{}:{CONTAINER_RUNTIME_MOUNT}", agent_dir.display());
run(&["create", &container, "--flake", agent_flake, "--bind", &bind]).await?;
run(&["start", &container]).await
}