code wiki / (root) / nx_restage.nx

nx_restage.nx

buildroot/runtime/nx_restage.nx

6269 B101 linesdepth 3pulls 3 transitivereach 1 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_restage.nx -- EAT THE DEPLOY-TOOLING DEBT (operator 2026-07-17 "eat the debt and build the tools"): the missing primitive that restages a freshly-built elf into a build tree's _offc/. Without it, buildroot/_offc generators go STALE vs runtime source (the F-004 stale-binary class: e.g. the compare @verdict directive existed in nx_swcompare_sota.nx source but the staged _offc elf predated it, so the SSOT verdict silently fell back to a hardcoded string). nx_fs_write refuses _offc (text + deny), nx_shelltool is read-only, /api/build stages to nishihost not _offc -- so this closed gap blocked EVERY generator refresh. nx_restage <target> [broot] broot default "buildroot" ("." = in-place / local test) -> chdir broot; fork _offc/nx_sov_build_run.elf <target> --build-only (=> /tmp/<target>.sov.elf) -> binary-safe copy to _offc/<target>.elf.new; VERIFY ELF magic + nonzero; atomic rename over _offc/<target>.elf target sanitized [A-Za-z0-9_] (no path escape). Exit 0 restaged | 1 build/copy fail | 2 usage/bad-target. license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0

dependencies 1 imports · 1 importers

nx_tool_run.nx nx_restage.nx nx_restage_gate.nx

imports: nx_tool_run.nx

imported by: nx_restage_gate.nx

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

main rpe r_san sys_chdir sys_mmap tr_run_capture sys_mmap ↻ sys_pipe2 sys_fork sys_close sys_dup3 sys_execve_clean sys_close ↻ sys_execve sys_exit sys_read sys_wait4 wait_exit_code r_cat sys_openat_wr sys_read ↻ sys_renameat rp rn

structs

none

consts

13const K_MAGIC_262144: i64 = 262144
14const K_MAGIC_65536: i64 = 65536

functions

16func rp(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 1: main
17func rpe(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(2,s,n); return 0 }
called by 1: main
18func rn(v: i64) -> i64 { let b: *u8=sys_mmap(28); var m: i64=v; if m<0{sys_write(1,"-" as *u8,1);m=0-m} let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i: i64=0; while i<k{b[i]=t[k-1-i];i=i+1} sys_write(1,b,k); return 0 }
called by 1: main
20func r_cat(dst: *u8, off: i64, src: *u8) -> i64 { var o: i64=off; var j: i64=0; while src[j]!=(0 as u8){dst[o]=src[j];o=o+1;j=j+1} return o }
called by 1: main
22func r_san(name: *u8) -> i64
called by 2: mainmain
38func main(argc: i64, argv: *i64) -> i64