code wiki / (root) / nx_nxa_secdump.nx

nx_nxa_secdump.nx

buildroot/runtime/nx_nxa_secdump.nx

11432 B305 linesdepth 2pulls 3 transitivereach 0 importersview sourcekind tooltopic nxa
docsdependenciesstructsconstsfunctions

about

nx_nxa_secdump.nx -- THE MISSING NXA INSPECTOR: print the section directory of an NXA asset, verify every section against the checksum the format already carries, reconcile the byte partition, and on request print the leading words of any one section. WHY THIS EXISTS (measured 2026-09-01, lane=consumer-gap). The estate holds a WRITER for every NXA section (nx_nxa_texc, nx_nxa_texm, nx_nxa_dyna, nx_nxa_morf, nx_nxa_skin, nx_garment_gen) and a floor gate that prints tag:wordcount -- and NOTHING that can answer "are these two assets the same bytes in the sections they share?" or "how many map records does the SHIPPED TEXM carry, and how long is each?". nx_capsearch over 7,175 organs, corpus_complete=1, returns no inspector. The consequence was concrete: a 40 MB superset claim had to be argued from declared word counts alone, because nx_contentdiff CAPS BOTH SIDES AT 4,194,304 BYTES and therefore cannot adjudicate any asset larger than 4 MiB at all. THE OBSERVATION THIS ORGAN MONETISES: the NXA directory ALREADY CARRIES a per-section order-sensitive rolling checksum over that section's words. Byte-identity of a section between two assets is therefore a FREE, FORMAT-NATIVE comparison. Equal tag + equal wordlen + equal check is a weak-but-native identity claim, and it is stated as exactly that rather than dressed up as a cryptographic hash. COMPOSES, NEVER RE-IMPLEMENTS: nxa_check2 comes from nx_nxa.nx, the ONE definition of the format checksum, so this verifier cannot drift from the writers. nx_nxa_secdump <asset.nxa> -- directory + per-section verify + reconciliation nx_nxa_secdump <asset.nxa> <TAG> [nwords] -- the same, plus the first nwords words of <TAG> EXITS: 0 OK (every section checksum recomputed and matched) 1 I/O -- asset unreadable 2 usage (including a non-numeric nwords, which REFUSES rather than defaulting) 3 bad container (magic, version, section count, or a directory past EOF) 4 named TAG not present in the directory 5 at least one section FAILED verification (corrupt, hand-edited, or out of file) license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_nxa.nx nx_nxa_secdump.nx

imports: nx_syscalls.nxnx_nxa.nx

imported by: nobody (leaf or entry point)

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

main sd_out sys_write sd_slen sys_exit sd_atoi 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_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_munmap sys_close sd_num sys_write ↻ sys_mmap ↻ sd_rd64 nxa_check2 sd_tag_eq

structs

none

consts

37const SD_OK: i64 = 0
38const SD_E_IO: i64 = 1
39const SD_E_USAGE: i64 = 2
40const SD_E_BAD: i64 = 3
41const SD_E_NOTAG: i64 = 4
42const SD_E_CKSUM: i64 = 5
45const SD_HDR_BYTES: i64 = 32
46const SD_DIRENT_BYTES: i64 = 32
47const SD_DIRENT_WORDS: i64 = 4
48const SD_WORD: i64 = 8
49const SD_TAG_CHARS: i64 = 4
50const SD_OFF_VER: i64 = 8
51const SD_OFF_NSEC: i64 = 16
52const SD_OFF_TOCCK: i64 = 24
53const SD_DIR_OFF: i64 = 8
54const SD_DIR_WLEN: i64 = 16
55const SD_DIR_CHECK: i64 = 24
56const SD_NSEC_MAX: i64 = 64
57const SD_MAGIC_CHARS: i64 = 8
58const SD_BYTE: i64 = 256
59const SD_BYTE_MASK: i64 = 255
60const SD_TOP_BYTE: i64 = 7
61const SD_ASCII_ZERO: i64 = 48
62const SD_DECIMAL: i64 = 10
63const SD_DIGIT_MAX: i64 = 9
64const SD_STDOUT: i64 = 1
65const SD_NUMBUF: i64 = 32
66const SD_CHECK_SEED: i64 = 1
67const SD_WORDS_DEFAULT: i64 = 24
68const SD_ARG_ASSET: i64 = 1
69const SD_ARG_TAG: i64 = 2
70const SD_ARG_NWORDS: i64 = 3
71const SD_ARGC_ASSET: i64 = 2
72const SD_ARGC_TAG: i64 = 3
73const SD_ARGC_NWORDS: i64 = 4
74const SD_TAGBUF: i64 = 8
75const SD_SCRATCH: i64 = 16
76const SD_MISS: i64 = 0 - 1

functions

78func sd_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 1: sd_out
79func sd_out(s: *u8) -> i64 { sys_write(SD_STDOUT, s, sd_slen(s)); return 0 }
called by 1: main calls 2: sys_writesd_slen
80func sd_num(v: i64) -> i64
called by 1: main calls 2: sys_writesys_mmap
94func sd_rd64(b: *u8, off: i64) -> i64
called by 1: main
102func sd_atoi(s: *u8) -> i64
called by 1: main
118func sd_tag_eq(b: *u8, e: i64, t: *u8) -> i64
called by 1: main
124func main(argc: i64, argv: *i64) -> i64