nx_sbr_admission_candidate.nx
buildroot/runtime/nx_sbr_admission_candidate.nx
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
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
structs
| none |
consts
| 44 | const SBR_STATBUF: i64 = 256 |
| 45 | const SBR_STAT_MTIME_OFF: i64 = 88 |
| 167 | const SBR_MAGIC_4096: i64 = 4096 // read-chunk size (folded from the buildroot branch's rule-11 sweep, 2026-07-29 merge) |
| 180 | const SBR_SHA_HEX: i64 = 64 |
| 181 | const SBR_QMARK: i64 = 63 // '?' fills the digest slot when a file is unreadable / row absent |
| 184 | const SBR_EMPTY_RESERVE: i64 = 4294967296 |
| 209 | const SBR_OK: i64 = 0 |
| 210 | const SBR_USAGE: i64 = 2 |
| 211 | const SBR_COMPILE_FAIL: i64 = 3 |
| 212 | const SBR_ASM_FAIL: i64 = 4 |
| 213 | const SBR_ADMIT_REFUSED: i64 = 6 // build admission said no; distinct from a compile/assemble failure |
| 216 | const SBR_CANON_REFUSED: i64 = 7 // canon evidence unavailable, invalid, or divergent |
| 217 | const SBR_CANON_PATH_BYTES: i64 = 512 |
| 218 | const SBR_RUNTIME_PREFIX_BYTES: i64 = 8 |
| 219 | const SBR_MIN_ASM_BYTES: i64 = 128 // empty/failed .s is ~0-byte header; the smallest real program (_min42) is 540B |
| 220 | const SBR_MAX_RETRIES: i64 = 12 |
| 230 | const SBR_TIMEOUT_RC: i64 = 0 - 9 // sbr_run sentinel: NEGATIVE, so it cannot collide with a real |
| 232 | const SBR_BUILD_TIMEOUT: i64 = 8 // process exit code; next free after CANON_REFUSED=7 |
| 233 | const SBR_SIGKILL: i64 = 9 |
| 234 | const SBR_POLL_MS: i64 = 100 // wait4(WNOHANG) poll interval; fork+WNOHANG liveness is already |
| 236 | const SBR_NO_DEADLINE: i64 = 0 // explicit: RUNNING the built program must never be time-boxed |
| 242 | const SBR_BUILD_DEADLINE_MS: i64 = 900000 |
| 366 | const SBR_CACHE_EXPAND_CAP: i64 = 33554432 // 32 MiB: biggest measured closure .s is ~9.2 MB (nx_browser); |
| 382 | const SBR_STAT_MODE_OFF: i64 = 24 |
| 383 | const SBR_MODE_PERM_MASK: i64 = 511 // 0777: permission bits only; type bits never travel |
| 397 | const SBR_STAT_SIZE_OFF: i64 = 48 |
| 398 | const SBR_STAT_SIZE_W: i64 = 8 |
| 521 | const SBR_CACHE_SIDE_SUFFIX: *u8 = ".sha" |
| 522 | const SBR_CACHE_TMP_INFIX: *u8 = ".tmp-" |
| 523 | const SBR_CACHE_TMPW: i64 = 512 // 4 x SBR_CACHE_PATHW, see derivation above |
| 524 | const SBR_CACHE_SIDE_MAX: i64 = 256 // sha256= (7+64) + bytes= (6+20 max i64 digits) + key= (4+64) + 3 NL = 168 < 256 |
| 525 | const SBR_CACHE_ELF_SUFFIX_LEN: i64 = 8 // ".sov.elf" -- the key is the SBR_SHA_HEX hex chars before it |
| 754 | const SBR_CACHE_BUDGET_DEFAULT: i64 = 1073741824 |
| 755 | const SBR_CACHE_DIRBUF: i64 = 65536 |
| 759 | const SBR_CACHE_PRUNE_SLOTS: i64 = 32768 |
| 765 | const SBR_CACHE_PATHW: i64 = 128 |
functions
| 46 | func sbr_mtime(path: *u8) -> i64 |
| 55 | func sbr_name_is(a: *u8, b: *u8) -> i64 |
| 61 | func sbr_is_toolchain(name: *u8) -> i64 |
| 90 | func sbr_is_daemon(name: *u8) -> i64 |
| 185 | func sbr_sha_hex(path: *u8, out: *u8) -> i64 |
| 244 | func 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 } called by 7: sbr_runsbr_copyfilebld_cache_cas_saybld_cache_casbld_cache_cas_storesbr_cache_prune+1 calls 1: sys_write |
| 249 | func sbr_putn(v: i64) -> i64 { nxi_out(v); return 0 } |
| 252 | func 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 } |
| 255 | func sbr_ceq_at(a: *u8, ao: i64, al: i64, b: *u8, bo: i64, bl: i64) -> i64 called by 1: main |
| 262 | func sbr_exitcode(status: i64) -> i64 { return (status >> 8) & 0xff } called by 1: sbr_run |
| 267 | func sbr_atoi(s: *u8) -> i64 |
| 290 | func sbr_run(path: *u8, argv: *i64, envp: *i64, redir_out: i64, redir_err: i64, deadline_ms: i64) -> i64 |
| 335 | func sbr_filesize(path: *u8) -> i64 |
| 384 | func sbr_src_mode(path: *u8) -> i64 |
| 399 | func sbr_stat_size(path: *u8) -> i64 called by 3: bld_cache_cas_verifybld_cache_casbld_cache_cas_store calls 3: sys_mmapsys_fstatatsys_munmap |
| 411 | func sbr_copyfile(srcp: *u8, dstp: *u8) -> i64 called by 2: bld_cache_casbld_cache_cas_store calls 9: sys_mmapsys_read_filesys_munmapsbr_src_modesys_openat_wrsys_write+3 |
| 438 | func bld_cache_cas_hex(d: *u8, out: *u8) -> i64 called by 1: sbr_cache_key |
| 459 | func sbr_incumbent_flavour(path: *u8) -> i64 |
| 487 | func sbr_cache_key(src: *u8, compiler: *u8, asm_tool: *u8, want_debug: i64, out: *u8) -> i64 called by 1: main calls 7: sys_mmapexpand_ctx_newexpand_importssys_munmapsha256_digestbld_cache_cas_hex+1 |
| 530 | func bld_cache_cas_field(buf: *u8, n: i64, key: *u8, out: *u8, cap: i64) -> i64 called by 1: bld_cache_cas_verify |
| 571 | func bld_cache_cas_verify(cachepath: *u8, shaout: *u8, bytesout: *i64) -> i64 |
| 607 | func bld_cache_cas_say(name: *u8, what: *u8, key: *u8) -> i64 |
| 612 | func 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 } |
| 618 | func bld_cache_cas(cachekey: *u8, cachepath: *u8, elfpath: *u8, name: *u8) -> i64 called by 1: main calls 11: sys_mmapbld_cache_cas_verifybld_cache_cas_saybld_cache_cas_nlsbr_catsys_unlinkat+5 |
| 677 | func bld_cache_cas_store(elfpath: *u8, cachepath: *u8, name: *u8) -> i64 called by 1: main calls 15: bld_cache_cas_saybld_cache_cas_nlsys_mmapsbr_catsbr_copyfilesys_unlinkat+9 |
| 770 | func sbr_cache_conf_int(key: *u8, dflt: i64) -> i64 |
| 813 | func sbr_cache_budget() -> i64 |
| 819 | func sbr_cache_enabled() -> i64 |
| 828 | func sbr_cache_prune() -> i64 |
| 934 | func main(argc: i64, argv: *i64) -> i64 |