hive-c0re: push NeedsLogin/LoggedIn as todos, not broker messages

This commit is contained in:
damocles 2026-08-02 23:48:46 +02:00 committed by mara
commit c4c35bafe3

View file

@ -56,7 +56,8 @@ pub fn spawn(coord: Arc<Coordinator>) {
&current_logged_in, &current_logged_in,
&sub_agents, &sub_agents,
&prev_sub_agents, &prev_sub_agents,
); )
.await;
} }
// Periodic container rescan — catches state flips that // Periodic container rescan — catches state flips that
// happen outside our mutation surface (operator runs // happen outside our mutation surface (operator runs
@ -122,7 +123,7 @@ fn is_deliberate_stop(active: Option<bool>, recently_cleared: Option<bool>) -> b
active.unwrap_or(false) || recently_cleared.unwrap_or(false) active.unwrap_or(false) || recently_cleared.unwrap_or(false)
} }
fn emit_login_transitions( async fn emit_login_transitions(
coord: &Coordinator, coord: &Coordinator,
prev: &HashSet<String>, prev: &HashSet<String>,
current: &HashSet<String>, current: &HashSet<String>,
@ -131,9 +132,15 @@ fn emit_login_transitions(
) { ) {
for agent in current.difference(prev) { for agent in current.difference(prev) {
tracing::info!(%agent, "agent logged in"); tracing::info!(%agent, "agent logged in");
coord.notify_manager(&hive_sh4re::HelperEvent::LoggedIn { coord
agent: agent.clone(), .push_todo(
}); hive_sh4re::MANAGER_AGENT,
"core",
Some(format!("logged_in:{agent}")),
format!("agent '{agent}' logged in"),
None,
)
.await;
} }
// Detect transitions into "needs login": an agent that was previously // Detect transitions into "needs login": an agent that was previously
// logged-in goes unsigned (credentials deleted), OR a brand-new agent // logged-in goes unsigned (credentials deleted), OR a brand-new agent
@ -156,9 +163,15 @@ fn emit_login_transitions(
.collect(); .collect();
for agent in current_needs.difference(&prev_needs) { for agent in current_needs.difference(&prev_needs) {
tracing::info!(%agent, "agent needs login"); tracing::info!(%agent, "agent needs login");
coord.notify_manager(&hive_sh4re::HelperEvent::NeedsLogin { coord
agent: (*agent).to_owned(), .push_todo(
}); hive_sh4re::MANAGER_AGENT,
"core",
Some(format!("needs_login:{agent}")),
format!("agent '{agent}' needs login"),
None,
)
.await;
} }
} }