code wiki / (root) / nx_workflow_tool_register.nx

nx_workflow_tool_register.nx source

↩ module page · 37 lines · 2623 B

1// nx_workflow_tool_register.nx -- register nx_workflow (consolidated workflow tool, READ-ONLY increment) 2// into the discovery registry -> mcp__nishi__nx_workflow stub. Idempotent; verifies by READBACK. 3// expect_exit: 0 license_tier: ORIGINAL 4import "nx_tool_registry.nx" 5 6const ASCII_0: i64 = 48 // named so this registrar is itself rule-11 clean 7 8func wr_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 9func wr_putn(v: i64) -> i64 { 10 if v == 0 { sys_write(1, "0" as *u8, 1); return 0 } 11 var m: i64 = v 12 if m < 0 { sys_write(1, "-" as *u8, 1); m = 0 - m } 13 let d: *u8 = sys_mmap(24); var k: i64 = 0 14 while m > 0 { d[k] = (ASCII_0 + (m % 10)) as u8; m = m / 10; k = k + 1 } 15 let o: *u8 = sys_mmap(24); var i: i64 = 0 16 while i < k { o[i] = d[k - 1 - i]; i = i + 1 } 17 sys_write(1, o, k) 18 return 0 19} 20 21func main() -> i64 { 22 wr_puts("=== nx_workflow_tool_register -- the WMS board into the discovery registry ===\n" as *u8) 23 let w: i64 = tool_register("nx_workflow" as *u8, 24 "Consolidated workflow tool (READ-ONLY): the WMS workstream registry SSOT callable from anywhere -- the crash-resume board. VERBS: board [prefix] = every workstream (state/empire/id/last_touched + per-state totals); show <id> [prefix] = one workstream fully labeled (memory link, code link, deps). Default prefix knowledge/store/ws- (the NAS-hub mirror, synced from the laptop SSOT by nx_wms_sync). found/tombstoned/absent discriminated honestly. spawn/dispatch/resume = WRITE increments behind their own cap." as *u8, 25 "over /mcp: tools/call name=nx_workflow arguments={argv:[VERB,...]}. e.g. {argv:[\"board\"]} -> the full workstream board ; {argv:[\"show\",\"WMS-R1\"]} -> one workstream labeled. exit in _meta: 0 ok | 3 absent | 4 tombstoned." as *u8, 26 "GREEN (nx_workflow_gate 5/5 on a REAL fixture registry: board totals, show found/absent/TOMBSTONED discriminated, ws_seg_next UNCAPPED [the WMS writer cap-bug fixed at the organ]; rule-11 0-magic; board proven on the real 202-segfile laptop SSOT)" as *u8) 27 let p: *i64 = sys_mmap(8) as *i64 28 let l: *i64 = sys_mmap(8) as *i64 29 let g: i64 = tool_get("nx_workflow" as *u8, p, l) 30 wr_puts(" nx_workflow put-rc=" as *u8); wr_putn(w); wr_puts(" readback=" as *u8) 31 if g == 1 { if l[0] > 0 { 32 wr_puts("OK len=" as *u8); wr_putn(l[0]); wr_puts("\nverdict=GREEN (nx_workflow discoverable -> mcp__nishi__nx_workflow stub)\n" as *u8) 33 sys_exit(0); return 0 34 } } 35 wr_puts("MISSING -- REGISTER FAILED\nverdict=RED\n" as *u8) 36 sys_exit(1); return 1 37}