code wiki / (root) / nx_board_idref_gate.nx

nx_board_idref_gate.nx

buildroot/runtime/nx_board_idref_gate.nx

18388 B361 linesdepth 3pulls 5 transitivereach 0 importersview sourcekind gate/prooftopic board
docsdependenciesstructsconstsfunctions

about

nx_board_idref_gate.nx -- THE COMPARE BOARD'S REFERENTIAL INTEGRITY REFEREE (2026-09-04). WHY THIS EXISTS, AND WHY IT IS A MECHANISM RATHER THAN ANOTHER LAW. On 2026-09-03 a seat appended a rung as LN37 and four log rows as LN36 and BOTH ids were already taken by another lane the same day. It journaled the finding, renumbered to LN41/LN42 after grepping for free ids, and wrote the durable remedy in its own words: "the durable fix is a uniqueness tooth in the compare referee rather than a habit." By 2026-09-04 LN41 AND LN42 had each collided AGAIN -- the renumbering itself landed on ids a third lane had taken while it worked. That is the whole argument for this file: GREP-BEFORE-APPEND IS A HABIT, AND A HABIT LOSES TO CONCURRENCY EVERY TIME. Only something in the path can hold this invariant. WHAT IT JUDGES. A .plan is a board, and a board's ids are its addresses. Three ways an address goes bad: DUPID two rung rows share an id, so the ranker, a watch flip and a done-rule all attach to whichever the reader matches first. Measured live: lang carried one LANDED and one OPEN rung under LN42, which is the dangerous shape -- the board can report the open work as finished. DANGLOG a log row is journaled against a rung id no rung row declares, so the worked plan a crashed session is supposed to inherit points at nothing. DANGMS a milestone lists a member rung that does not exist, so its cumulative estimate is over a set the board cannot enumerate. IT RATCHETS RATHER THAN DEMANDING ZERO, AND THAT IS DELIBERATE. Real offenders already exist that belong to other lanes, and a detector that is permanently RED is one everyone learns to ignore. The bar is knowledge/status/board_idref.baseline; the gate goes RED only when the count RISES, and it TIGHTENS the baseline when the count falls so a fix cannot be undone silently. EVERY OFFENDER IS NAMED IN THE OUTPUT whatever the verdict, because a count without a worklist is not actionable. COMPOSES nx_rowparse_lib for pipe-delimited column extraction rather than hand-rolling a fourth copy of that arithmetic, and gk_* for directory and file access. license_tier: ORIGINAL. Reads the compare trees, writes only its own baseline. No hw writes (Rule 26).

dependencies 4 imports · 0 importers

nx_syscalls.nx nx_gate_verdict.nx nx_gatekit_lib.nx nx_rowparse_lib.nx nx_board_idref_gate.nx

imports: nx_syscalls.nxnx_gate_verdict.nxnx_gatekit_lib.nxnx_rowparse_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 ↻ gk_dirscan_ext sys_openat_rd sys_mmap ↻ gk_ext_is gk_len gk_cat gk_exists sys_openat_rd ↻ sys_close gk_len ↻ sys_close ↻ gk_ext_is ↻ rp_cstr rp_slen gk_size sys_openat_rd ↻ sys_lseek sys_close ↻ rp_put

structs

none

consts

37const BI_FILECAP: i64 = 4194304
38const BI_NAMES: i64 = 262144
39const BI_NAMESTRIDE: i64 = 256
40const BI_MAXFILES: i64 = 512
41const BI_IDCAP: i64 = 32
42const BI_MAXIDS: i64 = 1024
43const BI_PATH: i64 = 1024
44const BI_OUT: i64 = 262144
45const BI_SPAN: i64 = 8
46const BI_BASEMAX: i64 = 64
47const BI_DIR_PRIMARY: *u8 = "buildroot/knowledge/compare/"
48const BI_DIR_SECONDARY: *u8 = "knowledge/compare/"
49const BI_BASELINE: *u8 = "knowledge/status/board_idref.baseline"
50const BI_FLD_KIND: i64 = 0
51const BI_FLD_RUNGID: i64 = 1
52const BI_FLD_LOGID: i64 = 2
53const BI_FLD_MSMEMBERS: i64 = 4
54const BI_COMMA: i64 = 44
55const BI_SPACE: i64 = 32
56const BI_CR: i64 = 13

functions

60func bi_put_id(tab: *u8, n: i64, b: *u8, s: i64, l: i64) -> i64
called by 1: main
69func bi_id_at(tab: *u8, i: i64) -> *u8 { return (tab as i64 + i * BI_IDCAP) as *u8 }
75func bi_trim(b: *u8) -> i64
called by 1: main
88func bi_count(tab: *u8, n: i64, k: i64) -> i64
called by 1: main calls 2: gk_streqbi_id_at
97func bi_has_id(tab: *u8, n: i64, want: *u8) -> i64
called by 1: main calls 2: gk_streqbi_id_at
106func bi_first(tab: *u8, k: i64) -> i64
called by 1: main calls 2: gk_streqbi_id_at
115func main(argc: i64, argv: **u8) -> i64