swarm-queue-based lifecycle notices, replacing push_todo(MANAGER_AGENT)

This commit is contained in:
damocles 2026-08-16 15:58:45 +02:00 committed by mara
commit e44ea9d8d4
12 changed files with 388 additions and 142 deletions

View file

@ -326,16 +326,13 @@ async fn run_destroy_bookkeeping(coord: &Arc<Coordinator>, agent: &str, purge: b
if let Err(e) = coord.power.remove(agent) {
tracing::warn!(%agent, error = ?e, "agent_power: remove on destroy failed");
}
let _ = coord
.push_todo(
hive_sh4re::manager::MANAGER_AGENT,
"core",
Some(format!("destroyed:{agent}")),
format!("agent '{agent}' destroyed"),
None,
false,
)
.await;
crate::swarm_notices::notify(
"core",
Some(format!("destroyed:{agent}")),
format!("agent '{agent}' destroyed"),
None,
)
.await;
// Container row disappeared — rescan so the dashboard fires
// `ContainerRemoved` for the gone row, then emit the tombstones snapshot
// (gained one on destroy, lost one on purge — recompute either way).
@ -358,16 +355,7 @@ async fn run_emit_rebuilt(coord: &Arc<Coordinator>, agent: &str, dag_id: Option<
.then(|| dag_id.and_then(|dag| coord.job_queue.first_error(dag)))
.flatten();
let summary = crate::coordinator::rebuilt_todo_summary(agent, ok, note.as_deref(), None, None);
let _ = coord
.push_todo(
hive_sh4re::manager::MANAGER_AGENT,
"core",
Some(format!("rebuilt:{agent}")),
summary,
None,
false,
)
.await;
crate::swarm_notices::notify("core", Some(format!("rebuilt:{agent}")), summary, None).await;
}
/// Write the agent's durable power intent — the DAG-node form of the old
@ -622,16 +610,13 @@ async fn run_stop(coord: &Arc<Coordinator>, name: &str) -> Result<()> {
// own kind now.
crate::lifecycle::kill(name).await?;
coord.unregister_agent(name);
let _ = coord
.push_todo(
hive_sh4re::manager::MANAGER_AGENT,
"core",
Some(format!("killed:{name}")),
format!("agent '{name}' killed"),
None,
false,
)
.await;
crate::swarm_notices::notify(
"core",
Some(format!("killed:{name}")),
format!("agent '{name}' killed"),
None,
)
.await;
coord.rescan_containers_and_emit().await;
Ok(())
}