nx_gen_dispatch_gate.nx
buildroot/runtime/nx_gen_dispatch_gate.nx
about
nx_gen_dispatch_gate.nx -- the REFEREE for gen G17 (dispatch honesty) on the CHAT path: a planted SLOW worker (listens,
never answers) must make the LIVE daemon answer BUSY-TIMEOUT, and an ABSENT worker must make it answer the health-probe
refusal -- and NEITHER may read "all in the registry are down", the false attribution measured 2026-08-29 (a socket watch
showed the worker ESTABLISHED and rendering while the caller was told no worker existed).
SUBJECT = the LIVE binary at /volume1/ai/gen (what serves, never a build). The daemon is launched on a throwaway port from a
scratch cwd, so no swarm SSOT conf is visible and the fixture argv worker is its ONLY candidate; budget=2 (one probe connect,
one POST) so it exits by itself and leaves no process behind. The slow fixture LISTENS AND NEVER ACCEPTS: the kernel completes
the handshake into the backlog, so the daemon's probe and connect succeed and its read times out -- exactly the connected-and-
silent worker the defect misattributed. Against the PRE-FIX binary this gate is RED by construction (the bite is the live
history, not a planted mutant). RUNTIME ~4 min (three chat tries at the conf budget): run via nx_job_run, never the FAST
gate_run path.
G18 ADDED 2026-08-30 (the async lane): a third fixture ANSWERS, but only after DG_ANSWER_DELAY_MS. POST /api/chat_async must
return a job id BEFORE that delay can have elapsed (so nothing waited on the worker socket), a poll must read pending first,
and the planted reply must then land through GET /api/batch/<job> -- a completion slower than the submit round-trip lands
instead of being dropped, which is the whole of G18's done-rule. The nonce in the landed reply is the isolation witness.
license_tier: ORIGINAL expect_exit: 0
dependencies 3 imports · 0 importers
imports: nx_syscalls.nxnx_gate_verdict.nxnx_connect.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 21 | const DG_DAEMON: *u8 = "/volume1/ai/gen/nx_gen_orchestrator_daemon.elf" as *u8 |
| 22 | const DG_DIR: *u8 = "/tmp/nx_gen_dispatch_gate" as *u8 |
| 23 | const DG_MODE_DIR: i64 = 511 |
| 24 | const DG_PORT: i64 = 18979 |
| 25 | const DG_WPORT_SLOW: i64 = 18978 |
| 26 | const DG_WPORT_ABSENT: i64 = 18977 |
| 27 | const DG_CAP: i64 = 65536 |
| 28 | const DG_CONNECT_MS: i64 = 3000 |
| 29 | const DG_PROBE_MS: i64 = 500 |
| 31 | const DG_READ_TMO_S: i64 = 200 |
| 33 | const DG_ISOLATION_US: i64 = 30000000 |
| 35 | const DG_UP_TRIES: i64 = 50 |
| 36 | const DG_UP_STEP_MS: i64 = 100 |
| 37 | const DG_BODY: *u8 = "{\"message\":\"hello there\"}" as *u8 |
| 38 | const DG_BACKLOG: i64 = 16 |
| 39 | const DG_STATUS_503: *u8 = " 503 " as *u8 |
| 40 | const DG_OLD_LIE: *u8 = "all in the registry are down" as *u8 |
| 41 | const DG_BUSY: *u8 = "BUSY-TIMEOUT" as *u8 |
| 42 | const DG_PROBE_TEXT: *u8 = "health probe" as *u8 |
| 45 | const DG_WPORT_ANSWERS: i64 = 18976 |
| 46 | const DG_ANSWER_DELAY_MS: i64 = 6000 |
| 47 | const DG_FIX_READ_TMO_S: i64 = 1 |
| 48 | const DG_FIX_REQ_CAP: i64 = 262144 |
| 49 | const DG_POLL_MS: i64 = 1000 |
| 50 | const DG_POLL_TRIES: i64 = 60 |
| 51 | const DG_BUDGET_ASYNC: *u8 = "64" as *u8 |
| 52 | const DG_NONCE: *u8 = "FIXTURE-REPLY-7f3a9c" as *u8 |
| 53 | const DG_FIX_JSON: *u8 = "{\"choices\":[{\"finish_reason\":\"stop\",\"index\":0,\"message\":{\"role\":\"assistant\",\"content\":\"FIXTURE-REPLY-7f3a9c\"}}]}" as *u8 |
| 54 | const DG_PENDING: *u8 = "\"done\":0" as *u8 |
| 55 | const DG_JOB_KEY: *u8 = "\"job\":\"" as *u8 |
| 56 | const DG_CH_QUOTE: i64 = 34 |
| 57 | const DG_JID_CAP: i64 = 30 |
| 58 | const DG_US_PER_MS: i64 = 1000 |
| 59 | const DG_SIGKILL: i64 = 9 |
| 60 | const DG_PATH_CAP: i64 = 96 |
| 61 | const DG_NONE_CAP: i64 = 8 |
| 62 | const DG_FIX_RESP_CAP: i64 = 4096 |
functions
| 64 | func dg_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 65 | func dg_cat(dst: *u8, off: i64, s: *u8) -> i64 { var o: i64 = off; var i: i64 = 0; while s[i] != (0 as u8) { dst[o] = s[i]; o = o + 1; i = i + 1 } return o } |
| 66 | func dg_itoa(dst: *u8, off: i64, v: i64) -> i64 |
| 74 | func dg_str(v: i64) -> *u8 { let b: *u8 = sys_mmap(32); let o: i64 = dg_itoa(b, 0, v); b[o] = 0 as u8; return b } |
| 75 | func dg_find(buf: *u8, n: i64, needle: *u8) -> i64 |
| 90 | func dg_addr(a: *u8, port: i64) -> i64 |
| 98 | func dg_can_connect(port: i64, budget_ms: i64) -> i64 |
| 109 | func dg_slow_listen(port: i64) -> i64 called by 2: dg_answering_workermain calls 7: sys_socketsys_mmapsys_setsockoptdg_addrsys_bindsys_close+1 |
| 125 | func dg_write_swarm_conf(wport: i64) -> i64 |
| 141 | func dg_start_daemon_budget(wport: i64, budget: *u8) -> i64 called by 2: dg_start_daemonmain calls 7: dg_write_swarm_confsys_forksys_chdirsys_mmapdg_strsys_execve_clean+1 |
| 169 | func dg_start_daemon(wport: i64) -> i64 { return dg_start_daemon_budget(wport, "2" as *u8) } |
| 171 | func dg_wait_up(port: i64) -> i64 |
| 182 | func dg_req(port: i64, method: *u8, path: *u8, body: *u8, out: *u8, cap: i64) -> i64 called by 2: dg_postdg_get calls 11: sys_socketsys_mmapdg_addrnx_connect_boundedsys_closesys_set_socket_timeout+5 |
| 214 | func dg_post(port: i64, path: *u8, body: *u8, out: *u8, cap: i64) -> i64 { return dg_req(port, "POST" as *u8, path, body, out, cap) } |
| 215 | func dg_get(port: i64, path: *u8, out: *u8, cap: i64) -> i64 |
| 223 | func dg_answering_worker(port: i64) -> i64 |
| 255 | func main() -> i64 |