code wiki / _hdl_build / nx_capability_no_regression_check.nx

nx_capability_no_regression_check.nx source

↩ module page · 39 lines · 2763 B

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