code wiki / _hdl_build / nx_head_audit.nx
nx_head_audit.nx
buildroot/runtime/_hdl_build/nx_head_audit.nx
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
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
| 27 | const HA_DIRBUF: i64 = 131072 |
| 28 | const HA_PREFIX: i64 = 65536 |
| 29 | const HA_PATH: i64 = 4096 |
| 30 | const HA_OUT: i64 = 4096 |
| 31 | const HA_FILECAP: i64 = 40000 |
functions
| 33 | func 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 } |
| 35 | func ha_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 38 | func ha_starts(b: *u8, i: i64, n: i64, lit: *u8) -> i64 |
| 49 | func ha_has(b: *u8, n: i64, lit: *u8) -> i64 |
| 59 | func ha_ends(nm: *u8, suf: *u8) -> i64 |
| 71 | func ha_path(out: *u8, dir: *u8, nm: *u8) -> i64 called by 1: ha_audit |
| 82 | func ha_lit(out: *u8, o: i64, s: *u8) -> i64 |
| 88 | func ha_num(out: *u8, o: i64, v: i64) -> i64 |
| 100 | func ha_migrated(b: *u8, n: i64) -> i64 |
| 112 | func ha_candidate(b: *u8, n: i64) -> i64 |
| 119 | func ha_shape_fd(b: *u8, n: i64) -> i64 |
| 125 | func ha_read_prefix(path: *u8, pbuf: *u8) -> i64 |
| 134 | func ha_audit(dir: *u8) -> i64 |
| 213 | func ha_selftest() -> i64 |
| 250 | func main(argc: i64, argv: *i64) -> i64 |