Skip to main content

Module other_instances

Module other_instances 

Source
Expand description

Read-only detection of OTHER AgentMux (channel, version) instances currently running on this machine, for diagnostic logging ONLY.

Scope note (task #35 / docs/specs/SPEC_WIN10_PAGEFILE_OOM_CRASH_2026_06_29.md P1, “shut down old version on upgrade”): the original ask was a full opt-in “close the old version?” prompt with a cross-instance graceful quit. Investigation found that a cross-instance quit action is currently blocked by invariant I4 in docs/specs/SPEC_MULTI_INSTANCE_ISOLATION_HARDENING_2026_06_03.md (“the only permitted interaction with another instance is the authenticated open_new_window forward; it is side-effect-free w.r.t. that instance’s lifecycle”) — extending that invariant is a design decision that needs its own review, not something to fold into a minimal patch. This module implements ONLY the read-only half:

  1. Enumerate sibling (channel, version) directories on disk under channels/.
  2. Connect-probe each one’s single-instance pipe/socket — the SAME kind of non-destructive liveness check second_instance.rs already performs for the CURRENT channel’s stale-socket recovery, just pointed at a different (channel, version) pair. A bare connect (no command sent) is side-effect-free w.r.t. the target’s lifecycle, consistent with I4.
  3. Log (never prompt, never dialog, never contact the other instance beyond the liveness probe itself) when a LIVE, strictly OLDER version is found.

Every function here is best-effort: any failure (missing dir, unreadable entry, probe error) is treated as “nothing to report”, never a hard error. This is a diagnostic nicety — it must never block or fail this process’s own launch.

Structs§

SiblingInstance
A sibling (channel, version) directory found on disk, distinct from the caller’s own. Liveness is NOT implied by construction — see log_older_running_instances, which probes before logging.

Functions§

enumerate_sibling_instances
Walk <channels_root>/*/versions/*/ and return every (channel, version) pair other than (own_channel, own_version).
is_strictly_older 🔒
True iff candidate parses as strictly older than own. Unparseable input on either side is never treated as older — fail quiet rather than risk a misleading log line.
log_older_running_instances
Enumerate sibling instances, probe each for liveness, and log (via crate::logging::log) every LIVE instance running a strictly OLDER version than own_version. Never prompts, never blocks, never sends anything beyond the liveness probe itself. Intended to be called from a detached/spawned task at startup — every failure path here is a no-op, so there is nothing for the caller to react to.
parse_semver_core 🔒
Parse a leading major.minor.patch out of a version string, ignoring any -prerelease or +build suffix. Returns None for anything that doesn’t start with three dot-separated integers (e.g. a local build’s labeled version, which normally lives in a local-* channel rather than under a released stable channel anyway). Callers must treat None as “can’t compare” — never guess.
probe_liveness 🔒
Unix equivalent: a plain connect() either finds a listening peer or doesn’t. Mirrors the probe second_instance.rs::bind_socket_with_recovery already performs for the current channel’s stale-socket recovery.