code wiki / (root) / nx_sbr_admission_candidate.nx

nx_sbr_admission_candidate.nx

buildroot/runtime/nx_sbr_admission_candidate.nx

120839 B1832 linesdepth 5pulls 10 transitivereach 0 importersview sourcekind tooltopic sbr
docsdependenciesstructsconstsfunctions

about

nx_sov_build_run.nx -- FULLY SOVEREIGN, REUSABLE build runner (operator: "no sh and no c build, from the hardware layer up"). Generalizes nx_retire_gcc_orchestrator from hardcoded targets to ANY module passed as argv[1]. The build path is bits-up sovereign end to end: nx_cc_sovereign.elf <module>.nx -> _build/<module>.s (the team's SELF-HOSTED compiler) nxasm_x86_main.elf <module>.s -> _build/<module>.sov.elf (the team's x86-64 assembler+linker) _build/<module>.sov.elf (run it; exit = its exit) ⚠OUTPUT PATH IS _build/, RELATIVE TO CWD -- NOT /tmp/. These three lines said /tmp/ until 2026-07-30, left stale by the flock change that moved artifacts to a per-target _build/<name>.lock+.s+.sov.elf so concurrent sweeps stop overwriting each other mid-build. A doc that disagrees with the code is a defect, not a nit: it is why callers hunt for the artifact, and it hid a REAL brick hazard -- nx_hostctl cmd_buildrun (nx_hostctl.nx) ONCE read only /tmp/<name>.sov.elf, which made this runner and that supervisor a MATCHED PAIR that had to ship together or every /api/build failed. CLOSED -- VERIFIED 2026-08-17 BY READING THE LIVE SOURCE, not by assuming: cmd_buildrun now probes the ABSOLUTE .../nishihost/buildroot/_build/<name>.sov.elf FIRST (the parent is not in the child's CWD, so it must name it absolutely), falls back to /tmp/ for pre-flock builders, and its failure line NAMES BOTH paths. The pairing constraint no longer holds and this runner ships alone. The old line also cited :3089 while the code now sits near :3571 -- a stale line number is the tell. * A STALE HAZARD NOTE IS ITSELF A HAZARD: it makes the next reader either avoid a safe change or hunt a defect that was already fixed. This estate has the receipt -- a standing RED-gate list that nobody re-measured cost NINE sessions the SAME nine investigations, and 5 of the 9 were already green. Re-measure a warning before repeating it. NO gcc, NO bash, NO .sh anywhere. Orchestration is NishiLang sys_fork/dup3/execve/wait4. Recompile-retry guards the known-good compiler's empty-.s nondeterminism. Usage: nx_sov_build_run.elf <module-basename-in-runtime/_hdl_build>

dependencies 6 imports · 0 importers

nx_syscalls.nx nx_itoa_lib.nx nx_sha256.nx nx_import.nx nx_builddeploy_lib.nx nx_build_canon_input_lib.nx nx_sbr_admission_candidate.nx

imports: nx_syscalls.nxnx_itoa_lib.nxnx_sha256.nxnx_import.nxnx_builddeploy_lib.nxnx_build_canon_input_lib.nx

imported by: nobody (leaf or entry point)

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

main sbr_puts sys_write sys_exit sys_openat_rd sys_close sys_chdir 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 ↻ sbr_atoi sys_mmap ↻ sbr_cat sbr_incumbent_flavour sys_mmap ↻ sys_read_file sys_openat_rd ↻ sys_lseek sys_mmap ↻ sys_read sys_munmap sys_close ↻ sys_munmap ↻ sbr_cat ↻ sys_munmap ↻ sbr_putn nxi_out nxi_fd

structs

none

consts

44const SBR_STATBUF: i64 = 256
45const SBR_STAT_MTIME_OFF: i64 = 88
167const SBR_MAGIC_4096: i64 = 4096 // read-chunk size (folded from the buildroot branch's rule-11 sweep, 2026-07-29 merge)
180const SBR_SHA_HEX: i64 = 64
181const SBR_QMARK: i64 = 63 // '?' fills the digest slot when a file is unreadable / row absent
184const SBR_EMPTY_RESERVE: i64 = 4294967296
209const SBR_OK: i64 = 0
210const SBR_USAGE: i64 = 2
211const SBR_COMPILE_FAIL: i64 = 3
212const SBR_ASM_FAIL: i64 = 4
213const SBR_ADMIT_REFUSED: i64 = 6 // build admission said no; distinct from a compile/assemble failure
216const SBR_CANON_REFUSED: i64 = 7 // canon evidence unavailable, invalid, or divergent
217const SBR_CANON_PATH_BYTES: i64 = 512
218const SBR_RUNTIME_PREFIX_BYTES: i64 = 8
219const SBR_MIN_ASM_BYTES: i64 = 128 // empty/failed .s is ~0-byte header; the smallest real program (_min42) is 540B
220const SBR_MAX_RETRIES: i64 = 12
230const SBR_TIMEOUT_RC: i64 = 0 - 9 // sbr_run sentinel: NEGATIVE, so it cannot collide with a real
232const SBR_BUILD_TIMEOUT: i64 = 8 // process exit code; next free after CANON_REFUSED=7
233const SBR_SIGKILL: i64 = 9
234const SBR_POLL_MS: i64 = 100 // wait4(WNOHANG) poll interval; fork+WNOHANG liveness is already
236const SBR_NO_DEADLINE: i64 = 0 // explicit: RUNNING the built program must never be time-boxed
242const SBR_BUILD_DEADLINE_MS: i64 = 900000
366const SBR_CACHE_EXPAND_CAP: i64 = 33554432 // 32 MiB: biggest measured closure .s is ~9.2 MB (nx_browser);
382const SBR_STAT_MODE_OFF: i64 = 24
383const SBR_MODE_PERM_MASK: i64 = 511 // 0777: permission bits only; type bits never travel
397const SBR_STAT_SIZE_OFF: i64 = 48
398const SBR_STAT_SIZE_W: i64 = 8
521const SBR_CACHE_SIDE_SUFFIX: *u8 = ".sha"
522const SBR_CACHE_TMP_INFIX: *u8 = ".tmp-"
523const SBR_CACHE_TMPW: i64 = 512 // 4 x SBR_CACHE_PATHW, see derivation above
524const SBR_CACHE_SIDE_MAX: i64 = 256 // sha256= (7+64) + bytes= (6+20 max i64 digits) + key= (4+64) + 3 NL = 168 < 256
525const SBR_CACHE_ELF_SUFFIX_LEN: i64 = 8 // ".sov.elf" -- the key is the SBR_SHA_HEX hex chars before it
754const SBR_CACHE_BUDGET_DEFAULT: i64 = 1073741824
755const SBR_CACHE_DIRBUF: i64 = 65536
759const SBR_CACHE_PRUNE_SLOTS: i64 = 32768
765const SBR_CACHE_PATHW: i64 = 128

functions

46func sbr_mtime(path: *u8) -> i64
55func sbr_name_is(a: *u8, b: *u8) -> i64
61func sbr_is_toolchain(name: *u8) -> i64
called by 1: main calls 1: sbr_name_is
90func sbr_is_daemon(name: *u8) -> i64
185func sbr_sha_hex(path: *u8, out: *u8) -> i64
244func sbr_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
249func sbr_putn(v: i64) -> i64 { nxi_out(v); return 0 }
252func sbr_cat(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { dst[off+i] = s[i]; i = i + 1 } return off + i }
255func sbr_ceq_at(a: *u8, ao: i64, al: i64, b: *u8, bo: i64, bl: i64) -> i64
called by 1: main
262func sbr_exitcode(status: i64) -> i64 { return (status >> 8) & 0xff }
called by 1: sbr_run
267func sbr_atoi(s: *u8) -> i64
290func sbr_run(path: *u8, argv: *i64, envp: *i64, redir_out: i64, redir_err: i64, deadline_ms: i64) -> i64
335func sbr_filesize(path: *u8) -> i64
384func sbr_src_mode(path: *u8) -> i64
399func sbr_stat_size(path: *u8) -> i64
411func sbr_copyfile(srcp: *u8, dstp: *u8) -> i64
438func bld_cache_cas_hex(d: *u8, out: *u8) -> i64
called by 1: sbr_cache_key
459func sbr_incumbent_flavour(path: *u8) -> i64
487func sbr_cache_key(src: *u8, compiler: *u8, asm_tool: *u8, want_debug: i64, out: *u8) -> i64
530func bld_cache_cas_field(buf: *u8, n: i64, key: *u8, out: *u8, cap: i64) -> i64
571func bld_cache_cas_verify(cachepath: *u8, shaout: *u8, bytesout: *i64) -> i64
607func bld_cache_cas_say(name: *u8, what: *u8, key: *u8) -> i64
612func bld_cache_cas_nl() -> i64 { let b: *u8 = sys_mmap(2); b[0] = 10 as u8; sys_write(1, b, 1); sys_munmap(b, 2); return 0 }
618func bld_cache_cas(cachekey: *u8, cachepath: *u8, elfpath: *u8, name: *u8) -> i64
677func bld_cache_cas_store(elfpath: *u8, cachepath: *u8, name: *u8) -> i64
770func sbr_cache_conf_int(key: *u8, dflt: i64) -> i64
813func sbr_cache_budget() -> i64
called by 1: sbr_cache_prune calls 1: sbr_cache_conf_int
819func sbr_cache_enabled() -> i64
called by 1: main calls 1: sbr_cache_conf_int
828func sbr_cache_prune() -> i64
934func main(argc: i64, argv: *i64) -> i64