fold hive-c0re module tree into the daemon binary + drop dead pub items surfaced by bin-only (#2513)
This commit is contained in:
parent
d04c86e9ac
commit
673aea4e50
15 changed files with 95 additions and 250 deletions
|
|
@ -4,23 +4,58 @@ use std::sync::Arc;
|
|||
use anyhow::{Context as _, Result};
|
||||
use clap::{Parser, Subcommand};
|
||||
|
||||
// Every module hangs off the `hive_c0re` library (see `src/lib.rs`).
|
||||
// The daemon and the `hivectl` sibling binary share the same module
|
||||
// tree — no per-binary duplication. Enumerated rather than wildcard
|
||||
// so clippy stays happy + the lib surface this bin consumes is
|
||||
// explicit (any new daemon entry point reads off the next add).
|
||||
use hive_c0re::coordinator::{Coordinator, HiveEnv, ServeConfig};
|
||||
use hive_c0re::{
|
||||
agent_sockets, auto_update, broker, crash_watch, dashboard, dashboard_events, forge,
|
||||
host_stats, job_queue, knowledge, matrix, mcp_sockets, migrate, reminder_scheduler,
|
||||
scheduled_prompts_worker, server, socket_server, sweep_health, warnings,
|
||||
// `hive-c0re` is bin-only: this binary owns the whole daemon module
|
||||
// tree. The operator CLI moved to the standalone `hivectl` crate (it
|
||||
// talks to the daemon over the host admin socket), so there's no longer
|
||||
// a library shared between two binaries — the modules that used to live
|
||||
// in `src/lib.rs` are declared here directly.
|
||||
//
|
||||
// Cohesive clusters live in directory submodules (`stores`, `stats`,
|
||||
// `agent_config`, `workers`); each child is re-exported at the crate
|
||||
// root so `crate::broker::…` style paths keep resolving unchanged.
|
||||
mod actions;
|
||||
mod agent_config;
|
||||
mod container_view;
|
||||
mod coordinator;
|
||||
mod dashboard;
|
||||
mod dashboard_events;
|
||||
mod forge;
|
||||
mod gateway_nginx;
|
||||
mod job_queue;
|
||||
mod lifecycle;
|
||||
mod loose_ends;
|
||||
mod matrix;
|
||||
mod meta;
|
||||
mod migrate;
|
||||
mod paths;
|
||||
mod priv_client;
|
||||
mod questions;
|
||||
mod server;
|
||||
mod socket_server;
|
||||
mod stats;
|
||||
mod stores;
|
||||
mod webhook_secret;
|
||||
mod workers;
|
||||
|
||||
pub(crate) use agent_config::{capabilities, limits, tool_groups, topology};
|
||||
pub(crate) use stats::{
|
||||
container_stats, hive_stats, host_stats, otel_metrics, sweep_health, warnings,
|
||||
};
|
||||
pub(crate) use stores::{
|
||||
approvals, audit_log, broker, build_logs, db, operator_questions, power, scheduled_prompts,
|
||||
};
|
||||
pub(crate) use workers::{
|
||||
agent_sockets, auto_update, crash_watch, knowledge, mcp_sockets, reminder_scheduler,
|
||||
scheduled_prompts_worker,
|
||||
};
|
||||
|
||||
use coordinator::{Coordinator, HiveEnv, ServeConfig};
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(name = "hive-c0re", about = "hyperhive coordinator daemon and CLI")]
|
||||
#[command(name = "hive-c0re", about = "hyperhive coordinator daemon")]
|
||||
struct Cli {
|
||||
/// Path to the host admin socket.
|
||||
#[arg(long, global = true, default_value = hive_c0re::paths::HOST_SOCKET)]
|
||||
#[arg(long, global = true, default_value = crate::paths::HOST_SOCKET)]
|
||||
socket: PathBuf,
|
||||
|
||||
#[command(subcommand)]
|
||||
|
|
@ -32,7 +67,7 @@ enum Cmd {
|
|||
/// Run the coordinator daemon.
|
||||
Serve {
|
||||
/// Path to a JSON config file holding the host-level daemon config
|
||||
/// (the [`ServeConfig`](hive_c0re::coordinator::ServeConfig) shape:
|
||||
/// (the [`ServeConfig`](crate::coordinator::ServeConfig) shape:
|
||||
/// the container-injected `HiveEnv` fields + the hive-c0re-local
|
||||
/// `model_prices` table). Used as the base; any per-flag override
|
||||
/// below wins over the file. Absent → start from the built-in
|
||||
|
|
@ -42,7 +77,7 @@ enum Cmd {
|
|||
#[arg(long)]
|
||||
config: Option<PathBuf>,
|
||||
/// Path to the sqlite message store.
|
||||
#[arg(long, default_value = hive_c0re::paths::BROKER_DB)]
|
||||
#[arg(long, default_value = crate::paths::BROKER_DB)]
|
||||
db: PathBuf,
|
||||
/// Override: URL of the hyperhive flake. Inlined into each
|
||||
/// per-agent `flake.nix` as the `hyperhive` input.
|
||||
|
|
@ -174,7 +209,7 @@ async fn main() -> Result<()> {
|
|||
)]
|
||||
async fn cmd_serve(
|
||||
env: HiveEnv,
|
||||
model_prices: hive_c0re::hive_stats::PriceTable,
|
||||
model_prices: crate::hive_stats::PriceTable,
|
||||
build_slots: usize,
|
||||
db: std::path::PathBuf,
|
||||
socket: &std::path::Path,
|
||||
|
|
@ -183,7 +218,7 @@ async fn cmd_serve(
|
|||
// subdir (`db/`, `forge/`, `matrix/`, `run/`) BEFORE opening the
|
||||
// broker db — the broker + build-logs dbs are among the relocated
|
||||
// files. Idempotent; a no-op once migrated.
|
||||
hive_c0re::paths::relocate_legacy_state();
|
||||
crate::paths::relocate_legacy_state();
|
||||
// `dashboard_port` is consumed into the Coordinator below; capture the
|
||||
// Copy value first for the dashboard + knowledge-webhook tasks.
|
||||
let dashboard_port = env.dashboard_port;
|
||||
|
|
@ -208,7 +243,7 @@ async fn cmd_serve(
|
|||
// Sync /etc/tmpfiles.d/hyperhive-agents.conf so agent runtime dirs are
|
||||
// pre-declared for the next boot. Best-effort background task — a failure
|
||||
// here must not block hive-c0re startup. See lifecycle::sync_tmpfiles.
|
||||
tokio::spawn(hive_c0re::lifecycle::sync_tmpfiles());
|
||||
tokio::spawn(crate::lifecycle::sync_tmpfiles());
|
||||
// Auto-update in the background — don't block service start.
|
||||
// Sub-agent rebuilds can take tens of seconds; we want the admin
|
||||
// socket up immediately.
|
||||
|
|
@ -228,7 +263,7 @@ async fn cmd_serve(
|
|||
// Webhook HMAC secret: load from state dir or generate on first run.
|
||||
// Used by both the webhook handlers (verification) and the Forgejo
|
||||
// hook registrations (so Forgejo signs deliveries with the same key).
|
||||
let webhook_secret: Option<String> = match hive_c0re::webhook_secret::load_or_generate() {
|
||||
let webhook_secret: Option<String> = match crate::webhook_secret::load_or_generate() {
|
||||
Ok(s) => Some(s),
|
||||
Err(e) => {
|
||||
tracing::error!(
|
||||
|
|
@ -427,18 +462,18 @@ async fn cmd_serve(
|
|||
// + writable rootfs every ~5 min, cached so the 5s container-load
|
||||
// poll stays cheap cgroup-only reads. Feeds `disk_bytes` on the LOAD
|
||||
// tab. See container_stats::disk_sampler_loop.
|
||||
hive_c0re::container_stats::spawn_disk_sampler();
|
||||
crate::container_stats::spawn_disk_sampler();
|
||||
// Per-agent container-resource OTEL export: rides the same
|
||||
// cgroup gauges out to the configured OTLP endpoint, reusing the hive
|
||||
// `services.hyperhive.otel` config (endpoint + LoadCredential auth).
|
||||
// No-op when OTEL isn't configured.
|
||||
hive_c0re::otel_metrics::spawn_exporter();
|
||||
crate::otel_metrics::spawn_exporter();
|
||||
// build_logs.sqlite vacuum: c0re-side (single db). Failures kept
|
||||
// 30d, successes 24h — see `build_logs::vacuum` for the rule.
|
||||
hive_c0re::build_logs::spawn_vacuum(&coord);
|
||||
crate::build_logs::spawn_vacuum(&coord);
|
||||
// audit_log.sqlite vacuum: agent-initiated privileged-action trail,
|
||||
// 90d retention — see `audit_log::vacuum`.
|
||||
hive_c0re::audit_log::spawn_vacuum(&coord);
|
||||
crate::audit_log::spawn_vacuum(&coord);
|
||||
// Container crash watcher: emits HelperEvent::ContainerCrash
|
||||
// when a previously-running container goes away without an
|
||||
// operator-initiated transient state.
|
||||
|
|
|
|||
Loading…
Reference in a new issue