code wiki / _hdl_build / nx_law_warden.nx

nx_law_warden.nx

buildroot/runtime/_hdl_build/nx_law_warden.nx

77354 B1598 linesdepth 5pulls 9 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

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

nx_store_seed_lib.nx nx_syscalls.nx nx_estate_path.nx nx_tool_run.nx nx_gate_verdict.nx nx_law_warden.nx

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

main ep_anchor sys_openat_rd sys_close sys_chdir sys_mmap lw_slen lw_span_eq lw_slen ↻ lw_selftest gv_ctr sys_mmap ↻ gv_head gv_puts sys_write lw_wfile sys_openat_wr sys_write ↻ lw_slen ↻ sys_close ↻ lw_file_lits sys_mmap ↻ sys_read_file sys_openat_rd ↻ sys_lseek sys_mmap ↻ sys_read sys_close ↻ lw_is_comment lw_line_start lw_is_const lw_line_start ↻ lw_line_lits gv_check gv_puts ↻ sys_mmap ↻ sys_read_file ↻ lw_file_valuenamed lw_is_comment ↻ lw_line_valuenamed

structs

none

consts

65const LW_OUT: i64 = 262144
66const LW_DIRBUF: i64 = 131072
67const LW_PLANE: i64 = 1048576
68const LW_PATH: i64 = 512
69const LW_NAMEMAX: i64 = 256
70const LW_SCRATCH: i64 = 64
71const LW_FILECAP: i64 = 600
72const LW_COLS: i64 = 8
73const LW_COLS_MAX: i64 = 9
74const LW_FLD_BYTES: i64 = 128
75const LW_OVF: i64 = 100000000000
76const LW_MODE: i64 = 0x1a4
77const LW_NL: i64 = 10
78const LW_TAB: i64 = 9
79const LW_HASH: i64 = 35
80const LW_SP: i64 = 32
81const LW_COMMA: i64 = 44
82const LW_DQ: i64 = 34
83const LW_BSL: i64 = 92
84const LW_SL: i64 = 47
90const LW_MAGIC_THR: i64 = 1024
91const LW_MODE_LIT: i64 = 1
92const LW_MODE_ELF: i64 = 2
93const LW_MODE_TOK: i64 = 3
94const LW_SEGMAX: i64 = 64
95const LW_SEGNAME: i64 = 64
96const LW_SEGTAB: i64 = 4096
97const LW_SEGCNT: i64 = 512
98const LW_DIRMODE: i64 = 0x1ed
99const LW_ST_SLOTS: i64 = 64
317const LW_MODE_VNAME: i64 = 4
323const LW_MODE_GATEDRY: i64 = 5
324const LW_MODE_HELPERDUP: i64 = 6
325const LW_MODE_SCANCAP: i64 = 7

functions

102func lw_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
103func 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 }
104func 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 }
106func lw_catesc(o: *u8, at: i64, p: *u8, n: i64) -> i64
called by 2: lw_scanlw_file
117func lw_catn(o: *u8, at: i64, v: i64) -> i64
129func lw_count(buf: *u8, n: i64, needle: *u8) -> i64
143func lw_span_eq(b: *u8, s: i64, l: i64, lit: *u8) -> i64
150func lw_ends(nm: *u8, suf: *u8) -> i64
called by 2: lw_segamplw_walk calls 1: lw_slen
158func lw_join(dst: *u8, dir: *u8, nm: *u8) -> i64
called by 1: lw_walk calls 1: lw_cat
167func lw_wfile(path: *u8, content: *u8) -> i64
176func lw_line_start(b: *u8, ls: i64, le: i64) -> i64
183func lw_is_const(b: *u8, ls: i64, le: i64) -> i64
194func lw_is_comment(b: *u8, ls: i64, le: i64) -> i64
213func lw_line_lits(b: *u8, ls: i64, le: i64, thr: i64) -> i64
called by 1: lw_file_lits
261func lw_file_lits(path: *u8, thr: i64) -> i64
288func lw_countfile(path: *u8) -> i64
328func lw_digits(v: i64, out: *u8) -> i64
called by 1: lw_line_valuenamed calls 1: sys_mmap
339func lw_span_has(b: *u8, s: i64, e: i64, pat: *u8, pl: i64) -> i64
called by 1: lw_line_valuenamed
353func lw_line_valuenamed(b: *u8, ls: i64, le: i64) -> i64
396func lw_file_valuenamed(f: *u8, n: i64) -> i64
412func lw_field0_has(buf: *u8, n: i64, name: *u8) -> i64
called by 1: lw_walk calls 1: lw_slen
447func lw_segamp(dir: *u8, thr: i64, cx: *i64, worst: *u8) -> i64
530func lw_debt_id(b: *u8, n: i64) -> i64
called by 1: lw_file calls 1: lw_slen
561func lw_file_gatedry(b: *u8, n: i64) -> i64
called by 1: lw_walk calls 1: lw_count
570func lw_file_helperdup(b: *u8, n: i64) -> i64
called by 1: lw_walk calls 1: lw_count
584func lw_file_scancap(b: *u8, n: i64) -> i64
called by 1: lw_walk calls 1: lw_count
595func lw_walk(dir: *u8, cx: *i64, worst: *u8, abuf: *u8) -> i64
748func lw_count_lines(b: *u8, n: i64, needle: *u8, excl: *u8) -> i64
called by 1: lw_token_scan calls 2: lw_slenlw_count
764func lw_token_scan(corpus: *u8, csv: *u8, cx: *i64, worst: *u8, excl: *u8) -> i64
803func lw_last_ts(buf: *u8, n: i64) -> i64
called by 2: lw_selftestlw_file
828func lw_filed_has(buf: *u8, n: i64, lawid: *u8) -> i64
847func lw_allow_path(abuf: *u8, an: i64, name: *u8, out: *u8) -> i64
874func lw_selftest() -> i64
1123func lw_scan(prefix: *u8) -> i64
1356func lw_plane_find(rb: *u8, rn: i64, lawid: *u8, gs: *i64, gl: *i64) -> i64
1379func lw_file(prefix: *u8, toolname: *u8) -> i64
1567func main(argc: i64, argv: *i64) -> i64