code wiki / _hdl_build / nx_offc_install.nx

nx_offc_install.nx

buildroot/runtime/_hdl_build/nx_offc_install.nx

28956 B473 linesdepth 2pulls 2 transitivereach 3 importersview sourcekind tooltopic offc
docsdependenciesstructsconstsfunctions

about

nx_offc_install.nx -- ENGINEER GUARDRAIL against LM-026 (the stale-_offc landmine that cost a full session on the MMU instruction-fetch rung): `nx_sov_build_run <name>` builds the FRESH binary to /tmp/<name>.sov.elf and runs THAT as its smoke, but does NOT reliably install it to _offc/<name>.elf. Gates/organs fork _offc/*.elf, so they silently test a STALE binary -- source edits never take effect and diagnostics never fire. This organ is the structural prevention: it DETECTS the staleness (byte mismatch between the installed _offc artifact and the fresh /tmp build) and ATOMICALLY installs the fresh build (write temp + renameat = rule 16 immutable/atomic deploy), then VERIFIES byte-equal. It is the AUTO remedy seeded as known-issue LM-026 (nx_known_issue_seed): when any Engineer/Doctor diagnostic contains the signature "STALE-OFFC-ARTIFACT", ki_recall routes here (nx_offc_install:oi_install) so the team auto-heals instead of chasing phantom logic bugs. oi_stale(name) -> 1 if _offc/<name>.elf differs from /tmp/<name>.sov.elf (or _offc absent while a fresh /tmp build exists); 0 if byte-identical (fresh) or no /tmp build to judge. oi_install(name) -> atomically copy /tmp/<name>.sov.elf -> _offc/<name>.elf + verify; 1 on success. main <name> -> detect; install-if-stale; emit the STALE-OFFC-ARTIFACT recall signature + verdict. Sovereign, no gcc/.sh. license_tier: ORIGINAL

dependencies 1 imports · 3 importers

nx_syscalls.nx nx_offc_install.nx _freshness_gate.nx _offc_install_gate.nx _sbr_install_gate.nx

imports: nx_syscalls.nx

imported by: _freshness_gate.nx_offc_install_gate.nx_sbr_install_gate.nx

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

main oi_p sys_write oi_len oi_streq oi_census sys_openat_rd oi_p ↻ sys_mmap nxa_die sys_write ↻ sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ sys_getdents64 dirent_reclen dirent_name dirent_type oi_ends oi_len ↻ oi_len ↻ oi_stale sys_mmap ↻ oi_offc_path oi_cat oi_src_pick oi_tmp_path oi_cat ↻ sys_mmap ↻ sys_read_file sys_openat_rd ↻

structs

none

consts

19const OI_MAGIC_1024: i64 = 1024
20const OI_MAGIC_1000000000: i64 = 1000000000
22const OI_SIG: *u8 = "STALE-OFFC-ARTIFACT"
23const OI_LOG: *u8 = "knowledge/status/offc_install.log"
24const OI_ATFDCWD: i64 = 0 - 100
114const OI_STAT_MODE_OFF: i64 = 24
115const OI_S_IXUSR: i64 = 64
236const OI_DIRBUF: i64 = 65536

functions

26func oi_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
27func oi_p(s: *u8) -> i64 { sys_write(1, s, oi_len(s)); return 0 }
called by 2: oi_censusmain calls 2: sys_writeoi_len
28func oi_fp(fd: i64, s: *u8) -> i64 { sys_write(fd, s, oi_len(s)); return 0 }
called by 1: main calls 2: sys_writeoi_len
31func oi_cat(out: *u8, a: *u8, b: *u8, c: *u8) -> i64
42func oi_offc_path(name: *u8, out: *u8) -> i64 { return oi_cat(out, "_offc/" as *u8, name, ".elf" as *u8) }
43func oi_tmp_path(name: *u8, out: *u8) -> i64 { return oi_cat(out, "/tmp/" as *u8, name, ".sov.elf" as *u8) }
called by 1: oi_src_pick calls 1: oi_cat
44func oi_tmpinstall_path(name: *u8, out: *u8) -> i64 { return oi_cat(out, "_offc/" as *u8, name, ".elf.oitmp" as *u8) }
called by 1: oi_install_from calls 1: oi_cat
45func oi_cat2(out: *u8, a: *u8, b: *u8) -> i64
63func oi_src_pick(name: *u8, out: *u8) -> i64
89func oi_differ(a: *u8, alen: i64, b: *u8, blen: i64) -> i64
116func oi_executable(path: *u8) -> i64
called by 1: oi_stale calls 2: sys_mmapsys_fstatat
123func oi_stale(name: *u8) -> i64
142func oi_install_from(name: *u8, tp: *u8) -> i64
161func oi_install(name: *u8) -> i64
171func oi_install_promoted(name: *u8) -> i64
184func oi_fresh(path: *u8) -> i64
called by 3: mainmainmain calls 2: sys_mmapsys_read_file
194func oi_mtime_ns(path: *u8) -> i64
208func oi_src_stale(artifact: *u8, source: *u8) -> i64
called by 1: main calls 1: oi_mtime_ns
217func oi_wn(fd: i64, v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(fd,"-" as *u8,1)}; let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48;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{bb[i]=t[k-1-i];i=i+1}; sys_write(fd,bb,k); return 0 }
238func oi_streq(a: *u8, b: *u8) -> i64
called by 1: main
245func oi_ends(s: *u8, suf: *u8) -> i64
called by 1: oi_census calls 1: oi_len
254func oi_promoted_path(name: *u8, out: *u8) -> i64 { return oi_cat2(out, name, ".elf" as *u8) }
263func oi_refresh(name: *u8) -> i64
279func oi_stale_vs(name: *u8, sp: *u8) -> i64
296func oi_has_source(name: *u8, out: *u8) -> i64
306func oi_census() -> i64
413func main(argc: i64, argv: *i64) -> i64