hivectl: error on pause/resume of a non-existent agent

This commit is contained in:
damocles 2026-08-10 20:55:38 +02:00 committed by mara
commit 3a69ad4256

View file

@ -204,7 +204,19 @@ pub(crate) async fn agents_list(socket: &Path, json: bool) -> Result<()> {
/// `hivectl agent <name> pause|resume` — flip the agent's pause marker. Not a
/// DAG, so there's nothing to wait on: the daemon writes the marker and
/// the harness picks it up on its next poll.
///
/// Checks existence first, same as `agents_start` above — the daemon side
/// (`Coordinator::set_paused`) writes the marker file unconditionally via
/// the priv-helper and has no notion of "no such agent", so without this
/// check `hivectl agent typo-name resume` would exit 0 and print
/// `resumed: typo-name` for a name that was never a real agent.
async fn set_paused(socket: &Path, name: &str, paused: bool) -> Result<()> {
if !crate::util::agent_exists(socket, name).await? {
bail!(
"no such agent: '{name}' (no state dir under {}/)",
hive_host_sock::AGENTS_ROOT
);
}
let resp = crate::client::request(
socket,
HostRequest::SetPaused {