hive-c0re: push HelperEvent::Spawned as a todo, not a broker message
Follow-up from #2955 (mara: 'make core able to give agent a todo'). First migration slice: Spawned was pure FYI-check-when-convenient material, not something needing an immediate turn. Coordinator::push_todo/push_todo_submitter do a best-effort live dial of the target agent's own hive-agent-sock (hive_host_sock::agent_todo_ socket), sending the exact UpsertTodo request in-container producers (matrix/bash/forge-notify) already send. Push, not queue: agent offline (socket absent) or dial failure is a silent no-op, no retry, no fallback delivery -- matches mara's 'not available if offline' call exactly. HelperEvent::Spawned removed entirely (enum variant + all 3 call sites migrated: handle_spawn's two arms, finish_approval's Spawn approval-kind arm) rather than kept alongside a translation layer -- per mara's correction on the first design attempt, migrating the producer means deleting the old path, not bridging it. Verified: cargo build/clippy/test -p hive-c0re -p hive-host-sock -p hive-sh4re clean (318 tests), nix fmt clean.
This commit is contained in:
parent
f60e8a8470
commit
d77f81cd1e
8 changed files with 150 additions and 37 deletions
|
|
@ -297,22 +297,30 @@ async fn handle_spawn(coord: &Arc<Coordinator>, name: &str) -> Result<HostRespon
|
|||
// Bind the MCP listener now that the container is starting up.
|
||||
// The harness connects to this socket on its first turn.
|
||||
coord.register_agent(name)?;
|
||||
coord.notify_manager(&hive_sh4re::HelperEvent::Spawned {
|
||||
agent: name.to_owned(),
|
||||
ok: true,
|
||||
note: None,
|
||||
});
|
||||
coord
|
||||
.push_todo(
|
||||
hive_sh4re::MANAGER_AGENT,
|
||||
"core",
|
||||
Some(format!("spawned:{name}")),
|
||||
format!("agent '{name}' spawned"),
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
// Update tmpfiles.d so the new agent's dirs survive a reboot.
|
||||
tokio::spawn(lifecycle::sync_tmpfiles());
|
||||
}
|
||||
Err(e) => {
|
||||
// Spawn failed: register_agent was never called, so there is
|
||||
// nothing to unregister. Notify the manager and propagate.
|
||||
coord.notify_manager(&hive_sh4re::HelperEvent::Spawned {
|
||||
agent: name.to_owned(),
|
||||
ok: false,
|
||||
note: Some(format!("{e:#}")),
|
||||
});
|
||||
coord
|
||||
.push_todo(
|
||||
hive_sh4re::MANAGER_AGENT,
|
||||
"core",
|
||||
Some(format!("spawned:{name}")),
|
||||
format!("agent '{name}' spawn FAILED: {e:#}"),
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
return Err(e);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue