code wiki / (root) / nx_board_contract_gate.nx

nx_board_contract_gate.nx

buildroot/runtime/nx_board_contract_gate.nx

48073 B850 linesdepth 3pulls 5 transitivereach 0 importersview sourcekind gate/prooftopic board
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_gate_verdict.nx nx_comparetree_lib.nx nx_gatekit_lib.nx nx_board_contract_gate.nx

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

main gv_ctr sys_mmap nxa_die sys_write sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ gv_head gv_puts sys_write ↻ sys_mmap ↻ bc_cat bc_catn bc_put sys_mmap ↻ sys_clock_now_us sys_now_us sys_mmap ↻ sys_clock_gettime_mono sys_mkdir bc_write sys_openat_wr bc_slen sys_write ↻ sys_close

structs

none

consts

58const BC_PATH: i64 = 1024
59const BC_CAP: i64 = 1048576
60const BC_LIST: i64 = 65536
61const BC_MODE_RWX: i64 = 493
62const BC_MODE_RW: i64 = 420
63const BC_NL: i64 = 10
64const BC_BAR: i64 = 124
65const BC_ZERO: i64 = 48
66const BC_NINE: i64 = 57
67const BC_MINUS: i64 = 45
68const BC_HASH: i64 = 35
69const BC_AT: i64 = 64
70const BC_MARKLEN: i64 = 9
71const BC_FLD_ORGAN: i64 = 1
72const BC_FLD_SYM: i64 = 2
73const BC_NAMECAP: i64 = 40
74const BC_SYMCAP: i64 = 256
77const BC_C_CONTRACTS: i64 = 0
78const BC_C_DECLARED: i64 = 1
79const BC_C_SUBSTR: i64 = 2
80const BC_C_ABSENT: i64 = 3
81const BC_C_UNREAD: i64 = 4
82const BC_C_DOMAINS: i64 = 5
83const BC_C_ROWS: i64 = 6
98const BC_C_PROSE: i64 = 7
105const BC_C_BINSTALE: i64 = 8
106const BC_NOTECAP: i64 = 8192
109const BC_C_EMITTED: i64 = 9
110const BC_C_SLOTS: i64 = 10
117const BC_LIST_CAP: i64 = 20
130const BC_HASH_MINSLOTS: i64 = 16 // the smallest useful table, not a ceiling: it only ever grows
131const BC_HASH_LOAD_NUM: i64 = 2 // slots per record before rounding up to a power of two
132const BC_LOWA: i64 = 97
133const BC_LOWZ: i64 = 122
134const BC_UPA: i64 = 65
135const BC_UPZ: i64 = 90
136const BC_US: i64 = 95
137const BC_LPAREN: i64 = 40
138const BC_HASH_SEED: i64 = 5381
139const BC_HASH_MUL: i64 = 33
140const BC_HASH_MOD: i64 = 1000000007
262const BC_NBINMARK: i64 = 3
290const BC_NMARK: i64 = 4

functions

141func bc_isident(ch: i64) -> i64
148func bc_streq_p(a: *u8, b: *u8) -> i64
154func bc_hash(t: *u8, slots: i64) -> i64
160func bc_find_from(buf: *u8, n: i64, needle: *u8, from: i64) -> i64
174func bc_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
175func 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 }
176func 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
177func bc_catn(dst: *u8, off: i64, v: i64) -> i64
called by 1: main calls 2: bc_putsys_mmap
190func bc_find(buf: *u8, n: i64, needle: *u8) -> i64
called by 1: bc_has calls 1: bc_slen
203func bc_has(buf: *u8, n: i64, needle: *u8) -> i64 { if bc_find(buf, n, needle) >= 0 { return 1 } return 0 }
220func bc_note_absence(note: *u8, n: i64) -> i64
calls 1: bc_has
242func bc_is_stop(b: *u8, i: i64, n: i64) -> i64
248func bc_span_retracted(b: *u8, s: i64, e: i64, tmp: *u8, cap: i64) -> i64
263func bc_binmarker(i: i64) -> *u8
271func bc_note_binary_claim(note: *u8, n: i64, tmp: *u8, cap: i64) -> i64
291func bc_marker(i: i64) -> *u8
called by 1: bc_note_stale_claim
299func bc_note_stale_claim(note: *u8, n: i64, tmp: *u8, cap: i64) -> i64
321func bc_field_last(buf: *u8, ls: i64, le: i64, out: *u8, cap: i64) -> i64
called by 1: bc_census_domain
332func bc_exists(path: *u8) -> i64 { let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 } sys_close(fd); return 1 }
334func bc_target_of(organ: *u8, out: *u8, cap: i64) -> i64
called by 1: bc_census_domain calls 1: bc_slen
355func bc_artifact_exists(tname: *u8, tmp: *u8) -> i64
called by 1: bc_census_domain calls 2: bc_catbc_exists
377func bc_write(path: *u8, text: *u8) -> i64
387func bc_field(buf: *u8, ls: i64, le: i64, idx: i64, out: *u8, cap: i64) -> i64
called by 1: bc_census_domain
413func bc_resolve_organ(rel: *u8, out: *u8) -> i64
called by 1: bc_classify calls 2: bc_catbc_exists
428func bc_classify(organrel: *u8, sym: *u8, scratch: *u8, srcbuf: *u8) -> i64
443func bc_say(s: *u8) -> i64 { sys_write(1, s, bc_slen(s)); return 0 }
called by 1: bc_census_domain calls 2: sys_writebc_slen
445func 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
545func bc_zero(ctr: *i64) -> i64 { var i: i64 = 0; while i < BC_C_SLOTS { ctr[i] = 0; i = i + 1 } return 0 }
553func bc_unflippable(ctr: *i64) -> i64 { return ctr[BC_C_SUBSTR] }
558func 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
577func main(argc: i64, argv: *i64) -> i64