code wiki / (root) / nx_gen_dispatch_gate.nx

nx_gen_dispatch_gate.nx

buildroot/runtime/nx_gen_dispatch_gate.nx

18796 B355 linesdepth 5pulls 6 transitivereach 0 importersview sourcekind gate/prooftopic gen
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_gate_verdict.nx nx_connect.nx nx_gen_dispatch_gate.nx

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

main gv_head gv_puts sys_write gv_ctr sys_mmap nxa_die sys_write ↻ sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ sys_mkdir sys_chdir sys_mmap ↻ gv_check gv_puts ↻ dg_can_connect sys_socket sys_mmap ↻ dg_addr nx_connect_bounded nx_fcntl sys_connect sys_mmap ↻ sys_poll sys_munmap sys_close dg_slow_listen sys_socket ↻ sys_mmap ↻ sys_setsockopt

structs

none

consts

21const DG_DAEMON: *u8 = "/volume1/ai/gen/nx_gen_orchestrator_daemon.elf" as *u8
22const DG_DIR: *u8 = "/tmp/nx_gen_dispatch_gate" as *u8
23const DG_MODE_DIR: i64 = 511
24const DG_PORT: i64 = 18979
25const DG_WPORT_SLOW: i64 = 18978
26const DG_WPORT_ABSENT: i64 = 18977
27const DG_CAP: i64 = 65536
28const DG_CONNECT_MS: i64 = 3000
29const DG_PROBE_MS: i64 = 500
31const DG_READ_TMO_S: i64 = 200
33const DG_ISOLATION_US: i64 = 30000000
35const DG_UP_TRIES: i64 = 50
36const DG_UP_STEP_MS: i64 = 100
37const DG_BODY: *u8 = "{\"message\":\"hello there\"}" as *u8
38const DG_BACKLOG: i64 = 16
39const DG_STATUS_503: *u8 = " 503 " as *u8
40const DG_OLD_LIE: *u8 = "all in the registry are down" as *u8
41const DG_BUSY: *u8 = "BUSY-TIMEOUT" as *u8
42const DG_PROBE_TEXT: *u8 = "health probe" as *u8
45const DG_WPORT_ANSWERS: i64 = 18976
46const DG_ANSWER_DELAY_MS: i64 = 6000
47const DG_FIX_READ_TMO_S: i64 = 1
48const DG_FIX_REQ_CAP: i64 = 262144
49const DG_POLL_MS: i64 = 1000
50const DG_POLL_TRIES: i64 = 60
51const DG_BUDGET_ASYNC: *u8 = "64" as *u8
52const DG_NONCE: *u8 = "FIXTURE-REPLY-7f3a9c" as *u8
53const DG_FIX_JSON: *u8 = "{\"choices\":[{\"finish_reason\":\"stop\",\"index\":0,\"message\":{\"role\":\"assistant\",\"content\":\"FIXTURE-REPLY-7f3a9c\"}}]}" as *u8
54const DG_PENDING: *u8 = "\"done\":0" as *u8
55const DG_JOB_KEY: *u8 = "\"job\":\"" as *u8
56const DG_CH_QUOTE: i64 = 34
57const DG_JID_CAP: i64 = 30
58const DG_US_PER_MS: i64 = 1000
59const DG_SIGKILL: i64 = 9
60const DG_PATH_CAP: i64 = 96
61const DG_NONE_CAP: i64 = 8
62const DG_FIX_RESP_CAP: i64 = 4096

functions

64func dg_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
65func 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 }
66func dg_itoa(dst: *u8, off: i64, v: i64) -> i64
74func 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 }
75func dg_find(buf: *u8, n: i64, needle: *u8) -> i64
called by 1: main calls 1: dg_len
90func dg_addr(a: *u8, port: i64) -> i64
98func dg_can_connect(port: i64, budget_ms: i64) -> i64
109func dg_slow_listen(port: i64) -> i64
125func dg_write_swarm_conf(wport: i64) -> i64
141func dg_start_daemon_budget(wport: i64, budget: *u8) -> i64
169func dg_start_daemon(wport: i64) -> i64 { return dg_start_daemon_budget(wport, "2" as *u8) }
called by 1: main calls 1: dg_start_daemon_budget
171func dg_wait_up(port: i64) -> i64
called by 1: main calls 2: dg_can_connectsys_sleep_ms
182func dg_req(port: i64, method: *u8, path: *u8, body: *u8, out: *u8, cap: i64) -> i64
214func dg_post(port: i64, path: *u8, body: *u8, out: *u8, cap: i64) -> i64 { return dg_req(port, "POST" as *u8, path, body, out, cap) }
called by 1: main calls 1: dg_req
215func dg_get(port: i64, path: *u8, out: *u8, cap: i64) -> i64
called by 1: main calls 2: sys_mmapdg_req
223func dg_answering_worker(port: i64) -> i64
255func main() -> i64