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