code wiki / (root) / nx_buildpath_lib.nx

nx_buildpath_lib.nx

buildroot/runtime/nx_buildpath_lib.nx

7285 B127 linesdepth 2pulls 2 transitivereach 2 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_buildpath_lib.nx -- THE ONE ANSWER TO "WHERE DID THE BUILDER PUT THE ARTIFACT?" WHY IT EXISTS (measured 2026-08-16, coverage_complete=1 / corpus_complete=1 over 23,232 sources): nx_sov_build_run anchors its CWD to buildroot/ and writes _build/<name>.sov.elf. It has not written /tmp since 2026-07-30, when the flock change moved artifacts to a per-target _build/<n>.lock+.s+.sov.elf. Every consumer that wants the freshly-built artifact must know that, and the knowledge had NO CALLABLE HOME -- so each one re-derived it, and they disagree: - nx_stale_check probes /tmp THEN _build. Fixed under seq1554, whose own comment records that probing ONE location "made this guard answer BUILDFAIL for EVERY target, so the instrument that gates a risky promote was DEAD". - nx_drift_watch INLINED nx_stale_check's logic ("the SAME logic as nx_stale_check, INLINED to stay single-nest") and NEVER RECEIVED THAT FIX. It logged BUILDFAIL against all four of its subjects for ~32h while reporting verdict=GREEN. - 13 further organs probe /tmp ONLY, with no fallback at all. *AN INLINED COPY DOES NOT RECEIVE ITS ORIGINAL'S FIXES -- the duplicate-ruler defect with a delay fuse, because the copy looks correct on the day it is written. *A BUG YOU FIX BY REWRITING THE LINE, RATHER THAN BY EXTRACTING THE FIX, IS A BUG YOU WILL WRITE AGAIN. A correction with no callable home fixes exactly one site. WHY THE PROBE ORDER IS WHAT IT IS -- every root is here for a NAMED reason, never for luck: BP_AT_BUILD "_build/" the caller already runs from buildroot/ (nx_drift_watch chdirs there before checking; so does the builder itself). BP_AT_BUILDROOT "buildroot/_build/" the caller runs from the SERVING ROOT -- every gate invoked by /api/gate_run, and the 48 gates repointed on 2026-08-16. BP_AT_TMP "/tmp/" LEGACY, pre-2026-07-30. Kept so an older host still resolves, and reported SEPARATELY so that resolving only via the legacy root is VISIBLE AS DRIFT instead of silent. THE RETURN IS THE ROOT THAT MATCHED, NOT A BOOLEAN. A caller that can say WHICH root answered can distinguish "found where the builder writes" from "found only in the legacy location" -- and one of those is a warning. A two-state answer collapses them, which is how this class stayed invisible. *AN AXIS THAT CANNOT SAY *WHICH* CANNOT REPORT DRIFT, ONLY PRESENCE. `out` ALWAYS holds a path, including on failure, where it holds the PRIMARY probe -- so a caller reports what it LOOKED FOR rather than printing an empty string. A guard whose failure message names no path is the reason this defect took three lanes to find. NO GUESSED CAP: bp_needed(name) derives the exact bytes required from the longest prefix, the caller's name and the suffix, and bp_artifact REFUSES with BP_OUTCAP_TOO_SMALL rather than truncating. A ceiling that has to be guessed is a defect generator in both directions.

dependencies 1 imports · 2 importers

nx_syscalls.nx nx_buildpath_lib.nx nx_buildpath_gate.nx nx_drift_watch.nx

imports: nx_syscalls.nx

imported by: nx_buildpath_gate.nxnx_drift_watch.nx

structs

none

consts

52const BP_OUTCAP_TOO_SMALL: i64 = 0 - 1
53const BP_NOTFOUND: i64 = 0
54const BP_AT_BUILD: i64 = 1
55const BP_AT_BUILDROOT: i64 = 2
56const BP_AT_TMP: i64 = 3

functions

58func bp_slen(s: *u8) -> i64
called by 1: bp_needed
63func bp_cat(dst: *u8, off: i64, src: *u8) -> i64
called by 1: bp_compose
70func bp_root_build() -> *u8 { return "_build/" as *u8 }
71func bp_root_buildroot() -> *u8 { return "buildroot/_build/" as *u8 }
72func bp_root_tmp() -> *u8 { return "/tmp/" as *u8 }
73func bp_suffix() -> *u8 { return ".sov.elf" as *u8 }
called by 2: bp_neededbp_compose
77func bp_needed(name: *u8) -> i64
86func bp_exists(path: *u8) -> i64
called by 1: bp_artifact calls 2: sys_openat_rdsys_close
94func bp_compose(root: *u8, name: *u8, out: *u8) -> i64
called by 2: mainbp_artifact calls 2: bp_catbp_suffix
105func bp_artifact(name: *u8, out: *u8, outcap: i64) -> i64
121func bp_reason(code: i64) -> *u8
called by 1: main