code wiki / _hdl_build / nx_tooldiff.nx
nx_tooldiff.nx
buildroot/runtime/_hdl_build/nx_tooldiff.nx
about
nx_tooldiff.nx -- toolsplane (seq162 DETECTION half #2: the tool_allowlist ROW-SET shrink detector).
Sibling of nx_route_diff (which covers /api routes): THIS catches any GREEN tool row VANISHING (or being
de-GREENed) vs a captured baseline -- the allowlist-clobber class (a hub re-assemble, stale-mirror deploy,
or bad edit silently killing MCP capability for every session). Transactional use: `snapshot` before a
deploy/registry edit, `check` after -> a MISSING name = a capability regression (exit 3 + restore hint).
READ-ONLY over the live registry; baseline + verdict land in the evidence layer (deploy_checks row
tool-shrink -> nx_deploy_ready surfaces it). ENFORCEMENT/auto-rollback stays mgmt-owned, same stance as
nx_route_diff (a cron cannot know intent; the deploy transaction can -- filed rung).
nx_tooldiff snapshot | check
ENVELOPE (declared in output): TD_MAXTOOLS rows, TD_REGCAP registry read. exit: 0 GREEN | 3 RED-SHRINK |
4 read-fail | 2 usage.
RULE-11 (seq274 / law-warden L001, own-house-first 2026-07-20): v1 of this organ shipped with inline
literals (16000/16384/32768/262144). REWRITTEN, not patched -- every bound is a NAMED CONST below, so a
future session tuning a limit edits a declaration instead of burying a new magic number in the body.
license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0
dependencies 1 imports · 0 importers
imports: nx_syscalls.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
| 18 | const TD_REGCAP: i64 = 262144 |
| 19 | const TD_BLOBCAP: i64 = 16384 |
| 20 | const TD_BASECAP: i64 = 16384 |
| 21 | const TD_BASEREAD: i64 = 16000 |
| 22 | const TD_WBUFMAX: i64 = 16300 |
| 23 | const TD_REPCAP: i64 = 32768 |
| 24 | const TD_REPMAX: i64 = 32000 |
| 34 | const TD_MAXTOOLS: i64 = 4096 |
| 35 | const TD_PTR: i64 = 8 |
| 36 | const TD_SLACK: i64 = 16 |
| 37 | const TD_NL: i64 = 10 |
| 38 | const TD_TAB: i64 = 9 |
| 39 | const TD_HASH: i64 = 35 |
| 40 | const TD_SNAPCH: i64 = 115 |
| 41 | const TD_MODE: i64 = 420 |
| 42 | const TD_STDOUT: i64 = 1 |
| 43 | const TD_STDERR: i64 = 2 |
| 44 | const TD_EXIT_USAGE: i64 = 2 |
| 45 | const TD_EXIT_SHRINK: i64 = 3 |
| 46 | const TD_EXIT_FAIL: i64 = 4 |
functions
| 48 | func td_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 } |
| 49 | func td_b(rep: *u8, pos: i64, s: *u8) -> i64 { var p: i64 = pos; var i: i64 = 0; while s[i] != (0 as u8) { if p < TD_REPMAX { rep[p] = s[i]; p = p + 1 } i = i + 1 } return p } called by 1: main |
| 50 | func td_bn(rep: *u8, pos: i64, v: i64) -> i64 { var p: i64 = pos; var m: i64 = v; if m < 0 { if p < TD_REPMAX { rep[p] = 45 as u8; p = p + 1 } m = 0 - m } let t: *u8 = sys_mmap(28); var k: i64 = 0; if m == 0 { t[0] = 48 as u8; k = 1 } while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } var i: i64 = 0; while i < k { if p < TD_REPMAX { rep[p] = t[k - 1 - i]; p = p + 1 } i = i + 1 } return p } |
| 51 | func td_reads(path: *u8, buf: *u8, cap: i64) -> i64 |
| 60 | func td_span_eq_z(a: *u8, ls: i64, le: i64, z: *u8) -> i64 |
| 67 | func td_in_baseline(bbuf: *u8, bn: i64, z: *u8) -> i64 |
| 79 | func td_line_in_cur(bbuf: *u8, ls: i64, le: i64, blob: *u8, offs: *i64, cnt: i64) -> i64 |
| 85 | func td_extract(buf: *u8, n: i64, blob: *u8, offs: *i64, maxr: i64) -> i64 |
| 124 | func main(argc: i64, argv: *i64) -> i64 |