Expand description
The AgentMux instances running on this machine, one record each, so a tool in one instance can
name another (muxspect instances, muxspect --channel <name> ...;
docs/specs/SPEC_MUXSPECT_CROSS_TIER_INSTANCE_INSPECTION_2026_09_02.md §2, Phase 2a).
One <channel>-<hash>.json per running srv under registry::resolve_shared_instances_dir(),
written when srv starts, rewritten every HEARTBEAT_INTERVAL and removed when it exits. The
agent registry cannot answer this: it has one file per agent, so a channel with no agent
registered has no file at all. A record carries the instance’s auth_key (the way the agent
registry’s entries do) so a request can be forwarded to it; the file is readable by its owner
only, and muxspect instances never prints the key.
A record is listed only while its srv is alive: a fresh updated_at AND a process that started
no later than that write (reactive::registry::pid_alive_since, so a recycled pid does not keep
a dead instance listed). A record whose process is gone is removed by whoever reads it.
Structs§
- Identity
- What this srv knows about itself; the rest of its record is read fresh on each beat.
- Instance
Record - One instance’s record, as stored on disk.
Constants§
- HEARTBEAT_
INTERVAL - How often a running instance rewrites its record.
- STALE_
AFTER_ MS - A record not rewritten for this long (three missed beats) is not listed.
Functions§
- live_
instances read_liveagainst the real process table.- read_
live - The live instances in
dir, sorted by channel.pid_alive(pid, updated_at)says whether the process that wrote a record at that time still runs. A record whose process is gone is deleted; one that is merely stale (a live process that stopped beating) is skipped and left. - record_
file_ name - The file a channel’s record lives in: a readable stem (reduced to
[a-z0-9_-]and capped, so it can never name a path outside the directory) and 8 hex chars of a SHA-256 of the exact channel name, because the stem alone is lossy (Fooandfoo bar/foo_barwould share one file). - remove_
own_ record - Remove
channel’s record if it is the one processpidwrote. Another process on the same channel name owns its own record and keeps it. - spawn
- Publish this instance’s record now and again every
HEARTBEAT_INTERVALfor as long as srv runs. - withdraw
- Remove this instance’s record at a clean exit. A crash leaves it; the next reader removes it because its process is gone.
- write_
record - Write
recordatomically (temp file in the same folder, then rename). The temp file is created owner-only on Unix; on Windows the folder inherits the user’s own profile ACL.