code wiki / _hdl_build / nx_mgmt_promote_gate.nx

nx_mgmt_promote_gate.nx

buildroot/runtime/_hdl_build/nx_mgmt_promote_gate.nx

10664 B182 linesdepth 18pulls 72 transitivereach 0 importersview sourcekind gate/prooftopic mgmt
docsdependenciesstructsconstsfunctions

about

nx_mgmt_promote_gate.nx -- prove POST /api/promote (organ ELF) is fail-closed + never-brick. In-process referee (no socket): crafts request BYTES and feeds the pure handler ma_do_promote. Auth is the SAME ma_level_of gate as every other write route (proven in nx_mgmt_api_gate), so this focuses on the NEW logic: T1 NEG daemon target ("sites") -> 400 allowlist, staged file UNTOUCHED (daemons must use /api/deploy) T2 NEG path-escape ("../etc/x") -> 400 invalid name (sanitize refuses) T3 NEG missing staged (allowlisted, no .sov.elf.new) -> 400 no-valid-staged, no brick T4 NEG non-ELF staged (garbage bytes) -> 400 must-be-ELF, live UNTOUCHED (never promote corruption) T5 NEG no confirm=yes -> 400, staged UNTOUCHED T6 POS promote -> live == the new ELF, <t>.elf.prev == the old live (never-brick backup), staged consumed Runs FS under /tmp (WSL-native ext4-like) to avoid 9p flakiness. license_tier: ORIGINAL expect_exit: 0

dependencies 2 imports · 0 importers

nx_mgmt_api.nx nx_syscalls.nx nx_mgmt_promote_gate.nx

imports: nx_mgmt_api.nxnx_syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main w sys_write sys_mkdir sys_chdir sys_mmap sys_mmap ↻ fio_unlink wfile sys_openat_wr sys_write ↻ sys_close mkreq glen gcat sys_mmap ↻ gcatn ma_do_promote sd_body_off sd_form_field ma_emit_400 sd_cat ma_emit_json sd_cat ↻ sd_catn sys_mmap ↻ ma_sanitize_name ok_kind_of_path sys_openat_rd sys_mmap ↻ sys_read sys_close ↻ sys_munmap ok_kind_of ok_is_sep ok_kind_code md_promote_organ_ok md_promote_deny md_promote_deny_hard md_name_is_oracle

structs

none

consts

none

functions

14func 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
15func pn(v: i64) -> i64
called by 1: main calls 2: sys_mmapsys_write
26func glen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
called by 2: gcontainsmkreq
27func gcat(d: *u8, o: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){d[o+i]=s[i]; i=i+1} return o+i }
called by 1: mkreq
28func gcatn(d: *u8, o: i64, s: *u8, n: i64) -> i64 { var i: i64=0; while i<n {d[o+i]=s[i]; i=i+1} return o+n }
called by 1: mkreq
29func gcontains(hay: *u8, n: i64, needle: *u8) -> i64
called by 1: main calls 1: glen
41func mkreq(dst: *u8, line: *u8, body: *u8) -> i64
called by 1: main calls 4: glengcatsys_mmapgcatn
55func wfile(path: *u8, buf: *u8, n: i64) -> i64
63func bytes_eq(path: *u8, want: *u8, wn: i64) -> i64
called by 1: main calls 2: sys_mmapsys_read_file
72func file_absent(path: *u8) -> i64
called by 1: main calls 2: sys_openat_rdsys_close
79func main() -> i64