Module parent_process

Module parent_process 

Source
Expand description

Parent-process identity check used by the launcher-IPC connection guard in main.rs. Returns true when the host’s parent process is the AgentMux launcher.

Background — see docs/specs/SPEC_DEV_MODE_LAUNCHER_IPC_2026_05_16.md. Before this helper, the connect-to-launcher gate used is_dev_build_exe(exe_dir) as a proxy for “the launcher is not running, skip IPC”. That worked when task dev invoked the host directly. After SPEC_LAUNCHER_DEV_INTEGRATION_2026-05-13.md made task dev spawn the host via the launcher (production-parallel layout), the path-based guard wrongly skipped legitimate IPC in dev, breaking WindowOpened / BackendWindowIdRegistered event delivery (visible as: status-bar window-count desync and missing opacity slider in dev).

Parent-process check is a tighter discriminator: it admits the dev launcher (correct) and still rejects a standalone dev host that happened to inherit AGENTMUX_LAUNCHER_PIPE from a parent shell (also correct — that’s the original isolation concern).

Constants§

ACCEPTED_PARENT_STEMS 🔒
Exe filenames we accept as “the AgentMux launcher.” Compared case-insensitively after stripping the .exe extension.

Functions§

parent_exe_file_windows 🔒
Walk the Toolhelp32 process snapshot in a single pass to:
parent_is_agentmux_launcher
Returns Some(true) if the host’s parent process is the AgentMux launcher (under any of its on-disk names), Some(false) if it’s something else, or None if the parent identity couldn’t be determined (snapshot creation failed, parent process exited between PID discovery and lookup). Callers treat None as “fall through to the path-based guard” — see the call site.