code wiki / _hdl_build / nx_overnight_conductor.nx

nx_overnight_conductor.nx source

↩ module page · 81 lines · 5383 B

1// nx_overnight_conductor.nx -- the self-improvement CREW, clean RACI, orchestrated. No one 2// organ does another's job: 3// ENGINEER monitors + VERIFIES the run, and passes BAD to the Doctor (detect/verify only). 4// DOCTOR HEALS the bad with its toolkit -- here a broken/miscompiled build is healed by 5// doc_rebuild (regenerate a fresh build; the compiler is non-deterministic). The 6// Doctor PAUSES the run for a build-heal (the artifact must be sound before it runs 7// again); other heals could run in PARALLEL with the work -- the Doctor picks per 8// the situation. 9// BUILDER when the Doctor's existing toolkit CANNOT heal it (it persists across fresh 10// rebuilds -> a real deterministic bug / a missing capability), the Conductor hands 11// it to the BUILDER to ARCHITECT + build NEW functionality and test whether it 12// addresses the problem. Until the team can author that itself, the Builder records 13// the architecture and escalates to human review (the M0 supervised step). 14// CONDUCTOR orchestrates the beats; WARDEN/COUNCIL govern (additive-only, escalation logged). 15// The Conductor never fixes, the Doctor never verifies its own fix, the Engineer never heals. 16// license_tier: ORIGINAL 17 18import "nx_doctor_build.nx" // DOCTOR -- doc_rebuild (the build-heal) 19import "nx_engineer_crash.nx" // ENGINEER -- eng_run + eng_crashed (run + detect) 20import "nx_crew_scribe.nx" // SCRIBE -- documents every area-to-area deliverable, parseably 21 22func cd_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 23func cd_num(v: i64) -> i64 { 24 let bb: *u8 = sys_mmap(28); var m: i64 = v; if m < 0 { m = 0 - m } 25 let t: *u8 = sys_mmap(28); var k: i64 = 0 26 if m == 0 { t[0] = 48; k = 1 } 27 while m > 0 { t[k] = 48 + (m % 10); m = m / 10; k = k + 1 } 28 var i: i64 = 0; while i < k { bb[i] = t[k - 1 - i]; i = i + 1 } 29 sys_write(1, bb, k); return 0 30} 31func cd_log(s: *u8) -> i64 { 32 var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } 33 sys_write(1, s, n) 34 let ef: i64 = sys_openat_append("/tmp/nishi_escalations.log" as *u8, 0x1a4) 35 if ef >= 0 { sys_write(ef, s, n); sys_close(ef) } 36 return 0 37} 38 39func main() -> i64 { 40 cd_puts("=== OVERNIGHT CREW (areas communicate deliverables; the SCRIBE documents every one, parseable) ===\n" as *u8) 41 let kg: *u8 = "_offc/nx_cc_known_good.elf" as *u8 42 let src: *u8 = "runtime/_hdl_build/nx_overnight.nx" as *u8 43 let seq: *i64 = sys_mmap(8) as *i64; seq[0] = 0 // SCRIBE conversation counter 44 let DOC_TRIES: i64 = 5 45 var attempt: i64 = 0 46 var done: i64 = 0 47 while done == 0 { 48 // CONDUCTOR -> DOCTOR: request a build (PAUSE-mode: the worker isn't running while the 49 // Doctor regenerates; the artifact must be sound before the Engineer runs it). 50 scribe(seq, ORG_CONDUCTOR, ORG_DOCTOR, K_BUILD, V_OK, "worker-build" as *u8, "regenerate a fresh build of the overnight worker" as *u8) 51 if doc_rebuild(kg, src, "/tmp/ovw.s" as *u8, "/tmp/ovw.elf" as *u8) != 0 { 52 // DOCTOR -> CONDUCTOR: could not produce a build 53 scribe(seq, ORG_DOCTOR, ORG_CONDUCTOR, K_HEAL, V_UNFIXABLE, "worker-build" as *u8, "compile or link failed this pass" as *u8) 54 attempt = attempt + 1 55 } else { 56 // DOCTOR -> ENGINEER: a fresh build is ready; deliver it for verification. 57 scribe(seq, ORG_DOCTOR, ORG_ENGINEER, K_HEAL, V_HEALED, "worker-build" as *u8, "fresh build ready -- verify it" as *u8) 58 let rc: i64 = eng_run("/tmp/ovw.elf" as *u8, "/tmp/nishi_overnight_stdout.log" as *u8) 59 if eng_crashed(rc) == 1 { 60 scribe(seq, ORG_ENGINEER, ORG_DOCTOR, K_DETECT, V_BAD, "worker-run" as *u8, "worker crashed -- pass to Doctor to re-heal" as *u8) 61 attempt = attempt + 1 62 } else { if rc == 2 { 63 scribe(seq, ORG_ENGINEER, ORG_DOCTOR, K_DETECT, V_BAD, "worker-run" as *u8, "canary caught a broken build -- pass to Doctor to re-heal" as *u8) 64 attempt = attempt + 1 65 } else { 66 scribe(seq, ORG_ENGINEER, ORG_COUNCIL, K_VERIFY, V_OK, "worker-run" as *u8, "worker ran clean and self-verified each beat" as *u8) 67 scribe(seq, ORG_COUNCIL, ORG_CONDUCTOR, K_ADMIT, V_OK, "worker-run" as *u8, "admitted -- journal + escalations ready for review" as *u8) 68 done = 1 69 } } 70 } 71 // CONDUCTOR -> BUILDER: Doctor's toolkit exhausted -> the heal needs NEW functionality. 72 if done == 0 { if attempt >= DOC_TRIES { 73 scribe(seq, ORG_DOCTOR, ORG_BUILDER, K_HEAL, V_NEEDBUILD, "worker-build" as *u8, "5 fresh rebuilds all failed the self-check -> deterministic bug, not the non-det compiler; my toolkit cannot reach it" as *u8) 74 scribe(seq, ORG_BUILDER, ORG_COUNCIL, K_BUILD, V_NEEDBUILD, "new-functionality" as *u8, "architecture: defect is in a source path recompile-retry cannot reach; needs a targeted source fix / new verifier -- escalate to human (M0 supervised build)" as *u8) 75 done = 1 76 } } 77 } 78 cd_puts("=== conductor done -- crew log at /tmp/nishi_crew.log (parseable). Clean RACI, every handoff documented. ===\n" as *u8) 79 sys_exit(0) 80 return 0 81}