code wiki / _hdl_build / nx_rebuild_plan.nx

nx_rebuild_plan.nx

buildroot/runtime/_hdl_build/nx_rebuild_plan.nx

17891 B387 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_rebuild_plan.nx -- DEPENDENCY-AWARE STALENESS: which deployed organs must be rebuilt, and WHY. THE WOUND (measured 2026-07-30, debt 1785446507 sev8): 667 of 722 deployed organs run binaries older than what their source+deps produce. Only 222 of those are stale by their OWN source. The other 445 are stale because a SHARED runtime moved underneath them -- `nx_syscalls.nx` is imported by 14,172 files, so one edit to it invalidates almost every statically linked elf in the ecosystem WITHOUT touching a single line of their own .nx. Nothing in the ecosystem could compute that. The existing instruments each answer a smaller question: `nx_stale_check <target>` rebuilds ONE target and byte-compares (correct but O(one build) and says nothing about WHY), and an own-source mtime census misses the dominant 445 entirely. ★★★THE POINT IS THE TRIGGER, NOT THE VERDICT. "stale" is useless on its own -- 667 rows of "stale" is not a work order, it is noise. Naming the ONE file whose mtime invalidated each organ turns the census into a plan: 445 organs all triggered by nx_syscalls.nx is a SINGLE decision (rebuild the dependents of one file), not 445 investigations. A tool that reports a problem without naming its cause makes the operator redo the diagnosis the tool already did. METHOD: resolve each deployed <t>.elf to its source, walk the TRANSITIVE import closure (lazily, from the deployed organs as roots -- never the whole 17.5k-file tree), memoise closure_max_mtime + argmax per node, then compare against the deployed elf's mtime. Cycles are coloured and broken, so a cyclic import cannot hang the walk or silently drop a subtree. nx_rebuild_plan [elfdir] [srcroot] [maxrows] -> per-organ rows {organ, verdict, trigger, age_min} + a summary keyed by TRIGGER verdicts: CURRENT | STALE-BY-OWN | STALE-BY-DEP | STALE-BY-TOOLCHAIN | NOSOURCE Exit 0 always (a census is not a gate; it reports, it does not refuse). license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_itoa_lib.nx nx_rebuild_plan.nx

imports: nx_syscalls.nxnx_itoa_lib.nx

imported by: nobody (leaf or entry point)

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

main rp_eq sys_mmap sys_openat_rd rp_w sys_write sys_exit sys_getdents64 dirent_reclen dirent_name rp_is_elf rp_len rp_len ↻ rp_cpy rp_cat rp_mtime sys_mmap ↻ sys_close rp_readhead sys_openat_rd ↻ sys_read sys_close ↻ rp_import_of rp_n nxi_out nxi_fd sys_mmap ↻ ccz_cat_num sys_write ↻ sys_munmap

structs

none

consts

30const RP_AT_FDCWD: i64 = 0 - 100
31const RP_SYS_NEWFSTATAT: i64 = 262
32const RP_STATBUF: i64 = 256
33const RP_OFF_SIZE: i64 = 48
34const RP_OFF_MTIME: i64 = 88
37const RP_MAXN: i64 = 8192
38const RP_PATHCAP: i64 = 192
39const RP_MAXE: i64 = 131072
40const RP_MAXROOT: i64 = 4096
44const RP_HEAD: i64 = 32768
45const RP_DIRBUF: i64 = 262144
46const RP_SEC_PER_MIN: i64 = 60
49const RP_TOP_TRIGGERS: i64 = 12

functions

51func rp_w(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 calls 1: sys_write
56func rp_n(v: i64) -> i64 { nxi_out(v); return 0 }
called by 1: main calls 1: nxi_out
57func rp_eq(a: *u8, b: *u8) -> i64 { var i: i64 = 0; while a[i] != (0 as u8) { if a[i] != b[i] { return 0 } i = i + 1 } if b[i] != (0 as u8) { return 0 } return 1 }
called by 1: main
58func rp_len(a: *u8) -> i64 { var i: i64 = 0; while a[i] != (0 as u8) { i = i + 1 } return i }
called by 2: rp_is_elfmain
59func rp_cpy(dst: *u8, src: *u8) -> i64 { var i: i64 = 0; while src[i] != (0 as u8) { dst[i] = src[i]; i = i + 1 } dst[i] = 0 as u8; return i }
called by 1: main
60func rp_cat(dst: *u8, o: i64, src: *u8) -> i64 { var i: i64 = 0; var p: i64 = o; while src[i] != (0 as u8) { dst[p] = src[i]; p = p + 1; i = i + 1 } dst[p] = 0 as u8; return p }
called by 1: main
62func rp_mtime(path: *u8) -> i64
called by 1: main calls 1: sys_mmap
69func rp_readhead(path: *u8, buf: *u8, cap: i64) -> i64
called by 1: main calls 3: sys_openat_rdsys_readsys_close
80func rp_is_elf(name: *u8) -> i64
called by 1: main calls 1: rp_len
91func rp_import_of(buf: *u8, i: i64, le: i64, dst: *u8, cap: i64) -> i64
called by 1: main
115func main(argc: i64, argv: *i64) -> i64