code wiki / _hdl_build / nx_head_audit.nx

nx_head_audit.nx

buildroot/runtime/_hdl_build/nx_head_audit.nx

11133 B260 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_head_audit.nx -- FLEET AUDITOR for the accessible-head migration (seq702/seq703/seq707). THE SCALE PROBLEM: 65+ live page emitters each hand-rolled a lang-less <html><head> literal. Hand-fixing does not scale (65 flaky build/promote cycles) and a raw grep hit its 65KB output cap = INCOMPLETE. This organ is the DRIVER: one call classifies the whole emitter fleet and emits a deterministic migration worklist that an agent or a workflow can loop over. It is the measurement half of the nx_html_head / nx_html_head_fd base libraries -- same relationship as nx_law_warden to the laws it scans, or nx_gate_verdict's adoption census to the gate base class. DESIGN FOR HONESTY (laws L011 / seq395 / seq670 -- a scanner with no negative control is a liar): * per-file scan is a bounded 8KiB PREFIX read into ONE reused buffer -> zero per-file mmap growth (avoids the ~1GB/run leak that OOM'd nx_dup_source_check v2). The head literal is always near the top of an emitter; a head beyond 8KiB is a DECLARED miss, not a silent one. * the directory walk DRAINS getdents (loops until nr<=0) so coverage is complete within the cap. * emits a DECLARED ENVELOPE: scanned / nx-files / candidates / migrated / gates / cap_hit. * `selftest` runs 1 positive + 3 NEGATIVE controls through the SAME ha_candidate() the live walk uses, so the gate actually guards live behaviour. VERBS: nx_head_audit audit <dir> -> one TAB line per migration candidate: <file>\t<shape>\tCANDIDATE then a final `ENVELOPE ...` line. shape = buffer|fd (which head lib variant the emitter must adopt). nx_head_audit selftest -> non-vacuous gate (positive + 3 negative controls) -> VERDICT license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_head_audit.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 hw sys_write ha_starts ha_slen ha_selftest ha_candidate ha_has ha_starts ↻ ha_migrated ha_has ↻ ha_slen ↻ ha_shape_fd ha_has ↻ sys_mmap ha_lit ha_num hw ↻ ha_audit sys_openat_rd hw ↻ sys_mmap ↻ sys_getdents64 dirent_name ha_ends ha_slen ↻ ha_path ha_read_prefix sys_openat_rd ↻ sys_read sys_close ha_candidate ↻ ha_lit ↻ ha_shape_fd ↻ ha_migrated ↻ dirent_reclen sys_close ↻ ha_num ↻

structs

none

consts

27const HA_DIRBUF: i64 = 131072
28const HA_PREFIX: i64 = 65536
29const HA_PATH: i64 = 4096
30const HA_OUT: i64 = 4096
31const HA_FILECAP: i64 = 40000

functions

33func hw(fd: i64, s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(fd, s, n); return 0 }
called by 3: ha_auditha_selftestmain calls 1: sys_write
35func ha_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
38func ha_starts(b: *u8, i: i64, n: i64, lit: *u8) -> i64
called by 2: ha_hasmain
49func ha_has(b: *u8, n: i64, lit: *u8) -> i64
59func ha_ends(nm: *u8, suf: *u8) -> i64
called by 1: ha_audit calls 1: ha_slen
71func ha_path(out: *u8, dir: *u8, nm: *u8) -> i64
called by 1: ha_audit
82func ha_lit(out: *u8, o: i64, s: *u8) -> i64
called by 2: ha_auditha_selftest
88func ha_num(out: *u8, o: i64, v: i64) -> i64
called by 2: ha_auditha_selftest
100func ha_migrated(b: *u8, n: i64) -> i64
called by 2: ha_candidateha_audit calls 1: ha_has
112func ha_candidate(b: *u8, n: i64) -> i64
119func ha_shape_fd(b: *u8, n: i64) -> i64
called by 2: ha_auditha_selftest calls 1: ha_has
125func ha_read_prefix(path: *u8, pbuf: *u8) -> i64
134func ha_audit(dir: *u8) -> i64
213func ha_selftest() -> i64
250func main(argc: i64, argv: *i64) -> i64