code wiki / _hdl_build / nx_builder_authors_qref.nx

nx_builder_authors_qref.nx source

↩ module page · 58 lines · 4285 B

1// nx_builder_authors_qref.nx -- the BUILDER authors the qualitative referee (Claude does NOT write it), and 2// Claude EVALUATES the Builder's job (operator: "you dont build it build the builder to build it into the 3// referee and evaluate the job the builder does"). The Builder uses its scorer template to author a 4// qualitative referee (score 4 dims; pass iff all >= solid AND any >= exceptional), compiles + runs it; the 5// evaluation = did the Builder author a CORRECT, compiling, self-test-passing referee. NishiLang fork/exec. 6// license_tier: ORIGINAL 7 8import "nx_module_author.nx" 9import "nx_pm_review_log.nx" 10import "nx_syscalls.nx" 11 12func _puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 13func _putn(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 _exitcode(s: i64) -> i64 { return (s >> 8) & 0xff } 15func _run(path: *u8, argv: *i64, envp: *i64, redir: i64) -> i64 { 16 let pid: i64 = sys_fork() 17 if pid == 0 { if redir >= 0 { sys_dup3(redir, 1, 0) } sys_execve(path, argv, envp) sys_exit(127) } 18 let st: *i64 = sys_mmap(16) as *i64; sys_wait4(pid, st, 0); return _exitcode(st[0]) 19} 20 21func main() -> i64 { 22 _puts("=== BUILDER authors the qualitative referee; Claude evaluates the Builder's job ===\n" as *u8) 23 let cc: *u8 = "_offc/nx_cc_known_good.elf" as *u8 24 let gcc: *u8 = "/usr/bin/gcc" as *u8 25 let src: *u8 = "runtime/_hdl_build/_qref_authored.nx" as *u8 26 let envp: *i64 = sys_mmap(8*4) as *i64; envp[0]="PATH=/usr/bin:/bin" as *u8 as i64; envp[1]=0 27 28 // THE BUILDER AUTHORS the qualitative referee from the spec (4 dims, solid=2, exceptional=3). 29 let afd: i64 = sys_openat_wr(src, 0x1a4) 30 ma_emit_scorer(afd, "qref_sclass" as *u8, 2, 3) 31 sys_close(afd) 32 _puts(" Builder authored runtime/_hdl_build/_qref_authored.nx (qualitative referee: 4 dims, solid>=2, one>=3)\n" as *u8) 33 34 // compile + link + run the Builder's output (its self-test passes iff it scores correctly) 35 let sfd: i64 = sys_openat_wr("/tmp/_qref.s" as *u8, 0x1a4) 36 let ac: *i64 = sys_mmap(8*4) as *i64; ac[0]=cc as i64; ac[1]=src as i64; ac[2]=0 37 let rc_c: i64 = _run(cc, ac, envp, sfd); sys_close(sfd) 38 let al: *i64 = sys_mmap(8*12) as *i64 39 al[0]=gcc as i64; al[1]="-nostdlib" as *u8 as i64; al[2]="-no-pie" as *u8 as i64; al[3]="-static" as *u8 as i64 40 al[4]="/tmp/_qref.s" as *u8 as i64; al[5]="-o" as *u8 as i64; al[6]="/tmp/_qref.elf" as *u8 as i64; al[7]=0 41 let rc_l: i64 = _run(gcc, al, envp, 0 - 1) 42 var rc_r: i64 = 0 - 1 43 if rc_l == 0 { let ar: *i64 = sys_mmap(8*4) as *i64; ar[0]="/tmp/_qref.elf" as *u8 as i64; ar[1]=0; rc_r = _run("/tmp/_qref.elf" as *u8, ar, envp, 0 - 1) } 44 _puts(" EVALUATION of the Builder's job: compile rc=" as *u8); _putn(rc_c); _puts(" link rc=" as *u8); _putn(rc_l); _puts(" self-test exit=" as *u8); _putn(rc_r); _puts("\n" as *u8) 45 46 let pm: i64 = pm_open("/tmp/nishi_pm_review.log" as *u8) 47 if rc_c == 0 { if rc_l == 0 { if rc_r == 0 { 48 pm_deliverable(pm, "builder/qualitative-referee" as *u8, "Builder authored the referee" as *u8, "the BUILDER authored a qualitative-referee scorer (4 dims, all>=solid AND one>=exceptional) from a spec; it compiled + self-test PASSED (good set passes, shallow set fails). Claude evaluated the Builder's job = CORRECT. Claude did not write the referee" as *u8) 49 sys_close(pm) 50 _puts(" GRADE (Claude evaluating the Builder): PASS -- the Builder authored a correct, compiling, self-verifying\n" as *u8) 51 _puts(" qualitative referee. The Builder built it; Claude only graded the build. Wire it into the Referee next.\n" as *u8) 52 sys_exit(0); return 0 53 } } } 54 pm_gap(pm, "builder/qualitative-referee" as *u8, "NEEDS-LOGIC" as *u8, "Builder authoring" as *u8, "the Builder's authored referee failed to compile/run -- tutor the scorer template" as *u8) 55 sys_close(pm) 56 _puts(" GRADE: the Builder's output did not pass -- tutor the template (Claude evaluates, does not hand-write the referee).\n" as *u8) 57 sys_exit(1); return 1 58}