code wiki / (root) / nx_crew_tool_register.nx

nx_crew_tool_register.nx source

↩ module page · 46 lines · 3822 B

1// nx_crew_tool_register.nx -- register the nishi_crew capability-directory API into the sovereign tool registry 2// (operator 2026-07-10: "each role owns its raci capabilities and gets them to be mcp apis"). The registry IS what 3// nishifamily.com/api/tools + /mcp tools/list serve, so this = DISCOVERABILITY: any engaging model SEES that a single 4// consolidated crew-capability API exists and how to call it. Mirrors nx_compare_tool_register. EXECUTION is already 5// live (tool_allowlist row nishi_crew + cap-minted, proven over /mcp loopback); this adds the discovery half. Writes the 6// CWD registry (knowledge/toolreg-); run on the NAS (CWD nishihost, as root) to flip the LIVE registry. Idempotent 7// (reg_put additive). Verifies by READBACK, not claim. expect_exit: 0 license_tier: ORIGINAL 8import "nx_tool_registry.nx" 9 10func cr_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 cr_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] = (48 + (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} 22func cr_reg1(name: *u8, desc: *u8, invoke: *u8, status: *u8) -> i64 { 23 let w: i64 = tool_register(name, desc, invoke, status) 24 let p: *i64 = sys_mmap(8) as *i64 25 let l: *i64 = sys_mmap(8) as *i64 26 let g: i64 = tool_get(name, p, l) 27 cr_puts(" " as *u8); cr_puts(name); cr_puts(" put-rc=" as *u8); cr_putn(w); cr_puts(" readback=" as *u8) 28 if g == 1 { if l[0] > 0 { cr_puts("OK len=" as *u8); cr_putn(l[0]); cr_puts("\n" as *u8); return 1 } } 29 cr_puts("MISSING -- REGISTER FAILED\n" as *u8) 30 return 0 31} 32 33func main() -> i64 { 34 cr_puts("=== nx_crew_tool_register -- nishi_crew into the discovery registry (knowledge/toolreg-) ===\n" as *u8) 35 var ok: i64 = 0 36 ok = ok + cr_reg1("nishi_crew" as *u8, 37 "the Nishi CREW capability directory: every RACI role, the capability organ it OWNS, and whether that capability is a live MCP API. Data-driven from knowledge/registry/crew_capabilities.data joined with the live tool registry; reports MCP-exposure coverage (permille) plus counts (mcp / organ-only / concept). ONE consolidated tool for the whole 36-role crew -- no per-role tool proliferation. Roles already MCP: racing, pm, workstream, assistant, supervisor, publisher, host_operator, researcher, librarian, hr, examiner, auditor." as *u8, 38 "over /mcp: tools/call name=nishi_crew arguments={argv:[]} -> {v:1, api:nishi-crew/v1, resource:crew-capabilities, coverage_permil, counts:{roles,mcp,organ_only,concept,human}, roles:[{role,activity,organ,mcp_tool,status}]}. Versioned JSON v:1; status in mcp|organ|concept|human." as *u8, 39 "GREEN (exec-live: the cap->allowlist->fork-exec->serve chain is proven over the /mcp loopback, returning the ledger JSON; coverage 342 permille = 12 of 35 non-human roles own an MCP API; the ledger is liar-killed by nx_crew_capability_gate against the live tool snapshot -- no role can claim a tool that is not really registered)" as *u8) 40 cr_puts("registered+readback " as *u8); cr_putn(ok); cr_puts(" / 1\n" as *u8) 41 cr_puts("NOTE: writes the CWD registry (knowledge/toolreg-). Run on the NAS (CWD nishihost, as root) to flip the LIVE\n" as *u8) 42 cr_puts(" nishifamily.com/api/tools registry. Native /mcp binding needs the .mcp.json read cap to add nishi_crew.\n" as *u8) 43 if ok == 1 { cr_puts("verdict=GREEN (nishi_crew discoverable in the sovereign tool surface)\n" as *u8); sys_exit(0); return 0 } 44 cr_puts("verdict=RED\n" as *u8) 45 sys_exit(1); return 1 46}