code wiki / _hdl_build / nx_law_warden.nx
nx_law_warden.nx
buildroot/runtime/_hdl_build/nx_law_warden.nx
about
============================================================================================
STOP -- DO NOT BUILD OR PROMOTE THIS ORGAN. FREEZE 2026-07-31, debt 1785516173 (sev9).
The DEPLOYED binary exposes {scan | file | countfile | selftest} and runs a 20/20 gate including
T15 segamp, T16 gatedry, T17 helperdup, T18 scancap, T20 debt-id-parse. THIS SOURCE HAS NONE OF
countfile / scancap / gatedry / helperdup / T20 -- countfile appears in ZERO of 20016 .nx files
NAS-wide (only nx_magicratchet CALLS it). Meanwhile this source ALONE has valuenamed (seq1348),
which the deployed binary lacks. NEITHER SIDE IS A SUPERSET; THERE IS NO SAFE DIRECTION.
WHY IT MATTERS: nx_magicratchet is wired into /api/build and gates every build on
`nx_law_warden countfile`. Rebuild -> the verb is gone -> mr_parse_magic returns -1 -> the ratchet
FAILS OPEN BY DESIGN -> magic-number enforcement is permanently disarmed AND the hourly autofiler
stops, silently, WITH EVERY GATE STILL GREEN. One routine rebuild turns off both enforcement and
detection at once. Restore the four missing capabilities into this file FIRST, then build.
Already restored here: countfile (exact output contract, thr locked to the deployed 1024) and the
rewritten string/comment-aware inlinelit scanner plus teeth T21-T27.
============================================================================================
nx_law_warden.nx -- MECHANICAL ENFORCEMENT for written laws (ws=cap-autonomy, 2026-07-20).
Operator: "make sure autonomously that our nishi ecosystem is getting sota ... what needs to become mcp or
api or raci or workflows or agents or other modern capabilities just gets logged and worked without me
having to call its need out"; + "our magic number audit and bug stuff dont appear to be autonomous ... lots
of workstreams are flagging them as bugs they hit and then just gave a new number to"; + "callouts of using
webrtc or webassembly ... not building from the first byte up to a sovereign nishi os and browser".
THE GAP THIS EATS: every conformance surface we own is a CURATED manifest -- nx_favela_census states it
outright ("unnamed shanty stays invisible until a row names it"). A written law (CLAUDE rule 11, the
first-byte-up doctrine, F208 modernization) therefore has NO detector: a human must NOTICE a breach and
NAME it before anything tracks it. That is exactly the call-it-out tax the operator is paying. This organ
is the DETECTOR tier: laws live as DATA in the sovereign **lawreg- seg-store plane** (nx_store_put, same
substrate as raci-/debt-/frontier-), each row carrying its own detector + threshold + severity + RACI
owner, and the warden MEASURES live artifacts against them. NO flat TSV, NO truncating .log -- the
registry is a plane (provenanced hist- rows) and the evidence is an append-only .jrnl (history is sacred).
RULE-11 COMPLIANT BY CONSTRUCTION: every POLICY number (threshold, severity, corpus, owner, token set) is
manifest data, never code. Point the warden at its own source and the property holds -- that is a gate tooth,
not a promise. The consts below are structural envelopes (buffer sizes, byte codes), all NAMED, never inline.
DETECTORS (detector <param> over <corpus>)
valuenamed CLAUDE-11 breach, the GOODHART half (seq1348): a `const NAME = V` whose NAME
contains V's own digits (SS_MAGIC_65536 = 65536). Clears `inlinelit` while
explaining nothing, so part of the inlinelit improvement is a DETECTOR
ARTIFACT. Reported as its OWN law -- never folded into inlinelit, because a
dependencies 5 imports · 0 importers
imports: nx_store_seed_lib.nxnx_syscalls.nxnx_estate_path.nxnx_tool_run.nxnx_gate_verdict.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
| 65 | const LW_OUT: i64 = 262144 |
| 66 | const LW_DIRBUF: i64 = 131072 |
| 67 | const LW_PLANE: i64 = 1048576 |
| 68 | const LW_PATH: i64 = 512 |
| 69 | const LW_NAMEMAX: i64 = 256 |
| 70 | const LW_SCRATCH: i64 = 64 |
| 71 | const LW_FILECAP: i64 = 600 |
| 72 | const LW_COLS: i64 = 8 |
| 73 | const LW_COLS_MAX: i64 = 9 |
| 74 | const LW_FLD_BYTES: i64 = 128 |
| 75 | const LW_OVF: i64 = 100000000000 |
| 76 | const LW_MODE: i64 = 0x1a4 |
| 77 | const LW_NL: i64 = 10 |
| 78 | const LW_TAB: i64 = 9 |
| 79 | const LW_HASH: i64 = 35 |
| 80 | const LW_SP: i64 = 32 |
| 81 | const LW_COMMA: i64 = 44 |
| 82 | const LW_DQ: i64 = 34 |
| 83 | const LW_BSL: i64 = 92 |
| 84 | const LW_SL: i64 = 47 |
| 90 | const LW_MAGIC_THR: i64 = 1024 |
| 91 | const LW_MODE_LIT: i64 = 1 |
| 92 | const LW_MODE_ELF: i64 = 2 |
| 93 | const LW_MODE_TOK: i64 = 3 |
| 94 | const LW_SEGMAX: i64 = 64 |
| 95 | const LW_SEGNAME: i64 = 64 |
| 96 | const LW_SEGTAB: i64 = 4096 |
| 97 | const LW_SEGCNT: i64 = 512 |
| 98 | const LW_DIRMODE: i64 = 0x1ed |
| 99 | const LW_ST_SLOTS: i64 = 64 |
| 317 | const LW_MODE_VNAME: i64 = 4 |
| 323 | const LW_MODE_GATEDRY: i64 = 5 |
| 324 | const LW_MODE_HELPERDUP: i64 = 6 |
| 325 | const LW_MODE_SCANCAP: i64 = 7 |
functions
| 102 | func lw_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } |
| 103 | func lw_cat(o: *u8, at: i64, s: *u8) -> i64 { var a: i64=at; var i: i64=0; while s[i]!=(0 as u8){o[a]=s[i]; a=a+1; i=i+1} return a } |
| 104 | func lw_catf(o: *u8, at: i64, p: *u8, n: i64) -> i64 { var a: i64=at; var i: i64=0; while i<n { o[a]=p[i]; a=a+1; i=i+1 } return a } |
| 106 | func lw_catesc(o: *u8, at: i64, p: *u8, n: i64) -> i64 |
| 117 | func lw_catn(o: *u8, at: i64, v: i64) -> i64 |
| 129 | func lw_count(buf: *u8, n: i64, needle: *u8) -> i64 |
| 143 | func lw_span_eq(b: *u8, s: i64, l: i64, lit: *u8) -> i64 |
| 150 | func lw_ends(nm: *u8, suf: *u8) -> i64 |
| 158 | func lw_join(dst: *u8, dir: *u8, nm: *u8) -> i64 |
| 167 | func lw_wfile(path: *u8, content: *u8) -> i64 |
| 176 | func lw_line_start(b: *u8, ls: i64, le: i64) -> i64 |
| 183 | func lw_is_const(b: *u8, ls: i64, le: i64) -> i64 |
| 194 | func lw_is_comment(b: *u8, ls: i64, le: i64) -> i64 |
| 213 | func lw_line_lits(b: *u8, ls: i64, le: i64, thr: i64) -> i64 called by 1: lw_file_lits |
| 261 | func lw_file_lits(path: *u8, thr: i64) -> i64 called by 3: lw_countfilelw_walklw_selftest calls 5: sys_mmapsys_read_filelw_is_commentlw_is_constlw_line_lits |
| 288 | func lw_countfile(path: *u8) -> i64 |
| 328 | func lw_digits(v: i64, out: *u8) -> i64 |
| 339 | func lw_span_has(b: *u8, s: i64, e: i64, pat: *u8, pl: i64) -> i64 called by 1: lw_line_valuenamed |
| 353 | func lw_line_valuenamed(b: *u8, ls: i64, le: i64) -> i64 |
| 396 | func lw_file_valuenamed(f: *u8, n: i64) -> i64 |
| 412 | func lw_field0_has(buf: *u8, n: i64, name: *u8) -> i64 |
| 447 | func lw_segamp(dir: *u8, thr: i64, cx: *i64, worst: *u8) -> i64 called by 2: lw_selftestlw_scan calls 10: sys_openat_rdsys_mmapsys_getdents64dirent_namelw_endslw_slen+4 |
| 530 | func lw_debt_id(b: *u8, n: i64) -> i64 |
| 561 | func lw_file_gatedry(b: *u8, n: i64) -> i64 |
| 570 | func lw_file_helperdup(b: *u8, n: i64) -> i64 |
| 584 | func lw_file_scancap(b: *u8, n: i64) -> i64 |
| 595 | func lw_walk(dir: *u8, cx: *i64, worst: *u8, abuf: *u8) -> i64 called by 2: lw_selftestlw_scan calls 18: sys_openat_rdsys_mmapsys_getdents64dirent_namelw_endslw_join+12 |
| 748 | func lw_count_lines(b: *u8, n: i64, needle: *u8, excl: *u8) -> i64 |
| 764 | func lw_token_scan(corpus: *u8, csv: *u8, cx: *i64, worst: *u8, excl: *u8) -> i64 |
| 803 | func lw_last_ts(buf: *u8, n: i64) -> i64 |
| 828 | func lw_filed_has(buf: *u8, n: i64, lawid: *u8) -> i64 |
| 847 | func lw_allow_path(abuf: *u8, an: i64, name: *u8, out: *u8) -> i64 |
| 874 | func lw_selftest() -> i64 |
| 1123 | func lw_scan(prefix: *u8) -> i64 |
| 1356 | func lw_plane_find(rb: *u8, rn: i64, lawid: *u8, gs: *i64, gl: *i64) -> i64 |
| 1379 | func lw_file(prefix: *u8, toolname: *u8) -> i64 |
| 1567 | func main(argc: i64, argv: *i64) -> i64 |