nx_verify_tool_register.nx source
↩ module page · 42 lines · 3163 B
1// nx_verify_tool_register.nx -- register nx_verify (rule-11 magic gate + capability triage + SOTA racing
2// lap) into the discovery registry so /mcp tools/list + /api/tools expose it -> first-class
3// mcp__nishi__nx_verify STUB (so a workstream and Claude itself discover + PREFER the sovereign tool).
4// EXECUTION already live (allowlist row + cap 72060, tools/call PROVEN over /mcp loopback: magic returned
5// VERIFY-MAGIC). This adds the DISCOVERY half -- unblocked by the reg_put 256-cap persistence fix (registrations
6// past 256 segments now land instead of clobbering seg-256). Writes the CWD registry (knowledge/toolreg-);
7// run on the NAS (CWD nishihost) to flip the LIVE registry. Idempotent; verifies by READBACK.
8// expect_exit: 0 license_tier: ORIGINAL
9import "nx_tool_registry.nx"
10
11const ASCII_0: i64 = 48 // named so this registrar is itself rule-11 clean (the magic ratchet checks it)
12
13func sr_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
14func sr_putn(v: i64) -> i64 {
15 if v == 0 { sys_write(1, "0" as *u8, 1); return 0 }
16 var m: i64 = v
17 if m < 0 { sys_write(1, "-" as *u8, 1); m = 0 - m }
18 let d: *u8 = sys_mmap(24); var k: i64 = 0
19 while m > 0 { d[k] = (ASCII_0 + (m % 10)) as u8; m = m / 10; k = k + 1 }
20 let o: *u8 = sys_mmap(24); var i: i64 = 0
21 while i < k { o[i] = d[k - 1 - i]; i = i + 1 }
22 sys_write(1, o, k)
23 return 0
24}
25
26func main() -> i64 {
27 sr_puts("=== nx_verify_tool_register -- rule-11 magic / triage / SOTA-lap into the discovery registry ===\n" as *u8)
28 let w: i64 = tool_register("nx_verify" as *u8,
29 "Sovereign verification tool. VERBS: magic = rule-11 magic-number gate (flags un-named numeric literals; allowlists casts/hex/mmap+syscall args/radix-10/const-lines; exempts data tables by density+count; graded 10/10 vs ESLint no-magic-numbers external oracle); triage = capability route/wire/build gap analysis; ground = evidence-grounding; lap = racing-crew where-was/is/to-go vs SOTA. Read-only analysis; runs on the NAS over MCP." as *u8,
30 "over /mcp: tools/call name=nx_verify arguments={argv:[VERB, ...]}. e.g. {argv:[\"magic\",\"/path/file.nx\"]} -> VERIFY-MAGIC file=.. magic_numbers=N lines=.. -> PASS|FAIL|EXEMPT ; {argv:[\"lap\",\"magic-detector\"]} -> racing-crew lap report vs SOTA. Read-only; newline text output." as *u8,
31 "GREEN (detector graded 10/10 vs ESLint no-magic-numbers external oracle -- not self-certified; ratchet LIVE in pre-commit, bare-literal commit BLOCKED + proven; lap magic-detector AT-OR-BEYOND-SOTA; tools/call LIVE over /mcp loopback cap 72060)" as *u8)
32 let p: *i64 = sys_mmap(8) as *i64
33 let l: *i64 = sys_mmap(8) as *i64
34 let g: i64 = tool_get("nx_verify" as *u8, p, l)
35 sr_puts(" nx_verify put-rc=" as *u8); sr_putn(w); sr_puts(" readback=" as *u8)
36 if g == 1 { if l[0] > 0 {
37 sr_puts("OK len=" as *u8); sr_putn(l[0]); sr_puts("\nverdict=GREEN (nx_verify discoverable -> mcp__nishi__nx_verify stub)\n" as *u8)
38 sys_exit(0); return 0
39 } }
40 sr_puts("MISSING -- REGISTER FAILED\nverdict=RED\n" as *u8)
41 sys_exit(1); return 1
42}