Skip to main content

forward_stop_to_shared_channel

Function forward_stop_to_shared_channel 

Source
pub(crate) async fn forward_stop_to_shared_channel(
    state: &AppState,
    block_id: &str,
    signal: Option<&str>,
) -> Option<(String, Result<(), String>)>
Expand description

Stops targets (block ids) via the existing single-target stop_one_agent_block, one call per target, and — unlike that single-target primitive, which involves no jekt signing and so was never audited — records one AuditLogEntry per target via ReactiveHandler::log_fleet_action_audit, so Warden’s Audit tab sees every fleet-initiated stop (SPEC_MULTI_AGENT_FLEET_CONTROL_2026_08_20.md §6; reagent/Codex P2, PR #2687 review — this was missing entirely). Without staged, runs every target as a single batch (still returns full per-target detail, never a bool). With staged, targets are stopped batch_size at a time; if the failure rate WITHIN a completed batch exceeds max_fail_percentage, remaining targets are recorded as failed (untried) and aborted_early is set — caps blast radius on a bad selection rather than plowing through every remaining target. aborted_early is only ever set when targets were genuinely left unattempted — tripping the threshold on the LAST batch (nothing left to skip) must not report “aborted early” when the full list actually ran (reagent P2, same review). Look up block_id in the shared cross-channel registry (this host, other channels — same registry server/reactive.rs’s inject cascade tier-2b already reads) and forward a stop request over loopback HTTP to that channel’s own srv (/agentmux/agent/stop), using its own auth_key from the registry entry — identical trust model to the inject cascade’s own cross-channel forward (same host, same user).

Returns None when block_id isn’t in the shared registry at all, or every matching entry is filtered out (not loopback, or a stale self-entry pointing at THIS instance) — the caller falls through to the normal local “not running” error in that case, same message as before this feature existed. Some((agent_name, outcome)) otherwise.