nx_self_build_test.nx
buildroot/runtime/nx_self_build_test.nx
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
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
structs
| none |
consts
| 54 | const GATE_FAIL: i64 = 1 |
| 55 | const GATE_PASS: i64 = 0 |
functions
| 29 | func 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 } |
| 30 | func t_putn(n: i64) -> i64 |
| 41 | func t_assert_eq(label: *u8, got: i64, want: i64) -> i64 |
| 58 | func t_seed_file(path: *u8, buf: *u8, len: i64) -> i64 |
| 74 | func t_hash_file(store: *NxBlobStore, path: *u8, out_hash: *NxBlobHash) -> i64 |
| 82 | func main() -> i64 |