feat(#2006): rename manageRootAgent option to ruthless (invert sense)

This commit is contained in:
damocles 2026-06-26 23:16:09 +02:00 committed by mara
commit 09603b77b9
2 changed files with 34 additions and 34 deletions

View file

@ -164,16 +164,17 @@ pub async fn rebuild_agent(
result
}
/// Whether hive-c0re auto-manages the root/manager agent — creating it on
/// startup and restarting it when present-but-stopped. Controlled by the
/// host option `services.hyperhive.manageRootAgent`, threaded in via the
/// `HYPERHIVE_MANAGE_ROOT_AGENT` env var. Defaults to enabled when the
/// var is unset (back-compat: the root agent was always managed before
/// this opt-out existed); only an explicit `false` / `0` / `no` disables.
fn manage_root_agent() -> bool {
match std::env::var("HYPERHIVE_MANAGE_ROOT_AGENT") {
Ok(v) => !matches!(v.trim().to_ascii_lowercase().as_str(), "false" | "0" | "no"),
Err(_) => true,
/// Whether this hive is "ruthless" — running with no root/manager agent at
/// all (no ruth). When true, hive-c0re skips the root-agent create/start
/// sweep entirely. Controlled by the host option
/// `services.hyperhive.ruthless`, threaded in via the `HYPERHIVE_RUTHLESS`
/// env var. Defaults to `false` when the var is unset (back-compat: the
/// root agent was always auto-managed before this opt-out existed); only
/// an explicit `true` / `1` / `yes` enables ruthless mode.
fn ruthless() -> bool {
match std::env::var("HYPERHIVE_RUTHLESS") {
Ok(v) => matches!(v.trim().to_ascii_lowercase().as_str(), "true" | "1" | "yes"),
Err(_) => false,
}
}
@ -181,13 +182,12 @@ fn manage_root_agent() -> bool {
/// hive-c0re manages the manager end-to-end: operators no longer declare
/// `containers.h-ruth` in their host NixOS config. Bypasses the approval
/// queue — the root/manager is auto-managed by default. Operators who
/// don't want a root agent at all set `services.hyperhive.manageRootAgent
/// = false`, which short-circuits this whole function. Idempotent.
/// don't want a root agent at all set `services.hyperhive.ruthless = true`,
/// which short-circuits this whole function. Idempotent.
pub async fn ensure_root_agent(coord: &Arc<Coordinator>) -> Result<()> {
if !manage_root_agent() {
if ruthless() {
tracing::info!(
"root-agent auto-management disabled (services.hyperhive.manageRootAgent = false) - \
skipping root agent create/start"
"ruthless mode (services.hyperhive.ruthless = true) - skipping root agent create/start"
);
return Ok(());
}
@ -224,7 +224,7 @@ pub async fn ensure_root_agent(coord: &Arc<Coordinator>) -> Result<()> {
// stays down until a manual `nixos-container start`. The sub-agent
// `was_running` guard is intentionally left untouched. (Operators
// opt out of this whole auto-management with
// `services.hyperhive.manageRootAgent = false`, gated at the top of
// `services.hyperhive.ruthless = true`, gated at the top of
// this function.)
if !lifecycle::is_running(MANAGER_NAME).await {
tracing::info!("manager container present but not running — starting");