On macOS, the system hostname can silently change between reboots or network transitions. This is particularly common in setups where:
- The dock and wireless network are on separate VLANs, each assigning a different IP and hostname
- Rebooting away from the home network causes macOS to revert to the default computer name (e.g.
macbook-dock.internal → macbook-wireless.internal)
When this happens, agents in the registry retain the old hostname as their hostId. The current normalizeHostId() function only performs basic string normalization (lowercase, strip .local suffix) — it has no awareness that a stale hostname still refers to the local machine.
Impact
- Broken mesh visibility — remote peers can't match local agents to the correct host
- AMP messages fall back to relay instead of direct mesh delivery
- Wake/hibernate failures — agents with stale hostIds are treated as "remote" and the server proxies to itself, returning "unreachable"
- Startup failures —
createSession() can inherit a stale TMUX env var from a parent tmux session that no longer exists after reboot
Proposed fix
normalizeHostId() and needsHostIdNormalization() should call isSelf(), which checks the hostname against all known aliases and local IPs in the hosts config. If a hostId is recognized as this machine but doesn't match the current hostname, it should be automatically migrated to the canonical self ID.
createSession() should unset the TMUX env var to prevent stale parent socket errors.
- Additionally,
validateHosts() should preserve old hostnames as aliases during self-host migration, and registerPeer()/syncWithAllPeers() should detect and migrate peer hostname changes instead of silently treating them as "already known."
We have a working fix in our fork and are happy to open a PR if there's interest.
On macOS, the system hostname can silently change between reboots or network transitions. This is particularly common in setups where:
macbook-dock.internal→macbook-wireless.internal)When this happens, agents in the registry retain the old hostname as their
hostId. The currentnormalizeHostId()function only performs basic string normalization (lowercase, strip.localsuffix) — it has no awareness that a stale hostname still refers to the local machine.Impact
createSession()can inherit a staleTMUXenv var from a parent tmux session that no longer exists after rebootProposed fix
normalizeHostId()andneedsHostIdNormalization()should callisSelf(), which checks the hostname against all known aliases and local IPs in the hosts config. If a hostId is recognized as this machine but doesn't match the current hostname, it should be automatically migrated to the canonical self ID.createSession()should unset theTMUXenv var to prevent stale parent socket errors.validateHosts()should preserve old hostnames as aliases during self-host migration, andregisterPeer()/syncWithAllPeers()should detect and migrate peer hostname changes instead of silently treating them as "already known."We have a working fix in our fork and are happy to open a PR if there's interest.