nx_stale_check.nx
buildroot/runtime/nx_stale_check.nx
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
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
structs
| none |
consts
| 14 | const K_MAGIC_262144: i64 = 262144 |
| 15 | const K_MAGIC_8388608: i64 = 8388608 |
| 16 | const K_MAGIC_4096: i64 = 4096 |
| 58 | const SC_MINRUN: i64 = 12 // shortest printable run treated as a capability string |
| 59 | const SC_MAXSTR: i64 = 4000 // bounded work; coverage is DECLARED, never presented as complete (L011) |
| 60 | const SC_SHOW: i64 = 3 // exemplar misses printed so a human can judge, not just a count |
| 61 | const SC_ASCII_LO: i64 = 32 |
| 62 | const SC_ASCII_HI: i64 = 126 |
| 63 | const SC_EXIT_CAPLOSS: i64 = 4 // distinct from STALE(1)/AMBIGUOUS+DEPLOYED-AHEAD(2)/usage(3) |
functions
| 18 | func 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 |
| 19 | func 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 |
| 20 | func 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 |
| 21 | func 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 |
| 22 | func s_san(name: *u8) -> i64 called by 1: main |
| 39 | func s_read(path: *u8, buf: *u8, cap: i64) -> i64 |
| 48 | func 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 |
| 64 | func 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 |
| 65 | func sc_has(hay: *u8, hn: i64, ndl: *u8, at: i64, len: i64) -> i64 called by 1: main |
| 79 | func main(argc: i64, argv: *i64) -> i64 |