code wiki / _hdl_build / nx_itoaclone.nx

nx_itoaclone.nx

buildroot/runtime/_hdl_build/nx_itoaclone.nx

26644 B583 linesdepth 3pulls 4 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_itoaclone.nx -- census of HAND-ROLLED integer->decimal emitters that SILENTLY DROP NEGATIVES. WHY THIS EXISTS. nx_matter_lib.mt_catn -- the number formatter for the BILLING/matter lane -- emitted ZERO BYTES for any v < 0: its digit loop is `while m > 0` and the only special case was `m == 0`, so a negative rendered as an EMPTY FIELD. Caught 2026-08-15 by a values-dump in nx_billing_gate printing `overdraw_rc=` with nothing after it. The value was -1, the REFUSAL SENTINEL, and the tooth asserting it was PASSING the whole time. **A NUMBER FORMATTER THAT EMITS NOTHING FOR A NEGATIVE TURNS AN ERROR CODE INTO AN ABSENT FIELD, AND AN ABSENT FIELD READS AS "NOT MEASURED" RATHER THAN "MEASURED, AND NEGATIVE"** -- the worst available direction to fail, because every positive value keeps printing perfectly and nothing looks wrong. THE CLASS IS NOT ONE SITE. A literal grep for the digit-emit idiom returns matches=2545 over 23,169 files (corpus_complete=1) -- roughly 29x the "~87 sites" nx_itoa_lib's own header estimates, so that estimate is stale. Reading 2545 sites is not an option and SAMPLING them would answer the wrong question: rare and empty demand different decisions, and only a full pass can tell them apart. WHAT IT MEASURES. Per function (split on a line-initial `func `), a body is an EMITTER if it contains the ASCII-digit idiom (a `48 +` next to a `% 10`). An emitter is NEGATIVE-SAFE if that same body contains a `< 0` test; otherwise it DROPS NEGATIVES. DECLARED IMPRECISION -- read this before trusting a number: * FLOOR, NOT A TOTAL. Emitters whose digit base is a NAMED CONST (`SG_D0 + (x % 10)`) or that build digits MSB-first via a power-of-ten walk are NOT matched by the `48 +` anchor. The real emitter population is >= what this reports. * The `< 0` test is presence-in-body, not dataflow. A body containing an UNRELATED `< 0` is scored SAFE, so this UNDER-reports the defect. That direction is deliberate: a detector with false positives is worse than none, because everyone learns to ignore it. Every offender is NAMED so the claim is checkable one file at a time rather than taken on faith. * The verdict binds to this organ's OWN CONTROLS (bite + positive control + coverage), NEVER to the offender count. An uncalibrated classifier must report numbers, not verdicts. license_tier: ORIGINAL Read-only: opens sources, writes nothing outside /tmp fixtures.

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_gate_verdict.nx nx_itoa_lib.nx nx_itoaclone.nx

imports: nx_syscalls.nxnx_gate_verdict.nxnx_itoa_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_mkdir ic_wfile sys_openat_wr sys_write ↻ ic_len sys_close sys_mmap ↻ ic_scan_dir sys_openat_rd sys_mmap ↻ sys_getdents64 dirent_type dirent_name ic_endswith_nx ic_len ↻ sys_read_file sys_openat_rd ↻ sys_lseek sys_mmap ↻ sys_read

structs

none

consts

36const IC_DIRBUF: i64 = 131072
37const IC_PATHBUF: i64 = 4096
39const IC_SETBUF: i64 = 1048576

functions

41func ic_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
42func ic_p(s: *u8) -> i64 { sys_write(1, s, ic_len(s)); return 0 }
43func ic_n(v: i64) -> i64 { return nxi_out(v) }
called by 1: main calls 1: nxi_out
44func ic_nl() -> i64 { let b: *u8 = sys_mmap(8); b[0] = 10 as u8; sys_write(1, b, 1); sys_munmap(b, 8); return 0 }
47func ic_has(buf: *u8, a: i64, b: i64, pat: *u8) -> i64
called by 1: ic_classify calls 1: ic_len
76func ic_strip(buf: *u8, n: i64) -> i64
called by 1: ic_classify
112func ic_bol(buf: *u8, i: i64) -> i64
called by 1: ic_next_func
120func ic_next_func(buf: *u8, n: i64, i: i64) -> i64
called by 1: ic_classify calls 1: ic_bol
146func ic_sig(buf: *u8, a: i64, b: i64) -> i64
called by 1: ic_classify calls 1: sys_write
167func ic_offid(path: *u8, buf: *u8, s: i64, e: i64, out: *u8) -> i64
called by 1: ic_classify
188func ic_line_in(hay: *u8, hn: i64, line: *u8, ll: i64) -> i64
called by 1: ic_diff
229func ic_classify(path: *u8, buf: *u8, n: i64, c: *i64, verbose: i64, setb: *u8) -> i64
293func ic_endswith_nx(nm: *u8) -> i64
called by 1: ic_scan_dir calls 1: ic_len
303func ic_scan_dir(dir: *u8, c: *i64, verbose: i64, setb: *u8) -> i64
352func ic_eol(buf: *u8, n: i64, i: i64) -> i64
called by 1: ic_diff
366func ic_diff(a: *u8, an: i64, b: *u8, bn: i64, label: *u8, verbose: i64) -> i64
392func ic_write_set(path: *u8, buf: *u8, n: i64, oldn: i64) -> i64
413func ic_wfile(path: *u8, s: *u8) -> i64
421func main() -> i64