code wiki / (root) / nx_capability_triage_core.nx

nx_capability_triage_core.nx source

↩ module page · 198 lines · 8532 B

1// nx_capability_triage_core.nx -- the INTELLIGENT CATCH with ANTI-NAVEL-GAZING + OPERATOR-PROPOSAL 2// (07-15 operator: "make sure we have 3rd-party benchmarks for our research vs yours and all the 3// other things so this isn't navel gazing like it has been with our graders; and when we see a gap 4// the flag should be raised to PROPOSE INVESTMENT to me in what should be improved even if we are 5// doing another workstream so we can stop and eat our debt"). 6// 7// TWO load-bearing properties, both gate-proven: 8// 1. ANTI-NAVEL-GAZING: a PARITY/EXCEEDS claim is credited (-> ROUTE) ONLY when backed by an 9// EXTERNAL 3rd-party benchmark. A self-graded (our-own-grader) or unbenchmarked SOTA claim is 10// NEVER trusted -> TR_SELFGRADED_SUSPECT -> go get a 3rd-party number. "Our research vs yours 11// (Claude) vs the external tool" is a valid external benchmark; "our grader says we're SOTA" is not. 12// 2. OPERATOR-PROPOSAL: a real gap on a CORE capability, OR any suspected self-graded overclaim, 13// RAISES an interrupt-worthy investment proposal to the operator (stop current work, eat the 14// debt) rather than silently work-listing it. 15// Pure decision funcs here (gate-locked); a scan CLI reads the registry + emits proposals. 16// license_tier: ORIGINAL 17import "nx_syscalls.nx" 18import "nx_crashresume_census_core.nx" // ccz_slen / ccz_cat_str / ccz_cat_num / ccz_read 19 20// SOTA standing of an organ vs the best EXTERNAL alternative 21const SOTA_UNMEASURED: i64 = 0 22const SOTA_BEHIND: i64 = 1 23const SOTA_PARITY: i64 = 2 24const SOTA_EXCEEDS: i64 = 3 25 26// how a PARITY/EXCEEDS claim was graded -- the anti-navel-gazing axis 27const BENCH_NONE: i64 = 0 // no benchmark at all 28const BENCH_SELF: i64 = 1 // OUR OWN grader said so (navel-gazing -- NOT trusted for a SOTA claim) 29const BENCH_EXTERNAL: i64 = 2 // 3rd-party suite / tool / Claude-as-baseline (the ONLY trusted SOTA proof) 30 31// capability weight (interrupt priority for proposals) 32const WEIGHT_PERIPHERAL: i64 = 0 33const WEIGHT_STD: i64 = 1 34const WEIGHT_CORE: i64 = 2 35 36// triage verdicts 37const TR_BUILD: i64 = 1 38const TR_WIRE: i64 = 2 39const TR_MEASURE: i64 = 3 40const TR_USE_IMPROVE: i64 = 4 41const TR_ROUTE: i64 = 5 42const TR_SELFGRADED_SUSPECT: i64 = 6 // claimed SOTA on self/none grading -> get a 3rd-party benchmark 43 44// proposal decision 45const PROP_QUEUE: i64 = 0 // work-list it, keep going 46const PROP_RAISE: i64 = 1 // interrupt-worthy -> propose investment to the operator NOW 47 48// THE decision, benchmark-aware. Non-optimistic AND anti-navel-gazing by construction. 49func tr_decide(has_organ: i64, wired: i64, sota: i64, bench: i64) -> i64 { 50 if has_organ == 0 { return TR_BUILD } 51 if wired == 0 { return TR_WIRE } 52 if sota == SOTA_UNMEASURED { return TR_MEASURE } 53 if sota == SOTA_BEHIND { return TR_USE_IMPROVE } 54 // sota is PARITY or EXCEEDS -- an actual SOTA CLAIM. It is only credited if EXTERNALLY benchmarked. 55 if bench != BENCH_EXTERNAL { return TR_SELFGRADED_SUSPECT } // navel-gazing guard 56 return TR_ROUTE // externally proven >= SOTA 57} 58 59// operator investment proposal: RAISE when a self-graded overclaim is suspected (ALWAYS surface a 60// possible navel-gaze), OR a real gap sits on a CORE capability (worth interrupting to eat the debt). 61func tr_proposal(verdict: i64, weight: i64) -> i64 { 62 if verdict == TR_SELFGRADED_SUSPECT { return PROP_RAISE } 63 if weight == WEIGHT_CORE { 64 if tr_is_gap(verdict) == 1 { return PROP_RAISE } 65 } 66 return PROP_QUEUE 67} 68 69// "team can handle NOW" -> route away from Claude. A self-graded suspect does NOT route (untrusted). 70func tr_routes_to_nishi(v: i64) -> i64 { 71 if v == TR_ROUTE { return 1 } 72 if v == TR_USE_IMPROVE { return 1 } 73 return 0 74} 75 76// raises a gap work-item? BUILD/WIRE/MEASURE/USE_IMPROVE/SELFGRADED_SUSPECT. ROUTE raises nothing. 77func tr_is_gap(v: i64) -> i64 { 78 if v == TR_ROUTE { return 0 } 79 if v >= 1 { if v <= 6 { return 1 } } 80 return 0 81} 82 83func tr_verdict_name(v: i64) -> *u8 { 84 if v == TR_BUILD { return "BUILD(missing)" as *u8 } 85 if v == TR_WIRE { return "WIRE(unwired)" as *u8 } 86 if v == TR_MEASURE { return "MEASURE(unproven-vs-SOTA)" as *u8 } 87 if v == TR_USE_IMPROVE { return "USE+IMPROVE(behind-SOTA)" as *u8 } 88 if v == TR_ROUTE { return "ROUTE(Nishi>=SOTA,3rd-party-proven)" as *u8 } 89 if v == TR_SELFGRADED_SUSPECT { return "SELF-GRADED-SUSPECT(get 3rd-party bench!)" as *u8 } 90 return "?" as *u8 91} 92 93func tr_streq(a: *u8, b: *u8) -> i64 { 94 var i: i64 = 0 95 while a[i] != (0 as u8) { if a[i] != b[i] { return 0 } i = i + 1 } 96 if b[i] != (0 as u8) { return 0 } 97 return 1 98} 99 100// copy trimmed buf[s..e) into a NUL-terminated scratch (<=31 chars) for keyword matching. 101func tr_trim_copy(buf: *u8, s: i64, e: i64, sc: *u8) -> i64 { 102 var a: i64 = s 103 var go: i64 = 1 104 while go == 1 { go = 0; if a < e { let c: i64 = buf[a] as i64; if c == 32 { a = a + 1; go = 1 } else { if c == 9 { a = a + 1; go = 1 } } } } 105 var b: i64 = e 106 go = 1 107 while go == 1 { go = 0; if b > a { let c: i64 = buf[b-1] as i64; if c == 32 { b = b - 1; go = 1 } else { if c == 9 { b = b - 1; go = 1 } } } } 108 var i: i64 = 0 109 let len: i64 = b - a 110 while i < len { if i < 31 { sc[i] = buf[a+i] } i = i + 1 } 111 var sl: i64 = len 112 if sl > 31 { sl = 31 } 113 sc[sl] = 0 as u8 114 return 0 115} 116 117func tr_sota_match(buf: *u8, s: i64, e: i64) -> i64 { 118 let sc: *u8 = sys_mmap(32) 119 tr_trim_copy(buf, s, e, sc) 120 if tr_streq(sc, "unmeasured" as *u8) == 1 { return SOTA_UNMEASURED } 121 if tr_streq(sc, "behind" as *u8) == 1 { return SOTA_BEHIND } 122 if tr_streq(sc, "parity" as *u8) == 1 { return SOTA_PARITY } 123 if tr_streq(sc, "exceeds" as *u8) == 1 { return SOTA_EXCEEDS } 124 return 0 - 1 125} 126 127func tr_bench_match(buf: *u8, s: i64, e: i64) -> i64 { 128 let sc: *u8 = sys_mmap(32) 129 tr_trim_copy(buf, s, e, sc) 130 if tr_streq(sc, "external" as *u8) == 1 { return BENCH_EXTERNAL } 131 if tr_streq(sc, "self" as *u8) == 1 { return BENCH_SELF } 132 if tr_streq(sc, "none" as *u8) == 1 { return BENCH_NONE } 133 return 0 - 1 134} 135 136func tr_weight_match(buf: *u8, s: i64, e: i64) -> i64 { 137 let sc: *u8 = sys_mmap(32) 138 tr_trim_copy(buf, s, e, sc) 139 if tr_streq(sc, "core" as *u8) == 1 { return WEIGHT_CORE } 140 if tr_streq(sc, "std" as *u8) == 1 { return WEIGHT_STD } 141 if tr_streq(sc, "peripheral" as *u8) == 1 { return WEIGHT_PERIPHERAL } 142 return 0 - 1 143} 144 145// parse `task|organ|has_organ|wired|sota|bench|weight` in buf[ls..le). Writes out[0..4]=has_organ, 146// wired, sota, bench, weight. Returns 1 if a valid data row, else 0. Backward compatible: a 5-field 147// row (no bench/weight) defaults bench=SELF (conservative -- an unlabeled SOTA claim is NOT trusted) 148// and weight=STD. 149func tr_parse_row(buf: *u8, ls: i64, le: i64, out: *i64) -> i64 { 150 var i: i64 = ls 151 var go: i64 = 1 152 while go == 1 { go = 0; if i < le { let c: i64 = buf[i] as i64; if c == 32 { i = i + 1; go = 1 } else { if c == 9 { i = i + 1; go = 1 } } } } 153 if i >= le { return 0 } 154 if buf[i] == (35 as u8) { return 0 } 155 let fs: *i64 = sys_mmap(128) as *i64 156 let fe: *i64 = sys_mmap(128) as *i64 157 var nf: i64 = 0 158 var cur: i64 = ls 159 var j: i64 = ls 160 go = 1 161 while go == 1 { 162 go = 0 163 if j <= le { 164 var atend: i64 = 0 165 if j == le { atend = 1 } 166 var atbar: i64 = 0 167 if j < le { if buf[j] == (124 as u8) { atbar = 1 } } 168 if atend == 1 { 169 if nf < 8 { fs[nf] = cur; fe[nf] = j; nf = nf + 1 } 170 } else { 171 if atbar == 1 { 172 if nf < 8 { fs[nf] = cur; fe[nf] = j; nf = nf + 1 } 173 cur = j + 1 174 } 175 j = j + 1 176 go = 1 177 } 178 } 179 } 180 if nf < 5 { return 0 } 181 let ep: *i64 = sys_mmap(16) as *i64 182 let ho: i64 = ccz_num_at(buf, fe[2], fs[2], ep) 183 let wi: i64 = ccz_num_at(buf, fe[3], fs[3], ep) 184 let so: i64 = tr_sota_match(buf, fs[4], fe[4]) 185 if ho < 0 { return 0 } 186 if wi < 0 { return 0 } 187 if so < 0 { return 0 } 188 var be: i64 = BENCH_SELF // default: unlabeled SOTA claim is NOT trusted 189 var we: i64 = WEIGHT_STD 190 if nf >= 6 { let b: i64 = tr_bench_match(buf, fs[5], fe[5]); if b >= 0 { be = b } } 191 if nf >= 7 { let w: i64 = tr_weight_match(buf, fs[6], fe[6]); if w >= 0 { we = w } } 192 out[0] = ho 193 out[1] = wi 194 out[2] = so 195 out[3] = be 196 out[4] = we 197 return 1 198}