code wiki / _hdl_build / nx_gatebuilt_gate.nx
nx_gatebuilt_gate.nx
buildroot/runtime/_hdl_build/nx_gatebuilt_gate.nx
about
nx_gatebuilt_gate.nx -- THE UNBUILT-GATE CENSUS. For every authored *_gate.nx, does a promoted *_gate.elf
actually exist? A gate that lives only in source makes its subject PERMANENTLY UNVERIFIABLE, and nothing
in the ecosystem reports it.
WHY (found by accident 2026-07-30, id 1785472297): I tried to VERIFY the FD_CLOEXEC port-hostage fix before
eating three sev-9 rows that depend on it. `POST /api/gate_run target=nx_cloexec_gate` returned
**exit_code=127 verdict=NOT-FOUND bytes=0** -- a fully-written gate (T1 control proving the disease state is
reachable, T5 neg-control, T6 non-vacuity) that had NEVER BEEN COMPILED. Building it took one call and it
came back 6/6 GREEN. Until then, three sev-9 incidents rested on a fix nobody could prove.
A two-glob spot check then said the gap is systemic: ~2877 *_gate.nx sources vs ~187 *_gate.elf binaries.
WHY NOTHING ELSE CATCHES IT -- an unbuilt gate is invisible in EVERY direction:
nx_gate_rollup reads LOGS -> no binary means no log means the gate is ABSENT from the roster, not RED.
nx_wirecensus S3 counts promoted-but-unregistered -- never authored-but-unbuilt.
every debt row citing 'gate-proven' reads as evidence regardless.
It is the exact INVERSE of PROVEN_UNWIRED (4952 capabilities BUILT+GATED+never called): there the gate
exists and the capability is unused; here the capability is used and the gate does not exist.
BOTH SCORE AS DONE.
LAW: AN UNBUILT GATE IS INDISTINGUISHABLE FROM A PASSING ONE IN EVERY REPORT THAT MENTIONS IT.
SECOND CLASS, ADDED 2026-08-07 -- STALE-BUILT: the binary EXISTS but PREDATES its own source. Strictly
WORSE than unbuilt, because unbuilt fails LOUD: /api/gate_run answers exit 127 NOT-FOUND for a missing
binary, but exit 0 verdict=GREEN for a stale one -- and a GREEN is believed. Found the expensive way:
nx_fsops_gate served pass=23/23 GREEN off a 2026-07-29 binary while its source declared 28 checks. The
contradiction sat in the SAME response (printed total != declared total) and nothing read it; I reported
"no regression" on that GREEN. MEASURED on this census first run: 3168 sources, 715 built, of which only
176 are CURRENT and 539 are STALE-BUILT -- so 5.6pc of authored gates can speak about their own source.
LAW: A STALE GATE IS WORSE THAN AN UNBUILT ONE. UNBUILT FAILS LOUD; STALE PASSES QUIETLY.
COROLLARY, and the reason this organ must be rebuilt on every edit: EDITING A GATE SOURCE WITHOUT
REBUILDING IT CREATES THE VERY CONDITION THIS GATE REPORTS.
ENVELOPE, declared in the output and never silent: FLAT scan of the two named dirs (no recursion, so the
_attic/_retired/_stage_local shadow trees are deliberately EXCLUDED and this counts LIVE gates only);
existence is probed with openat, not a read, so it is cheap and cannot be fooled by an empty file being
unreadable; the shown list is capped and the cap is printed.
license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0
dependencies 3 imports · 0 importers
imports: nx_syscalls.nxnx_srcfresh.nxnx_doc_mainscan.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
| 42 | const GB_DIR1: *u8 = "buildroot/runtime" as *u8 |
| 43 | const GB_DIR2: *u8 = "buildroot/runtime/_hdl_build" as *u8 |
| 44 | const GB_DIRBUF: i64 = 262144 |
| 45 | const GB_NAMEBUF: i64 = 512 |
| 46 | const GB_MAXSHOW: i64 = 25 |
| 47 | const GB_RECLEN_OFF: i64 = 16 |
| 48 | const GB_NAME_OFF: i64 = 19 |
| 49 | const GB_STATBUF: i64 = 256 // fstatat buffer -- sized as nx_gate_verdict_lib.gv_mtime does |
| 50 | const GB_STAT_MTIME_OFF: i64 = 88 // st_mtime offset, LIFTED from gv_mtime rather than re-derived |
| 51 | const GB_SEC_MIN: i64 = 60 |
| 52 | const GB_MAXSTALE: i64 = 25 // capped list, and the cap is PRINTED |
| 53 | const GB_MAXPARTIAL: i64 = 40 // PARTIAL names listed: a count nobody can act on is a scoreboard |
| 54 | const GB_LINE: i64 = 640 |
| 55 | const GB_MODE_644: i64 = 0x1a4 |
| 59 | const GB_WO_BUILD: *u8 = "knowledge/status/gatebuilt_buildstate.tsv" |
| 60 | const GB_WO_GV: *u8 = "knowledge/status/gatebuilt_verdictstate.tsv" |
| 61 | const GB_SRCSCAN: i64 = 262144 // entry-point probe buffer, allocated ONCE and REUSED per scan |
functions
| 63 | func gb_puts(s: *u8) |
| 69 | func gb_puti(x: i64) |
| 96 | func gb_is_gate_src(nm: *u8, n: i64) -> i64 called by 1: gb_scan |
| 108 | func gb_exists(path: *u8) -> i64 |
| 116 | func gb_at(buf: *u8, i: i64, n: i64, needle: *u8) -> i64 |
| 135 | func gb_wo(fd: i64, lb: *u8, cls: *u8, path: *u8, num: i64) -> i64 |
| 160 | func gb_read_src(path: *u8, buf: *u8) -> i64 |
| 179 | func gb_import_at_bol(buf: *u8, n: i64, needle: *u8) -> i64 |
| 192 | func gb_call_site(buf: *u8, n: i64, needle: *u8) -> i64 |
| 203 | func gb_find(buf: *u8, n: i64, needle: *u8) -> i64 |
| 212 | func gb_mtime(path: *u8) -> i64 |
| 222 | func gb_scan(dir: *u8, ctr: *i64) -> i64 called by 1: main calls 16: sys_openat_rdsys_mmapsys_getdents64gb_is_gate_srcgb_read_srcms_has_main_buf+10 |
| 458 | func main(argc: i64, argv: *i64) -> i64 |