code wiki / _hdl_build / nx_cc_promote.nx
nx_cc_promote.nx
buildroot/runtime/_hdl_build/nx_cc_promote.nx
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
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
structs
| none |
consts
| 33 | const CC_MAGIC_65536: i64 = 65536 |
| 34 | const CC_MAGIC_262144: i64 = 262144 |
| 36 | const CC_BASELINE: *u8 = "_offc/nx_compile_x86_native.elf" |
| 37 | const CC_BAK: *u8 = "_offc/nx_compile_x86_native.elf.bak-preflock" |
| 38 | const CC_CHAL: *u8 = "/tmp/cc_challenger.elf" |
| 39 | const CC_CHAL_S: *u8 = "/tmp/cc_chal.s" |
| 40 | const CC_TMPE: *u8 = "/tmp/_ccp_asm_out.elf" |
| 41 | const CC_SRC: *u8 = "runtime/nx_compile_x86.nx" |
| 42 | const CC_NXASM: *u8 = "_offc/nxasm_x86_main.elf" |
| 43 | const CC_SBR: *u8 = "./_offc/nx_sov_build_run.elf" |
| 44 | const CC_EQLOG: *u8 = "knowledge/status/cc_equiv_gate.log" |
| 45 | const CC_DEPLOG: *u8 = "knowledge/status/cc_promote.log" |
| 46 | const CC_PROBE: *u8 = "runtime/_derefcast_minrepro.nx" |
| 47 | const CC_PROBE_S: *u8 = "/tmp/_ccp_probe.s" |
| 48 | const CC_PROBE_E: *u8 = "/tmp/_ccp_probe.elf" |
| 49 | const CC_STAGE: *u8 = "_offc/.cc_deploy_stage.elf" // stage on baseline's OWN device (drvfs); /tmp->_offc renameat=EXDEV |
| 50 | const CC_MODE: i64 = 420 // 0644 |
| 51 | const CC_BUF: i64 = 1048576 |
functions
| 53 | func 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 } |
| 54 | func cp_wn(fd: i64, v: i64) -> i64 |
| 61 | func cp_run(path: *u8, argv: *i64, out_fd: i64) -> i64 |
| 78 | func cp_exists(path: *u8) -> i64 |
| 84 | func cp_read_tail(path: *u8, buf: *u8, cap: i64) -> i64 |
| 99 | func cp_contains(buf: *u8, n: i64, needle: *u8) -> i64 called by 1: cp_lastline_has2 |
| 113 | func cp_lastline_has2(buf: *u8, n: i64, a: *u8, b: *u8) -> i64 |
| 125 | func cp_copy(src: *u8, dst: *u8) -> i64 |
| 142 | func cp_files_equal(pa: *u8, pb: *u8) -> i64 |
| 167 | func cp_build_challenger() -> i64 |
| 185 | func cp_equiv_green() -> i64 |
| 196 | func cp_post_probe() -> i64 |
| 214 | func cp_log(verdict: *u8, mode: *u8, green: i64) -> i64 |
| 225 | func main(argc: i64, argv: *i64) -> i64 |