code wiki / (root) / nx_cad_exceed_gate.nx

nx_cad_exceed_gate.nx source

↩ module page · 60 lines · 3038 B

1// nx_cad_exceed_gate.nx -- liar-kill gate for the MEASURED CAD exceed census. 2// Proves the three superiority axes by RUNNING them (not asserting), and enforces 3// census HONESTY: the census must admit real BEHIND axes (a census claiming zero 4// gaps is refused). This is what lets nishifamily.com/cad say "superior" about the 5// narrow axes it actually leads on, while staying honest about modeling breadth. 6// expect_exit: 0. 7 8import "nx_syscalls.nx" 9import "nx_cad_exceed.nx" 10 11func w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 12func wn(v: i64) -> i64 { 13 let b: *u8 = sys_mmap(28); var m: i64 = v 14 if m < 0 { m = 0 - m; sys_write(1, "-" as *u8, 1) } 15 let t: *u8 = sys_mmap(28); var k: i64 = 0 16 if m == 0 { t[0] = 48 as u8; k = 1 } 17 while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } 18 var i: i64 = 0; while i < k { b[i] = t[k - 1 - i]; i = i + 1 } 19 sys_write(1, b, k); return 0 20} 21func chk(cond: i64, pass: *i64, fail: *i64, label: *u8) -> i64 { 22 if cond == 1 { pass[0] = pass[0] + 1; w(" ok " as *u8); w(label); w("\n" as *u8) } 23 else { fail[0] = fail[0] + 1; w(" XX " as *u8); w(label); w("\n" as *u8) } 24 return 0 25} 26func eqi(a: i64, b: i64) -> i64 { if a == b { return 1 } return 0 } 27 28func main() -> i64 { 29 let pass: *i64 = (sys_mmap(8)) as *i64 30 let fail: *i64 = (sys_mmap(8)) as *i64 31 pass[0] = 0 32 fail[0] = 0 33 w("=== nx_cad_exceed: MEASURED superiority + census honesty ===\n" as *u8) 34 35 // --- the three superiority axes, PROVEN by running them --- 36 let det: i64 = nx_cad_measure_determinism() 37 chk(eqi(det, 1), pass, fail, "DETERMINISM: two pipeline runs byte-identical (float CAD is not)" as *u8) 38 39 let wt: i64 = nx_cad_measure_watertight() 40 chk(eqi(wt, 1), pass, fail, "WATERTIGHT: sculpted curved solid slices CLOSED by construction" as *u8) 41 42 let ib: i64 = nx_cad_measure_integrated_bytes() 43 w(" integrated G-code bytes=" as *u8); wn(ib); w("\n" as *u8) 44 chk(ib > 10000, pass, fail, "INTEGRATED: sketch->solid->slice->complete G-code, one sovereign tool" as *u8) 45 46 let cg: i64 = nx_cad_measure_csg() 47 chk(eqi(cg, 1), pass, fail, "ROBUST CSG: box-minus-cylinder is watertight + has the hole (B-rep can fail)" as *u8) 48 49 let fl: i64 = nx_cad_measure_fillet() 50 chk(eqi(fl, 1), pass, fail, "ROBUST FILLETS: smooth union adds material + watertight (B-rep fillets fail)" as *u8) 51 52 // --- census honesty (liar-kill: must admit gaps, totals must add up) --- 53 chk(eqi(NX_CAD_AXES_TOTAL, NX_CAD_AXES_AHEAD + NX_CAD_AXES_BEHIND), pass, fail, "census totals consistent (ahead+behind=total)" as *u8) 54 chk(NX_CAD_AXES_BEHIND >= 4, pass, fail, "census is HONEST: admits >=4 BEHIND axes (no all-win lie)" as *u8) 55 chk(NX_CAD_AXES_AHEAD >= 3, pass, fail, "census claims >=3 lead axes (all measured/architectural)" as *u8) 56 57 w("=== VERDICT pass=" as *u8); wn(pass[0]); w(" fail=" as *u8); wn(fail[0]); w(" ===\n" as *u8) 58 if fail[0] == 0 { return 0 } 59 return 1 60}