nx_swarm_endpoint_lib.nx
buildroot/runtime/nx_swarm_endpoint_lib.nx
about
nx_swarm_endpoint_lib.nx -- THE one act every swarm caller performs: resolve a ROLE to an ADDRESS.
WHY (a live outage, measured 2026-07-30): the laptop GPU endpoint was a hardcoded string literal in
FIVE files -- nx_mesh_lb:42, nx_swarm_coord:66, nx_worker_dispatch:67, nx_hostctl:268,
nx_mgmt_api:456. DHCP moved the box from .193 to .192 and all five went stale in the same instant.
nx_swarm_coord:66 even carried the comment "worker_dispatch SSOT" while COPYING the value -- a
claimed single source of truth that was really a fifth duplicate. Meanwhile sd-server sat HEALTHY
on the 5080 and all four swarm gates read GREEN, because a gate that measures the PLAN does not
measure the REACHABILITY.
LAW APPLIED: a fix that must be remembered at N sites has to bind to the ONE act all N perform.
That act is this function. Callers ask for a role; nobody spells an address again.
LAYER: lives in runtime/ (the PRIMITIVE layer) precisely so BOTH runtime/ organs and
_hdl_build/ organs can import it -- the import edge is directed and primitives may not depend on
tools (seq1450). Library only: NO main(), so any organ can import it without a duplicate entry.
FAIL-CLOSED: unknown role or unreadable table returns 0, never a fabricated address. A wrong
endpoint fails SILENTLY at dispatch; a missing one fails LOUDLY at resolve. Prefer loud.
The table is re-read on every call (~1KB), so an address edit takes effect with no restart.
license_tier: ORIGINAL
dependencies 1 imports · 7 importers
imports: nx_syscalls.nx
imported by: nx_gen_orchestrator.nxnx_mesh_lb.nxnx_se_addr_probe.nxnx_swarm_coord.nxnx_swarm_endpoint.nxnx_worker_dispatch.nxnx_write.nx
structs
| none |
consts
| 24 | const K_MAGIC_65536: i64 = 65536 |
| 25 | const K_MAGIC_65535: i64 = 65535 |
functions
| 27 | func se_len(s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { i = i + 1 } return i } |
| 29 | func se_put(o: *u8, at: i64, s: *u8) -> i64 |
| 36 | func se_putn(o: *u8, at: i64, buf: *u8, off: i64, n: i64) -> i64 |
| 43 | func se_putd(o: *u8, at: i64, v: i64) -> i64 |
| 55 | func se_ceq(a: *u8, b: *u8) -> i64 called by 1: main |
| 66 | func se_seq(buf: *u8, off: i64, n: i64, s: *u8) -> i64 |
| 74 | func se_has(buf: *u8, off: i64, n: i64, needle: *u8) -> i64 |
| 89 | func se_field(buf: *u8, s: i64, e: i64, idx: i64, box: *i64) -> i64 called by 1: se_ctx |
| 112 | func se_slurp(path: *u8, buf: *u8, cap: i64) -> i64 |
| 128 | func se_ctx() -> *i64 |
| 174 | func se_find(ctx: *i64, role: *u8) -> i64 |
| 189 | func se_addr(role: *u8) -> *u8 called by 7: go_swarm_workermainco_usablemainse_hostwd_where_role+1 calls 4: se_ctxse_findsys_mmapse_putn |
| 204 | func se_host(role: *u8) -> *u8 |
| 219 | func se_desc(role: *u8) -> *u8 |
| 232 | func se_addr_desc(role: *u8) -> *u8 |