code wiki / _hdl_build / nx_liblift.nx
nx_liblift.nx
buildroot/runtime/_hdl_build/nx_liblift.nx
about
nx_liblift.nx -- BYTE-PRESERVING LIFT of a shared lib from _hdl_build/ into runtime/, the one file
operation this ecosystem could not perform and therefore never performed.
WHY IT EXISTS (measured 2026-07-31, id 1785474294): nx_layerscan_gate found **8 misplaced libs darkening
26+ organs** -- nx_ingest(5) nx_grep(5) nx_lib_ingest(4, incl the nx_lib_http daemon) nx_fft(3, PLUS the
entire training capability via nx_fft_f32 -> nx_autograd_tensor) nx_bm25(3, PLUS rights-enforced DMS search)
nx_proc_ctl(3, incl **nx_proc_kill**, the sovereign runaway-process killer) nx_json_emit(2) nx_teacher(1).
Each is unbuildable because runtime/ CANNOT import _hdl_build/. The whole remedy is 8 file moves -- and
there was NO TOOL THAT COULD MOVE A FILE IN THAT DIRECTION. nx_retire_path only moves into
knowledge/retired/ (fixed destination) and nx_dedupe_source moves the WRONG WAY (it deletes the runtime
copy and calls _hdl_build canonical, id 1785474494). So the ecosystem could diagnose this class but not
fix it, which is why 8 libs sat misplaced long enough to darken a training stack.
THE DIRECTION IS NOT A PREFERENCE, IT IS FORCED BY THE ASYMMETRY: _hdl_build/ CAN import runtime/, and
runtime/ CANNOT import _hdl_build/. A lib that BOTH trees need therefore has exactly ONE correct home:
runtime/. Lifting satisfies every consumer at once and creates no duplicate that could later diverge --
which is why this is a LIFT (copy down + retire the original), never a copy-and-leave.
SAFETY, all fail-closed and all verified rather than assumed:
- REFUSES if the source is missing (nothing to lift)
- REFUSES if the destination already exists -- NEVER clobbers a runtime/ file, because the whole point
is to stop losing work, and a lift that overwrites is just a faster way to lose it
- BYTE-VERIFIES after writing: re-reads the destination and compares length AND every byte against the
source, reporting VERIFY-FAIL rather than success if they differ (a copy nobody checked is a rumour)
- DOES NOT DELETE THE ORIGINAL. Retiring it is a SEPARATE, reversible act:
nx_retire_path retire buildroot/runtime/_hdl_build/<name>.nx
Two verbs, two decisions -- so a half-finished lift leaves both copies rather than none.
nx_liblift check <name> -- report src/dst presence + sizes, MUTATES NOTHING
nx_liblift lift <name> -- copy _hdl_build/<name>.nx -> runtime/<name>.nx, byte-verified
exit 0 ok | 2 usage | 3 source missing | 4 destination exists | 5 read fail | 6 write fail | 7 verify fail
license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0
dependencies 1 imports · 0 importers
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
structs
| none |
consts
| 35 | const LL_SRCDIR: *u8 = "buildroot/runtime/_hdl_build" as *u8 |
| 36 | const LL_DSTDIR: *u8 = "buildroot/runtime" as *u8 |
| 37 | const LL_PATHBUF: i64 = 1024 |
| 38 | const LL_MODE: i64 = 420 |
| 110 | const LL_MAXQ: i64 = 256 |
| 111 | const LL_NAMELEN: i64 = 64 |
functions
| 40 | func ll_puts(s: *u8) |
| 46 | func ll_puti(x: i64) |
| 73 | func ll_path(out: *u8, dir: *u8, name: *u8) called by 1: main |
| 95 | func ll_exists(path: *u8) -> i64 |
| 113 | func ll_nlen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } called by 1: main |
| 115 | func ll_streq(a: *u8, b: *u8) -> i64 called by 1: ll_push |
| 125 | func ll_slot(tab: *u8, idx: i64) -> *u8 { return ((tab as i64) + idx * LL_NAMELEN) as *u8 } |
| 130 | func ll_push(tab: *u8, cnt: i64, src: *u8, n: i64) -> i64 |
| 149 | func ll_scan_imports(buf: *u8, n: i64, tab: *u8, cnt: i64) -> i64 |
| 197 | func main(argc: i64, argv: *i64) -> i64 |