code wiki / _hdl_build / nx_build_admit_gate.nx

nx_build_admit_gate.nx

buildroot/runtime/_hdl_build/nx_build_admit_gate.nx

23297 B355 linesdepth 6pulls 8 transitivereach 0 importersview sourcekind gate/prooftopic build
docsdependenciesstructsconstsfunctions

about

nx_build_admit_gate.nx -- proves the build-admission verdict ADMITS and REFUSES for the right reason. THE DEFECT THIS GATE EXISTS FOR (measured 2026-07-30): nx_build_admit gated a CPU-bound compile on /proc/loadavg field 1, which on Linux counts tasks in R *and* D state. On this host the OS itself split a load1 of 8.33 into IO=3.75 / CPU=4.58 across 8 cores -- 43% of the CPU idle -- and the build was REFUSED. nx_procchurn agreed independently (procs_blocked>=1 with procs_running 3-6: "I/O or lock bound, NOT compute; more CPU would not help"). Every seat's builds were refused on DISK WAIT, and because the fix for the churn is itself a build, the ecosystem could not repair itself through the mgmt API path. THE FIX: a QUEUE verdict must be CONFIRMED by procs_running from /proc/stat -- the TRUE run queue (R only, D excluded). It can only ever admit MORE builds, never fewer, and only when the run queue itself says the CPUs are free. The memory floor remains the ONE unconditional block: it is the measured 2026-07-20 wedge cause, where userspace could not fork at all. Tests execute the imported production policy. The compiler resolves this entry point over the imported module main; no copied policy or substring scan can substitute for execution. Source scans below check textual contracts only, not behavioral equivalence. T8 is the liar-killer: it replays the ORIGINAL loadavg-only policy against the EXACT case the fix was written for and REQUIRES it to refuse. T2 and T8 are the same inputs through the new and old policies: if the fix is ever reverted, T2 fails; if T8 ever stops refusing, this gate is not testing the defect. A gate that cannot demonstrate it catches its own bug is decoration. MIGRATED 2026-08-19 onto nx_gate_verdict (per-tooth gv_check, gv_verdict carries the verdict in the exit code, gv_journal writes the shared gate journal) -- the hand-rolled pass/total pair could print RED and exit 0, and a tooth that silently stopped running lowered both numbers and still read GREEN. The fixture numbers are NAMED for what they measured (rule 11): they are real readings from the incidents the teeth replay, not tuning knobs, and a reader must be able to see which incident each tooth is replaying. license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0

dependencies 3 imports · 0 importers

nx_build_admit.nx nx_syscalls.nx nx_gate_verdict.nx nx_build_admit_gate.nx

imports: nx_build_admit.nxnx_syscalls.nxnx_gate_verdict.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 ↻ bg_verdict ba_verdict ba_reason_exit ba_reason gv_check gv_puts ↻ bg_verdict_old bg_verdict_prestorm bg_verdict_preblocked sys_mmap ↻ bg_read sys_openat_rd sys_read sys_close gv_need gv_puts ↻ bg_find bg_len ba_reason ↻ sys_openat_append

structs

none

consts

38const BG_SRC: *u8 = "runtime/_hdl_build/nx_build_admit.nx"
39const BG_SRC_UP: *u8 = "buildroot/runtime/_hdl_build/nx_build_admit.nx"
41const BG_CALLER: *u8 = "runtime/_hdl_build/nx_sov_build_run.nx"
42const BG_CALLER_UP: *u8 = "buildroot/runtime/_hdl_build/nx_sov_build_run.nx"
43const BG_LOG: *u8 = "knowledge/status/build_admit_gate.log"
44const BG_CAP: i64 = 2097152
45const BG_MODE: i64 = 420
47const BG_GRANT: i64 = 0
48const BG_DENY: i64 = 3
49const BG_QUEUE: i64 = 4
54const BG_FX_AVAIL_MB: i64 = 28302 // MemAvailable on the 07-30 host while the false refusal fired
55const BG_FX_AVAIL_QUEUE_MB: i64 = 28035 // MemAvailable minutes later, when the run queue WAS saturated (T3)
56const BG_FX_FLOOR_MB: i64 = 512 // the floor in force (BA_FLOOR_MB)
57const BG_FX_NCPU: i64 = 8 // the host's CPU count (ioa_ncpu over /proc/stat)
58const BG_FX_MAX_CENTI: i64 = 800 // host-derived ceiling, 1.00 x ncpu in centi-load
59const BG_FX_LOAD_HEALTHY: i64 = 400 // 4.00 -- plainly under the ceiling
60const BG_FX_LOAD_DISKWAIT: i64 = 833 // 8.33 -- the 07-30 reading: over the ceiling, IO 3.75 / CPU 4.58
61const BG_FX_LOAD_SATURATED: i64 = 1458 // 14.58 with procs_running 17 on 8 cores: real saturation (T3)
62const BG_FX_LOAD_STORM: i64 = 3500 // 35.00 -- the 2026-08-16 swap-storm shape (4.4 x ncpu, 2 runnable)
63const BG_FX_LOAD_AT_STORM_LINE: i64 = 1600 // exactly BG_HARD_FACTOR x BG_FX_MAX_CENTI (the > vs >= boundary, T12)
64const BG_FX_LOAD_MILD: i64 = 900 // 9.00 -- mild overshoot where only the blocked axis can decide (T14-T17)
65const BG_FX_MAX_UNREACHABLE: i64 = 1000000 // the ceiling nx_sov_build_run actually passes (load axis disabled)
66const BG_FX_BLOCKED_STORM: i64 = 9 // the 2026-08-16 roster: ~9 in D on 8 CPUs (>= ncpu)
67const BG_FX_BLOCKED_DISKWAIT: i64 = 6 // the 07-30 healthy disk-wait case: blocked 1-6 (below ncpu)
68const BG_FX_RUNQ_IDLE: i64 = 1
69const BG_FX_RUNQ_LOW: i64 = 2
70const BG_FX_RUNQ_HEALTHY: i64 = 3
71const BG_FX_RUNQ_DISKWAIT: i64 = 4 // run queue 4/8 while load read 8.33 -- the CPUs were half idle
72const BG_FX_RUNQ_SATURATED: i64 = 17 // run queue 17/8 -- T3
73const BG_FX_RUNQ_ABSURD: i64 = 99 // T7: load AT the ceiling admits regardless of the run queue
74const BG_FX_BELOW_FLOOR_MB: i64 = 100 // T4: under the memory floor
75const BG_FX_LOAD_IDLE: i64 = 100 // 1.00 -- an idle box (T4 pairs it with the below-floor memory)
76const BG_FX_SENSOR_UNREADABLE: i64 = 0 - 1 // the -1 every sensor reports when it could not read
88const BG_HARD_FACTOR: i64 = 2

functions

78func bg_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 2: bg_wbg_find
79func bg_w(fd: i64, s: *u8) -> i64 { let n: i64 = bg_len(s); sys_write(fd, s, n); return 0 }
called by 1: main calls 2: bg_lensys_write
89func bg_verdict(avail_mb: i64, floor_mb: i64, load1: i64, max_load: i64, procs_run: i64, ncpu: i64, procs_blk: i64, blocked_max: i64) -> i64
called by 2: mainmain calls 1: ba_verdict
95func bg_verdict_prestorm(avail_mb: i64, floor_mb: i64, load1: i64, max_load: i64, procs_run: i64, ncpu: i64) -> i64
called by 1: main
104func bg_verdict_preblocked(avail_mb: i64, floor_mb: i64, load1: i64, max_load: i64, procs_run: i64, ncpu: i64) -> i64
called by 1: main
113func bg_verdict_old(avail_mb: i64, floor_mb: i64, load1: i64, max_load: i64) -> i64
called by 1: main
119func bg_read(path: *u8, buf: *u8) -> i64
called by 1: main calls 3: sys_openat_rdsys_readsys_close
137func bg_find(buf: *u8, n: i64, pat: *u8) -> i64
called by 1: main calls 1: bg_len
151func main() -> i64