code wiki / _hdl_build / nx_magicname.nx

nx_magicname.nx

buildroot/runtime/_hdl_build/nx_magicname.nx

11008 B258 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_magicname.nx

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

main 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 ↻ mn_puts sys_write ↻ mn_scan_dir sys_openat_rd sys_mmap ↻ sys_getdents64 dirent_reclen dirent_name mn_is_nx mn_scan_file sys_mmap ↻ sys_openat_rd ↻ sys_read sys_close mn_puts ↻ b_at mn_is_valuename sys_write ↻ sys_close ↻ sys_munmap mn_num sys_write ↻ sys_mmap ↻ sys_munmap ↻

structs

none

consts

22const MN_CONF: *u8 = "knowledge/status/magicname.conf"
23const MN_DIRBUF: i64 = 131072
24const MN_FILEBUF: i64 = 1048576 // per-source read window; a source over this is REPORTED, never silently cut
25const MN_NAMEBUF: i64 = 4096
26const MN_MAXSHOW: i64 = 40 // the printed worklist head; the COUNT is always the full population
27const MN_CH_COLON: i64 = 58
28const MN_CH_NL: i64 = 10
29const MN_CH_SP: i64 = 32
30const MN_CH_0: i64 = 48
31const MN_CH_9: i64 = 57
32const MN_DEC: i64 = 10
37const MN_MIN_FILES: i64 = 1000

functions

39func 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 }
called by 2: mn_scan_filemain calls 1: sys_write
40func mn_num(v: i64) -> i64
called by 1: main calls 3: sys_writesys_mmapsys_munmap
55func mn_is_nx(nm: *u8) -> i64
called by 1: mn_scan_dir
65func mn_is_valuename(b: *u8, s: i64, e: i64) -> i64
called by 1: mn_scan_file
88func mn_scan_file(path: *u8, buf: *u8, shown: *i64) -> i64
142func b_at(b: *u8, i: i64) -> i64 { return b[i] as i64 }
called by 1: mn_scan_file
144func mn_scan_dir(dir: *u8, buf: *u8, nbuf: *u8, shown: *i64, files: *i64) -> i64
180func mn_read_floor() -> i64
called by 1: main calls 2: sys_mmapsys_read_file
197func mn_write_floor(v: i64) -> i64
214func main(argc: i64, argv: *i64) -> i64