code wiki / _hdl_build / nx_param_census.nx
nx_param_census.nx
buildroot/runtime/_hdl_build/nx_param_census.nx
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
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
structs
| none |
consts
| 32 | const PC_MAGIC_2000000: i64 = 2000000 |
| 33 | const PC_MAGIC_8192: i64 = 8192 |
| 34 | const PC_MAGIC_80000: i64 = 80000 |
| 35 | const PC_MAGIC_1000000: i64 = 1000000 |
| 37 | const PC_REF: *u8 = "knowledge/registry/param_surfaces.tsv" |
| 38 | const PC_REG: *u8 = "knowledge/registry/params.tsv" |
| 39 | const PC_OUT: *u8 = "knowledge/registry/param_census.tsv" |
| 40 | const PC_LOG: *u8 = "knowledge/status/param_census.log" |
| 41 | const PC_BAK: *u8 = "knowledge/registry/params.tsv.bak.preParamCensus" |
| 42 | const PC_FX_DIRTY: *u8 = "/tmp/_prm_fx_dirty.nx" |
| 43 | const PC_FX_CLEAN: *u8 = "/tmp/_prm_fx_clean.nx" |
functions
| 45 | func 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 |
| 50 | func pc_wn(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 } |
| 53 | func pc_read_file(path: *u8, buf: *u8, cap: i64) -> i64 |
| 68 | func pc_scan_to(buf: *u8, n: i64, start: i64, delim: i64) -> i64 called by 1: main |
| 76 | func 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 } |
| 79 | func pc_app_slice(dst: *u8, off: i64, src: *u8, a: i64, b: i64) -> i64 called by 1: pc_emit_debt |
| 86 | func pc_write_fixture(path: *u8, content: *u8) -> i64 |
| 96 | func pc_is_abi(src: *u8, a: i64, b: i64) -> i64 called by 1: pc_scan_consts |
| 121 | func pc_is_alnum_us(c: i64) -> i64 called by 1: pc_scan_consts |
| 131 | func pc_emit_debt(dst: *u8, off: i64, src: *u8, na: i64, nb: i64, va: i64, vb: i64, onm: *u8, spath: *u8) -> i64 |
| 145 | func pc_basename(path: *u8, out: *u8) -> i64 called by 1: main |
| 159 | func pc_scan_consts(src: *u8, n: i64, reg: *u8, regn: i64, dbuf: *u8, doff: i64, onm: *u8, spath: *u8, filemode: i64, found: *i64) -> i64 |
| 215 | func main(argc: i64, argv: *i64) -> i64 |