code wiki / _hdl_build / nx_rebuild_drain.nx
nx_rebuild_drain.nx
buildroot/runtime/_hdl_build/nx_rebuild_drain.nx
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
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
structs
| none |
consts
| 34 | const RD_AT_FDCWD: i64 = 0 - 100 |
| 35 | const RD_SYS_NEWFSTATAT: i64 = 262 |
| 36 | const RD_STATBUF: i64 = 256 |
| 37 | const RD_OFF_SIZE: i64 = 48 |
| 38 | const RD_PATHCAP: i64 = 512 |
| 39 | const RD_LISTCAP: i64 = 262144 |
| 42 | const RD_DEFAULT_BATCH: i64 = 8 |
| 45 | const RD_STUB_NUM: i64 = 2 |
| 50 | const RD_COPYBUF: i64 = 1048576 |
| 69 | const RD_ALIAS_CONF: *u8 = "knowledge/registry/elf_source_alias.conf" |
| 70 | const RD_TAB_C: i64 = 9 |
| 71 | const RD_HASH_C: i64 = 35 |
| 304 | const RD_DEBUG_MARK: *u8 = ".debug_line" |
| 380 | const RD_INSTALLLOG: *u8 = "knowledge/status/rebuild_installs.log" |
| 407 | const RD_FAILLOG: *u8 = "knowledge/status/rebuild_buildfail.log" |
| 433 | const RD_LOSSLOG: *u8 = "knowledge/status/rebuild_contentloss.log" |
| 434 | const RD_CDIFF_ELF: *u8 = "./_offc/nx_contentdiff.elf" |
| 435 | const RD_CDIFF_TMPA: *u8 = "/tmp/nx_rd_cdiff_" |
| 436 | const RD_CDIFF_TMPB: *u8 = ".txt" |
| 437 | const RD_STATLINE: *u8 = "runs_scanned=" |
| 438 | const RD_LOSTFIELD: *u8 = "lost_from_live=" |
| 601 | const RD_SNAP: *u8 = "mgmt_snap.json" |
| 635 | const RD_PORTMAP: *u8 = "knowledge/status/portmap.conf" |
| 675 | const RD_LOSS_REGRESSION_RUNS: i64 = 10 |
| 676 | const RD_ADMIT_REFUSED: i64 = 6 |
| 686 | const RD_BEAT_BATCH: i64 = 4 |
| 693 | const RD_TREND: *u8 = "knowledge/status/rebuild_drain.jrnl" |
| 744 | const RD_PLAN_ELF: *u8 = "./_offc/nx_rebuild_plan.elf" |
| 745 | const RD_BEAT_LIST: *u8 = "/tmp/nx_rebuild_beat.list" |
| 775 | const RD_MAINDECL: *u8 = "func main(" |
functions
| 52 | func 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 } |
| 57 | func rd_n(v: i64) -> i64 { nxi_out(v); return 0 } |
| 58 | func rd_len(a: *u8) -> i64 { var i: i64 = 0; while a[i] != (0 as u8) { i = i + 1 } return i } |
| 59 | func 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 } |
| 60 | func 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 } |
| 74 | func rd_alias(name: *u8, out: *u8) -> i64 |
| 138 | func rd_find_byte(b: *u8, s: i64, e: i64, c: i64) -> i64 |
| 150 | func rd_starts_at(b: *u8, s: i64, e: i64, pre: *u8) -> i64 |
| 160 | func rd_streq(a: *u8, b: *u8) -> i64 called by 1: main |
| 171 | func rd_size(path: *u8) -> i64 |
| 180 | func rd_safe(name: *u8) -> i64 |
| 198 | func rd_same(a: *u8, b: *u8) -> i64 |
| 227 | func rd_copy(src: *u8, dst: *u8) -> i64 |
| 305 | func rd_live_has_debug(dep: *u8) -> i64 |
| 325 | func rd_build(broot: *u8, target: *u8, want_debug: i64) -> i64 |
| 387 | func rd_install_log(organ: *u8, was: i64, now: i64, prevn: *u8) -> i64 |
| 417 | func rd_fail_log(organ: *u8, tgt: *u8, rc: i64) -> i64 |
| 450 | func rd_cdiff_lost(organ: *u8, dep: *u8, fresh: *u8, logit: i64) -> i64 |
| 542 | func rd_name_losses(organ: *u8, dep: *u8, fresh: *u8) -> i64 |
| 609 | func rd_is_live_service(name: *u8) -> i64 |
| 643 | func rd_owns_port(name: *u8) -> i64 |
| 694 | func 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 |
| 732 | func rd_catn(dst: *u8, o: i64, v: i64) -> i64 called by 6: rd_install_logrd_fail_logrd_cdiff_lostrd_name_lossesrd_trendrd_catn calls 3: rd_catnsys_mmapsys_munmap |
| 746 | func rd_plan_list(elfdir: *u8, srcroot: *u8, outpath: *u8) -> i64 |
| 781 | func rd_has_main(broot: *u8, name: *u8) -> i64 |
| 835 | func rd_classify(listp: *u8, broot: *u8, elfdir: *u8) -> i64 |
| 907 | func main(argc: i64, argv: *i64) -> i64 |