diff --git a/hive-ag3nt/src/bin/hive.rs b/hive-ag3nt/src/bin/hive.rs index 0748f356..6e710138 100644 --- a/hive-ag3nt/src/bin/hive.rs +++ b/hive-ag3nt/src/bin/hive.rs @@ -429,7 +429,7 @@ async fn serve_main(socket: &Path, poll_ms: u64) -> Result<()> { // through `` via the `send_to_parent` failure-notify path. // The broker resolves `` per `topology::parent_of`; // root agents fall through to operator. - for failure in plugins::install_configured(socket).await { + for failure in plugins::install_configured().await { S::send_to_parent(socket, failure).await; } tokio::spawn(hive_ag3nt::forge_notify::run(socket.to_path_buf())); diff --git a/hive-ag3nt/src/client.rs b/hive-ag3nt/src/client.rs index 33e9fa80..0cfd36f9 100644 --- a/hive-ag3nt/src/client.rs +++ b/hive-ag3nt/src/client.rs @@ -76,7 +76,9 @@ where } } } - Err(last_err.unwrap_or_else(|| anyhow!("hive socket: retries exhausted"))) + // Reaching here means the final attempt returned `Transient`, which always + // sets `last_err` — so this is infallible. + Err(last_err.expect("a transient failure on the final attempt set last_err")) } /// Transient = connect / IO error worth a retry (server restart, broken diff --git a/hive-ag3nt/src/identity.rs b/hive-ag3nt/src/identity.rs index 56759aee..4cafa13b 100644 --- a/hive-ag3nt/src/identity.rs +++ b/hive-ag3nt/src/identity.rs @@ -14,14 +14,18 @@ pub fn label() -> String { env::var("HIVE_LABEL").unwrap_or_default() } +/// `env::var(key)` reduced to `Some(value)` only when the var is set and +/// non-empty — the shared shape of the hive/swarm display-name lookups below. +fn non_empty_env(key: &str) -> Option { + env::var(key).ok().filter(|s| !s.is_empty()) +} + /// The hive's canonical DNS domain when set, otherwise None. Single-hive /// deployments where `HYPERHIVE_HIVE_DOMAIN` is unset return None — callers /// then degrade gracefully to the short label. #[must_use] pub fn hive_domain() -> Option { - env::var("HYPERHIVE_HIVE_DOMAIN") - .ok() - .filter(|s| !s.is_empty()) + non_empty_env("HYPERHIVE_HIVE_DOMAIN") } /// Human display name of this hive (e.g. `pr1ma`). Distinct from @@ -32,9 +36,7 @@ pub fn hive_domain() -> Option { /// at their discretion. #[must_use] pub fn hive_name() -> Option { - env::var("HYPERHIVE_HIVE_NAME") - .ok() - .filter(|s| !s.is_empty()) + non_empty_env("HYPERHIVE_HIVE_NAME") } /// Human display name of the wider swarm this hive belongs to (e.g. @@ -43,9 +45,7 @@ pub fn hive_name() -> Option { /// `services.hyperhive.swarmName` option is unset. #[must_use] pub fn swarm_name() -> Option { - env::var("HYPERHIVE_SWARM_NAME") - .ok() - .filter(|s| !s.is_empty()) + non_empty_env("HYPERHIVE_SWARM_NAME") } /// One peer hive in the same swarm. Parsed from `HYPERHIVE_PEERS`. diff --git a/hive-ag3nt/src/plugins.rs b/hive-ag3nt/src/plugins.rs index f5b21765..e3bc3cdc 100644 --- a/hive-ag3nt/src/plugins.rs +++ b/hive-ag3nt/src/plugins.rs @@ -11,8 +11,6 @@ //! plugin specs resolve against current index data. Marketplace update //! failures are non-fatal — stale index is better than no install attempt. -use std::path::Path; - use tokio::process::Command; const PLUGINS_PATH: &str = "/etc/hyperhive/claude-plugins.json"; @@ -103,8 +101,7 @@ async fn update_marketplaces() { /// notification, see `Surface::send_to_parent`). Wire-agnostic: the /// caller picks the recipient via the same `` sentinel that /// failure-notify uses everywhere else. -pub async fn install_configured(socket: &Path) -> Vec { - let _ = socket; // Reserved for future telemetry; currently unused. +pub async fn install_configured() -> Vec { let Ok(raw) = tokio::fs::read_to_string(PLUGINS_PATH).await else { return Vec::new(); };