---
name: two-daemon-one-box-rig
description: Recipe for a two-SPT_HOME two-daemon rig on one box — ask net_status for the address instead of sniffing the ephemeral port by pid.
metadata: 
  node_type: memory
  type: project
  originSessionId: e1c4771a-c467-47ae-abd7-f426d6ba0705
  modified: 2026-08-02T10:28:47.196Z
---

A cross-node spt rig on ONE machine needs two `spt daemon run` processes, one `SPT_HOME`
each. The daemon has no bind-port knob (`BindScope::All` + mDNS, `daemon.rs`), and the
instinct is to discover its ephemeral UDP port by pid. **Don't — `Brain::net_status()`
returns the daemon's OWN `EndpointAddr`**, which is the production answer to "what am I
reachable as". Read it, then `PeerAddrStore::record(<other-home>/identity/peer-addrs.json,
hex, addr)`. No knob grown, no port sniffing.

The rest of the recipe (all verified 2026-08-02 in `crates/spt/tests/knock_mutual_cross_node_e2e.rs`):

- Socket names are a pure function of `SPT_HOME` (`endpoint.rs::home_tag`), so a
  `fn in_home(path, f)` wrapper that sets `SPT_HOME` and calls the canonical store
  helpers reads/seeds each home through PRODUCTION path names. Sound ONLY in a
  single-`#[test]` binary — see [[two-locks-one-env-var]].
- `daemon.json` `{"relay":"disabled","peer_pump":false}` — `peer_pump:false` is the
  SHIPPED hermetic kill switch, not a test-only knob; it also stops the pump rewriting
  seeded registry snapshots.
- A sealed knock code routes via `<home>/identity/registry/<subnet>.json`
  (`SubnetRegistry::merge_node_label`), NOT via `PeerAddrStore` — seed both.
- mDNS has no off switch, and this box runs the LIVE fleet daemon. Isolation is the rig's
  own subnet seed plus production seed-proof membership, which refuses a discovered fleet
  peer on every dial and accept. Say so in the file rather than hoping.
- `crates/spt` is a BIN crate: tests cannot call its internals, so a router decision must
  be probed through the CLI and its NAMED miss codes.
- A doc-comment line starting with `+ ` parses as a markdown list item and fails clippy's
  `doc list item without indentation` for every following line.
