code wiki / (root) / nx_tool_registry_gate.nx

nx_tool_registry_gate.nx source

↩ module page · 39 lines · 2264 B

1// nx_tool_registry_gate.nx -- proves MCP-style register + discover on the real seg_store (test prefix): register two 2// tools, LIST them (discovery returns both), GET one and read its record fields. license_tier: ORIGINAL 3import "nx_tool_registry.nx" 4import "nx_gate.nx" 5 6func main() -> i64 { 7 gw("=== nx_tool_registry_gate: sovereign tool register + discover (MCP Tools parity) ===\n" as *u8) 8 let TP: *u8 = "knowledge/toolreg-test-" as *u8 9 10 tool_register_pfx(TP, "nx_http_probe" as *u8, "sovereign HTTP GET probe" as *u8, "nx_http_probe <path> [expect]" as *u8, "gate-proven" as *u8) 11 tool_register_pfx(TP, "nx_proc_ctl" as *u8, "kill by full /proc cmdline" as *u8, "nx_pctl_kill_by_cmdline(name,sig)" as *u8, "gate-5/5" as *u8) 12 13 var pass: i64=0; var tot: i64=0 14 let idxbuf: *u8 = sys_mmap(65536) 15 let il: i64 = tool_list_pfx(TP, idxbuf, 65536) 16 17 tot=tot+1; var t1: i64=0 18 if reg_id_present(idxbuf, il, "nx_http_probe" as *u8, 13)==1 { if reg_id_present(idxbuf, il, "nx_proc_ctl" as *u8, 11)==1 { t1=1 } } 19 if t1==1 { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) } 20 gw("T1 DISCOVERY: tool_list returns both registered tools\n" as *u8) 21 22 let po: *i64=sys_mmap(16) as *i64 23 let lo: *i64=sys_mmap(16) as *i64 24 let f2: *i64=sys_mmap(16) as *i64 25 let g: i64 = tool_get_pfx(TP, "nx_http_probe" as *u8, po, lo) 26 tot=tot+1; var t2: i64=0 27 if g==1 { if tr_field_eq(po[0] as *u8, lo[0], 0, "nx_http_probe" as *u8, f2)==1 { t2=1 } } 28 if t2==1 { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) } 29 gw("T2 GET: record field 0 = the tool name\n" as *u8) 30 31 tot=tot+1; var t3: i64=0 32 if g==1 { if tr_field_eq(po[0] as *u8, lo[0], 3, "gate-proven" as *u8, f2)==1 { t3=1 } } 33 if t3==1 { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) } 34 gw("T3 GET: record field 3 = gate-status (so the registry doubles as the census source)\n" as *u8) 35 36 gw("\n=== nx_tool_registry_gate " as *u8); gn(pass); gw("/" as *u8); gn(tot); gw(" ===\n" as *u8) 37 if pass==tot { gw("TOOL-REGISTRY GREEN -- sovereign register + discover on seg_store (MCP Tools parity)\n" as *u8); sys_exit(0); return 0 } 38 gw("TOOL-REGISTRY RED\n" as *u8); sys_exit(1); return 1 39}