Module runtime_mode

Module runtime_mode 

Source
Expand description

Runtime mode detection — single source of truth.

The launcher computes RuntimeMode::current once at startup and propagates the result to host + srv via the AGENTMUX_RUNTIME_MODE environment variable. No binary should call [current] more than once per process; downstream binaries read the env var via [from_env] instead.

Replaces the legacy mix of cfg!(debug_assertions), env::var ("AGENTMUX_DEV").is_ok(), and == Ok("1") checks across launcher, host, and sidecar — which were each correct in isolation but desynchronized in combination (see docs/specs/ SPEC_DATA_DIR_UNIFICATION_2026-05-05.md §2.1).

§Detection priority

  1. AGENTMUX_RUNTIME_MODE env override (testing, CI).
  2. Marker-based portable detection: <exe-dir>/agentmux-portable.marker exists (also looks two levels up for macOS .app bundles). Written by scripts/package-portable.sh at packaging time (see the printf '...' > "$PORTABLE/agentmux-portable.marker" line).
  3. Path-based dev detection: exe is under a known dev-build dir (dist/cef-dev/, target/debug/, target/release/).
  4. AGENTMUX_DEV_BRANCH env override (CI override for dev mode).
  5. Default: Installed.

Enums§

RuntimeMode
Where this AgentMux binary is running from. Determines data path layout (see crate::DataPaths).

Functions§

is_dev_build_exe
True when this binary is running from one of our known dev-build output directories (dist/cef-dev/, target/debug/, target/release/). Walks ancestors to handle nested cases (CEF subprocesses run from a runtime/ subdir even in dev). Path-only — does not read env.