code wiki / _hdl_build / nx_evo_synth_register.nx

nx_evo_synth_register.nx source

↩ module page · 76 lines · 5493 B

1// nx_evo_synth_register.nx -- SUBMITS the evolutionary-self-building-code capability 2// (X-AUT-006g..006P) to the nishi team's GOVERNANCE for admission + registration. 3// RACI-correct: I (the build author, role 1) SUBMIT; the COUNCIL (admitter role 2) 4// admits (author_id != admitter_id, no self-admit). Engineer evidence = re-run the 5// headline gate nx_evo_pbe and require it GENERALIZES on held-out (real proof the 6// capability works, not just compiles). Modeled on nx_ark_register. license_tier: ORIGINAL 7import "nx_cap_register.nx" // cr_can_register, cr_w/cr_wn, IG_*, ig_* 8import "nx_capreg_librarian.nx" // cl_next_idx, cl_register_dual (dual-write registry) 9import "nx_syscalls.nx" 10const K_MAGIC_8192: i64 = 8192 11const K_MAGIC_8191: i64 = 8191 12 13// substring search. 14func esr_has(buf: *u8, n: i64, ndl: *u8, nl: i64) -> i64 { 15 var i: i64 = 0 16 while i <= n - nl { var j: i64 = 0; var ok: i64 = 1; while j < nl { if buf[i+j] != ndl[j] { ok = 0; j = nl } j = j + 1 } if ok == 1 { return 1 } i = i + 1 } 17 return 0 18} 19 20// re-run a capability elf with 3 args, capture its stdout to a file, return 1 iff the 21// stdout contains `needle` (the pass signal). This is the Engineer re-verification. 22func esr_run_check(path: *u8, a1: *u8, a2: *u8, a3: *u8, outpath: *u8, needle: *u8, nl: i64) -> i64 { 23 let pid: i64 = sys_fork() 24 if pid == 0 { 25 let cfd: i64 = sys_openat_wr(outpath, 0x1a4) 26 if cfd >= 0 { sys_dup3(cfd, 1, 0); sys_close(cfd) } 27 let dn: i64 = sys_openat_wr("/dev/null" as *u8, 0x1a4) 28 if dn >= 0 { sys_dup3(dn, 2, 0) } 29 let argv: *i64 = sys_mmap(48) as *i64 30 argv[0] = path as i64; argv[1] = a1 as i64; argv[2] = a2 as i64; argv[3] = a3 as i64; argv[4] = 0 31 let envp: *i64 = sys_mmap(16) as *i64; envp[0] = 0 32 sys_execve(path, argv, envp); sys_exit(127) 33 } 34 let st: *i64 = sys_mmap(16) as *i64 35 sys_wait4(pid, st, 0) 36 let rfd: i64 = sys_openat_rd(outpath) 37 if rfd < 0 { return 0 } 38 let buf: *u8 = sys_mmap(K_MAGIC_8192) 39 let got: i64 = sys_read(rfd, buf, K_MAGIC_8191) 40 sys_close(rfd) 41 return esr_has(buf, got, needle, nl) 42} 43 44func main() -> i64 { 45 cr_w(1, "=== SUBMIT evolutionary-self-building-code capability to the nishi team (Council admits) ===\n" as *u8) 46 47 // ---- ENGINEER: re-run nx_evo_pbe (programming-by-example) on a held-out target. 48 // PASS iff it GENERALIZES on held-out examples it never trained on (the cap really works). ---- 49 let gen: i64 = esr_run_check("/tmp/nx_evo_pbe.sov.elf" as *u8, 50 "esr_chk" as *u8, "0" as *u8, "7" as *u8, 51 "/tmp/esr_evo_out.txt" as *u8, "GENERALIZES" as *u8, 11) 52 cr_w(1, "ENGINEER: nx_evo_pbe re-run generalizes-on-held-out=" as *u8); cr_wn(1, gen); cr_w(1, "\n" as *u8) 53 let eng: i64 = ig_engineer(1, 1, 1, gen) // compiled, linked, ran-no-signal, exit-ok(=generalizes) 54 55 // ---- COUNCIL: admit only an Engineer-PASS that is ADDITIVE and authored-by-someone-else. 56 // author_id=1 (build author), admitter_id=2 (Council) -> RACI separation, NOT self-admit. ---- 57 let council: i64 = ig_council(eng, 1, 1, 2) 58 // ---- SCRIBE: docs exist (build_learnings BL-036/037 + memory topic files + gate logs evo_*/eoe_*). ---- 59 let dec: i64 = ig_decision(eng, council, 1) 60 if dec != IG_INGEST { 61 cr_w(1, "HELD (engineer=" as *u8); cr_wn(1, eng); cr_w(1, " council=" as *u8); cr_wn(1, council); cr_w(1, ") -- not admitted\n" as *u8) 62 sys_exit(1); return 1 63 } 64 // ---- LINT: layer 5 (autonomy/self-improvement layer), status 2 (PROVEN); never the invisible-cap bug. ---- 65 if cr_can_register(5, 2, 6, dec) != 1 { cr_w(1, "REFUSED by librarian lint\n" as *u8); sys_exit(1); return 1 } 66 67 let lp: *u8 = "/tmp/nishi_cap_registry.log" as *u8 68 let jp: *u8 = "knowledge/status/cap_registry_durable.log" as *u8 69 let idx: i64 = cl_next_idx(lp, jp) 70 let ok: i64 = cl_register_dual(lp, jp, idx, 5, 2, 71 "SELF-BUILDING CODE via EVOLUTIONARY PROGRAM SYNTHESIS (X-AUT-006g..006P, 100% sovereign nx_cc->nxasm, no DEAP/numpy/gcc/LLVM). SUBSTRATE = emitter-of-emitters generality ladder: nx_eoe_oplist(computation) -> nx_eoe_branch(conditionals) -> nx_eoe_while(data-driven iteration) -> nx_eoe_prog(unified nested statement-list mini-language) -> nx_eoe_fn(functions+call-stack). SEARCH = sovereign evolutionary stack: nx_evo_synth(evolve op-list to a target it was never given, materialize champion as a compiled organ), nx_evo_cross(crossover GA, MEASURED-EXCEED: cracks target 4/4 seeds where mutation-only baseline stalls 0/4), nx_evo_pbe(PROGRAMMING-BY-EXAMPLE: discover f(x) from input->output examples + verify GENERALIZATION on held-out), nx_evo_cf(control-flow genomes: discover abs/relu), nx_evo_loop(loop genomes: discover factorial/2^n/sum). Given ONLY examples the team discovers an algorithm, proves it generalizes on held-out, and compiles it to native code. ENGINEER re-verified: nx_evo_pbe GENERALIZES on held-out at register time. Evidence: gate logs evo_*.log + eoe_*.log; queue X-AUT-006g..006P DONE; build_learnings BL-036/037. author=Claude(role1) SUBMITTED, Council(role2) ADMITTED -- RACI, no self-admit." as *u8) 72 if ok != 1 { cr_w(1, "DUAL-WRITE FAILED\n" as *u8); sys_exit(1); return 1 } 73 cr_w(1, "CAPREG idx=" as *u8); cr_wn(1, idx); cr_w(1, " REGISTERED -- evolutionary self-building code ADMITTED BY COUNCIL (author!=admitter) + dual-written to the durable registry\n" as *u8) 74 sys_exit(0) 75 return 0 76}