code wiki / _hdl_build / nx_capability_no_regression_check.nx
nx_capability_no_regression_check.nx source
↩ module page · 38 lines · 2625 B
1import "nx_gate_gn.nx"
2import "nx_gate_base.nx"
3// nx_capability_no_regression_check.nx -- the ACTIVE standing no-regression guard (run it / fire it as a
4// conductor pulse). Reads the LIVE capability-audit metrics (perfect=, collisions=) and checks them against
5// the persisted ratchet baseline (nr_check: perfect must not drop below the floor, collisions must not rise
6// above the ceiling) AND verifies the merge-gates stay GREEN (no functionality lost). GREEN = no regression;
7// RED = a capability was un-climbed, sprawl rose, or a consolidation dropped a capability. Unlike the _gate
8// (synthetic proof), this NEVER resets the baseline -- it only ratchets gains in + flags any erosion.
9// Run `nx_capability_shape_audit` first to refresh the log. license_tier: ORIGINAL expect_exit: 0
10import "nx_capability_no_regression.nx"
11import "nx_syscalls.nx"
12
13func grow(name: *u8, ok: i64) -> i64 { if ok==1 { gw(" PASS " as *u8) } else { gw(" FAIL " as *u8) } gw(name); gw("
14" as *u8); return ok }
15
16func main() -> i64 {
17 gw("=== nx_capability_no_regression_check: standing guard on the capability climb ===\n" as *u8)
18 let p: i64=nr_metric("perfect=\x00" as *u8); let c: i64=nr_metric("collisions=\x00" as *u8)
19 if p < 0 { gw(" audit not run yet -- run nx_capability_shape_audit first.\n" as *u8); sys_exit(1); return 1 }
20 if c < 0 { gw(" audit log missing collisions -- re-run nx_capability_shape_audit.\n" as *u8); sys_exit(1); return 1 }
21
22 let reg: *i64=sys_mmap(16) as *i64
23 let counts_ok: i64=nr_check(p, c, reg) // ratchets gains in; flags any erosion vs the baseline
24 let gates: i64=nr_gates_green() // no functionality lost in any consolidation
25
26 gw(" LIVE perfect=" as *u8); gn(p); gw(" collisions=" as *u8); gn(c)
27 gw(" | counts_ok=" as *u8); gn(counts_ok); gw(" reg_bitmask=" as *u8); gn(reg[0]); gw(" (bit0=perfect-drop bit1=collision-rise)" as *u8)
28 gw(" | merge_gates_green=" as *u8); gn(gates); gw("\n" as *u8)
29
30 if counts_ok==1 { if gates==1 {
31 gw("CAP-NO-REGRESSION=GREEN -- nothing un-climbed, no new sprawl, no functionality lost. The climb holds.\n" as *u8)
32 sys_exit(0); return 0
33 } }
34 if reg[0] & 1 == 1 { gw(" REGRESSION: PERFECT count dropped below the floor (a frontier object was un-climbed).\n" as *u8) }
35 if reg[0] & 2 == 2 { gw(" REGRESSION: COLLISIONS rose above the ceiling (new sprawl introduced).\n" as *u8) }
36 if gates != 1 { gw(" REGRESSION: a merge-verification gate went RED (a consolidation dropped a capability).\n" as *u8) }
37 gw("CAP-NO-REGRESSION=RED\n" as *u8); sys_exit(1); return 1
38}