code wiki / _hdl_build / nx_rebuild_drain.nx

nx_rebuild_drain.nx

buildroot/runtime/_hdl_build/nx_rebuild_drain.nx

79056 B1307 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_rebuild_drain.nx -- THE ACTING HALF of dependency-aware staleness (debt 1785447998). nx_rebuild_plan DIAGNOSES: 662 of 696 deployed organs run binaries predating their own dependencies, 638 of them traceable to just two shared runtimes carrying real behavioural root-fixes (SIGPIPE in nx_syscalls.nx, the ss_get O(whole-store) fix in nx_seg_store.nx). But a census nobody is OBLIGED to read is the same shape of defect as a fix nobody is OBLIGED to rebuild against -- both are capability that exists and does not reach the place it matters. This organ is the obligation. ★★★WHY AN ORGAN AND NOT THE SHELL SCRIPT IT REPLACES: a shell batch is something a human remembers to run. An organ can be SUPERVISED -- put on a beat, it turns "someone should rebuild the dependents" into a property of the system. That is the whole difference between a workaround and a fix. GUARDS, every one of them learned by being bitten today: • _cli/STUB TRAP: a fresh build far SMALLER than the deployed elf means the same-basename .nx is a smoke stub and the real tool came from another source. nx_https_get rebuilds 443KB vs 633KB deployed -- installing that BREAKS a working tool. REFUSED, never installed. • ETXTBSY: cp over a RUNNING elf fails; the daemon holds that inode. Install is write-to-.new then RENAME, which swaps the directory entry and leaves the live inode alone. • BUILD FAILURE IS NOT INSTALLABLE: a non-zero build rc or a missing artifact skips the target. • BOUNDED + SERIAL: today's saturation incident (load 63, mgmt+tools+sshd dead) came from wide fan-out. This drains a batch at a time, one build at a time, and stops. Idempotent: re-running simply picks up whatever is still stale, so a partial drain is always safe to resume. • IDENTICAL-BYTES IS A NO-OP: if the fresh build matches what is deployed, nothing is written. nx_rebuild_drain beat [batch] [buildroot] [elfdir] SELF-CONTAINED for a clock row: regenerates the list, then drains a bounded batch nx_rebuild_drain classify <listfile> [buildroot] [elfdir] PARTITION ONLY, spends no compile: buildable vs lib-basename vs no-elf nx_rebuild_drain <listfile> [batch] [buildroot] [elfdir] listfile = output of `nx_rebuild_plan list` (one target name per line) -> per-target rows + summary. Exit 0 always; a drain 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_drain.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 rd_w sys_write sys_exit sys_now_realtime_sec 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_clock_gettime_real rd_streq rd_plan_list sys_fork sys_openat_wr sys_exit ↻ sys_dup3 sys_mmap ↻ sys_execve sys_wait4 wait_exit_code rd_n nxi_out nxi_fd sys_mmap ↻ ccz_cat_num nxi_buf sys_write ↻ sys_munmap rd_classify

structs

none

consts

34const RD_AT_FDCWD: i64 = 0 - 100
35const RD_SYS_NEWFSTATAT: i64 = 262
36const RD_STATBUF: i64 = 256
37const RD_OFF_SIZE: i64 = 48
38const RD_PATHCAP: i64 = 512
39const RD_LISTCAP: i64 = 262144
42const RD_DEFAULT_BATCH: i64 = 8
45const RD_STUB_NUM: i64 = 2
50const RD_COPYBUF: i64 = 1048576
69const RD_ALIAS_CONF: *u8 = "knowledge/registry/elf_source_alias.conf"
70const RD_TAB_C: i64 = 9
71const RD_HASH_C: i64 = 35
304const RD_DEBUG_MARK: *u8 = ".debug_line"
380const RD_INSTALLLOG: *u8 = "knowledge/status/rebuild_installs.log"
407const RD_FAILLOG: *u8 = "knowledge/status/rebuild_buildfail.log"
433const RD_LOSSLOG: *u8 = "knowledge/status/rebuild_contentloss.log"
434const RD_CDIFF_ELF: *u8 = "./_offc/nx_contentdiff.elf"
435const RD_CDIFF_TMPA: *u8 = "/tmp/nx_rd_cdiff_"
436const RD_CDIFF_TMPB: *u8 = ".txt"
437const RD_STATLINE: *u8 = "runs_scanned="
438const RD_LOSTFIELD: *u8 = "lost_from_live="
601const RD_SNAP: *u8 = "mgmt_snap.json"
635const RD_PORTMAP: *u8 = "knowledge/status/portmap.conf"
675const RD_LOSS_REGRESSION_RUNS: i64 = 10
676const RD_ADMIT_REFUSED: i64 = 6
686const RD_BEAT_BATCH: i64 = 4
693const RD_TREND: *u8 = "knowledge/status/rebuild_drain.jrnl"
744const RD_PLAN_ELF: *u8 = "./_offc/nx_rebuild_plan.elf"
745const RD_BEAT_LIST: *u8 = "/tmp/nx_rebuild_beat.list"
775const RD_MAINDECL: *u8 = "func main("

functions

52func rd_w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
57func rd_n(v: i64) -> i64 { nxi_out(v); return 0 }
called by 2: rd_classifymain calls 1: nxi_out
58func rd_len(a: *u8) -> i64 { var i: i64 = 0; while a[i] != (0 as u8) { i = i + 1 } return i }
59func rd_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 }
60func rd_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 }
74func rd_alias(name: *u8, out: *u8) -> i64
138func rd_find_byte(b: *u8, s: i64, e: i64, c: i64) -> i64
150func rd_starts_at(b: *u8, s: i64, e: i64, pre: *u8) -> i64
160func rd_streq(a: *u8, b: *u8) -> i64
called by 1: main
171func rd_size(path: *u8) -> i64
called by 3: rd_samerd_classifymain calls 1: sys_mmap
180func rd_safe(name: *u8) -> i64
called by 2: rd_classifymain
198func rd_same(a: *u8, b: *u8) -> i64
227func rd_copy(src: *u8, dst: *u8) -> i64
305func rd_live_has_debug(dep: *u8) -> i64
325func rd_build(broot: *u8, target: *u8, want_debug: i64) -> i64
387func rd_install_log(organ: *u8, was: i64, now: i64, prevn: *u8) -> i64
417func rd_fail_log(organ: *u8, tgt: *u8, rc: i64) -> i64
450func rd_cdiff_lost(organ: *u8, dep: *u8, fresh: *u8, logit: i64) -> i64
542func rd_name_losses(organ: *u8, dep: *u8, fresh: *u8) -> i64
609func rd_is_live_service(name: *u8) -> i64
643func rd_owns_port(name: *u8) -> i64
694func rd_trend(backlog: i64, attempted: i64, installed: i64, notprog: i64, failed: i64, src: *u8, elapsed: i64, ddaemon: i64, dlive: i64, current: i64, hstop: i64) -> i64
732func rd_catn(dst: *u8, o: i64, v: i64) -> i64
746func rd_plan_list(elfdir: *u8, srcroot: *u8, outpath: *u8) -> i64
781func rd_has_main(broot: *u8, name: *u8) -> i64
835func rd_classify(listp: *u8, broot: *u8, elfdir: *u8) -> i64
907func main(argc: i64, argv: *i64) -> i64