code wiki / _hdl_build / nx_srclint.nx
nx_srclint.nx
buildroot/runtime/_hdl_build/nx_srclint.nx
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
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
structs
| none |
consts
| 36 | const SL_MAGIC_8192: i64 = 8192 |
| 37 | const SL_MAGIC_4096: i64 = 4096 |
| 38 | const SL_MAGIC_262144: i64 = 262144 |
| 39 | const SL_MAGIC_262000: i64 = 262000 |
| 41 | const SL_DIR: *u8 = "/mnt/c/Users/elder/nishi-core/nxc2/runtime/_hdl_build" |
| 42 | const SL_MAXF: i64 = 32768 // corpus is 18,561; 16,384 would REFUSE |
| 43 | const SL_FBUF: i64 = 4194304 |
| 44 | const SL_WIN: i64 = 600 // how far after the `+ N` the paired `- N` may appear |
functions
| 48 | func sl_isid(c: i64) -> i64 |
| 61 | func sl_at(buf: *u8, p: i64, n: i64, lit: *u8) -> i64 |
| 75 | func sl_lhs(buf: *u8, p: i64, out: *u8) -> i64 |
| 98 | func sl_line_is_comment(fbuf: *u8, i: i64, n: i64) -> i64 |
| 129 | func sl_rule2(fbuf: *u8, n: i64, cur: *u8, outval: *i64) -> i64 |
| 230 | func sl_lineno(fbuf: *u8, off: i64) -> i64 called by 1: main |
| 285 | func sl_next_line(fbuf: *u8, n: i64, off: i64) -> i64 called by 1: main |
| 301 | func sl_rule3(fbuf: *u8, n: i64, start: i64, cur: *u8, outval: *i64) -> i64 |
| 363 | func main(argc: i64, argv: *i64) -> i64 |