code wiki / (root) / nx_self_build_test.nx

nx_self_build_test.nx

buildroot/runtime/nx_self_build_test.nx

9039 B186 linesdepth 8pulls 9 transitivereach 0 importersview sourcekind gate/prooftopic self
docsdependenciesstructsconstsfunctions

about

nx_self_build_test.nx -- THE NET, PROVEN BEFORE THE TRAPEZE. PROOF #0 (the headline): a DELIBERATE FAILED WRITE. Snapshot a temp file, overwrite it with content that FAILS its gate, run the rollback, and ASSERT the restored bytes are BYTE-IDENTICAL to the snapshot (reread + rehash + nx_blob_hash_eq). The safety net works on a deliberate failure -> the reversible-modify tier is safe to point at real source files. Also asserts (the 3-tier policy): - a DESTRUCTIVE op (W_DELETE, and W_OVERWRITE_SRC with NO backup) is DENIED - an ADDITIVE op (W_ADDITIVE) is ALLOWED - the PASS path: a gated-GREEN reversible modify COMMITS (new bytes stand) FAIL-LOUD known-answer: every assertion has a known expected value; any mismatch prints WHAT failed and exits NONZERO. Exit 0 = ALL PROVEN. The re-gate verdict is injected by the caller (two-phase begin/finish): here it is a deterministic known-answer (1 = fail, 0 = pass) -- in-process, and free of the gate-runner's hardcoded /tmp scratch paths (so concurrent ticks cannot collide on it). This exercises the SAME snapshot -> write -> re-gate -> rollback flow the production path uses. license_tier: ORIGINAL

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_blob_store.nx nx_self_build.nx nx_self_build_test.nx

imports: nx_syscalls.nxnx_blob_store.nxnx_self_build.nx

imported by: nobody (leaf or entry point)

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

main t_puts sys_write t_assert_eq t_puts ↻ t_putn sys_write ↻ sys_mmap sys_exit nx_self_build_authorize nx_sb_classify warden_authorize warden_check w_is_build_artifact w_contains w_audit sys_openat_append w_wstr sys_write ↻ w_kind_name sys_close nx_sb_classify ↻ nx_self_build_new sys_mmap ↻ nx_blob_store_new sys_mmap ↻ nx_journal_log_new sys_mmap ↻ nx_self_build_is_valid nx_blob_store_is_valid nx_journal_log_is_valid sb_slen t_seed_file sys_openat_wr sys_write ↻ sys_close ↻ nx_blob_store_new ↻ nx_blob_hash_new sys_mmap ↻ t_hash_file

structs

none

consts

54const GATE_FAIL: i64 = 1
55const GATE_PASS: i64 = 0

functions

29func t_puts(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: t_assert_eqmain calls 1: sys_write
30func t_putn(n: i64) -> i64
called by 1: t_assert_eq calls 2: sys_writesys_mmap
41func t_assert_eq(label: *u8, got: i64, want: i64) -> i64
called by 1: main calls 3: t_putst_putnsys_exit
58func t_seed_file(path: *u8, buf: *u8, len: i64) -> i64
74func t_hash_file(store: *NxBlobStore, path: *u8, out_hash: *NxBlobHash) -> i64
82func main() -> i64