code wiki / (root) / nx_deploy_listen_gate.nx

nx_deploy_listen_gate.nx

buildroot/runtime/nx_deploy_listen_gate.nx

15316 B243 linesdepth 10pulls 29 transitivereach 0 importersview sourcekind gate/prooftopic deploy
docsdependenciesstructsconstsfunctions

about

nx_deploy_listen_gate.nx -- THE REFEREE FOR THE DEPLOY LISTEN CHECK (debt 1786068492). WHAT IT PROVES, AND WHAT IT DELIBERATELY DOES NOT. The subject is md_probe_listen_edge_cfg: the edge-triggered listener verification /api/deploy runs after it promotes and kills. The defect it exists to catch is NOT "no check ran" -- a check ran for weeks -- it is that the check was LEVEL-TRIGGERED, so "something is listening" was true both before and after the swap and a connect issued in the SIGKILL teardown window greened on the OUTGOING process. This gate therefore does not merely ask "did it say green"; it asks WHICH LISTENER the green describes. HERMETIC BY CONSTRUCTION: every fixture is a throwaway socket this gate binds itself, on a port it PROVES free first, in a forked child it reaps. It never touches a serving daemon and writes NO scratch file at all -- so it is idempotent by construction rather than by a teardown that a crash would skip. license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_gate_verdict.nx nx_mgmt_data.nx nx_deploy_listen_gate.nx

imports: nx_syscalls.nxnx_gate_verdict.nxnx_mgmt_data.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main 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 ↻ gv_head gv_puts sys_write ↻ dlg_slots sys_mmap ↻ dlg_cfg dlg_free_port md_tcp_alive sys_socket sys_mmap ↻ nx_connect_bounded nx_fcntl sys_connect sys_mmap ↻ sys_poll sys_munmap sys_close dlg_listen sys_socket ↻ sys_mmap ↻ sys_bind sys_close ↻ sys_listen

structs

none

consts

23const DLG_UP_TRIES: i64 = 6 // 6 x 100ms = 600ms up budget: 4x the bind delay below, so a healthy bind cannot lose on timing alone
24const DLG_UP_TICK_MS: i64 = 100
25const DLG_DOWN_TICK_MS: i64 = 20 // down window derives to 100/20 = 5 samples, mirroring the production derivation exactly
26const DLG_BIND_DELAY_MS: i64 = 150 // > one up-tick, so the probe MUST observe at least one REFUSED sample before the bind lands
27const DLG_HOLD_MS: i64 = 1200 // > the whole up budget, so the fixture cannot vanish mid-measurement
28const DLG_LINGER_MS: i64 = 1500 // fixture B outlives the probe: a child that exited early would free-run the port
29const DLG_PORT_BASE: i64 = 39701 // high, unassigned, above every port named in deploy_targets.conf
30const DLG_PORT_SCAN: i64 = 64 // bounded search; exhausting it is a PRECONDITION failure (SKIP), never a RED
40const DLG_BACKLOG: i64 = 64
44const DLG_SA_LEN: i64 = 16
45const DLG_SA_FAM_LO: i64 = 0
46const DLG_SA_FAM_HI: i64 = 1
47const DLG_SA_PORT_HI: i64 = 2
48const DLG_SA_PORT_LO: i64 = 3
49const DLG_SA_IP_A: i64 = 4
50const DLG_SA_IP_B: i64 = 5
51const DLG_SA_IP_C: i64 = 6
52const DLG_SA_IP_D: i64 = 7
53const DLG_SA_ADDR_END: i64 = 8
54const DLG_AF_INET_B: i64 = 2
55const DLG_BYTE_MASK: i64 = 0xff
56const DLG_PORT_SHIFT: i64 = 8
57const DLG_LOOPBACK_A: i64 = 127
58const DLG_LOOPBACK_D: i64 = 1
60const DLG_I64_BYTES: i64 = 8 // sizeof(i64): the slot table is MD_PC_SLOTS of these
61const DLG_WAIT_SCRATCH: i64 = 16 // wait4 status word scratch
64const DLG_PROD_UP_TRIES: i64 = 10
65const DLG_PROD_UP_TICK_MS: i64 = 3000
66const DLG_PROD_DOWN_TICK_MS: i64 = 50
70const DLG_GUARD_RESPAWN_BOUND_MS: i64 = 15000
75const DLG_TOOLSAPI_PORT: i64 = 18096

functions

79func dlg_listen(port: i64) -> i64
101func dlg_free_port(start: i64, tries: i64) -> i64
115func dlg_cfg(out: *i64, up_tries: i64, up_tick: i64, down_tick: i64) -> i64
called by 1: main
121func dlg_slots() -> *i64 { return sys_mmap(DLG_I64_BYTES * MD_PC_SLOTS) as *i64 }
called by 1: main calls 1: sys_mmap
123func main() -> i64