code wiki / _hdl_build / nx_capaxes_gate.nx

nx_capaxes_gate.nx source

↩ module page · 90 lines · 4203 B

1// nx_capaxes_gate.nx -- the gate for nx_capaxes_lib. NON-VACUOUS: T2b is a REVERT-DETECTING negative 2// control that turns RED if anyone changes the headline from MIN back to MEAN, and T4/T4b are a matched 3// pair so the grounding refusal cannot pass by accident. 4// license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0 5import "nx_capaxes_lib.nx" 6import "nx_gate_verdict.nx" // D001 base class: per-tooth gv_check + canonical gv_verdict LAST + journal frame 7 8func main(argc: i64, argv: *i64) -> i64 { 9 let ctr: *i64 = gv_ctr() 10 var v: *i64 = sys_mmap(128) as *i64 11 12 cax_puts("=== nx_capaxes_gate: multi-axis capability profile ===\n" as *u8) 13 14 v[0] = 800 15 v[1] = 800 16 v[2] = 800 17 v[3] = 800 18 v[4] = 800 19 v[5] = 800 20 gv_check("T1 balanced profile: headline==800" as *u8, cax_headline(v, CAX_N) == 800, ctr) 21 gv_check("T1b balanced profile: skew==0" as *u8, cax_skew(v, CAX_N) == 0, ctr) 22 gv_check("T1c balanced profile: balance==1000" as *u8, cax_balance(v, CAX_N) == CAX_FULL, ctr) 23 24 v[0] = 1000 25 v[1] = 200 26 v[2] = 100 27 v[3] = 0 28 v[4] = 0 29 v[5] = 500 30 gv_check("T2 GAMED vector: headline==0 (weakest axis, not the average)" as *u8, cax_headline(v, CAX_N) == 0, ctr) 31 gv_check("T2b NEG-CONTROL: headline != mean -- a revert to averaging makes this RED" as *u8, cax_headline(v, CAX_N) != cax_mean(v, CAX_N), ctr) 32 gv_check("T2c GAMED vector: the mean would have read 300 -- contrast recorded explicitly" as *u8, cax_mean(v, CAX_N) == 300, ctr) 33 gv_check("T2d GAMED vector: skew==1000" as *u8, cax_skew(v, CAX_N) == CAX_FULL, ctr) 34 gv_check("T2e GAMED vector: starved axis is NOT coverage" as *u8, cax_min_idx(v, CAX_N) != CAX_A_COVER, ctr) 35 gv_check("T2f GAMED vector: balance below the skew threshold" as *u8, cax_balance(v, CAX_N) < CAX_BALANCED_PERMIL, ctr) 36 37 v[0] = 900 38 v[1] = CAX_UNMEASURED 39 v[2] = 900 40 v[3] = 900 41 v[4] = 900 42 v[5] = 900 43 gv_check("T3 UNMEASURED(-1) does NOT become the minimum" as *u8, cax_headline(v, CAX_N) == 900, ctr) 44 gv_check("T3b UNMEASURED excluded from the measured count" as *u8, cax_measured(v, CAX_N) == 5, ctr) 45 46 v[0] = 1000 47 v[1] = 1000 48 v[2] = 1000 49 v[3] = 1000 50 v[4] = 1000 51 v[5] = 0 52 gv_check("T4 L2 grounding==0 => NOT grounded even with every other axis perfect" as *u8, cax_grounded(v, CAX_N) == 0, ctr) 53 gv_check("T4b L2 grounding==0 => cax_report refuses with exit 3" as *u8, cax_report(v, CAX_N, 1) == 3, ctr) 54 v[5] = 1 55 gv_check("T4c L2 grounding==1 => grounded (matched neg-control for T4)" as *u8, cax_grounded(v, CAX_N) == 1, ctr) 56 57 v[0] = 1000 58 v[1] = 200 59 v[2] = 1000 60 v[3] = 1000 61 v[4] = 1000 62 v[5] = 1000 63 let starved_rock: i64 = cax_rock(v, CAX_N, 10) 64 v[1] = 1000 65 let balanced_rock: i64 = cax_rock(v, CAX_N, 10) 66 gv_check("T5 a starved capability outranks a balanced one as a rock" as *u8, starved_rock > balanced_rock, ctr) 67 gv_check("T5b a fully-balanced-at-1000 capability has rock_score 0" as *u8, balanced_rock == 0, ctr) 68 69 v[0] = 1000 70 v[1] = 100 71 v[2] = 100 72 v[3] = 0 73 v[4] = 100 74 v[5] = 1 75 cax_puts("\n-- worked example: the workermesh shape (cov 1000, no executable evidence) --\n" as *u8) 76 let rc: i64 = cax_report(v, CAX_N, 10) 77 gv_check("T6 workermesh shape scores 0, not 550 -- coverage cannot hide evidence" as *u8, cax_headline(v, CAX_N) == 0, ctr) 78 gv_check("T6b workermesh shape is reported SKEWED" as *u8, cax_balance(v, CAX_N) < CAX_BALANCED_PERMIL, ctr) 79 80 cax_gate_log("knowledge/status/capaxes_gate.log" as *u8, "CAPAXESGATE" as *u8, ctr[0], ctr[1]) 81 cax_puts("\nCAPAXES-GATE " as *u8) 82 cax_puti(ctr[0]) 83 cax_puts("/" as *u8) 84 cax_puti(ctr[1]) 85 if ctr[0] == ctr[1] { cax_puts(" GREEN\n" as *u8) } else { cax_puts(" RED\n" as *u8) } 86 // The rich CAPAXES-GATE line above is the domain dialect and STAYS; the BASE CLASS emits the 87 // canonical `passed N/M verdict=` line LAST and records the harness.jrnl frame (D001 migration 88 // 2026-08-17 -- this gate previously read as pass=0/0 in the census while printing 18/18 GREEN). 89 return gv_verdict("CAPAXES-GATE" as *u8, ctr, "" as *u8) 90}