code wiki / (root) / nx_toolreg_reap.nx

nx_toolreg_reap.nx

buildroot/runtime/nx_toolreg_reap.nx

12681 B262 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tooltopic toolreg
docsdependenciesstructsconstsfunctions

about

nx_toolreg_reap.nx -- REMOVE named scaffold rows from tool_allowlist.conf. The counterpart the registry never had: nx_toolreg_reconcile only ever ADDS (rows=830 registered=0 already=815), /api has a tools/register route and NO unregister, and nx_fs_write refuses the allowlist by construction -- correctly, since a tool that can EDIT the capability allowlist can GRANT ITSELF ANYTHING. So scaffold registrations accumulated forever with no sanctioned way to clear them (debt 1785976684). WHY THIS IS SAFE TO EXIST AT ALL, and why it is a separate organ rather than a verb on the registrar: this organ can ONLY REMOVE, never add and never rewrite a target. Removal is strictly DE-privileging -- the worst case is a tool stops being callable, which is a recoverable annoyance, whereas an organ that could add or repoint a row would be a privilege-granting oracle. Single responsibility is the security property here, not a style preference. FAIL-CLOSED PREDICATE: a row is reapable ONLY if its elf path ends in ".new" -- the staged-artifact shape that scaffold aliases have. A row pointing at a promoted ".elf" is REFUSED and reported, so a fat-fingered name can never unregister a live tool. Names are EXPLICIT: there is no wildcard sweep, because rows like nx_meshmerge_staged and nx_ccingest_r7 also point at .new and other seats depend on them. nx_toolreg_reap <name> [<name>...] | nx_toolreg_reap --list (show reapable rows, change nothing) ---- THE SUPERSEDED LANE (2026-08-15) --------------------------------------------------------------- nx_toolreg_reap --superseded <name> <superseded-by> WHY IT WAS ADDED: a rename can leave a PROMOTED duplicate registered (measured: nx_promotestale and nx_servedrift, both superseded by nx_artifactdrift, three registry rows for one capability). The add lane exists (/api/tools/register, nx_toolreg_reconcile), the scaffold-reap lane exists, and there was NO sovereign path to unregister a promoted duplicate -- so duplicates could only accumulate. WHY IT DOES NOT WEAKEN THE DEFAULT: the bare-name lane still refuses every promoted row, unchanged. This lane is opt-in, takes exactly ONE name, has no wildcard, and REFUSES unless the caller also names a DIFFERENT row that is present AND promoted -- so the capability is proven to still have a home. The original property survives: a fat-fingered single name can never unregister a live tool, because one name is no longer enough. And removal stays strictly de-privileging, which is this organ's whole security argument. ⚠THE CEILING, STATED WITH THE REMEDY: this proves a promoted alternative EXISTS, never that it is semantically equivalent. That last step is the caller's judgement and the organ says so rather than implying it checked. ★★★★★A GUARD THAT CANNOT VERIFY THE CLAIM IT GATES MUST NAME WHAT IT DID VERIFY, OR THE NEXT READER CREDITS IT WITH THE STRONGER CHECK. license_tier: ORIGINAL expect_exit: 0

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_toolreg_reap.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 tr_w sys_write 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 ↻ sys_openat_rd sys_exit ↻ sys_read sys_close tr_eq tr_slen tr_find tr_name_is tr_slen ↻ tr_row_staged tr_row_staged ↻ sys_write ↻ tr_name_is ↻ tr_emit_field1 sys_write ↻ tr_wn sys_mmap ↻ sys_write ↻ sys_openat_wr sys_renameat

structs

none

consts

38const TR_CONF: *u8 = "tool_allowlist.conf"
39const TR_TMP: *u8 = "tool_allowlist.conf.reaptmp"
40const TR_CAP: i64 = 1048576
41const TR_MODE: i64 = 0x1a4
42const TR_MAXNAME: i64 = 128

functions

44func tr_w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 1: main calls 1: sys_write
45func tr_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
called by 2: tr_name_istr_eq
46func tr_wn(v: i64) -> i64
called by 1: main calls 2: sys_mmapsys_write
54func tr_name_is(buf: *u8, ls: i64, le: i64, nm: *u8) -> i64
called by 2: tr_findmain calls 1: tr_slen
64func tr_row_staged(buf: *u8, ls: i64, le: i64) -> i64
called by 2: tr_findmain
81func tr_emit_field1(buf: *u8, ls: i64, le: i64) -> i64
called by 1: main calls 1: sys_write
92func tr_eq(a: *u8, b: *u8) -> i64
called by 1: main calls 1: tr_slen
103func tr_find(buf: *u8, n: i64, nm: *u8) -> i64
called by 1: main calls 2: tr_name_istr_row_staged
121func main(argc: i64, argv: *i64) -> i64