code wiki / _hdl_build / nx_magicratchet.nx
nx_magicratchet.nx
buildroot/runtime/_hdl_build/nx_magicratchet.nx
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
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
structs
| none |
consts
| 31 | const MR_CAPBUF: i64 = 4096 |
| 32 | const MR_SMALLBUF: i64 = 64 |
| 33 | const MR_ARGVN: i64 = 64 |
| 34 | const MR_BASEDIR: *u8 = "knowledge/status/magicbase/" // the per-organ baselines: <organ>.cnt literals, <organ>.ph placeholder-named consts |
| 35 | const MR_PH_SFX: *u8 = ".ph" |
| 43 | const MR_MODE: i64 = MODE_0644 |
| 44 | const MR_DIRMODE: i64 = MODE_0755 |
| 45 | const MR_REFUSE: i64 = 3 |
| 46 | const MR_FEEDBUF: i64 = 8192 |
| 47 | const MR_MAPCAP: i64 = 1600 // bounded embed of nx_magic map output (keeps the refusal under the mgmt read cap) |
| 213 | const MR_I64: i64 = 8 |
| 214 | const MR_FV_SITES: i64 = 0 |
| 215 | const MR_FV_DISTINCT: i64 = 1 |
| 216 | const MR_FV_HEX: i64 = 2 |
| 217 | const MR_FV_OVERSIZE: i64 = 3 |
| 218 | const MR_FV_TRUNC: i64 = 4 |
| 219 | const MR_FV_READ_TRUNC: i64 = 5 |
| 220 | const MR_FV_THR_HEX: i64 = 6 |
| 221 | const MR_FV_N: i64 = 7 |
| 222 | const MR_FV_MEASURED: i64 = 1 |
| 223 | const MR_FV_UNMEASURED: i64 = 0 |
functions
| 51 | func mr_parse_sites(buf: *u8, n: i64) -> i64 called by 1: main |
| 68 | func mr_parse_magic(buf: *u8, n: i64) -> i64 called by 1: main |
| 139 | func mr_parse_thr(buf: *u8, n: i64) -> i64 called by 1: main |
| 169 | func mr_read_int(path: *u8) -> i64 |
| 185 | func mr_write_int(path: *u8, v: i64) -> i64 |
| 228 | func mr_floor_view(src: *u8, thr: i64, fv: *i64) -> i64 |
| 269 | func mr_emit_floor(rb: *u8, ro: i64, ok: i64, fv: *i64) -> i64 |
| 295 | func main(argc: i64, argv: *i64) -> i64 |