code wiki / _hdl_build / nx_deploy_stage_lib.nx

nx_deploy_stage_lib.nx

buildroot/runtime/_hdl_build/nx_deploy_stage_lib.nx

7024 B148 linesdepth 2pulls 2 transitivereach 2 importersview sourcekind librarytopic deploy
docsdependenciesstructsconstsfunctions

about

nx_deploy_stage_lib.nx -- the missing sovereign primitive: copy a validated staged ELF into a deploy `.new` slot. Closes the build->deploy name-bridge gap the api-first doctrine names as the last non-sovereign rename: /api/build stages <buildtarget>.sov.elf.new but a daemon whose deploy artifact has a DIFFERENT base (e.g. sites: build target nx_sites_daemon_v2, deploy slot sites.elf.new) can't be reached by the seq768 same-base auto-bridge, and nx_fs_write has only write/edit (no move), nx_restage targets buildroot/_offc. SAFE BY CONSTRUCTION: the dst MUST end in ".new" -> this organ can NEVER overwrite a live binary; it only STAGES. The never-brick promote (bank .prev, health-probe, auto-rollback) stays entirely in /api/deploy. src MUST be a nonzero ELF (magic 0x7f 'E' 'L' 'F' + size>1024) so a truncated/garbage stage is refused. license_tier: ORIGINAL genealogy: deploy-loop sovereignty (rename-gap closer)

dependencies 1 imports · 2 importers

nx_syscalls.nx nx_deploy_stage_lib.nx nx_deploy_stage.nx nx_deploy_stage_gate.nx

imports: nx_syscalls.nx

imported by: nx_deploy_stage.nxnx_deploy_stage_gate.nx

structs

none

consts

11const DS_MAGIC_1024: i64 = 1024
12const DS_MAGIC_4096: i64 = 4096
13const DS_MAGIC_2000: i64 = 2000
15const DS_MINSZ: i64 = 1024 // smallest plausible ELF; a smaller "binary" is a failed/torn build
16const DS_CAPMAX: i64 = 67108864 // 64MiB copy ceiling (edge daemon ~0.7MiB; guards a runaway mmap)

functions

18func ds_w(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 1: main calls 1: sys_write
19func ds_len(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
called by 2: mainds_dst_is_new
20func ds_cat(d: *u8, off: i64, s: *u8) -> i64 { var i: i64=0; var o: i64=off; while s[i]!=(0 as u8){d[o]=s[i]; o=o+1; i=i+1} return o }
called by 2: ds_stageds_emit
21func ds_catn(d: *u8, off: i64, v: i64) -> i64
called by 1: ds_emit calls 1: sys_mmap
28func ds_dst_is_new(dst: *u8) -> i64
called by 2: mainds_stage calls 1: ds_len
39func ds_src_size(src: *u8) -> i64
61func ds_stage(src: *u8, dst: *u8) -> i64
95func ds_emit(src: *u8, dst: *u8, rc: i64, sz: i64) -> i64
called by 1: main calls 4: sys_mmapds_catds_catnsys_write
114func ds_selftest() -> i64