code wiki / _hdl_build / nx_role_scorecard.nx

nx_role_scorecard.nx source

↩ module page · 139 lines · 9181 B

1// nx_role_scorecard.nx -- the EXAMINER/LIBRARIAN grade every role from HARD RESULTS only (operator 2// 2026-06-09: "all the roles s class exceed not just optimism but via hard results"). Evidence = 3// durable artifacts the work actually produced: the cap registry (Builder/Librarian), the bench log 4// (Racing/Referee), the meter (Scribe), the PM plan (PM), the issues log (Engineer/Doctor). Grades 5// are MECHANICAL: NO-EVIDENCE (nothing durable -> cannot be graded above TOY, the honest finding), 6// FUNCTIONAL (durable output exists), S-CLASS-COMPOSE (a measured verdict line exists), EXCEED only 7// when an EXCEED verdict line exists -- none does yet, so every role prints its NAMED race/gap. 8// license_tier: ORIGINAL 9import "nx_syscalls.nx" 10import "nx_itoa_lib.nx" // shared MSB-first emitter (zero-alloc) 11import "nx_framed_append.nx" // torn-write fix: each log record = ONE locked fa_appendz (was multi _fp/_fn) 12const RS_MAGIC_1048592: i64 = 1048592 13const RS_MAGIC_1048576: i64 = 1048576 14const RS_LOG: *u8 = "knowledge/status/role_scorecard.log" 15const RS_CAP: i64 = 1024 // bounded record (>= the longest ROLE row incl. the MODELWRIGHT gap) 16func _p(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 17// MIGRATED to the shared emitter (debt 1785563586). The old body mmapped a scratch buffer 18// per call and never freed it. At PAGE granularity that is 4096B leaked PER CALL -- the 19// defect that took 28.5GB of a 36GB host in nx_ts_lumadiff (2MB input, ~3.66M calls). 20// nxi_* is MSB-first, allocates NOTHING, and emits identical bytes including the sign. 21func _pn(v: i64) -> i64 { nxi_out(v); return 0 } 22func _fp(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 } 23// MIGRATED to the shared emitter (debt 1785563586). The old body mmapped a scratch buffer 24// per call and never freed it. At PAGE granularity that is 4096B leaked PER CALL -- the 25// defect that took 28.5GB of a 36GB host in nx_ts_lumadiff (2MB input, ~3.66M calls). 26// nxi_* is MSB-first, allocates NOTHING, and emits identical bytes including the sign. 27func _fn(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 } 28func rs_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } 29// count occurrences of pattern in a file (bounded read) 30func rs_count(path: *u8, pat: *u8) -> i64 { 31 let fd: i64 = sys_openat_rd(path) 32 if fd < 0 { return 0 } 33 let buf: *u8 = sys_mmap(RS_MAGIC_1048592) 34 var total: i64 = 0 35 var go: i64 = 1 36 while go == 1 { 37 let base: i64 = buf as i64 38 let n: i64 = sys_read(fd, (base + total) as *u8, RS_MAGIC_1048576 - total) 39 if n <= 0 { go = 0 } else { total = total + n } 40 if total >= RS_MAGIC_1048576 { go = 0 } 41 } 42 sys_close(fd) 43 let pl: i64 = rs_slen(pat) 44 var cnt: i64 = 0 45 var i: i64 = 0 46 while i + pl <= total { 47 var k: i64 = 0 48 var hit: i64 = 1 49 while k < pl { if buf[i+k] != pat[k] { hit = 0; k = pl } else { k = k + 1 } } 50 if hit == 1 { cnt = cnt + 1 } 51 i = i + 1 52 } 53 return cnt 54} 55// one role row: stdout (unchanged) + the durable log as ONE assembled locked fa_appendz write 56// (was 7 sequential _fp/_fn writes -> a multi-write torn-line channel). Record byte-identical. 57func rs_row(role: *u8, ev: i64, sclass: i64, gap: *u8) -> i64 { 58 var grade: *u8 = "NO-EVIDENCE" as *u8 59 if ev > 0 { grade = "FUNCTIONAL" as *u8 } 60 if sclass == 1 { grade = "S-CLASS-COMPOSE" as *u8 } 61 // stdout view (unchanged byte-for-byte) 62 _p(" " as *u8); _p(role); _p(" evidence=" as *u8); _pn(ev) 63 _p(" grade=" as *u8); _p(grade) 64 _p(" race-to-exceed: " as *u8); _p(gap); _p("\n" as *u8) 65 // durable log: assemble the whole row -> single fa_appendz 66 let buf: *u8 = sys_mmap(RS_CAP + 16) 67 var o: i64 = 0 68 o = fa_cat(buf, o, "ROLE name=" as *u8); o = fa_cat(buf, o, role) 69 o = fa_cat(buf, o, " evidence=" as *u8); o = fa_catn(buf, o, ev) 70 o = fa_cat(buf, o, " grade=" as *u8); o = fa_cat(buf, o, grade) 71 o = fa_cat(buf, o, " race-to-exceed=" as *u8); o = fa_cat(buf, o, gap) 72 buf[o] = 0 as u8 73 fa_appendz(RS_LOG, buf, RS_CAP) 74 return 0 75} 76func main() -> i64 { 77 _p("=== ROLE SCORECARD (mechanical: durable evidence only; EXCEED requires an EXCEED verdict line -- none exists yet) ===\n" as *u8) 78 let caps: i64 = rs_count("/tmp/nishi_cap_registry.log" as *u8, "CAPREG " as *u8) 79 let races: i64 = rs_count("knowledge/status/synth_bench.log" as *u8, "BENCH " as *u8) 80 let sclassv: i64 = rs_count("knowledge/status/synth_bench.log" as *u8, "S-CLASS-COMPOSE-ACHIEVED" as *u8) 81 let exceedv: i64 = rs_count("knowledge/status/synth_bench.log" as *u8, "verdict=S-CLASS-EXCEED" as *u8) 82 let meters: i64 = rs_count("knowledge/status/claude_meter.log" as *u8, "METER " as *u8) 83 let pmlogs: i64 = rs_count("/tmp/nishi_pm_plan.log" as *u8, "PMLOG " as *u8) 84 let sigs: i64 = rs_count("/tmp/nishi_issues.log" as *u8, "SIGNAL " as *u8) 85 let corpus: i64 = rs_count("knowledge/library/synth_corpus.log" as *u8, "SYNTH " as *u8) 86 // grading cluster now produces durable evidence (built 2026-06-10) -- read it, don't hardcode 0 87 let critic: i64 = rs_count("knowledge/status/critic_log.log" as *u8, "COUNTERGRADE " as *u8) 88 let auditv: i64 = rs_count("knowledge/status/maturity_audit.log" as *u8, "MATAUDIT " as *u8) 89 let examv: i64 = rs_count("knowledge/status/examiner_report.log" as *u8, "EXAMINER " as *u8) 90 let secstat: i64 = rs_count("knowledge/status/security_status.log" as *u8, "SECSTATUS " as *u8) 91 // T4 first-model evidence (2026-06-10): the Modelwright's durable rows -- loss curves, 92 // data oracles, verdicts -- written by _t4_first_model_authored on every gated run 93 let mwright: i64 = rs_count("knowledge/status/modelwright.log" as *u8, "MODELWRIGHT " as *u8) 94 var sc: i64 = 0 95 if sclassv > 0 { sc = 1 } 96 // writability fail-loud (open+close); all records below are atomic fa_appendz writes 97 let lfd: i64 = sys_openat_append(RS_LOG, 0x1a4) 98 if lfd < 0 { _p(" scorecard log open FAILED\n" as *u8); sys_exit(1); return 1 } 99 sys_close(lfd) 100 let eb: *u8 = sys_mmap(RS_CAP + 16) 101 var eo: i64 = 0 102 eo = fa_cat(eb, eo, "SCORECARD epoch=" as *u8); eo = fa_catn(eb, eo, sys_now_realtime_sec()) 103 eb[eo] = 0 as u8 104 fa_appendz(RS_LOG, eb, RS_CAP) 105 rs_row("BUILDER" as *u8, caps, sc, "win novel-v1 blind race (claude lane pending) -> first EXCEED verdict" as *u8) 106 rs_row("ENGINEER" as *u8, sigs, sc, "zero open miscompiles (NxDirent struct + compile-retry) + deploy fast-LICM _offc" as *u8) 107 rs_row("RACING" as *u8, races, sc, "external races: language-bench suite vs C/Rust/Go (research-gated R2)" as *u8) 108 rs_row("REFEREE" as *u8, races, sc, "score an EXTERNAL competitor lane, not only Claude" as *u8) 109 rs_row("LIBRARIAN" as *u8, caps, 0, "registry to durable storage (L6) + census enumerator on the loop" as *u8) 110 rs_row("PM" as *u8, pmlogs, 0, "decision matrix on the loop w/ check-ins, not per-session drivers" as *u8) 111 rs_row("SCRIBE" as *u8, meters, 0, "meter+scorecard auto-run on the loop (loop_monitor wiring)" as *u8) 112 rs_row("BUILDER-CORPUS" as *u8, corpus, 0, "corpus dedup via L5 CID store; (rejected,verified) pairs for the LLM" as *u8) 113 rs_row("EXAMINER" as *u8, examv, 0, "self-grade LIVE (examiner_report.log); next: run on the loop + grade teammates per-arc" as *u8) 114 rs_row("AUDITOR" as *u8, auditv, 0, "maturity audit LIVE (maturity_audit.log); next: triangulate crypto vs reference -> S-class evidence" as *u8) 115 rs_row("CRITIC" as *u8, critic, 0, "counter-grade LIVE (critic_log.log); next: counter-grade EVERY new verdict on the loop" as *u8) 116 rs_row("RESEARCHER" as *u8, 0, 0, "language-bench yardstick sourcing pass (R2) -- corroborated >=2, durable in library/" as *u8) 117 rs_row("MODELWRIGHT" as *u8, mwright, 0, "T4+T4b+T2r1+T2r2a DONE (census 149/149, closed-loop 30/30, vocab TRAINED, FIRST LM beats analytic midpoint bit-exact); next hidden-state LM (matmul node) -> decoder w/ attention backward -> RLVR on synthesis verdicts" as *u8) 118 _p(" totals: caps=" as *u8); _pn(caps) 119 _p(" races=" as *u8); _pn(races) 120 _p(" sclass-verdicts=" as *u8); _pn(sclassv) 121 _p(" exceed-verdicts=" as *u8); _pn(exceedv) 122 _p(" meters=" as *u8); _pn(meters) 123 _p(" pmlogs=" as *u8); _pn(pmlogs) 124 _p(" signals=" as *u8); _pn(sigs) 125 _p(" corpus=" as *u8); _pn(corpus); _p("\n" as *u8) 126 let tb: *u8 = sys_mmap(RS_CAP + 16) 127 var to: i64 = 0 128 to = fa_cat(tb, to, "SCORECARD-TOTALS caps=" as *u8); to = fa_catn(tb, to, caps) 129 to = fa_cat(tb, to, " races=" as *u8); to = fa_catn(tb, to, races) 130 to = fa_cat(tb, to, " sclass=" as *u8); to = fa_catn(tb, to, sclassv) 131 to = fa_cat(tb, to, " exceed=" as *u8); to = fa_catn(tb, to, exceedv) 132 tb[to] = 0 as u8 133 fa_appendz(RS_LOG, tb, RS_CAP) 134 _p(" ROLE SCORECARD: written to knowledge/status/role_scorecard.log\n" as *u8) 135 // gate: the scorecard itself must have found real evidence (else the readers are broken) 136 if caps > 0 { if races > 0 { if meters > 0 { sys_exit(0); return 0 } } } 137 sys_exit(1) 138 return 1 139}