code wiki / _hdl_build / nx_param_census.nx

nx_param_census.nx

buildroot/runtime/_hdl_build/nx_param_census.nx

20664 B394 linesdepth 3pulls 4 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_param_census.nx -- LOG_SCAN family, X-PRM-002 (operator rule-11: "No Magic Numbers -- every threshold/limit/timeout/weight/multiplier belongs in svc-config or a database table, not buried in code"). EXTENDS the live params registry X-PRM-001 (knowledge/registry/params.tsv). AUTHOR=ORGAN. Scans TWO REAL surfaces listed in param_surfaces.tsv (growable DATA, no recompile) and COMPUTES coverage/DEBT from file reads, NEVER asserted: HALF A CONF-KEY COVERAGE -- for each `C <conf>` row, extract every `key=value` key and check re_has against the real params.tsv bytes. A conf key with NO params row = an ABSENT coverage gap ("every conf key has a row" made measurable). HALF B SOURCE MAGIC-NUMBER DEBT -- for each `S <organ.nx>` row, scan for named numeric source constants `const NAME: i64 = <digit>`; any NAME not already in params.tsv -> AUTO-FILE a rule-11 DEBT row (the hidden tunable becomes visible work). ABI/syscall consts (SYS_/AT_/O_/SOCK/AF_/CLONE/DT_/SO_/SOL_/SIG) are FIXED-BY-SPEC, excluded so DEBT is signal. Outputs: knowledge/registry/param_census.tsv (full PRESENT/ABSENT/DEBT report, organ-authored header) + new DEBT rows APPENDED (additive, never truncate -- rule-13) to params.tsv after a .bak, + a PRMCENSUS verdict line to stdout AND appended to knowledge/status/param_census.log (the evidence nx_reconcile grades; the organ does NOT flip its own row). SELF-VALIDATING (no false-green, sibling of nx_competitive_census pos/neg + nx_hwmap derived-neg): BEFORE touching the real registry it runs baked controls on /tmp planted fixtures -- ctrl_pos_confkey = a KNOWN registered conf-key (diff_seed) MUST be found in the registry read. ctrl_pos_debtrow = the KNOWN existing DEBT row (an_load_max_rows) MUST be present (won't re-file). ctrl_neg_plantmagic = a /tmp fixture with `const ZZ_PLANTED_MAGIC: i64 = 31337` MUST scan to 1 unregistered DEBT candidate (detector is not blind). ctrl_neg_cleanzero = a /tmp fixture with no named numeric const MUST scan to 0 (no false-positive). Any control wrong -> RED, return 1, and the real params.tsv mutation is SKIPPED. Argv override of the surfaces list routes outputs to a /tmp tamper lane (self-tamper, no oracle). license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_research_extract.nx nx_itoa_lib.nx nx_param_census.nx

imports: nx_research_extract.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

main pc_read_file sys_read pc_w re_has re_find re_strlen pc_write_fixture sys_openat_wr pc_scan_consts pc_is_alnum_us pc_is_abi re_has ↻ pc_emit_debt pc_app_slice pc_app pc_app ↻ pc_scan_to pc_basename sys_openat_wr ↻ sys_openat_append pc_wn nxi_fd sys_mmap ccz_cat_num sys_write sys_munmap

structs

none

consts

32const PC_MAGIC_2000000: i64 = 2000000
33const PC_MAGIC_8192: i64 = 8192
34const PC_MAGIC_80000: i64 = 80000
35const PC_MAGIC_1000000: i64 = 1000000
37const PC_REF: *u8 = "knowledge/registry/param_surfaces.tsv"
38const PC_REG: *u8 = "knowledge/registry/params.tsv"
39const PC_OUT: *u8 = "knowledge/registry/param_census.tsv"
40const PC_LOG: *u8 = "knowledge/status/param_census.log"
41const PC_BAK: *u8 = "knowledge/registry/params.tsv.bak.preParamCensus"
42const PC_FX_DIRTY: *u8 = "/tmp/_prm_fx_dirty.nx"
43const PC_FX_CLEAN: *u8 = "/tmp/_prm_fx_clean.nx"

functions

45func pc_w(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 1: main
50func pc_wn(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 }
called by 1: main calls 1: nxi_fd
53func pc_read_file(path: *u8, buf: *u8, cap: i64) -> i64
called by 1: main calls 1: sys_read
68func pc_scan_to(buf: *u8, n: i64, start: i64, delim: i64) -> i64
called by 1: main
76func pc_app(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { dst[off+i] = s[i]; i = i + 1 } return off + i }
called by 2: pc_emit_debtmain
79func pc_app_slice(dst: *u8, off: i64, src: *u8, a: i64, b: i64) -> i64
called by 1: pc_emit_debt
86func pc_write_fixture(path: *u8, content: *u8) -> i64
called by 1: main calls 1: sys_openat_wr
96func pc_is_abi(src: *u8, a: i64, b: i64) -> i64
called by 1: pc_scan_consts
121func pc_is_alnum_us(c: i64) -> i64
called by 1: pc_scan_consts
131func pc_emit_debt(dst: *u8, off: i64, src: *u8, na: i64, nb: i64, va: i64, vb: i64, onm: *u8, spath: *u8) -> i64
called by 1: pc_scan_consts calls 2: pc_app_slicepc_app
145func pc_basename(path: *u8, out: *u8) -> i64
called by 1: main
159func pc_scan_consts(src: *u8, n: i64, reg: *u8, regn: i64, dbuf: *u8, doff: i64, onm: *u8, spath: *u8, filemode: i64, found: *i64) -> i64
215func main(argc: i64, argv: *i64) -> i64