Skip to main content

agentmux_launcher/supervisor/
mod.rs

1// Copyright 2025-2026, AgentMux Corp.
2// SPDX-License-Identifier: Apache-2.0
3
4//! Platform host-supervision loops. The Windows and Unix supervisors are
5//! fully `#[cfg]`-gated in separate files; only the flow spine
6//! (`launcher_main`) lives at the crate root.
7
8/// Phase 1 host supervision (spec
9/// `docs/specs/SPEC_SERVICE_SUPERVISION_AND_RECOVERY_2026_05_20.md`): on an
10/// abnormal host exit the launcher relaunches the host, but at most
11/// `HOST_RESTART_BUDGET` times within `HOST_RESTART_WINDOW` — a crash budget
12/// so a deterministic crash cannot spin forever (spec §10-A). Shared by
13/// the Windows (`run_windows`) and Unix (`run_unix`) supervisors.
14pub(crate) const HOST_RESTART_BUDGET: usize = 3;
15pub(crate) const HOST_RESTART_WINDOW: std::time::Duration = std::time::Duration::from_secs(60);
16
17/// SPEC_SRV_SUPERVISION_RECYCLE_2026_07_11 (#942 Phase 2) — srv gets its
18/// own crash budget: an unexpected srv exit respawns srv and recycles the
19/// host through the existing supervised-restart path (crash-reproject
20/// restores the session), at most this many times per window. A wider
21/// window than the host's: each srv recycle also costs a host restart, so
22/// a crash-looping srv burns both budgets and gives up loudly either way.
23#[cfg(target_os = "windows")]
24pub(crate) const SRV_RESTART_BUDGET: usize = 3;
25#[cfg(target_os = "windows")]
26pub(crate) const SRV_RESTART_WINDOW: std::time::Duration = std::time::Duration::from_secs(120);
27
28#[cfg(target_os = "windows")]
29mod windows;
30#[cfg(target_os = "windows")]
31pub(crate) use windows::run_windows;
32
33#[cfg(not(target_os = "windows"))]
34mod unix;
35#[cfg(not(target_os = "windows"))]
36pub(crate) use unix::run_unix;