From 891223219e44bd91b107ba8907ff7b37d3dbcca0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?m=C3=BCde?= Date: Sat, 16 May 2026 03:30:02 +0200 Subject: [PATCH] server: notify manager on admin-socket Rebuild outcomes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit HostRequest::Rebuild was the only rebuild path that bypassed notify_manager. dashboard / auto_update / actions::approve already emit Rebuilt events on both success + failure, but a 'hive-c0re rebuild ' from the host CLI (and the recent matrix-flake build failure that surfaced in journald) left the manager in the dark. mirror auto_update::rebuild_agent's pattern: on success → Rebuilt{ok:true}, on failure → Rebuilt{ok:false, note= format!('{e:#}')}. note carries the stderr tail lifecycle::run collected (the actual nix error: missing prompt file, dep build failure, etc.), so the manager has enough context to adjust the agent's agent.nix without ssh-ing to the host. --- hive-c0re/src/server.rs | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/hive-c0re/src/server.rs b/hive-c0re/src/server.rs index df86861..ee4bd06 100644 --- a/hive-c0re/src/server.rs +++ b/hive-c0re/src/server.rs @@ -129,7 +129,7 @@ async fn dispatch(req: &HostRequest, coord: Arc) -> HostResponse { let applied_dir = Coordinator::agent_applied_dir(name); let claude_dir = Coordinator::agent_claude_dir(name); let notes_dir = Coordinator::agent_notes_dir(name); - lifecycle::rebuild( + let result = lifecycle::rebuild( name, &coord.hyperhive_flake, &agent_dir, @@ -139,7 +139,30 @@ async fn dispatch(req: &HostRequest, coord: Arc) -> HostResponse { coord.dashboard_port, &coord.operator_pronouns, ) - .await?; + .await; + // Mirror auto_update::rebuild_agent — the manager wants + // to know about every rebuild attempt regardless of + // which surface triggered it, especially failures + // (build error → manager can adjust the agent's + // agent.nix). Without this the admin-socket CLI was + // a notify-gap. + match &result { + Ok(()) => coord.notify_manager(&hive_sh4re::HelperEvent::Rebuilt { + agent: name.clone(), + ok: true, + note: None, + sha: None, + tag: None, + }), + Err(e) => coord.notify_manager(&hive_sh4re::HelperEvent::Rebuilt { + agent: name.clone(), + ok: false, + note: Some(format!("{e:#}")), + sha: None, + tag: None, + }), + } + result?; HostResponse::success() } HostRequest::List => HostResponse::list(lifecycle::list().await?),