code wiki / _hdl_build / nx_cc_promote.nx

nx_cc_promote.nx

buildroot/runtime/_hdl_build/nx_cc_promote.nx

13037 B292 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tooltopic cc
docsdependenciesstructsconstsfunctions

about

SUPERSEDED-BY: nx_bless_compiler.nx (2026-06-14). The canonical deploy organ now carries BOTH an opt-in NEUTRAL mode (bless a behavior-neutral capability fix on no-regression) AND a pre-deploy cc_equiv guard (corpus+self-host equivalence) -- folding in this organ's equiv validation. Kept (not deleted) for history/the EXDEV same-device-rename + byte-landing-check learnings; not a live path. Safe to remove in a confirmed cleanup pass once no lineage row references it. nx_cc_promote.nx -- the EQUIV-GATED COMPILER-DEPLOY organ (the missing safe path to land a compiler-source change like the flock syscall-map fix). Today "deploying" a new nx_cc means a hand-cp of the binary ~7400 organs depend on, in a hot daemon env, with no gate -- the highest blast-radius op in the system. This organ makes the team's Engineer own that deploy: it can ONLY swap the live compiler when nx_cc_equiv_gate (the differential-behavior oracle) is GREEN, it backs up first, and it AUTO-ROLLS-BACK if the post-deploy probe fails. So a regressing compiler can never go live, and a bad swap self-heals. PIPELINE: 1. build CHALLENGER from current source: baseline-cc CC_SRC -> .s ; nxasm .s -> CC_CHAL 2. run nx_cc_equiv_gate (it uses CC_CHAL) -> read its log tail -> require the LAST summary line to be "selfhost=1 ... verdict=GREEN" (10/10 corpus + self-host). 3a. DRY-RUN (default, no arg): report READY/BLOCKED, swap NOTHING. (safe; proves the pipeline) 3b. DEPLOY (argv[1]=="DEPLOY"): IFF equiv GREEN -> cp baseline->CC_BAK ; renameat CHAL over baseline (atomic; an already-open compiler fd survives, new execs get the new one) -> POST-VERIFY: build _derefcast_minrepro with the NEW baseline + run -> exit 0. If post-OK keep + log DEPLOYED; ELSE renameat CC_BAK back (rollback) + log ROLLED-BACK + nonzero exit. SOVEREIGN: pure NishiLang fork/dup3/execve/wait4 (sovereign exit-judging law -- no shell, no $?). Imports the LIB-only (just nx_syscalls here). Additive: a DRY-RUN run mutates nothing. Durable log: knowledge/status/cc_promote.log. license_tier: ORIGINAL module: nishi-core.engineer.cc_promote depends: nishi-core.sys.syscalls capability: EQUIV_GATED_COMPILER_DEPLOY

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_cc_promote.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main cp_w sys_write cp_build_challenger sys_openat_wr sys_mmap cp_run sys_fork sys_dup3 sys_openat_wr ↻ sys_mmap ↻ sys_execve sys_exit sys_wait4 wait_exit_code sys_close sys_renameat cp_exists sys_openat_rd sys_close ↻ cp_wn sys_mmap ↻ sys_write ↻ cp_log sys_openat_append cp_w ↻ cp_wn ↻ sys_now_realtime_sec sys_mmap ↻ sys_clock_gettime_real sys_close ↻ sys_exit ↻ cp_equiv_green sys_mmap ↻ cp_run ↻ cp_read_tail sys_openat_rd ↻ sys_lseek sys_read sys_close ↻

structs

none

consts

33const CC_MAGIC_65536: i64 = 65536
34const CC_MAGIC_262144: i64 = 262144
36const CC_BASELINE: *u8 = "_offc/nx_compile_x86_native.elf"
37const CC_BAK: *u8 = "_offc/nx_compile_x86_native.elf.bak-preflock"
38const CC_CHAL: *u8 = "/tmp/cc_challenger.elf"
39const CC_CHAL_S: *u8 = "/tmp/cc_chal.s"
40const CC_TMPE: *u8 = "/tmp/_ccp_asm_out.elf"
41const CC_SRC: *u8 = "runtime/nx_compile_x86.nx"
42const CC_NXASM: *u8 = "_offc/nxasm_x86_main.elf"
43const CC_SBR: *u8 = "./_offc/nx_sov_build_run.elf"
44const CC_EQLOG: *u8 = "knowledge/status/cc_equiv_gate.log"
45const CC_DEPLOG: *u8 = "knowledge/status/cc_promote.log"
46const CC_PROBE: *u8 = "runtime/_derefcast_minrepro.nx"
47const CC_PROBE_S: *u8 = "/tmp/_ccp_probe.s"
48const CC_PROBE_E: *u8 = "/tmp/_ccp_probe.elf"
49const CC_STAGE: *u8 = "_offc/.cc_deploy_stage.elf" // stage on baseline's OWN device (drvfs); /tmp->_offc renameat=EXDEV
50const CC_MODE: i64 = 420 // 0644
51const CC_BUF: i64 = 1048576

functions

53func cp_w(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 }
called by 2: cp_logmain calls 1: sys_write
54func cp_wn(fd: i64, v: i64) -> i64
called by 2: cp_logmain calls 2: sys_mmapsys_write
61func cp_run(path: *u8, argv: *i64, out_fd: i64) -> i64
78func cp_exists(path: *u8) -> i64
84func cp_read_tail(path: *u8, buf: *u8, cap: i64) -> i64
99func cp_contains(buf: *u8, n: i64, needle: *u8) -> i64
called by 1: cp_lastline_has2
113func cp_lastline_has2(buf: *u8, n: i64, a: *u8, b: *u8) -> i64
called by 1: cp_equiv_green calls 1: cp_contains
125func cp_copy(src: *u8, dst: *u8) -> i64
142func cp_files_equal(pa: *u8, pb: *u8) -> i64
167func cp_build_challenger() -> i64
185func cp_equiv_green() -> i64
196func cp_post_probe() -> i64
214func cp_log(verdict: *u8, mode: *u8, green: i64) -> i64
225func main(argc: i64, argv: *i64) -> i64