nx_deploy_listen_gate.nx
buildroot/runtime/nx_deploy_listen_gate.nx
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
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
structs
| none |
consts
| 23 | const 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 |
| 24 | const DLG_UP_TICK_MS: i64 = 100 |
| 25 | const DLG_DOWN_TICK_MS: i64 = 20 // down window derives to 100/20 = 5 samples, mirroring the production derivation exactly |
| 26 | const DLG_BIND_DELAY_MS: i64 = 150 // > one up-tick, so the probe MUST observe at least one REFUSED sample before the bind lands |
| 27 | const DLG_HOLD_MS: i64 = 1200 // > the whole up budget, so the fixture cannot vanish mid-measurement |
| 28 | const DLG_LINGER_MS: i64 = 1500 // fixture B outlives the probe: a child that exited early would free-run the port |
| 29 | const DLG_PORT_BASE: i64 = 39701 // high, unassigned, above every port named in deploy_targets.conf |
| 30 | const DLG_PORT_SCAN: i64 = 64 // bounded search; exhausting it is a PRECONDITION failure (SKIP), never a RED |
| 40 | const DLG_BACKLOG: i64 = 64 |
| 44 | const DLG_SA_LEN: i64 = 16 |
| 45 | const DLG_SA_FAM_LO: i64 = 0 |
| 46 | const DLG_SA_FAM_HI: i64 = 1 |
| 47 | const DLG_SA_PORT_HI: i64 = 2 |
| 48 | const DLG_SA_PORT_LO: i64 = 3 |
| 49 | const DLG_SA_IP_A: i64 = 4 |
| 50 | const DLG_SA_IP_B: i64 = 5 |
| 51 | const DLG_SA_IP_C: i64 = 6 |
| 52 | const DLG_SA_IP_D: i64 = 7 |
| 53 | const DLG_SA_ADDR_END: i64 = 8 |
| 54 | const DLG_AF_INET_B: i64 = 2 |
| 55 | const DLG_BYTE_MASK: i64 = 0xff |
| 56 | const DLG_PORT_SHIFT: i64 = 8 |
| 57 | const DLG_LOOPBACK_A: i64 = 127 |
| 58 | const DLG_LOOPBACK_D: i64 = 1 |
| 60 | const DLG_I64_BYTES: i64 = 8 // sizeof(i64): the slot table is MD_PC_SLOTS of these |
| 61 | const DLG_WAIT_SCRATCH: i64 = 16 // wait4 status word scratch |
| 64 | const DLG_PROD_UP_TRIES: i64 = 10 |
| 65 | const DLG_PROD_UP_TICK_MS: i64 = 3000 |
| 66 | const DLG_PROD_DOWN_TICK_MS: i64 = 50 |
| 70 | const DLG_GUARD_RESPAWN_BOUND_MS: i64 = 15000 |
| 75 | const DLG_TOOLSAPI_PORT: i64 = 18096 |
functions
| 79 | func dlg_listen(port: i64) -> i64 |
| 101 | func dlg_free_port(start: i64, tries: i64) -> i64 |
| 115 | func dlg_cfg(out: *i64, up_tries: i64, up_tick: i64, down_tick: i64) -> i64 called by 1: main |
| 121 | func dlg_slots() -> *i64 { return sys_mmap(DLG_I64_BYTES * MD_PC_SLOTS) as *i64 } |
| 123 | func main() -> i64 |