code wiki / _hdl_build / nx_itoaclone.nx
nx_itoaclone.nx
buildroot/runtime/_hdl_build/nx_itoaclone.nx
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
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
structs
| none |
consts
| 36 | const IC_DIRBUF: i64 = 131072 |
| 37 | const IC_PATHBUF: i64 = 4096 |
| 39 | const IC_SETBUF: i64 = 1048576 |
functions
| 41 | func ic_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 42 | func ic_p(s: *u8) -> i64 { sys_write(1, s, ic_len(s)); return 0 } |
| 43 | func ic_n(v: i64) -> i64 { return nxi_out(v) } |
| 44 | func 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 } |
| 47 | func ic_has(buf: *u8, a: i64, b: i64, pat: *u8) -> i64 |
| 76 | func ic_strip(buf: *u8, n: i64) -> i64 called by 1: ic_classify |
| 112 | func ic_bol(buf: *u8, i: i64) -> i64 called by 1: ic_next_func |
| 120 | func ic_next_func(buf: *u8, n: i64, i: i64) -> i64 |
| 146 | func ic_sig(buf: *u8, a: i64, b: i64) -> i64 |
| 167 | func ic_offid(path: *u8, buf: *u8, s: i64, e: i64, out: *u8) -> i64 called by 1: ic_classify |
| 188 | func ic_line_in(hay: *u8, hn: i64, line: *u8, ll: i64) -> i64 called by 1: ic_diff |
| 229 | func ic_classify(path: *u8, buf: *u8, n: i64, c: *i64, verbose: i64, setb: *u8) -> i64 |
| 293 | func ic_endswith_nx(nm: *u8) -> i64 |
| 303 | func ic_scan_dir(dir: *u8, c: *i64, verbose: i64, setb: *u8) -> i64 called by 1: main calls 11: sys_openat_rdsys_mmapsys_getdents64dirent_typedirent_nameic_endswith_nx+5 |
| 352 | func ic_eol(buf: *u8, n: i64, i: i64) -> i64 called by 1: ic_diff |
| 366 | func ic_diff(a: *u8, an: i64, b: *u8, bn: i64, label: *u8, verbose: i64) -> i64 |
| 392 | func ic_write_set(path: *u8, buf: *u8, n: i64, oldn: i64) -> i64 |
| 413 | func ic_wfile(path: *u8, s: *u8) -> i64 |
| 421 | func main() -> i64 |