nx_board_contract_gate.nx
buildroot/runtime/nx_board_contract_gate.nx
about
nx_board_contract_gate.nx -- THE REFEREE FOR BUILD CONTRACTS ON THE COMPARE BOARDS (2026-09-03).
THE DEFECT THIS GUARDS, measured on /compare/lang the day this shipped. A matrix row declares a build
contract in its symbol field as _ABSENT_:<symbol>, and the emitter flips that cell the moment the symbol
exists in the organ named by field 2. That is the hive's completion signal. But NOTHING checks that the
named organ is even CAPABLE of carrying the symbol -- so a row whose field 2 points at the wrong file is a
contract that can NEVER flip, and it reads exactly like honest work-in-progress forever.
LR7 on the lang board sat in that state and cost a full re-derivation: its field 2 named
runtime/nx_boundscheck.nx while bck_elide_dominated is declared in runtime/nx_bck_elide.nx. The capability
had shipped; the cell still said WATCHING; the note still said the compiler lacked it.
WHY A SUBSTRING TEST WOULD BE WORSE THAN NOTHING HERE. nx_boundscheck.nx DOES contain the characters
bck_elide_dominated -- inside the DISTINCT symbol bck_elide_dominated_witness, and in a comment. A naive
substring probe therefore reports that row as perfectly resolvable and the whole class stays invisible.
This gate looks for a DECLARATION (func <symbol> followed by an open paren) and reports a bare textual hit
as its own class, SUBSTRING-ONLY, because that is the shape the trap actually takes.
CLASSES, and every one of them is NAMED, never merely counted:
DECLARED the named organ declares the symbol -- the contract CAN flip. Healthy.
MISPOINTED-CANDIDATE the symbol TEXT occurs in the named organ but no DECLARATION does. This is the LR7
shape and the ONLY class this gate treats as a defect.
PENDING-IN-FILE the organ exists and does not carry the symbol yet -- a normal OPEN contract.
PENDING-NO-ORGAN the named organ is not written yet -- also a normal OPEN contract.
THE RATCHET COUNTS MISPOINTED-CANDIDATE ALONE, AND THAT WAS A CORRECTION MADE ON THE FIRST LIVE RUN.
v1 called all three non-DECLARED classes "unflippable" and reported 1052 of 1169 contracts as defects.
That is a false-positive machine: an _ABSENT_ contract naming an organ nobody has written yet is EXACTLY
what an open build contract IS. Measured live: 468 PENDING-NO-ORGAN + 573 PENDING-IN-FILE are ordinary
work in flight, and only 11 rows carry the shape that can never flip.
⇒ A DETECTOR WITH FALSE POSITIVES IS WORSE THAN NONE, and its own first census is where you find them.
KNOWN LIMIT, DECLARED RATHER THAN HIDDEN. PENDING-IN-FILE cannot be split into "not written yet" versus
"declared somewhere ELSE while this row points here" without a tree-wide declaration index. That index is
a named next leg; this gate does NOT guess at it, and its absence is why PENDING-IN-FILE is reported as
its own axis instead of being folded into the defect count.
The partition SUMS over all four classes, and the sum is printed, because a partition you cannot reconcile
is a leak.
ADVISORY BY CONSTRUCTION ON THE RISE, RATCHETED ON THE FALL. A deliberate hold is legitimate (LR7 held its
dependencies 4 imports · 0 importers
imports: nx_syscalls.nxnx_gate_verdict.nxnx_comparetree_lib.nxnx_gatekit_lib.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
| 58 | const BC_PATH: i64 = 1024 |
| 59 | const BC_CAP: i64 = 1048576 |
| 60 | const BC_LIST: i64 = 65536 |
| 61 | const BC_MODE_RWX: i64 = 493 |
| 62 | const BC_MODE_RW: i64 = 420 |
| 63 | const BC_NL: i64 = 10 |
| 64 | const BC_BAR: i64 = 124 |
| 65 | const BC_ZERO: i64 = 48 |
| 66 | const BC_NINE: i64 = 57 |
| 67 | const BC_MINUS: i64 = 45 |
| 68 | const BC_HASH: i64 = 35 |
| 69 | const BC_AT: i64 = 64 |
| 70 | const BC_MARKLEN: i64 = 9 |
| 71 | const BC_FLD_ORGAN: i64 = 1 |
| 72 | const BC_FLD_SYM: i64 = 2 |
| 73 | const BC_NAMECAP: i64 = 40 |
| 74 | const BC_SYMCAP: i64 = 256 |
| 77 | const BC_C_CONTRACTS: i64 = 0 |
| 78 | const BC_C_DECLARED: i64 = 1 |
| 79 | const BC_C_SUBSTR: i64 = 2 |
| 80 | const BC_C_ABSENT: i64 = 3 |
| 81 | const BC_C_UNREAD: i64 = 4 |
| 82 | const BC_C_DOMAINS: i64 = 5 |
| 83 | const BC_C_ROWS: i64 = 6 |
| 98 | const BC_C_PROSE: i64 = 7 |
| 105 | const BC_C_BINSTALE: i64 = 8 |
| 106 | const BC_NOTECAP: i64 = 8192 |
| 109 | const BC_C_EMITTED: i64 = 9 |
| 110 | const BC_C_SLOTS: i64 = 10 |
| 117 | const BC_LIST_CAP: i64 = 20 |
| 130 | const BC_HASH_MINSLOTS: i64 = 16 // the smallest useful table, not a ceiling: it only ever grows |
| 131 | const BC_HASH_LOAD_NUM: i64 = 2 // slots per record before rounding up to a power of two |
| 132 | const BC_LOWA: i64 = 97 |
| 133 | const BC_LOWZ: i64 = 122 |
| 134 | const BC_UPA: i64 = 65 |
| 135 | const BC_UPZ: i64 = 90 |
| 136 | const BC_US: i64 = 95 |
| 137 | const BC_LPAREN: i64 = 40 |
| 138 | const BC_HASH_SEED: i64 = 5381 |
| 139 | const BC_HASH_MUL: i64 = 33 |
| 140 | const BC_HASH_MOD: i64 = 1000000007 |
| 262 | const BC_NBINMARK: i64 = 3 |
| 290 | const BC_NMARK: i64 = 4 |
functions
| 141 | func bc_isident(ch: i64) -> i64 |
| 148 | func bc_streq_p(a: *u8, b: *u8) -> i64 |
| 154 | func bc_hash(t: *u8, slots: i64) -> i64 |
| 160 | func bc_find_from(buf: *u8, n: i64, needle: *u8, from: i64) -> i64 |
| 174 | func bc_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 175 | func bc_cat(dst: *u8, off: i64, s: *u8) -> i64 { var o: i64 = off; var i: i64 = 0; while s[i] != (0 as u8) { dst[o] = s[i]; o = o + 1; i = i + 1 } dst[o] = 0 as u8; return o } |
| 176 | func bc_put(dst: *u8, off: i64, c: i64) -> i64 { dst[off] = c as u8; dst[off + 1] = 0 as u8; return off + 1 } called by 1: bc_catn |
| 177 | func bc_catn(dst: *u8, off: i64, v: i64) -> i64 |
| 190 | func bc_find(buf: *u8, n: i64, needle: *u8) -> i64 |
| 203 | func bc_has(buf: *u8, n: i64, needle: *u8) -> i64 { if bc_find(buf, n, needle) >= 0 { return 1 } return 0 } |
| 220 | func bc_note_absence(note: *u8, n: i64) -> i64 calls 1: bc_has |
| 242 | func bc_is_stop(b: *u8, i: i64, n: i64) -> i64 |
| 248 | func bc_span_retracted(b: *u8, s: i64, e: i64, tmp: *u8, cap: i64) -> i64 |
| 263 | func bc_binmarker(i: i64) -> *u8 called by 1: bc_note_binary_claim |
| 271 | func bc_note_binary_claim(note: *u8, n: i64, tmp: *u8, cap: i64) -> i64 |
| 291 | func bc_marker(i: i64) -> *u8 called by 1: bc_note_stale_claim |
| 299 | func bc_note_stale_claim(note: *u8, n: i64, tmp: *u8, cap: i64) -> i64 |
| 321 | func bc_field_last(buf: *u8, ls: i64, le: i64, out: *u8, cap: i64) -> i64 called by 1: bc_census_domain |
| 332 | func bc_exists(path: *u8) -> i64 { let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 } sys_close(fd); return 1 } |
| 334 | func bc_target_of(organ: *u8, out: *u8, cap: i64) -> i64 |
| 355 | func bc_artifact_exists(tname: *u8, tmp: *u8) -> i64 |
| 377 | func bc_write(path: *u8, text: *u8) -> i64 |
| 387 | func bc_field(buf: *u8, ls: i64, le: i64, idx: i64, out: *u8, cap: i64) -> i64 called by 1: bc_census_domain |
| 413 | func bc_resolve_organ(rel: *u8, out: *u8) -> i64 |
| 428 | func bc_classify(organrel: *u8, sym: *u8, scratch: *u8, srcbuf: *u8) -> i64 |
| 443 | func bc_say(s: *u8) -> i64 { sys_write(1, s, bc_slen(s)); return 0 } |
| 445 | func bc_census_domain(dom: *u8, ctr: *i64, mbuf: *u8, srcbuf: *u8, scratch: *u8, collect: i64, t_dom: *i64, t_org: *i64, t_sym: *i64, t_cls: *i64, nrec: *i64) -> i64 called by 1: bc_scan_all calls 13: sys_mmapct_compare_read_publishedbc_fieldbc_hasbc_slenbc_classify+7 |
| 545 | func bc_zero(ctr: *i64) -> i64 { var i: i64 = 0; while i < BC_C_SLOTS { ctr[i] = 0; i = i + 1 } return 0 } |
| 553 | func bc_unflippable(ctr: *i64) -> i64 { return ctr[BC_C_SUBSTR] } |
| 558 | func bc_scan_all(lst: *u8, ln: i64, c: *i64, mbuf: *u8, srcbuf: *u8, scratch: *u8, collect: i64, t_dom: *i64, t_org: *i64, t_sym: *i64, t_cls: *i64, nrec: *i64) -> i64 |
| 577 | func main(argc: i64, argv: *i64) -> i64 |