Watch
0
0
Fork
You've already forked hyperhive
0

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

View file

@ -187,22 +187,22 @@ in
''; '';
}; };
# Whether hive-c0re auto-manages the root/manager agent on startup # Whether this hive runs "ruthless" — with no root/manager agent at all.
# (create it if missing, restart it if present-but-stopped). Some hives # When true, hive-c0re skips the root-agent auto-management sweep (create
# don't want a root agent auto-managed at all — see issue tracker # if missing, restart if present-but-stopped). Some hives don't want a
# "scope concept: special agents". # root agent at all — see issue tracker "scope concept: special agents".
options.services.hyperhive.manageRootAgent = lib.mkOption { options.services.hyperhive.ruthless = lib.mkOption {
type = lib.types.bool; type = lib.types.bool;
default = true; default = false;
example = false; example = true;
description = '' description = ''
Whether hive-c0re auto-manages the root (manager) agent on Run this hive "ruthless" — with no root (manager) agent at all (no
startup: creating its container when missing and restarting it ruth). When `true`, hive-c0re skips the root-agent auto-management
when it's present but stopped. Defaults to `true` (the historical sweep entirely (it otherwise creates the root agent's container when
behaviour — the root agent was treated as required infrastructure). missing and restarts it when present but stopped). Defaults to
Set to `false` on hives that don't want a root agent at all; `false` (the historical behaviour — the root agent is auto-managed
hive-c0re then skips the root-agent create/start sweep entirely. as required infrastructure). Exposed to hive-c0re as
Exposed to hive-c0re as `HYPERHIVE_MANAGE_ROOT_AGENT`. `HYPERHIVE_RUTHLESS`.
''; '';
}; };
@ -892,10 +892,10 @@ in
# prompts). `hive_sh4re::assets::*` reads paths underneath. # prompts). `hive_sh4re::assets::*` reads paths underneath.
# `forge.rs` reads the avatar PNGs from here on startup. # `forge.rs` reads the avatar PNGs from here on startup.
HIVE_ASSETS_DIR = "${cfg.assets}/share/hyperhive"; HIVE_ASSETS_DIR = "${cfg.assets}/share/hyperhive";
# Whether hive-c0re auto-manages the root/manager agent on # Whether this hive runs ruthless — no root/manager agent at all
# startup (`auto_update::ensure_root_agent`). Default true = # (`auto_update::ensure_root_agent`). Default false = historical
# historical behaviour; false makes the root-agent sweep a no-op. # behaviour (root auto-managed); true makes the sweep a no-op.
HYPERHIVE_MANAGE_ROOT_AGENT = lib.boolToString config.services.hyperhive.manageRootAgent; HYPERHIVE_RUTHLESS = lib.boolToString config.services.hyperhive.ruthless;
} }
// lib.optionalAttrs (config.services.hyperhive.domain != null) { // lib.optionalAttrs (config.services.hyperhive.domain != null) {
# Identity env vars threaded into c0re's own service env and # Identity env vars threaded into c0re's own service env and