code wiki / _hdl_build / nx_magicratchet.nx

nx_magicratchet.nx

buildroot/runtime/_hdl_build/nx_magicratchet.nx

29465 B504 linesdepth 5pulls 7 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_magicratchet.nx -- F881 MAGIC-NUMBER RATCHET (the enforcement the operator demanded 2026-07-21: catch me at submission, not by re-sweeping). A build must NOT INCREASE an organ's inline-magic-number count vs its stored baseline. First build self-baselines (grandfathers existing violations); a build that ADDS a magic number is REFUSED. Non-breaking (existing organs build). ⚠⚠DO NOT RESTATE THE WIRING STATE IN THIS COMMENT. ASK THE INSTRUMENT: nx_shelltool grep nx_magicratchet buildroot/runtime nx -> nx_wiredclaim nx_magicratchet <out> This header has now been WRONG IN BOTH DIRECTIONS. It first claimed "unbypassable (wired into /api/build)" when nothing called it (sev-8 1785530277). That was corrected to "NOT CURRENTLY REACHED FROM /api/build ... nx_wiredclaim call_sites=0" -- and then the wiring LANDED THE SAME DAY (2026-08-15: md_exec_magicratchet in nx_mgmt_data, called from nx_mgmt_api:1502) and the correction itself went stale, now understating the organ instead of overstating it. MEASURED 2026-08-16: nx_wiredclaim -> WIRED call_sites=3. A reader trusting the stale line was one step from re-wiring an already-wired guard, or from editing the estate's BUILD RUNNER to do it. ★★A COMMENT THAT MIRRORS A MEASURABLE STATE IS A CACHE WITH NO INVALIDATION -- IT DRIFTS IN WHICHEVER DIRECTION THE CODE MOVED LAST, AND IT IS BELIEVED BECAUSE IT IS SPECIFIC. Name the instrument, not the answer; the instrument is never stale. fail-OPEN on any count/read uncertainty (a false refusal would be worse than a miss). Counting is DELEGATED to `nx_law_warden countfile` -- ONE canonical L001 counter, no divergent reimplementation. Rule-11 CLEAN itself (named consts, no inline magic). license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 4 imports · 0 importers

nx_syscalls.nx nx_estr.nx nx_tool_run.nx nx_magic_lib.nx nx_magicratchet.nx

imports: nx_syscalls.nxnx_estr.nxnx_tool_run.nxnx_magic_lib.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main es_puts sys_write es_len sys_exit sys_mmap nxa_die sys_write ↻ sys_exit ↻ nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ es_cat sys_openat_rd sys_close tr_run_capture sys_mmap ↻ sys_pipe2 sys_fork sys_close ↻ sys_dup3 sys_execve_clean sys_close_inherited sys_close_inherited_proc sys_openat_rd ↻ sys_mmap ↻ sys_getdents64 dirent_reclen sys_close ↻ sys_munmap sys_execve tr_exec_failed

structs

none

consts

31const MR_CAPBUF: i64 = 4096
32const MR_SMALLBUF: i64 = 64
33const MR_ARGVN: i64 = 64
34const MR_BASEDIR: *u8 = "knowledge/status/magicbase/" // the per-organ baselines: <organ>.cnt literals, <organ>.ph placeholder-named consts
35const MR_PH_SFX: *u8 = ".ph"
43const MR_MODE: i64 = MODE_0644
44const MR_DIRMODE: i64 = MODE_0755
45const MR_REFUSE: i64 = 3
46const MR_FEEDBUF: i64 = 8192
47const MR_MAPCAP: i64 = 1600 // bounded embed of nx_magic map output (keeps the refusal under the mgmt read cap)
213const MR_I64: i64 = 8
214const MR_FV_SITES: i64 = 0
215const MR_FV_DISTINCT: i64 = 1
216const MR_FV_HEX: i64 = 2
217const MR_FV_OVERSIZE: i64 = 3
218const MR_FV_TRUNC: i64 = 4
219const MR_FV_READ_TRUNC: i64 = 5
220const MR_FV_THR_HEX: i64 = 6
221const MR_FV_N: i64 = 7
222const MR_FV_MEASURED: i64 = 1
223const MR_FV_UNMEASURED: i64 = 0

functions

51func mr_parse_sites(buf: *u8, n: i64) -> i64
called by 1: main
68func mr_parse_magic(buf: *u8, n: i64) -> i64
called by 1: main
139func mr_parse_thr(buf: *u8, n: i64) -> i64
called by 1: main
169func mr_read_int(path: *u8) -> i64
185func mr_write_int(path: *u8, v: i64) -> i64
228func mr_floor_view(src: *u8, thr: i64, fv: *i64) -> i64
called by 1: main calls 1: sys_mmap
269func mr_emit_floor(rb: *u8, ro: i64, ok: i64, fv: *i64) -> i64
called by 1: main calls 2: es_cates_catn
295func main(argc: i64, argv: *i64) -> i64