code wiki / _hdl_build / nx_build_admit_gate.nx
nx_build_admit_gate.nx
buildroot/runtime/_hdl_build/nx_build_admit_gate.nx
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
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
structs
| none |
consts
| 26 | const BG_SRC: *u8 = "runtime/_hdl_build/nx_build_admit.nx" |
| 27 | const BG_LOG: *u8 = "knowledge/status/build_admit_gate.log" |
| 28 | const BG_CAP: i64 = 2097152 |
| 29 | const BG_MODE: i64 = 420 |
| 31 | const BG_GRANT: i64 = 0 |
| 32 | const BG_DENY: i64 = 3 |
| 33 | const BG_QUEUE: i64 = 4 |
functions
| 35 | func bg_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 36 | func bg_w(fd: i64, s: *u8) -> i64 { let n: i64 = bg_len(s); sys_write(fd, s, n); return 0 } |
| 37 | func bg_p(s: *u8) -> i64 { return bg_w(1, s) } |
| 38 | func bg_pn(v: i64) -> i64 |
| 51 | func bg_ck(name: *u8, c: i64) -> i64 |
| 58 | func bg_verdict(avail_mb: i64, floor_mb: i64, load1: i64, max_load: i64, procs_run: i64, ncpu: i64) -> i64 called by 1: main |
| 66 | func bg_verdict_old(avail_mb: i64, floor_mb: i64, load1: i64, max_load: i64) -> i64 called by 1: main |
| 72 | func bg_read(path: *u8, buf: *u8) -> i64 |
| 90 | func bg_find(buf: *u8, n: i64, pat: *u8) -> i64 |
| 104 | func main() -> i64 |