Module connection

Module connection 

Source
Expand description

Connection-lifecycle reducer handlers. Extracted from reducer/mod.rs in task #182 PR-E for navigability.

Covers: register, goodbye, get_snapshot, plus the enforce_host_only gate and host_is_running predicate that window/saga handlers also call (via super::).

Functions§

enforce_host_only 🔒
Phase B.4 — gate window-mirror reports to Host clients only. The host is the only source of truth about its own window lifecycle; allowing Renderer/Srv/Tool clients to mutate the mirror would let any registered process spoof open/close traffic and break the host-authoritative model. (codex P1 PR #576 round-1.)
handle_get_snapshot 🔒
Phase D.1 — clone the reducer’s canonical state into a Snapshot event. Read-only; doesn’t mutate state except for bumping event_version so the snapshot’s version is monotonically distinct from prior events (subscribers applying snapshot + delta events know the snapshot is “as-of” this version).
handle_goodbye 🔒
handle_register 🔒
host_is_running 🔒
Phase B.9.3 — does state.processes contain a Host in the Running lifecycle? Used by the OrphanInstance transition check; without this guard, a stale Exited record would fire HostShouldQuit on every benign close. Tool-only sessions (agentmux.exe --diag) also correctly skip the saga because they never register a Host.