code wiki / _hdl_build / nx_triangulate_test.nx

nx_triangulate_test.nx

buildroot/runtime/_hdl_build/nx_triangulate_test.nx

6170 B146 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

about

nx_triangulate_test.nx -- VALIDATES the reusable triangulation harness (nx_triangulate.nx) itself: proves it PASSES three agreeing legs and CATCHES a deliberately-wrong leg. A harness that only ever says "pass" is worthless; this test proves the catch path fires, so the harness can be trusted to gate real capabilities (Cardinal 7 test before ship; Cardinal 25 build intelligence). We exercise the harness on a REAL capability (integer division) using three genuinely independent legs over a battery, exactly as the divider proof does: LEG A -- Newton-Raphson reciprocal divide (the multiplicative frontier) LEG B -- restoring shift-subtract divide (independent algorithm) LEG C -- behavioral `/` (oracle is C; A,B are the legs judged against it) Then we run two adversarial scenarios THROUGH the harness: (1) all three legs correct -> harness must report PASS, all-agree. (2) one leg deliberately corrupted (off-by-one) -> harness must report a CAUGHT failure, naming the bad leg index + its wrong value. KNOWN ANSWER (FAIL LOUD), one line: "<good_passed> <good_total> <caught> <bad_leg> <bad_got> <bad_exp> <argguard>" good_passed == good_total (clean battery: every vector triangulates) caught == 1 (the corrupted leg WAS detected, not swallowed) bad_leg, bad_got, bad_exp (the 5W1H diagnostic the harness surfaced) argguard == 1 (boundary guard rejects a malformed request) Any deviation -> nonzero exit. Expected: "65536 65536 1 1 36 35 1 " run=0

dependencies 1 imports · 0 importers

nx_triangulate.nx nx_triangulate_test.nx

imports: nx_triangulate.nx

imported by: nobody (leaf or entry point)

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

main nx_tri_tally_init tw_newton tw_msb_pos tw_restoring nx_tri_pass_strict nx_tri_check nx_tri_tally_add nx_tri_check ↻ _emit_num _nl

structs

none

consts

27const TW_W: i64 = 16
28const TW_F: i64 = 65536
29const TW_FF: i64 = 4294967296
30const TW_ITERS: i64 = 3

functions

32func _emit_num(v: i64) -> i64
called by 1: main
40func _nl() -> i64 { let z: *u8 = sys_mmap(2); z[0] = 10; sys_write(1, z, 1); return 0 }
called by 1: main
43func tw_msb_pos(d: i64) -> i64
called by 1: tw_newton
50func tw_newton(N: i64, D: i64) -> i64
called by 1: main calls 1: tw_msb_pos
69func tw_restoring(N: i64, D: i64) -> i64
called by 1: main
81func main() -> i64