code wiki / _hdl_build / nx_deploy_stage_lib.nx
nx_deploy_stage_lib.nx
buildroot/runtime/_hdl_build/nx_deploy_stage_lib.nx
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
imports: nx_syscalls.nx
imported by: nx_deploy_stage.nxnx_deploy_stage_gate.nx
structs
| none |
consts
| 11 | const DS_MAGIC_1024: i64 = 1024 |
| 12 | const DS_MAGIC_4096: i64 = 4096 |
| 13 | const DS_MAGIC_2000: i64 = 2000 |
| 15 | const DS_MINSZ: i64 = 1024 // smallest plausible ELF; a smaller "binary" is a failed/torn build |
| 16 | const DS_CAPMAX: i64 = 67108864 // 64MiB copy ceiling (edge daemon ~0.7MiB; guards a runaway mmap) |
functions
| 18 | func 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 } |
| 19 | func ds_len(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } |
| 20 | func 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 } |
| 21 | func ds_catn(d: *u8, off: i64, v: i64) -> i64 |
| 28 | func ds_dst_is_new(dst: *u8) -> i64 |
| 39 | func ds_src_size(src: *u8) -> i64 |
| 61 | func ds_stage(src: *u8, dst: *u8) -> i64 called by 3: mainmainds_selftest calls 11: ds_dst_is_newds_src_sizesys_openat_rdsys_mmapsys_readsys_close+5 |
| 95 | func ds_emit(src: *u8, dst: *u8, rc: i64, sz: i64) -> i64 |
| 114 | func ds_selftest() -> i64 |