code wiki / _hdl_build / nx_nxe.nx
nx_nxe.nx
buildroot/runtime/_hdl_build/nx_nxe.nx
about
nx_nxe.nx -- the SOVEREIGN NISHI EXECUTABLE FORMAT (NXE) demonstrator + conformance suite. Our OWN
file -- NOT an ELF knockoff. A UNIQUE exceed: it bakes in what ELF/Mach-O/PE LACK by default --
(1) INTEGRITY by construction: a content hash of the code section in the header; the loader VERIFIES it and
REFUSES tampered binaries (ELF/Mach-O/PE have no built-in integrity -- they rely on external signing).
(2) CAPABILITY MANIFEST (capability-based security, ef_capsec.raw): the binary DECLARES its caps (file/net/exec/
raw-hw); the loader enforces least-privilege -- an undeclared cap is denied. (ELF declares nothing.)
(3) NEVER-BRICK tag (cardinal 26 IN THE FORMAT): a binary flagged HW_WRITE is REFUSED unless it carries a
never-brick guarantee. The brand-critical law enforced at load, by construction.
CONVERGED 2026-08-15 -- THIS FILE NO LONGER CARRIES ITS OWN COPY OF THE FORMAT.
It used to define its own nxe_write/nxe_magic_ok/nxe_integrity_ok/nxe_may/p64/r64 with `HOFF = 80` and
a DJB2 code hash, sitting beside nx_nxe_lib.nx -- whose own header promises it was extracted "(rule-15
DRY) so both compose ONE copy". The extraction never reached this file, so the estate shipped TWO
incompatible NXE1 layouts (code@80 djb2 here, code@96 SHA-256 there) and the on-disk artifacts proved
it: knowledge/nxe_hello.nxe was 98 bytes while knowledge/organ_fx.nxe was 107.
* A DRY EXTRACTION THAT LEAVES THE ORIGINAL IN TREE HAS NOT DEDUPLICATED THE RULER, IT HAS FORKED IT
-- AND A FORKED FORMAT OUTLIVES THE CODE, BECAUSE THE ARTIFACTS PERSIST.
Now it imports nx_nxe_lib and tests THE SHIPPING FORMAT: code@96, FIPS-180-4 SHA-256, one writer.
Measured by buildroot/runtime/nx_nxeconform_gate.nx, which retires the duplicate LAYOUT row.
Layout (8-byte fields): [0]magic'NXE1' [8]version [16]arch [24]flags [32]caps [40]entry [48]code_off=96
[56]code_len [64..96]code_hash(32B SHA-256) ; code@96.
T1 write/validate roundtrip. T2 integrity (verify ok; tampered code -> rejected). T3 capability
(declared allowed, undeclared denied). T4 never-brick (HW_WRITE without a guarantee -> REFUSED).
expect_exit: 0 Sovereign: nx_nxe_lib (+nx_syscalls, nx_sha256) and the shared itoa emitter.
dependencies 2 imports · 0 importers
imports: nx_nxe_lib.nxnx_itoa_lib.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 28 | const K_MAGIC_4096: i64 = 4096 |
functions
| 30 | func g_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 35 | func g_pn(v: i64) -> i64 { nxi_out(v); return 0 } |
| 36 | func ck(name: *u8, c: i64) -> i64 { if c==1 { g_puts(" PASS " as *u8) } else { g_puts(" FAIL " as *u8) } g_puts(name); g_puts("\n" as *u8); return c } |
| 37 | func have(path: *u8) -> i64 { let fd: i64=sys_openat_rd(path); if fd<0 { return 0 } sys_close(fd); return 1 } |
| 43 | func nxe_validate(m: *u8) -> i64 |
| 50 | func main() -> i64 |