code wiki / (root) / nx_capability_triage.nx

nx_capability_triage.nx source

↩ module page · 90 lines · 4323 B

1// nx_capability_triage.nx -- CLI of the intelligent catch / gap-analysis loop (07-15). 2// `scan <registry>` reads the capability registry and emits, per row, the triage verdict + a 3// tally = the team's SOTA-climb work-list (how many capabilities ROUTE at/above SOTA, how many 4// need WIRE / BUILD / MEASURE / USE+IMPROVE). This is the analysis Claude runs ONCE to seed the 5// loop; the SOTA target is a census auto-populating the registry so the team self-hosts it. 6// usage: nx_capability_triage scan [registry] (default knowledge/capability_triage.reg) 7// Always exits 0 (analysis, not a gate); appends a summary to knowledge/status/capability_triage.log. 8// license_tier: ORIGINAL expect_exit: 0 9import "nx_syscalls.nx" 10import "nx_capability_triage_core.nx" 11const K_MAGIC_65536: i64 = 65536 12const K_MAGIC_65535: i64 = 65535 13const K_MAGIC_1024: i64 = 1024 14 15func t_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 16func t_putn(v: i64) -> i64 { nxi_out(v); return 0 } 17func t_streq(a: *u8, b: *u8) -> i64 { var i: i64 = 0; while a[i] != (0 as u8) { if a[i] != b[i] { return 0 } i = i + 1 } if b[i] != (0 as u8) { return 0 } return 1 } 18 19// print the task_class field (field 0) of a row for the per-row line 20func t_print_field0(buf: *u8, ls: i64, le: i64) -> i64 { 21 var i: i64 = ls 22 while i < le { if buf[i] == (124 as u8) { i = le } else { sys_write(1, (buf as i64 + i) as *u8, 1); i = i + 1 } } 23 return 0 24} 25 26func main(argc: i64, argv: *i64) -> i64 { 27 var reg: *u8 = "knowledge/capability_triage.reg" as *u8 28 if argc >= 2 { if t_streq(argv[1] as *u8, "scan" as *u8) == 1 { if argc >= 3 { reg = argv[2] as *u8 } } } 29 30 let buf: *u8 = sys_mmap(K_MAGIC_65536) 31 let n: i64 = ccz_read(reg, buf, K_MAGIC_65535) 32 if n <= 0 { t_puts("TRIAGE no-registry\n" as *u8); return 0 } 33 34 let out: *i64 = sys_mmap(32) as *i64 35 let cnt: *i64 = sys_mmap(64) as *i64 // cnt[1..5] per verdict 36 var k: i64 = 0 37 while k < 7 { cnt[k] = 0; k = k + 1 } 38 var rows: i64 = 0 39 var raises: i64 = 0 40 41 var ls: i64 = 0 42 while ls < n { 43 var le: i64 = ls 44 var go: i64 = 1 45 while go == 1 { go = 0; if le < n { if buf[le] != (10 as u8) { le = le + 1; go = 1 } } } 46 if tr_parse_row(buf, ls, le, out) == 1 { 47 let v: i64 = tr_decide(out[0], out[1], out[2], out[3]) 48 let prop: i64 = tr_proposal(v, out[4]) 49 cnt[v] = cnt[v] + 1 50 if prop == PROP_RAISE { raises = raises + 1 } 51 rows = rows + 1 52 t_puts("TRIAGE " as *u8) 53 t_print_field0(buf, ls, le) 54 t_puts(" -> " as *u8) 55 t_puts(tr_verdict_name(v)) 56 if tr_routes_to_nishi(v) == 1 { t_puts(" [Nishi handles -- 0 Claude tokens]" as *u8) } else { t_puts(" [GAP]" as *u8) } 57 if prop == PROP_RAISE { t_puts(" ***PROPOSE-INVESTMENT (interrupt-worthy -- flag to operator)***" as *u8) } 58 t_puts("\n" as *u8) 59 } 60 ls = le + 1 61 } 62 63 // summary = the climb work-list 64 let line: *u8 = sys_mmap(K_MAGIC_1024) 65 var o: i64 = 0 66 o = ccz_cat_str(line, o, "TRIAGE-SUM rows=" as *u8) 67 o = ccz_cat_num(line, o, rows) 68 o = ccz_cat_str(line, o, " ROUTE=" as *u8) 69 o = ccz_cat_num(line, o, cnt[TR_ROUTE]) 70 o = ccz_cat_str(line, o, " USE_IMPROVE=" as *u8) 71 o = ccz_cat_num(line, o, cnt[TR_USE_IMPROVE]) 72 o = ccz_cat_str(line, o, " MEASURE=" as *u8) 73 o = ccz_cat_num(line, o, cnt[TR_MEASURE]) 74 o = ccz_cat_str(line, o, " WIRE=" as *u8) 75 o = ccz_cat_num(line, o, cnt[TR_WIRE]) 76 o = ccz_cat_str(line, o, " BUILD=" as *u8) 77 o = ccz_cat_num(line, o, cnt[TR_BUILD]) 78 o = ccz_cat_str(line, o, " SELF-GRADED-SUSPECT=" as *u8) 79 o = ccz_cat_num(line, o, cnt[TR_SELFGRADED_SUSPECT]) 80 let gaps: i64 = cnt[TR_USE_IMPROVE] + cnt[TR_MEASURE] + cnt[TR_WIRE] + cnt[TR_BUILD] + cnt[TR_SELFGRADED_SUSPECT] 81 o = ccz_cat_str(line, o, " gaps=" as *u8) 82 o = ccz_cat_num(line, o, gaps) 83 o = ccz_cat_str(line, o, " PROPOSALS-TO-OPERATOR=" as *u8) 84 o = ccz_cat_num(line, o, raises) 85 o = ccz_cat_str(line, o, "\n" as *u8) 86 sys_write(1, line, o) 87 let lfd: i64 = sys_openat_append("knowledge/status/capability_triage.log" as *u8, 420) 88 if lfd >= 0 { sys_write(lfd, line, o); sys_close(lfd) } 89 return 0 90}