code wiki / _hdl_build / nx_srclint.nx

nx_srclint.nx

buildroot/runtime/_hdl_build/nx_srclint.nx

40604 B761 linesdepth 3pulls 4 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_srclint.nx -- LINT THE HAZARDS THAT HAVE ACTUALLY BITTEN, ESTATE-WIDE. RULE 1: CURSOR-SENTINEL. The idiom while p < n { if <done> { p = n + 9 } ... } if p > n { p = p - 9 } writes the loop's EXIT MARKER INTO THE VERY VARIABLE BEING SEARCHED FOR, and the restore lands on `n`, not on the position found. It does not crash and it does not fail to compile -- it silently returns the wrong index, so the caller reads the wrong byte and every downstream number is plausible and wrong. Measured cost on 2026-08-07 alone: FIVE defects. nx_memdemote -- the whole file parsed as ONE line nx_memnew -- file_path extraction returned nothing, the hook silently never fired nx_memnew -- the memfind output parsed as one line, zero results shown nx_unwired -- every identifier ran to end-of-file: 0 functions found across 7,113 sources nx_gatesubj -- the char after an identifier read from the wrong place: 0 of 157 end-to-end gates detected, in the organ built to measure exactly that The fourth and fifth happened INSIDE tools written to catch unverified work, hours after the primitive that fixes it (`gk_eol`) already existed. ★★★★★★ THE FIFTH TIME YOU FIX A BUG BY HAND IS PROOF THE FIX BELONGS IN A LINTER, NOT IN ANOTHER PATCH -- A HAZARD YOU CAN RECOGNISE ON SIGHT IS A HAZARD A MACHINE CAN RECOGNISE EVERY TIME. THE RULE IS THE PAIRING, NOT THE CONSTANT. `x = n + 9` alone is ordinary arithmetic; what makes it this defect is a matching `x - 9` restoring the same variable shortly after. Matching the pair keeps the rule precise -- a linter with false positives is worse than none, because it teaches everyone to ignore it. ★★★★★ A DETECTOR WITH FALSE POSITIVES IS WORSE THAN NONE. usage: nx_srclint [--dir D] [--quiet] [--accept] exit: 0 = no NEW hits since the baseline; 1 = a new hit (named, so it can be attributed) license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_memplane_lib.nx nx_gatekit_lib.nx nx_srclint.nx

imports: nx_memplane_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 mp_streq gk_ops_path gk_ops_dir 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 ↻ gk_corpus_root sys_mmap ↻ gk_cat gk_exists sys_openat_rd sys_close gk_streq gk_cat ↻ gk_mkdir sys_mkdir gk_len gk_cat ↻ mp_cat mp_say mp_write_all sys_write ↻ gk_corpus_scan sys_mmap ↻ gk_corpus_root ↻ gk_corpus_hdl gk_corpus_root ↻

structs

none

consts

36const SL_MAGIC_8192: i64 = 8192
37const SL_MAGIC_4096: i64 = 4096
38const SL_MAGIC_262144: i64 = 262144
39const SL_MAGIC_262000: i64 = 262000
41const SL_DIR: *u8 = "/mnt/c/Users/elder/nishi-core/nxc2/runtime/_hdl_build"
42const SL_MAXF: i64 = 32768 // corpus is 18,561; 16,384 would REFUSE
43const SL_FBUF: i64 = 4194304
44const SL_WIN: i64 = 600 // how far after the `+ N` the paired `- N` may appear

functions

48func sl_isid(c: i64) -> i64
called by 3: sl_lhssl_rule2main
61func sl_at(buf: *u8, p: i64, n: i64, lit: *u8) -> i64
called by 2: sl_rule2main calls 1: mp_len
75func sl_lhs(buf: *u8, p: i64, out: *u8) -> i64
called by 1: main calls 1: sl_isid
98func sl_line_is_comment(fbuf: *u8, i: i64, n: i64) -> i64
called by 2: sl_rule2sl_rule3
129func sl_rule2(fbuf: *u8, n: i64, cur: *u8, outval: *i64) -> i64
called by 1: main calls 3: sl_atsl_line_is_commentsl_isid
230func sl_lineno(fbuf: *u8, off: i64) -> i64
called by 1: main
285func sl_next_line(fbuf: *u8, n: i64, off: i64) -> i64
called by 1: main
301func sl_rule3(fbuf: *u8, n: i64, start: i64, cur: *u8, outval: *i64) -> i64
called by 1: main calls 1: sl_line_is_comment
363func main(argc: i64, argv: *i64) -> i64