code wiki / _hdl_build / nx_capgraph_selfcheck.nx

nx_capgraph_selfcheck.nx source

↩ module page · 79 lines · 3329 B

1// nx_capgraph_selfcheck.nx -- runs nx_gateverify over EVERY gate in this lane and refuses to pass 2// unless all of them AGREE. 3// 4// WHY: for the last several rounds I confirmed "all five gates GREEN and AGREE" with an ad-hoc shell 5// loop typed fresh each time. That is precisely the component this session proved least reliable -- 6// my own verification patterns accused seven innocent gates, missed a tooth-helper name, and twice 7// mis-counted correct output. ★A CHECK I RETYPE EACH TIME IS A CHECK THAT WILL EVENTUALLY BE TYPED 8// WRONG, and it leaves no artifact anyone else can re-run. 9// 10// AGREE is a strictly stronger claim than GREEN: GREEN says the teeth passed, AGREE says the LEDGER 11// can be trusted to say so -- and the ledger is what every ruler reads. 12// 13// nx_capgraph_selfcheck exit 0 = all AGREE · 1 = at least one gate's record cannot be trusted 14// license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0 15import "nx_gateorder_lib.nx" 16import "nx_tool_run.nx" 17 18const SC_CAP: i64 = 262144 19const SC_VERIFY: *u8 = "/volume1/homes/elderwesto/nishihost/nx_gateverify.elf" as *u8 20 21static sc_out: *u8 22static sc_pass: i64 23static sc_fail: i64 24 25// One gate: fork nx_gateverify <name>, then look for the AGREE verdict in its output. 26func sc_one(name: *u8) { 27 let olen: *i64 = sys_mmap(16) as *i64 28 let rc: i64 = tr_run1(SC_VERIFY, name, sc_out, SC_CAP, olen) 29 let n: i64 = olen[0] 30 go_puts(" " as *u8) 31 go_puts(name) 32 go_puts(" " as *u8) 33 if rc == 127 { 34 go_puts("RUN-FAIL (nx_gateverify not promoted?)\n" as *u8) 35 sc_fail = sc_fail + 1 36 return 37 } 38 if n <= 0 { 39 go_puts("NO-OUTPUT\n" as *u8) 40 sc_fail = sc_fail + 1 41 return 42 } 43 if go_first(sc_out, n, "verdict=AGREE" as *u8) >= 0 { 44 go_puts("AGREE\n" as *u8) 45 sc_pass = sc_pass + 1 46 return 47 } 48 // Report WHICH non-agreeing verdict, not just "not AGREE" -- NO-LOG and DISAGREE are different 49 // defects with different fixes, and collapsing them would hide which one you have. 50 if go_first(sc_out, n, "verdict=DISAGREE" as *u8) >= 0 { go_puts("DISAGREE <- the record contradicts the run\n" as *u8) } 51 else { 52 if go_first(sc_out, n, "verdict=NO-LOG" as *u8) >= 0 { go_puts("NO-LOG <- invisible to every ruler\n" as *u8) } 53 else { go_puts("UNPARSED\n" as *u8) } 54 } 55 sc_fail = sc_fail + 1 56} 57 58func main(argc: i64, argv: *i64) -> i64 { 59 sc_out = sys_mmap(SC_CAP + 64) as *u8 60 sc_pass = 0 61 sc_fail = 0 62 go_puts("=== NX-CAPGRAPH SELFCHECK: does every gate in this lane have a TRUSTWORTHY record? ===\n\n" as *u8) 63 sc_one("nx_capaxes_gate" as *u8) 64 sc_one("nx_capgraph_gate" as *u8) 65 sc_one("nx_capgraph_edges_gate" as *u8) 66 sc_one("nx_capgraph_derive_gate" as *u8) 67 sc_one("nx_gateorder_gate" as *u8) 68 go_puts("\n" as *u8) 69 go_kv("agree" as *u8, sc_pass) 70 go_kv("not_agree" as *u8, sc_fail) 71 go_puts("\n" as *u8) 72 if sc_fail == 0 { 73 go_puts("SELFCHECK GREEN -- every gate's ledger matches its run.\n" as *u8) 74 return 0 75 } 76 go_puts("SELFCHECK RED -- at least one gate's record cannot be trusted. AGREE is the claim that\n" as *u8) 77 go_puts(" matters: GREEN only says the teeth passed, AGREE says the ledger can be trusted to say so.\n" as *u8) 78 return 1 79}