Skip to main content

Module wan_presence

Module wan_presence 

Source
Expand description

Publish this install’s presence record to the account’s relay, so a signed-in phone off the LAN can list it (agentmux-mobile’s SPEC_FLEET_HOST_TAGS_AND_CLOUD_HOSTS_2026_10_06 §6.3).

The record (crate::muxbus::install_presence, version 2) is built from the LAN fleet feed’s snapshot (agent names, kinds and states, the channel count) plus this install’s platform, hostname, channel and version, and signed with the WAN instance key, the same identity wan_publish certifies agent keys with. It goes to the account the shared MuxBus sign-in names, with the same token and relay base URL wan_publish uses.

When. The rules live in machine, a pure state machine (signed_out, publishing, retrying, unsupported, rejected); [Driver] runs it. While publishing: on start, on every change of the agents, their kinds or the channel count (debounced [DEBOUNCE]), on a change of agent states alone at most every [STATE_MIN_INTERVAL] (agentmux-mobile’s SPEC_AGENT_STATUS_AND_LIVE_PANE_FEED_2026_10_07 §3.3, so busy agents don’t publish on every turn), and every minute otherwise. A failure backs off with jitter; a relay without the route (404) is tried again within minutes, and at once on a sign-in, a network change, a wake from sleep or a new relay version. Not signed in: no request at all. One request at a time, so an older record never lands after a newer one. Neither the token nor the signature is ever logged.

Goodbye. On a clean quit (goodbye_on_shutdown), a sign-out (goodbye_before_sign_out, then signed_out) and when publishing is turned off, one last record (v3, gone) tells the relay this computer went offline, so devices stop listing it as live at once rather than minutes later. Best effort, at most [GOODBYE_TIMEOUT]; a relay that refuses it (an older one) is not asked again, and nothing waits on it.

Who publishes is policy: not a dev build, an isolated home or a test harness, unless forced; never when the setting is off. A headless srv follows the same rule as the desktop.

presence.status reads status; presence.publish-now calls publish_now; a sign-in calls sign_in_changed; a change of the settings calls [settings_changed].

Modules§

machine
The presence publisher’s decisions, apart from its I/O. Given what just happened ([Event]) and the time ([Now]), [Machine::next] settles the state, says what to do ([Action]) and how long to wait before the next [Event::Due]. Nothing here reads a clock, a random number or the network, so every rule is tested with a fake clock; super::Driver runs it against the relay.
policy
Which installs publish their presence. A normal signed-in desktop does, unless the user turns off “Publish this computer to my devices” (cloud:publishpresence, [setting_on]), and so does a headless srv. A task dev build, an isolated home and a test harness don’t by default: each would leave an entry in the account’s list of computers that is not a computer anyone uses. [FORCE_ENV] turns publishing on for one of those, for testing presence itself; the setting still wins over it.

Functions§

goodbye_before_sign_out
A sign-out, before the sign-in is cleared (the goodbye needs it): say goodbye, at most [GOODBYE_TIMEOUT], and publish nothing more until signed_out. Whether the relay stored it.
goodbye_on_shutdown
A clean quit: say goodbye, at most [GOODBYE_TIMEOUT]. Nothing is published after it.
publish_now
Forget the backoff and try at once. False when no publisher runs.
sign_in_changed
A sign-in, sign-out or account change in this process: try at once.
signed_out
The sign-in is cleared (or clearing it failed): publishing may go on, and the status says “signed off” when the goodbye was stored.
spawn
Start the publisher. No-op without a WAN identity store (nothing to sign with). Stops with token (srv shutdown).
status
The publisher’s status; None until it has one (or without a publisher).