code wiki / _hdl_build / composedry_probe_gate.nx

composedry_probe_gate.nx source

↩ module page · 31 lines · 1706 B

1// AUTHORED BY nx_compose_builder (X-AUTH-EXT-001 composition shape) from a DATA spec. 2// Fail-fast pipeline sequencer: run stages in order; 0 if all exit 0, else 1-based index 3// of the first failure (the abort/rollback point). KAT computed from the step count. 4// DRY (2026-07-25, D001 / law L009+L010): verdict emission INHERITS nx_gate_verdict. 5// This generator used to stamp its own _p/_pn print helpers and a hand-rolled verdict 6// line into every organ it authored, so each generated gate landed as a FRESH L009 7// custom-verdict breach AND a fresh L010 helperdup breach -- which is why both laws 8// were RISING while hand-migration ate the backlog. Generated gates are now base-class 9// adopters BY CONSTRUCTION; the generator cannot emit a non-DRY gate. 10import "nx_syscalls.nx" 11import "nx_gate_verdict.nx" 12func composedry_probe_gate_run(codes: *i64, n: i64) -> i64 { var i: i64 = 0; while i < n { if codes[i] != 0 { return i + 1 } i = i + 1 } return 0 } 13func main() -> i64 { 14 let ctr: *i64 = gv_ctr() 15 gv_head("composedry_probe_gate -- fail-fast pipeline sequencer KAT" as *u8) 16 let a: *i64 = sys_mmap(8 * 4) as *i64 17 var i: i64 = 0 18 while i < 4 { a[i] = 0; i = i + 1 } 19 let all_ok: i64 = composedry_probe_gate_run(a, 4) 20 a[2] = 1 21 let fail_at: i64 = composedry_probe_gate_run(a, 4) 22 var t1: i64 = 0 23 if all_ok == 0 { t1 = 1 } 24 gv_check("T1 all-clean pipeline returns 0" as *u8, t1, ctr) 25 var t2: i64 = 0 26 if fail_at == 3 { t2 = 1 } 27 gv_check("T2 first failing stage reported 1-based (abort point)" as *u8, t2, ctr) 28 let rc: i64 = gv_verdict("composedry_probe_gate" as *u8, ctr, "fail-fast sequencer, 4 steps" as *u8) 29 sys_exit(rc) 30 return rc 31}