code wiki / _hdl_build / nx_mgmt_upload_gate.nx

nx_mgmt_upload_gate.nx

buildroot/runtime/_hdl_build/nx_mgmt_upload_gate.nx

16477 B327 linesdepth 18pulls 86 transitivereach 0 importersview sourcekind gate/prooftopic mgmt
docsdependenciesstructsconstsfunctions

about

nx_mgmt_upload_gate.nx -- SOVEREIGN in-process referee for the /api/upload keystone (chunked artifact publish). NO socket, NO curl, NO shell: it chdir's to /tmp (so every staging file lands there, NOT in the real build/NAS dir), then feeds crafted HTTP request BYTES straight into the PURE handler ma_do_upload and asserts BOTH the response bytes AND the on-disk result. Proves the reassembly + monotonic-seq gate + allowlist + sha256 + the atomic .upload->.new stage, all fail-closed. Because ma_do_upload composes the shipped mu_stage_chunk write primitive, this end-to-end gate also transitively covers it (retiring the old isolated primitive-only gate). The target names are the REAL allowlisted basenames (exercising md_upload_target_ok for real), rooted in /tmp so nothing live is ever touched. T1 multi-chunk happy path: seq0(final=0)+seq1(final=1) -> <t>.new == chunkA ++ chunkB, BYTE-EXACT T2 NEG unknown target -> 400, nothing written T3 NEG seq gap (seq0 then seq2) -> 400, .new NOT produced T4 NEG final without a prior seq0 (fresh target) -> 400 (bad seq), .new NOT produced T5 sha256 mismatch on final -> 400 + staging (.upload) DELETED, .new NOT produced T6 sha256 MATCH on final -> 200 + .new produced BYTE-EXACT (positive control for the hash path) T7 VIDEO content namespace (2026-07-11): sites/nishifamily/video/*.js uploads + stages; html/wasm/ver.txt validate T8 video namespace fail-closed: .elf ext, ".." traversal, dot-file, prefix-miss ALL refused (validator + handler) GREEN iff T1..T8 hold. Sovereign: nx_mgmt_api (-> ma_do_upload -> mu_stage_chunk) + nx_sha256 + nx_fio + nx_syscalls. license_tier: ORIGINAL expect_exit: 0

dependencies 5 imports · 0 importers

nx_mgmt_api.nx nx_sha256.nx nx_fio.nx nx_syscalls.nx nx_gate_verdict.nx nx_mgmt_upload_gate.nx

imports: nx_mgmt_api.nxnx_sha256.nxnx_fio.nxnx_syscalls.nxnx_gate_verdict.nx

imported by: nobody (leaf or entry point)

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

main u_w sys_write sys_chdir sys_mmap nxa_die sys_write ↻ sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ sys_exit ↻ sys_mmap ↻ fio_unlink u_build u_cat u_catn sys_mmap ↻ ma_do_upload sd_find_path mau_query_off ma_emit_400 sd_cat ma_emit_json sd_cat ↻ sd_catn sys_mmap ↻ mau_qparam md_upload_target_ok md_slice_eq md_content_target_ok md_content_pfx

structs

none

consts

none

functions

25func u_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 2: u_rowmain calls 1: sys_write
26func u_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
27func u_row(name: *u8, ok: i64) -> i64
called by 1: main calls 1: u_w
32func u_cat(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 2: u_buildmain
33func u_catn(d: *u8, o: i64, v: i64) -> i64
called by 2: u_buildmain calls 1: sys_mmap
43func u_starts(buf: *u8, n: i64, s: *u8) -> i64
called by 1: main calls 1: u_len
50func u_contains(hay: *u8, n: i64, needle: *u8) -> i64
called by 1: main calls 1: u_len
65func u_build(req: *u8, qs: *u8, chunk: *u8, clen: i64) -> i64
called by 1: main calls 2: u_catu_catn
78func u_read_file(path: *u8, out: *u8, cap: i64) -> i64
called by 1: main calls 3: sys_openat_rdsys_readsys_close
94func u_bytes_eq(a: *u8, an: i64, b: *u8, bn: i64) -> i64
called by 1: main
102func u_sha256_hex(bytes: *u8, n: i64, out: *u8) -> i64
called by 1: main calls 2: sys_mmapsha256_digest
117func main() -> i64