From 0e4b5a11205c2a392c6011331819050fe3c5ee81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?m=C3=BCde?= Date: Mon, 6 Jul 2026 22:38:47 +0200 Subject: [PATCH] refactor(hive-c0re): group src-root files into submodules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit stores/ (sqlite-backed host stores + db helper), stats/, agent_config/, workers/ — pure git-mv moves; crate-root re-exports keep every crate:: path compiling. flake_check stays at root (synchronous approval-flow validation, not a background worker) --- docs/approvals.md | 2 +- docs/coordinator.md | 2 +- docs/persistence.md | 2 +- .../src/{ => agent_config}/capabilities.rs | 0 hive-c0re/src/{ => agent_config}/limits.rs | 0 hive-c0re/src/agent_config/mod.rs | 10 +++++ .../src/{ => agent_config}/tool_groups.rs | 0 hive-c0re/src/{ => agent_config}/topology.rs | 0 hive-c0re/src/lib.rs | 42 +++++++++---------- hive-c0re/src/{ => stats}/container_stats.rs | 0 hive-c0re/src/{ => stats}/hive_stats.rs | 0 hive-c0re/src/{ => stats}/host_stats.rs | 0 hive-c0re/src/stats/mod.rs | 8 ++++ hive-c0re/src/{ => stores}/approvals.rs | 0 hive-c0re/src/{ => stores}/audit_log.rs | 0 hive-c0re/src/{ => stores}/broker.rs | 0 hive-c0re/src/{ => stores}/build_logs.rs | 0 hive-c0re/src/{ => stores}/db.rs | 0 hive-c0re/src/stores/mod.rs | 14 +++++++ .../src/{ => stores}/operator_questions.rs | 0 hive-c0re/src/{ => stores}/power.rs | 0 .../src/{ => stores}/scheduled_prompts.rs | 0 hive-c0re/src/{ => workers}/agent_sockets.rs | 0 hive-c0re/src/{ => workers}/auto_update.rs | 0 hive-c0re/src/{ => workers}/crash_watch.rs | 0 hive-c0re/src/{ => workers}/knowledge.rs | 0 hive-c0re/src/workers/mod.rs | 12 ++++++ .../src/{ => workers}/reminder_scheduler.rs | 0 .../{ => workers}/scheduled_prompts_worker.rs | 0 29 files changed, 68 insertions(+), 24 deletions(-) rename hive-c0re/src/{ => agent_config}/capabilities.rs (100%) rename hive-c0re/src/{ => agent_config}/limits.rs (100%) create mode 100644 hive-c0re/src/agent_config/mod.rs rename hive-c0re/src/{ => agent_config}/tool_groups.rs (100%) rename hive-c0re/src/{ => agent_config}/topology.rs (100%) rename hive-c0re/src/{ => stats}/container_stats.rs (100%) rename hive-c0re/src/{ => stats}/hive_stats.rs (100%) rename hive-c0re/src/{ => stats}/host_stats.rs (100%) create mode 100644 hive-c0re/src/stats/mod.rs rename hive-c0re/src/{ => stores}/approvals.rs (100%) rename hive-c0re/src/{ => stores}/audit_log.rs (100%) rename hive-c0re/src/{ => stores}/broker.rs (100%) rename hive-c0re/src/{ => stores}/build_logs.rs (100%) rename hive-c0re/src/{ => stores}/db.rs (100%) create mode 100644 hive-c0re/src/stores/mod.rs rename hive-c0re/src/{ => stores}/operator_questions.rs (100%) rename hive-c0re/src/{ => stores}/power.rs (100%) rename hive-c0re/src/{ => stores}/scheduled_prompts.rs (100%) rename hive-c0re/src/{ => workers}/agent_sockets.rs (100%) rename hive-c0re/src/{ => workers}/auto_update.rs (100%) rename hive-c0re/src/{ => workers}/crash_watch.rs (100%) rename hive-c0re/src/{ => workers}/knowledge.rs (100%) create mode 100644 hive-c0re/src/workers/mod.rs rename hive-c0re/src/{ => workers}/reminder_scheduler.rs (100%) rename hive-c0re/src/{ => workers}/scheduled_prompts_worker.rs (100%) diff --git a/docs/approvals.md b/docs/approvals.md index 32daa6d4..b730db34 100644 --- a/docs/approvals.md +++ b/docs/approvals.md @@ -413,7 +413,7 @@ tool group can therefore edit, commit, and submit changes for any of its direct children directly inside its container at `/agents//config/`. Agents holding the `can_manage_top_level_agents` topology role -(defined as `ROLE_CAN_MANAGE_TOP_LEVEL_AGENTS` in `hive-c0re/src/topology.rs`) +(defined as `ROLE_CAN_MANAGE_TOP_LEVEL_AGENTS` in `hive-c0re/src/agent_config/topology.rs`) get additional host-side bind mounts via `set_nspawn_flags`: - `/var/lib/hyperhive/agents/` → `/agents/` (RW) — all top-level diff --git a/docs/coordinator.md b/docs/coordinator.md index 554ae58b..4c83785a 100644 --- a/docs/coordinator.md +++ b/docs/coordinator.md @@ -109,7 +109,7 @@ Notable collapses: ### Desired-state (spec vs status) Per-agent power *intent* — `wanted: Up | Offline` — is durable as the -`agent_power` table in the coordinator DB (`hive-c0re/src/power.rs`). +`agent_power` table in the coordinator DB (`hive-c0re/src/stores/power.rs`). `container_view` remains the observed *status*; `Reconcile` nodes converge the two. Setting `wanted` is never a queued node: the submit layer (`job_queue/submit.rs`) writes the row synchronously, then submits the DAG diff --git a/docs/persistence.md b/docs/persistence.md index 51a911d4..c9aa1506 100644 --- a/docs/persistence.md +++ b/docs/persistence.md @@ -47,7 +47,7 @@ header/targets split, and the per-agent power-intent registry: - `agent_power` — one tiny row per agent: `agent PK / wanted (up | offline) / updated_at` — the durable power *intent* behind the job queue's desired-state reconciliation - (`docs/coordinator.md::Job queue`; owner: `hive-c0re/src/power.rs`). + (`docs/coordinator.md::Job queue`; owner: `hive-c0re/src/stores/power.rs`). Written synchronously by every operator/agent power action (dashboard start/stop, `hivectl stop`, the MCP kill/start tools, spawn approval); read by `Reconcile` nodes and the boot reconcile. diff --git a/hive-c0re/src/capabilities.rs b/hive-c0re/src/agent_config/capabilities.rs similarity index 100% rename from hive-c0re/src/capabilities.rs rename to hive-c0re/src/agent_config/capabilities.rs diff --git a/hive-c0re/src/limits.rs b/hive-c0re/src/agent_config/limits.rs similarity index 100% rename from hive-c0re/src/limits.rs rename to hive-c0re/src/agent_config/limits.rs diff --git a/hive-c0re/src/agent_config/mod.rs b/hive-c0re/src/agent_config/mod.rs new file mode 100644 index 00000000..7ef28556 --- /dev/null +++ b/hive-c0re/src/agent_config/mod.rs @@ -0,0 +1,10 @@ +//! Per-agent configuration registries: tool groups, capabilities, +//! topology (all JSON files under `/var/lib/hyperhive/meta/`) and the +//! shared wire-protocol size limits. Each submodule is re-exported at +//! the crate root, so `crate::topology::…` etc. keep working +//! unchanged. + +pub mod capabilities; +pub mod limits; +pub mod tool_groups; +pub mod topology; diff --git a/hive-c0re/src/tool_groups.rs b/hive-c0re/src/agent_config/tool_groups.rs similarity index 100% rename from hive-c0re/src/tool_groups.rs rename to hive-c0re/src/agent_config/tool_groups.rs diff --git a/hive-c0re/src/topology.rs b/hive-c0re/src/agent_config/topology.rs similarity index 100% rename from hive-c0re/src/topology.rs rename to hive-c0re/src/agent_config/topology.rs diff --git a/hive-c0re/src/lib.rs b/hive-c0re/src/lib.rs index 8f1309ac..3b20bd5e 100644 --- a/hive-c0re/src/lib.rs +++ b/hive-c0re/src/lib.rs @@ -11,45 +11,45 @@ //! Every module is re-exported `pub` so anything in the crate is //! addressable from either binary; the lib doesn't have a curated //! surface beyond "this is where the modules live". +//! +//! Cohesive clusters live in directory submodules (`stores`, `stats`, +//! `agent_config`, `workers`); each of their children is re-exported +//! at the crate root so pre-existing `crate::broker::…` / +//! `hive_c0re::broker::…` paths keep compiling unchanged. pub mod actions; -pub mod agent_sockets; -pub mod approvals; -pub mod audit_log; -pub mod auto_update; -pub mod broker; -pub mod build_logs; -pub mod capabilities; +pub mod agent_config; pub mod client; -pub mod container_stats; pub mod container_view; pub mod coordinator; -pub mod crash_watch; pub mod dashboard; pub mod dashboard_events; -pub mod db; pub mod flake_check; pub mod forge; pub mod gateway_nginx; -pub mod hive_stats; -pub mod host_stats; pub mod job_queue; -pub mod knowledge; pub mod lifecycle; -pub mod limits; pub mod loose_ends; pub mod matrix; pub mod meta; pub mod migrate; -pub mod operator_questions; pub mod paths; -pub mod power; pub mod priv_client; pub mod questions; -pub mod reminder_scheduler; -pub mod scheduled_prompts; -pub mod scheduled_prompts_worker; pub mod server; pub mod socket_server; -pub mod tool_groups; -pub mod topology; +pub mod stats; +pub mod stores; +pub mod workers; + +// Root re-exports: keep every pre-grouping `crate::` / +// `hive_c0re::` path compiling without touching consumers. +pub use agent_config::{capabilities, limits, tool_groups, topology}; +pub use stats::{container_stats, hive_stats, host_stats}; +pub use stores::{ + approvals, audit_log, broker, build_logs, db, operator_questions, power, scheduled_prompts, +}; +pub use workers::{ + agent_sockets, auto_update, crash_watch, knowledge, reminder_scheduler, + scheduled_prompts_worker, +}; diff --git a/hive-c0re/src/container_stats.rs b/hive-c0re/src/stats/container_stats.rs similarity index 100% rename from hive-c0re/src/container_stats.rs rename to hive-c0re/src/stats/container_stats.rs diff --git a/hive-c0re/src/hive_stats.rs b/hive-c0re/src/stats/hive_stats.rs similarity index 100% rename from hive-c0re/src/hive_stats.rs rename to hive-c0re/src/stats/hive_stats.rs diff --git a/hive-c0re/src/host_stats.rs b/hive-c0re/src/stats/host_stats.rs similarity index 100% rename from hive-c0re/src/host_stats.rs rename to hive-c0re/src/stats/host_stats.rs diff --git a/hive-c0re/src/stats/mod.rs b/hive-c0re/src/stats/mod.rs new file mode 100644 index 00000000..ee528cdc --- /dev/null +++ b/hive-c0re/src/stats/mod.rs @@ -0,0 +1,8 @@ +//! Metrics aggregation for the dashboard: hive-wide turn-stats +//! rollups, host-system probes / server warnings, and live +//! per-container cgroup load. Each submodule is re-exported at the +//! crate root, so `crate::hive_stats::…` etc. keep working unchanged. + +pub mod container_stats; +pub mod hive_stats; +pub mod host_stats; diff --git a/hive-c0re/src/approvals.rs b/hive-c0re/src/stores/approvals.rs similarity index 100% rename from hive-c0re/src/approvals.rs rename to hive-c0re/src/stores/approvals.rs diff --git a/hive-c0re/src/audit_log.rs b/hive-c0re/src/stores/audit_log.rs similarity index 100% rename from hive-c0re/src/audit_log.rs rename to hive-c0re/src/stores/audit_log.rs diff --git a/hive-c0re/src/broker.rs b/hive-c0re/src/stores/broker.rs similarity index 100% rename from hive-c0re/src/broker.rs rename to hive-c0re/src/stores/broker.rs diff --git a/hive-c0re/src/build_logs.rs b/hive-c0re/src/stores/build_logs.rs similarity index 100% rename from hive-c0re/src/build_logs.rs rename to hive-c0re/src/stores/build_logs.rs diff --git a/hive-c0re/src/db.rs b/hive-c0re/src/stores/db.rs similarity index 100% rename from hive-c0re/src/db.rs rename to hive-c0re/src/stores/db.rs diff --git a/hive-c0re/src/stores/mod.rs b/hive-c0re/src/stores/mod.rs new file mode 100644 index 00000000..1c02820c --- /dev/null +++ b/hive-c0re/src/stores/mod.rs @@ -0,0 +1,14 @@ +//! Sqlite-backed host-side stores (broker, approval / question / +//! schedule queues, build logs, audit trail, power intent) plus the +//! shared connection open/migration helper (`db`). Each submodule is +//! re-exported at the crate root, so `crate::broker::…` etc. keep +//! working unchanged. + +pub mod approvals; +pub mod audit_log; +pub mod broker; +pub mod build_logs; +pub mod db; +pub mod operator_questions; +pub mod power; +pub mod scheduled_prompts; diff --git a/hive-c0re/src/operator_questions.rs b/hive-c0re/src/stores/operator_questions.rs similarity index 100% rename from hive-c0re/src/operator_questions.rs rename to hive-c0re/src/stores/operator_questions.rs diff --git a/hive-c0re/src/power.rs b/hive-c0re/src/stores/power.rs similarity index 100% rename from hive-c0re/src/power.rs rename to hive-c0re/src/stores/power.rs diff --git a/hive-c0re/src/scheduled_prompts.rs b/hive-c0re/src/stores/scheduled_prompts.rs similarity index 100% rename from hive-c0re/src/scheduled_prompts.rs rename to hive-c0re/src/stores/scheduled_prompts.rs diff --git a/hive-c0re/src/agent_sockets.rs b/hive-c0re/src/workers/agent_sockets.rs similarity index 100% rename from hive-c0re/src/agent_sockets.rs rename to hive-c0re/src/workers/agent_sockets.rs diff --git a/hive-c0re/src/auto_update.rs b/hive-c0re/src/workers/auto_update.rs similarity index 100% rename from hive-c0re/src/auto_update.rs rename to hive-c0re/src/workers/auto_update.rs diff --git a/hive-c0re/src/crash_watch.rs b/hive-c0re/src/workers/crash_watch.rs similarity index 100% rename from hive-c0re/src/crash_watch.rs rename to hive-c0re/src/workers/crash_watch.rs diff --git a/hive-c0re/src/knowledge.rs b/hive-c0re/src/workers/knowledge.rs similarity index 100% rename from hive-c0re/src/knowledge.rs rename to hive-c0re/src/workers/knowledge.rs diff --git a/hive-c0re/src/workers/mod.rs b/hive-c0re/src/workers/mod.rs new file mode 100644 index 00000000..98654ea3 --- /dev/null +++ b/hive-c0re/src/workers/mod.rs @@ -0,0 +1,12 @@ +//! Background tasks and periodic sweeps: crash/login watcher, the +//! reminder and scheduled-prompt delivery loops, boot-time auto-update +//! reconcile, the agent-sockets.json writer loop, and knowledge-repo +//! sync. Each submodule is re-exported at the crate root, so +//! `crate::crash_watch::…` etc. keep working unchanged. + +pub mod agent_sockets; +pub mod auto_update; +pub mod crash_watch; +pub mod knowledge; +pub mod reminder_scheduler; +pub mod scheduled_prompts_worker; diff --git a/hive-c0re/src/reminder_scheduler.rs b/hive-c0re/src/workers/reminder_scheduler.rs similarity index 100% rename from hive-c0re/src/reminder_scheduler.rs rename to hive-c0re/src/workers/reminder_scheduler.rs diff --git a/hive-c0re/src/scheduled_prompts_worker.rs b/hive-c0re/src/workers/scheduled_prompts_worker.rs similarity index 100% rename from hive-c0re/src/scheduled_prompts_worker.rs rename to hive-c0re/src/workers/scheduled_prompts_worker.rs