nx_heal_tool_register.nx source
↩ module page · 39 lines · 2863 B
1// nx_heal_tool_register.nx -- register nx_heal (consolidated heal-plane tool, READ-ONLY increment)
2// into the discovery registry -> mcp__nishi__nx_heal stub. Models nx_verify_tool_register. The serve
3// reads the registry per request (proven 07-16: registrar-only exposure worked for nx_shelltool), so
4// no serve redeploy is needed. Idempotent; verifies by READBACK. Run on the NAS (cwd nishihost).
5// expect_exit: 0 license_tier: ORIGINAL
6import "nx_tool_registry.nx"
7
8const ASCII_0: i64 = 48 // named so this registrar is itself rule-11 clean
9
10func hr_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
11func hr_putn(v: i64) -> i64 {
12 if v == 0 { sys_write(1, "0" as *u8, 1); return 0 }
13 var m: i64 = v
14 if m < 0 { sys_write(1, "-" as *u8, 1); m = 0 - m }
15 let d: *u8 = sys_mmap(24); var k: i64 = 0
16 while m > 0 { d[k] = (ASCII_0 + (m % 10)) as u8; m = m / 10; k = k + 1 }
17 let o: *u8 = sys_mmap(24); var i: i64 = 0
18 while i < k { o[i] = d[k - 1 - i]; i = i + 1 }
19 sys_write(1, o, k)
20 return 0
21}
22
23func main() -> i64 {
24 hr_puts("=== nx_heal_tool_register -- heal-plane visibility into the discovery registry ===\n" as *u8)
25 let w: i64 = tool_register("nx_heal" as *u8,
26 "Consolidated heal-plane tool (READ-ONLY): supervision + self-heal + remediation state of the NAS service plane. VERBS: status = one rollup (supervisor snapshot UP/DOWN counts + every non-UP service line + selfheal state + per-plane last event & remediation totals; exit code = DOWN count, 0=GREEN); log tools|edge = tail of that plane self-heal log; remediations = force-restart event counts + recent epochs. Surfaces the prevention layer (tools_selfheal/edge_selfheal) so crash-loops and stale-inode remediations are SEEN, not silently absorbed." as *u8,
27 "over /mcp: tools/call name=nx_heal arguments={argv:[VERB,...]}. e.g. {argv:[\"status\"]} -> rollup + verdict GREEN|ATTENTION (exit=down-count) ; {argv:[\"log\",\"tools\"]} -> selfheal log tail ; {argv:[\"remediations\"]} -> per-plane restart counts. Read-only." as *u8,
28 "GREEN (nx_heal_gate 5/5: DOWN-service detected+counted, all-UP green, log tail counts, absent-log graceful, events counted; composes the 07-16 KILL-TESTED prevention layer -- selfheal itself proven by kill + stale-inode live tests)" as *u8)
29 let p: *i64 = sys_mmap(8) as *i64
30 let l: *i64 = sys_mmap(8) as *i64
31 let g: i64 = tool_get("nx_heal" as *u8, p, l)
32 hr_puts(" nx_heal put-rc=" as *u8); hr_putn(w); hr_puts(" readback=" as *u8)
33 if g == 1 { if l[0] > 0 {
34 hr_puts("OK len=" as *u8); hr_putn(l[0]); hr_puts("\nverdict=GREEN (nx_heal discoverable -> mcp__nishi__nx_heal stub)\n" as *u8)
35 sys_exit(0); return 0
36 } }
37 hr_puts("MISSING -- REGISTER FAILED\nverdict=RED\n" as *u8)
38 sys_exit(1); return 1
39}