code wiki / _hdl_build / nx_buildroot_guard.nx

nx_buildroot_guard.nx

buildroot/runtime/_hdl_build/nx_buildroot_guard.nx

9100 B172 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_buildroot_guard.nx -- SELF-HEALING buildroot integrity (eats seq140: the recurring lib-drift that breaks EVERY store-lib organ build when a sibling ships/reverts an OLD nx_seg_store.nx without ss_begin_cap). Data-driven (rule 11): a manifest of <buildroot-lib-path> <required-symbol> <pinned-good-path> rows. The drift signal is SEMANTIC (missing a required symbol = broken), NOT byte-equality -- so a legitimately-newer lib that still has the symbol survives; only a BROKEN revert is healed. Fail-safe BY CONSTRUCTION: `pin` refuses to snapshot a lib that lacks the symbol, and `heal` refuses to restore from a pin that lacks it -- the guard can never make a build WORSE, only restore a known-good. nx_buildroot_guard pin [manifest] (snapshot each currently-GOOD buildroot lib to its pinned-good path) nx_buildroot_guard check [manifest] (JSON: per lib -- has_symbol, pinned_ok, drifted) nx_buildroot_guard heal [manifest] (restore drifted libs from their pinned-good; JSON report) license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_buildroot_guard.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

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

main bg_werr sys_write sys_exit bg_vlen bg_contains sys_mmap bg_read sys_openat_rd sys_read sys_close bg_cat bg_le bg_col bg_cstr bg_write sys_openat_wr sys_write ↻ sys_close ↻ bg_cat_esc bg_catn sys_mmap ↻ sys_write ↻

structs

none

consts

14const BG_CAP: i64 = 1048576
15const BG_TAB: i64 = 9
16const BG_NL: i64 = 10
17const BG_HASH: i64 = 35
18const BG_STDERR: i64 = 2
19const BG_MODE: i64 = 420
20const BG_SPAN: i64 = 16
21const BG_EXIT_USAGE: i64 = 2

functions

23func bg_werr(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(BG_STDERR, s, n); return 0 }
called by 1: main calls 1: sys_write
24func bg_vlen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 1: main
25func bg_cat(d: *u8, o: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { d[o] = s[i]; o = o + 1; i = i + 1 } return o }
called by 1: main
26func bg_catn(d: *u8, o: i64, v: i64) -> i64 { let t: *u8 = sys_mmap(28); var m: i64 = v; if m < 0 { m = 0 } 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 { d[o] = t[k-1-i]; o = o + 1; i = i + 1 } return o }
called by 1: main calls 1: sys_mmap
27func bg_cat_esc(d: *u8, o: i64, q: *u8, s: i64, e: i64) -> i64 { var i: i64 = s; while i < e { var c: i64 = q[i] as i64; if c == 34 { c = 39 } if c == 92 { c = 47 } if c < 32 { c = 32 } d[o] = c as u8; o = o + 1; i = i + 1 } return o }
called by 1: main
29func bg_read(path: *u8, buf: *u8, cap: i64) -> i64
called by 1: main calls 3: sys_openat_rdsys_readsys_close
39func bg_write(path: *u8, buf: *u8, n: i64) -> i64
47func bg_contains(buf: *u8, n: i64, lit: *u8) -> i64
called by 1: main
61func bg_le(q: *u8, i: i64, n: i64) -> i64 { var e: i64 = i; var s: i64 = 1; while s == 1 { if e >= n { s = 0 } else { if q[e] == (BG_NL as u8) { s = 0 } else { e = e + 1 } } } return e }
called by 1: main
62func bg_col(q: *u8, ls: i64, le: i64, c: i64, out: *i64) -> i64
called by 1: main
79func bg_cstr(q: *u8, s: i64, e: i64, dst: *u8) -> i64 { var i: i64 = 0; while s + i < e { dst[i] = q[s+i]; i = i + 1 } dst[i] = 0 as u8; return i }
called by 1: main
80func main(argc: i64, argv: *i64) -> i64