code wiki / _hdl_build / nx_critic_countergrade.nx

nx_critic_countergrade.nx source

↩ module page · 117 lines · 6472 B

1// nx_critic_countergrade.nx -- the CRITIC counter-grades the bench verdicts IN WRITING (the role 2// scorecard's named gap: no durable BS-check log existed). Nothing is gospel: every verdict line in 3// synth_bench.log is re-checked against its OWN numbers, the honest trail (the 750 NOT-YET loss must 4// still be present -- history scrubbing voids everything), and the blind-protocol artifact (the 5// samples file must exist). Verdicts the Critic cannot confirm are flagged, not deleted (additive). 6// Output: knowledge/status/critic_log.log -- the grading cluster's first durable evidence. 7// license_tier: ORIGINAL 8import "nx_syscalls.nx" 9const K_MAGIC_999999: i64 = 999999 10const K_MAGIC_1048592: i64 = 1048592 11const K_MAGIC_1048576: i64 = 1048576 12func _p(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 13func _pn(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)}; let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48;k=1}; while m>0{t[k]=48+(m%10);m=m/10;k=k+1}; var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1}; sys_write(1,bb,k); return 0 } 14func _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 } 15func _fn(fd: i64, v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m}; let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48;k=1}; while m>0{t[k]=48+(m%10);m=m/10;k=k+1}; var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1}; sys_write(fd,bb,k); return 0 } 16func cc_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } 17func cc_read(path: *u8, buf: *u8, cap: i64) -> i64 { 18 let fd: i64 = sys_openat_rd(path) 19 if fd < 0 { return 0 - 1 } 20 var total: i64 = 0 21 var go: i64 = 1 22 while go == 1 { 23 let base: i64 = buf as i64 24 let n: i64 = sys_read(fd, (base + total) as *u8, cap - total) 25 if n <= 0 { go = 0 } else { total = total + n } 26 if total >= cap { go = 0 } 27 } 28 sys_close(fd) 29 return total 30} 31func cc_find(buf: *u8, s: i64, e: i64, pat: *u8) -> i64 { 32 let pl: i64 = cc_slen(pat) 33 var i: i64 = s 34 while i + pl <= e { 35 var k: i64 = 0 36 var hit: i64 = 1 37 while k < pl { if buf[i+k] != pat[k] { hit = 0; k = pl } else { k = k + 1 } } 38 if hit == 1 { return i } 39 i = i + 1 40 } 41 return 0 - 1 42} 43// parse the integer right after pat within [s,e); -999999 if absent 44func cc_num_after(buf: *u8, s: i64, e: i64, pat: *u8) -> i64 { 45 let at: i64 = cc_find(buf, s, e, pat) 46 if at < 0 { return 0 - K_MAGIC_999999 } 47 var i: i64 = at + cc_slen(pat) 48 var neg: i64 = 0 49 if buf[i] == (45 as u8) { neg = 1; i = i + 1 } 50 var v: i64 = 0 51 var any: i64 = 0 52 while i < e { 53 let c: i64 = buf[i] as i64 54 if c >= 48 { if c <= 57 { v = v * 10 + (c - 48); any = 1; i = i + 1 } else { i = e } } else { i = e } 55 } 56 if any == 0 { return 0 - K_MAGIC_999999 } 57 if neg == 1 { return 0 - v } 58 return v 59} 60func main() -> i64 { 61 _p("=== CRITIC counter-grades the bench log (nothing is gospel; checks are mechanical) ===\n" as *u8) 62 let buf: *u8 = sys_mmap(K_MAGIC_1048592) 63 let n: i64 = cc_read("knowledge/status/synth_bench.log" as *u8, buf, K_MAGIC_1048576) 64 let lfd: i64 = sys_openat_append("knowledge/status/critic_log.log" as *u8, 0x1a4) 65 if n <= 0 { _p(" CRITIC: bench log MISSING -> all verdicts UNCONFIRMED\n" as *u8); sys_exit(1); return 1 } 66 if lfd < 0 { sys_exit(1); return 1 } 67 _fp(lfd, "CRITIC epoch=" as *u8); _fn(lfd, sys_now_realtime_sec()); _fp(lfd, " target=synth_bench.log\n" as *u8) 68 var pass: i64 = 1 69 // check 1: the honest trail -- the 750 NOT-YET loss line must still exist (no history scrubbing) 70 var c1: i64 = 0 71 if cc_find(buf, 0, n, "team_permil=750" as *u8) >= 0 { if cc_find(buf, 0, n, "verdict=NOT-YET" as *u8) >= 0 { c1 = 1 } } 72 if c1 == 1 { _p(" check1 honest-trail (750 loss preserved): CONFIRMED\n" as *u8); _fp(lfd, "CHECK honest-trail=CONFIRMED\n" as *u8) } 73 else { _p(" check1 honest-trail: VIOLATED (history scrubbed?)\n" as *u8); _fp(lfd, "CHECK honest-trail=VIOLATED\n" as *u8); pass = 0 } 74 // check 2: every verdict line's claim matches its own numbers (line-by-line) 75 var bad: i64 = 0 76 var nlines: i64 = 0 77 var i: i64 = 0 78 while i < n { 79 var le: i64 = i 80 while le < n { if buf[le] == (10 as u8) { break } le = le + 1 } 81 if cc_find(buf, i, le, "BENCH " as *u8) >= 0 { if cc_find(buf, i, le, "verdict=" as *u8) >= 0 { 82 nlines = nlines + 1 83 let tp: i64 = cc_num_after(buf, i, le, "team_permil=" as *u8) 84 let cp: i64 = cc_num_after(buf, i, le, "claude_permil=" as *u8) 85 if cp != (0 - K_MAGIC_999999) { 86 if cc_find(buf, i, le, "ACHIEVED" as *u8) >= 0 { 87 // S-CLASS claims need team >= claude; EXCEED claims need team > claude 88 if cc_find(buf, i, le, "EXCEED" as *u8) >= 0 { if tp <= cp { bad = bad + 1 } } 89 else { if tp < cp { bad = bad + 1 } } 90 } 91 if cc_find(buf, i, le, "NOT-YET" as *u8) >= 0 { if tp >= cp { bad = bad + 1 } } 92 } 93 } } 94 i = le + 1 95 } 96 _p(" check2 verdict-vs-numbers: lines=" as *u8); _pn(nlines); _p(" inconsistent=" as *u8); _pn(bad); _p("\n" as *u8) 97 _fp(lfd, "CHECK verdict-lines=" as *u8); _fn(lfd, nlines); _fp(lfd, " inconsistent=" as *u8); _fn(lfd, bad); _fp(lfd, "\n" as *u8) 98 if bad > 0 { pass = 0 } 99 // check 3: the blind-protocol artifact exists (samples file the Claude lane answered from) 100 let sfd: i64 = sys_openat_rd("knowledge/status/novel_suite_samples.txt" as *u8) 101 var c3: i64 = 0 102 if sfd >= 0 { c3 = 1; sys_close(sfd) } 103 if c3 == 1 { _p(" check3 blind-protocol artifact: CONFIRMED\n" as *u8); _fp(lfd, "CHECK blind-artifact=CONFIRMED\n" as *u8) } 104 else { _p(" check3 blind-protocol artifact: MISSING\n" as *u8); _fp(lfd, "CHECK blind-artifact=MISSING\n" as *u8); pass = 0 } 105 if pass == 1 { 106 _p(" CRITIC COUNTER-GRADE: verdicts STAND (incl. S-CLASS-EXCEED-ACHIEVED) -- countersigned\n" as *u8) 107 _fp(lfd, "COUNTERGRADE verdicts=STAND exceed=COUNTERSIGNED\n" as *u8) 108 } 109 else { 110 _p(" CRITIC COUNTER-GRADE: FLAGGED (see checks above)\n" as *u8) 111 _fp(lfd, "COUNTERGRADE verdicts=FLAGGED\n" as *u8) 112 } 113 sys_close(lfd) 114 if pass == 1 { sys_exit(0); return 0 } 115 sys_exit(1) 116 return 1 117}