code wiki / _hdl_build / nx_tooldiff.nx

nx_tooldiff.nx

buildroot/runtime/_hdl_build/nx_tooldiff.nx

12263 B209 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_tooldiff.nx

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

main td_w sys_write sys_exit sys_mmap td_reads sys_openat_rd sys_read sys_close td_extract td_span_eq_z sys_openat_wr sys_write ↻ sys_close ↻ sys_renameat td_b td_bn sys_mmap ↻ sys_openat_append td_line_in_cur td_span_eq_z ↻ td_in_baseline td_span_eq_z ↻

structs

none

consts

18const TD_REGCAP: i64 = 262144
19const TD_BLOBCAP: i64 = 16384
20const TD_BASECAP: i64 = 16384
21const TD_BASEREAD: i64 = 16000
22const TD_WBUFMAX: i64 = 16300
23const TD_REPCAP: i64 = 32768
24const TD_REPMAX: i64 = 32000
34const TD_MAXTOOLS: i64 = 4096
35const TD_PTR: i64 = 8
36const TD_SLACK: i64 = 16
37const TD_NL: i64 = 10
38const TD_TAB: i64 = 9
39const TD_HASH: i64 = 35
40const TD_SNAPCH: i64 = 115
41const TD_MODE: i64 = 420
42const TD_STDOUT: i64 = 1
43const TD_STDERR: i64 = 2
44const TD_EXIT_USAGE: i64 = 2
45const TD_EXIT_SHRINK: i64 = 3
46const TD_EXIT_FAIL: i64 = 4

functions

48func 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 }
called by 1: main calls 1: sys_write
49func 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
50func 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 }
called by 1: main calls 1: sys_mmap
51func td_reads(path: *u8, buf: *u8, cap: i64) -> i64
called by 1: main calls 3: sys_openat_rdsys_readsys_close
60func td_span_eq_z(a: *u8, ls: i64, le: i64, z: *u8) -> i64
67func td_in_baseline(bbuf: *u8, bn: i64, z: *u8) -> i64
called by 1: main calls 1: td_span_eq_z
79func td_line_in_cur(bbuf: *u8, ls: i64, le: i64, blob: *u8, offs: *i64, cnt: i64) -> i64
called by 1: main calls 1: td_span_eq_z
85func td_extract(buf: *u8, n: i64, blob: *u8, offs: *i64, maxr: i64) -> i64
called by 1: main calls 1: td_span_eq_z
124func main(argc: i64, argv: *i64) -> i64