code wiki / (root) / nx_stale_check.nx

nx_stale_check.nx

buildroot/runtime/nx_stale_check.nx

14844 B229 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_stale_check.nx -- SAFE detect-only companion to nx_restage: is a build tree's _offc/<target>.elf current vs its source? Rebuilds <target> --build-only + byte-compares to the DEPLOYED elf. DETECT-ONLY (never writes _offc) so it can never break a tool -- the safe half of the deploy-drift loop. GUARDS the _cli/stub trap (LESSON 2026-07-17: a same-basename .nx can be a do-nothing SMOKE stub while the real tool was built from <target>_cli.nx -- a naive byte-diff then FALSE-flags STALE and restaging the stub breaks the tool): if the fresh elf is far SMALLER than the deployed one, reports AMBIGUOUS (source likely wrong) rather than STALE. nx_stale_check <target> [broot=buildroot] -> CURRENT (byte-identical) | STALE (differ, comparable size) | AMBIGUOUS (fresh<<deployed = stub src) | NOSOURCE | BUILDFAIL | NOELF argv[1]=target [A-Za-z0-9_], argv[2]=broot. Exit 0 CURRENT | 1 STALE | 2 AMBIGUOUS/error | 3 usage. license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0

dependencies 1 imports · 0 importers

nx_tool_run.nx nx_stale_check.nx

imports: nx_tool_run.nx

imported by: nobody (leaf or entry point)

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

main spe s_san sys_chdir sys_mmap s_cat s_exists sp 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 s_read sys_read ↻ snum sc_print sc_has

structs

none

consts

14const K_MAGIC_262144: i64 = 262144
15const K_MAGIC_8388608: i64 = 8388608
16const K_MAGIC_4096: i64 = 4096
58const SC_MINRUN: i64 = 12 // shortest printable run treated as a capability string
59const SC_MAXSTR: i64 = 4000 // bounded work; coverage is DECLARED, never presented as complete (L011)
60const SC_SHOW: i64 = 3 // exemplar misses printed so a human can judge, not just a count
61const SC_ASCII_LO: i64 = 32
62const SC_ASCII_HI: i64 = 126
63const SC_EXIT_CAPLOSS: i64 = 4 // distinct from STALE(1)/AMBIGUOUS+DEPLOYED-AHEAD(2)/usage(3)

functions

18func sp(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
19func spe(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
20func snum(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
21func s_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 s_san(name: *u8) -> i64
called by 1: main
39func s_read(path: *u8, buf: *u8, cap: i64) -> i64
called by 1: main calls 1: sys_read
48func s_exists(path: *u8) -> i64 { let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 } sys_close(fd); return 1 }
called by 1: main
64func sc_print(c: i64) -> i64 { if c < SC_ASCII_LO { return 0 } if c > SC_ASCII_HI { return 0 } return 1 }
called by 1: main
65func sc_has(hay: *u8, hn: i64, ndl: *u8, at: i64, len: i64) -> i64
called by 1: main
79func main(argc: i64, argv: *i64) -> i64