code wiki / _hdl_build / nx_magicname.nx
nx_magicname.nx
buildroot/runtime/_hdl_build/nx_magicname.nx
about
nx_magicname.nx -- THE MEANINGLESS-NAME DETECTOR, and the ratchet that keeps the number falling.
THE DEFECT IT MEASURES, stated plainly: the estate's own rule-11 remedy manufactures the disease.
nx_law_warden counts BARE LITERALS and nx_magic apply hoists them to a named const -- but it names them
X_MAGIC_<value>, which restates the number instead of saying what it MEANS. The ratchet then reads GREEN
while the code is no more legible than before: a magic number wearing a costume, and harder to grep for
because it no longer looks like a literal. Measured cases from one afternoon: BG_MAGIC_40500 was hiding
BHASKARA I'S SINE APPROXIMATION; AS_MAGIC_73856093/19349663/83492791 were hiding the TESCHNER 2003
spatial-hash primes; AS_MAGIC_8388607 was an IEEE-754 mantissa mask sharing its value with an unrelated
triangle cap. In every case the value was right and the NAME was the defect.
THE RULE, mechanical and unarguable: a const whose identifier contains _MAGIC_ followed only by digits is
named for its value. That is decidable from the identifier alone -- no heuristic, no threshold, no sample.
RATCHET: knowledge/status/magicname.conf holds the agreed ceiling. The count may FALL freely; a RISE is
refused. First run with no conf SEEDS it and says so, rather than inventing a floor and calling it a pass.
It NAMES every offender it counts -- a count without a worklist is not actionable (banked law).
nx_magicname [dir1] [dir2] default: runtime/_hdl_build and runtime
license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0
dependencies 1 imports · 0 importers
imports: nx_syscalls.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
| 22 | const MN_CONF: *u8 = "knowledge/status/magicname.conf" |
| 23 | const MN_DIRBUF: i64 = 131072 |
| 24 | const MN_FILEBUF: i64 = 1048576 // per-source read window; a source over this is REPORTED, never silently cut |
| 25 | const MN_NAMEBUF: i64 = 4096 |
| 26 | const MN_MAXSHOW: i64 = 40 // the printed worklist head; the COUNT is always the full population |
| 27 | const MN_CH_COLON: i64 = 58 |
| 28 | const MN_CH_NL: i64 = 10 |
| 29 | const MN_CH_SP: i64 = 32 |
| 30 | const MN_CH_0: i64 = 48 |
| 31 | const MN_CH_9: i64 = 57 |
| 32 | const MN_DEC: i64 = 10 |
| 37 | const MN_MIN_FILES: i64 = 1000 |
functions
| 39 | func mn_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } |
| 40 | func mn_num(v: i64) -> i64 |
| 55 | func mn_is_nx(nm: *u8) -> i64 called by 1: mn_scan_dir |
| 65 | func mn_is_valuename(b: *u8, s: i64, e: i64) -> i64 called by 1: mn_scan_file |
| 88 | func mn_scan_file(path: *u8, buf: *u8, shown: *i64) -> i64 |
| 142 | func b_at(b: *u8, i: i64) -> i64 { return b[i] as i64 } called by 1: mn_scan_file |
| 144 | func mn_scan_dir(dir: *u8, buf: *u8, nbuf: *u8, shown: *i64, files: *i64) -> i64 |
| 180 | func mn_read_floor() -> i64 |
| 197 | func mn_write_floor(v: i64) -> i64 |
| 214 | func main(argc: i64, argv: *i64) -> i64 |