code wiki / _hdl_build / nx_build_admit_gate.nx

nx_build_admit_gate.nx

buildroot/runtime/_hdl_build/nx_build_admit_gate.nx

9047 B180 linesdepth 2pulls 2 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. WHY THE POLICY IS MIRRORED RATHER THAN IMPORTED: nx_build_admit.nx carries its own main(), so importing it here would collide. The policy is therefore mirrored, and T9 MECHANICALLY TIES THE MIRROR TO THE REAL SOURCE so silent drift FAILS this gate instead of rotting quietly (the anti-dup-source discipline). 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. license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_build_admit_gate.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

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

main bg_p bg_w bg_len sys_write bg_verdict bg_ck bg_p ↻ bg_verdict_old sys_mmap bg_read sys_openat_rd sys_read sys_close bg_find bg_len ↻ bg_pn sys_mmap ↻ sys_write ↻ sys_openat_append bg_w ↻ sys_close ↻ sys_exit

structs

none

consts

26const BG_SRC: *u8 = "runtime/_hdl_build/nx_build_admit.nx"
27const BG_LOG: *u8 = "knowledge/status/build_admit_gate.log"
28const BG_CAP: i64 = 2097152
29const BG_MODE: i64 = 420
31const BG_GRANT: i64 = 0
32const BG_DENY: i64 = 3
33const BG_QUEUE: i64 = 4

functions

35func 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
36func bg_w(fd: i64, s: *u8) -> i64 { let n: i64 = bg_len(s); sys_write(fd, s, n); return 0 }
called by 2: bg_pmain calls 2: bg_lensys_write
37func bg_p(s: *u8) -> i64 { return bg_w(1, s) }
called by 2: bg_ckmain calls 1: bg_w
38func bg_pn(v: i64) -> i64
called by 1: main calls 2: sys_mmapsys_write
51func bg_ck(name: *u8, c: i64) -> i64
called by 1: main calls 1: bg_p
58func bg_verdict(avail_mb: i64, floor_mb: i64, load1: i64, max_load: i64, procs_run: i64, ncpu: i64) -> i64
called by 1: main
66func bg_verdict_old(avail_mb: i64, floor_mb: i64, load1: i64, max_load: i64) -> i64
called by 1: main
72func bg_read(path: *u8, buf: *u8) -> i64
called by 1: main calls 3: sys_openat_rdsys_readsys_close
90func bg_find(buf: *u8, n: i64, pat: *u8) -> i64
called by 1: main calls 1: bg_len
104func main() -> i64