code wiki / _hdl_build / nx_capaxes_gate.nx
nx_capaxes_gate.nx source
↩ module page · 104 lines · 3989 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"
6
7func cg_t(name: *u8, cond: i64, ctr: *i64) {
8 if cond == 1 {
9 cax_puts(" ok " as *u8)
10 ctr[0] = ctr[0] + 1
11 } else {
12 cax_puts(" FAIL " as *u8)
13 }
14 cax_puts(name)
15 cax_puts("\n" as *u8)
16 ctr[1] = ctr[1] + 1
17}
18
19func main(argc: i64, argv: *i64) -> i64 {
20 var ctr: *i64 = sys_mmap(64) as *i64
21 ctr[0] = 0
22 ctr[1] = 0
23 var v: *i64 = sys_mmap(128) as *i64
24
25 cax_puts("=== nx_capaxes_gate: multi-axis capability profile ===\n" as *u8)
26
27 v[0] = 800
28 v[1] = 800
29 v[2] = 800
30 v[3] = 800
31 v[4] = 800
32 v[5] = 800
33 cg_t("T1 balanced profile: headline==800" as *u8, cax_headline(v, CAX_N) == 800, ctr)
34 cg_t("T1b balanced profile: skew==0" as *u8, cax_skew(v, CAX_N) == 0, ctr)
35 cg_t("T1c balanced profile: balance==1000" as *u8, cax_balance(v, CAX_N) == CAX_FULL, ctr)
36
37 v[0] = 1000
38 v[1] = 200
39 v[2] = 100
40 v[3] = 0
41 v[4] = 0
42 v[5] = 500
43 cg_t("T2 GAMED vector: headline==0 (weakest axis, not the average)" as *u8, cax_headline(v, CAX_N) == 0, ctr)
44 cg_t("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)
45 cg_t("T2c GAMED vector: the mean would have read 300 -- contrast recorded explicitly" as *u8, cax_mean(v, CAX_N) == 300, ctr)
46 cg_t("T2d GAMED vector: skew==1000" as *u8, cax_skew(v, CAX_N) == CAX_FULL, ctr)
47 cg_t("T2e GAMED vector: starved axis is NOT coverage" as *u8, cax_min_idx(v, CAX_N) != CAX_A_COVER, ctr)
48 cg_t("T2f GAMED vector: balance below the skew threshold" as *u8, cax_balance(v, CAX_N) < CAX_BALANCED_PERMIL, ctr)
49
50 v[0] = 900
51 v[1] = CAX_UNMEASURED
52 v[2] = 900
53 v[3] = 900
54 v[4] = 900
55 v[5] = 900
56 cg_t("T3 UNMEASURED(-1) does NOT become the minimum" as *u8, cax_headline(v, CAX_N) == 900, ctr)
57 cg_t("T3b UNMEASURED excluded from the measured count" as *u8, cax_measured(v, CAX_N) == 5, ctr)
58
59 v[0] = 1000
60 v[1] = 1000
61 v[2] = 1000
62 v[3] = 1000
63 v[4] = 1000
64 v[5] = 0
65 cg_t("T4 L2 grounding==0 => NOT grounded even with every other axis perfect" as *u8, cax_grounded(v, CAX_N) == 0, ctr)
66 cg_t("T4b L2 grounding==0 => cax_report refuses with exit 3" as *u8, cax_report(v, CAX_N, 1) == 3, ctr)
67 v[5] = 1
68 cg_t("T4c L2 grounding==1 => grounded (matched neg-control for T4)" as *u8, cax_grounded(v, CAX_N) == 1, ctr)
69
70 v[0] = 1000
71 v[1] = 200
72 v[2] = 1000
73 v[3] = 1000
74 v[4] = 1000
75 v[5] = 1000
76 let starved_rock: i64 = cax_rock(v, CAX_N, 10)
77 v[1] = 1000
78 let balanced_rock: i64 = cax_rock(v, CAX_N, 10)
79 cg_t("T5 a starved capability outranks a balanced one as a rock" as *u8, starved_rock > balanced_rock, ctr)
80 cg_t("T5b a fully-balanced-at-1000 capability has rock_score 0" as *u8, balanced_rock == 0, ctr)
81
82 v[0] = 1000
83 v[1] = 100
84 v[2] = 100
85 v[3] = 0
86 v[4] = 100
87 v[5] = 1
88 cax_puts("\n-- worked example: the workermesh shape (cov 1000, no executable evidence) --\n" as *u8)
89 let rc: i64 = cax_report(v, CAX_N, 10)
90 cg_t("T6 workermesh shape scores 0, not 550 -- coverage cannot hide evidence" as *u8, cax_headline(v, CAX_N) == 0, ctr)
91 cg_t("T6b workermesh shape is reported SKEWED" as *u8, cax_balance(v, CAX_N) < CAX_BALANCED_PERMIL, ctr)
92
93 cax_gate_log("knowledge/status/capaxes_gate.log" as *u8, "CAPAXESGATE" as *u8, ctr[0], ctr[1])
94 cax_puts("\nCAPAXES-GATE " as *u8)
95 cax_puti(ctr[0])
96 cax_puts("/" as *u8)
97 cax_puti(ctr[1])
98 if ctr[0] == ctr[1] {
99 cax_puts(" GREEN\n" as *u8)
100 return 0
101 }
102 cax_puts(" RED\n" as *u8)
103 return 1
104}