code wiki / _hdl_build / nx_autonomy_register.nx

nx_autonomy_register.nx source

↩ module page · 94 lines · 5532 B

1// nx_autonomy_register.nx -- GOVERNED registration of the autonomy rung-2 2// pair: nx_gate_triage (CAPREG 219) + nx_bless_compiler (CAPREG 220). 3// ENGINEER verdicts, all mechanical: 4// triage: exit == nonpass count must DISCRIMINATE compilers -- unfixed 5// _offc -> 5 nonpass, fixed candidate -> 2 nonpass (the two known 6// non-compiler reds: perceptual + math_games); 7// bless: today it must REFUSE at the sovereign build step (exit 2, 8// BLOCKED-BY-G1) AND leave _offc byte-identical (size compared 9// before/after). The bless path itself is armed but unproven 10// until G1 lands -- status reflects that honestly in the entry. 11// license_tier: ORIGINAL 12import "nx_cap_register.nx" 13import "nx_pm_review_log.nx" 14import "nx_syscalls.nx" 15const AR_MAGIC_65536: i64 = 65536 16 17const AR_LAYER: i64 = 4 18const AR_STATUS: i64 = 2 19const AR_NLAYERS: i64 = 6 20 21func ar_run1(path: *u8, arg1: *u8) -> i64 { 22 let pid: i64 = sys_fork() 23 if pid == 0 { 24 let devnull: i64 = sys_openat_wr("/dev/null" as *u8, 0x1a4) 25 if devnull >= 0 { sys_dup3(devnull, 1, 0) } 26 let argv: *i64 = sys_mmap(32) as *i64; argv[0] = path as i64; argv[1] = arg1 as i64; argv[2] = 0 27 let envp: *i64 = sys_mmap(16) as *i64; envp[0] = "PATH=/usr/bin:/bin" as *u8 as i64; envp[1] = 0 28 sys_execve(path, argv, envp); sys_exit(127) 29 } 30 let st: *i64 = sys_mmap(16) as *i64 31 sys_wait4(pid, st, 0) 32 let sig: i64 = st[0] & 0x7f 33 if sig != 0 { return 128 + sig } 34 return (st[0] >> 8) & 0xff 35} 36 37func ar_filesize(path: *u8) -> i64 { 38 let fd: i64 = sys_openat_rd(path) 39 if fd < 0 { return 0 - 1 } 40 let buf: *u8 = sys_mmap(AR_MAGIC_65536) 41 var total: i64 = 0 42 var n: i64 = sys_read(fd, buf, AR_MAGIC_65536) 43 while n > 0 { total = total + n; n = sys_read(fd, buf, AR_MAGIC_65536) } 44 sys_close(fd) 45 return total 46} 47 48func main() -> i64 { 49 // ---- ENGINEER: triage discrimination ---- 50 let tri: *u8 = "/tmp/nx_gate_triage.sov.elf" as *u8 51 let np_old: i64 = ar_run1(tri, 0 as *u8) 52 cr_w(1, "ENGINEER: triage vs unfixed _offc nonpass=" as *u8); cr_wn(1, np_old); cr_w(1, " (need 5)\n" as *u8) 53 let np_fix: i64 = ar_run1(tri, "/tmp/nx_cc_fixed_oracle.elf" as *u8) 54 cr_w(1, "ENGINEER: triage vs fixed candidate nonpass=" as *u8); cr_wn(1, np_fix); cr_w(1, " (need 2)\n" as *u8) 55 var tri_ok: i64 = 0 56 if np_old == 5 { if np_fix == 2 { tri_ok = 1 } } 57 58 // ---- ENGINEER: bless refusal + no-touch ---- 59 let live: *u8 = "_offc/nx_cc_sovereign.elf" as *u8 60 let sz_before: i64 = ar_filesize(live) 61 let rc_bless: i64 = ar_run1("/tmp/nx_bless_compiler.sov.elf" as *u8, 0 as *u8) 62 let sz_after: i64 = ar_filesize(live) 63 cr_w(1, "ENGINEER: bless exit=" as *u8); cr_wn(1, rc_bless); cr_w(1, " (need 2 = BLOCKED-BY-G1)\n" as *u8) 64 cr_w(1, "ENGINEER: _offc size " as *u8); cr_wn(1, sz_before); cr_w(1, " -> " as *u8); cr_wn(1, sz_after); cr_w(1, " (need equal)\n" as *u8) 65 var bless_ok: i64 = 0 66 if rc_bless == 2 { if sz_before == sz_after { if sz_before > 0 { bless_ok = 1 } } } 67 68 var exit_ok: i64 = 0 69 if tri_ok == 1 { if bless_ok == 1 { exit_ok = 1 } } 70 let eng: i64 = ig_engineer(1, 1, 1, exit_ok) 71 72 let cat: i64 = sys_openat_rd("knowledge/CAPABILITY_CATALOG.md" as *u8) 73 var documented: i64 = 0 74 if cat >= 0 { documented = ig_documented(1, 1); sys_close(cat) } 75 let council: i64 = ig_council(eng, 1, 1, 2) 76 let decision: i64 = ig_decision(eng, council, documented) 77 78 let pm: i64 = pm_open("/tmp/nishi_pm_review.log" as *u8) 79 if decision == IG_INGEST { 80 pm_deliverable(pm, "game-engine/gates" as *u8, "nx_gate_triage+nx_bless_compiler" as *u8, "autonomy rung 2: triage auto-localizes every gate FAIL via dual-lane oracle differential (ASM-GAP / TOOLCHAIN-NXASM / COMPILER-OR-SOURCE; replicated the manual tictactoe diagnosis in one run, sentinel forks it on REGRESSION); bless self-deploys the compiler with backup+post-verify+rollback, currently REFUSES correctly at BLOCKED-BY-G1 leaving _offc untouched" as *u8) 81 } 82 sys_close(pm) 83 cr_w(1, "GOVERNED decision=" as *u8); cr_wn(1, decision); cr_w(1, " (1=INGEST)\n" as *u8) 84 85 if decision != IG_INGEST { sys_exit(1) } 86 if cr_can_register(AR_LAYER, AR_STATUS, AR_NLAYERS, decision) != 1 { cr_w(1, "REFUSED\n" as *u8); sys_exit(1) } 87 let fd: i64 = sys_openat_append("/tmp/nishi_cap_registry.log" as *u8, 0x1a4) 88 cr_write_entry(fd, 219, AR_LAYER, "CON GATE-TRIAGE -- auto-LOCALIZER for game-gate failures: rebuilds each module's .s, runs it through BOTH the sovereign assembler and a gcc oracle lane (diagnosis only), classifies ASM-GAP / TOOLCHAIN-NXASM / COMPILER-OR-SOURCE / COMPILE-FAIL per module to /tmp/nishi_game_gate_triage.log; forked automatically by nx_gate_sentinel on REGRESSION so escalations arrive pre-localized; proven: classified all 5 known reds correctly (3x compiler-bug class, 1 ASM-GAP, matched hand diagnosis)" as *u8, AR_STATUS) 89 cr_write_entry(fd, 220, AR_LAYER, "CON BLESS-COMPILER -- self-deploy for _offc/nx_cc_sovereign.elf: sovereign-rebuild candidate (NO gcc), pause gate-loop, gate candidate-vs-live (data verdict, bless only STRICTLY better), backup .bak, post-verify gate match else ROLLBACK, restart loop; TODAY refuses correctly with BLOCKED-BY-G1 (nxasm 2.4MB crash) leaving _offc byte-identical; bless path armed, exercises fully once GAME-G1 lands" as *u8, AR_STATUS) 90 sys_close(fd) 91 cr_w(1, "CAPREG idx=219+220 REGISTERED\n" as *u8) 92 sys_exit(0) 93 return 0 94}