code wiki / (root) / nx_ask_tool_register.nx

nx_ask_tool_register.nx source

↩ module page · 24 lines · 2236 B

1// nx_ask_tool_register.nx -- register nx_ask (user-question queue) into the discovery registry -> 2// mcp__nishi__nx_ask stub, so autonomous organs/agents can BLOCK ON OPERATOR INPUT properly instead of 3// guessing (the coverage BUILD-queue gap "user-question" = Claude AskUserQuestion parity). Idempotent; 4// verifies by READBACK. expect_exit: 0 license_tier: ORIGINAL 5import "nx_tool_registry.nx" 6 7func ar_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 8 9func main() -> i64 { 10 ar_puts("=== nx_ask_tool_register -- user-question queue into the discovery registry ===\n" as *u8) 11 let w: i64 = tool_register("nx_ask" as *u8, 12 "USER-QUESTION queue (the Claude AskUserQuestion peer for sovereign organs): when an autonomous organ/agent hits a decision only the OPERATOR can make, it posts a question and polls for the answer instead of guessing. VERBS: ask <from> <question> -> prints 'NX-ASK id=<epoch-id>' (agent->operator); pending -> '<id> <from> <question>' per OPEN question (operator view); answer <id> <text> (operator->agent); get <id> -> labeled state/from/question/answer, poll until state=ANSWERED. Backed by the sovereign seg store (knowledge/store/ask-): append-only additive, TABs/newlines in text flattened at the boundary so records stay parseable. Unknown id -> honest ABSENT (exit 3), never a fabricated answer." as *u8, 13 "over /mcp: tools/call name=nx_ask arguments={argv:[VERB,...]} + cap granting nx_ask. e.g. {argv:[\"ask\",\"forge\",\"ship model A or B?\"]} -> id; later {argv:[\"get\",\"<id>\"]} -> state/answer. exit 0 ok | 2 usage | 3 unknown id." as *u8, 14 "GREEN (nx_ask_gate 6/6: post->id, pending lists OPEN, get serves OPEN, answer lands, STORE holds ANSWERED+text, unknown-id honest ABSENT negctl; 0 magic; portability couplings=0)" as *u8) 15 let p: *i64 = sys_mmap(8) as *i64 16 let l: *i64 = sys_mmap(8) as *i64 17 let g: i64 = tool_get("nx_ask" as *u8, p, l) 18 if w == 0 { if g == 1 { if l[0] > 0 { 19 ar_puts("verdict=GREEN (nx_ask discoverable -> mcp__nishi__nx_ask stub)\n" as *u8) 20 sys_exit(0); return 0 21 } } } 22 ar_puts("REGISTER FAILED\nverdict=RED\n" as *u8) 23 sys_exit(1); return 1 24}