code wiki / _hdl_build / deployclass_gate.nx
deployclass_gate.nx source
↩ module page · 30 lines · 1636 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 MIGRATION 2026-08-01 (D001 / law L009): verdict emission INHERITS nx_gate_verdict.
5// The hand-rolled print helpers and hand-built verdict line are gone; the domain metadata they
6// carried (all_ok, fail_at, steps) is preserved in the gv_verdict note per rule 25.
7// Accepted by nx_gate_migrate as an ENRICHMENT: the original enumerated NO checks, and the base
8// class cannot emit GREEN with zero checks, so enumerating them is the only expressible migration.
9import "nx_syscalls.nx"
10import "nx_gate_verdict.nx"
11func deployclass_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 }
12func main() -> i64 {
13 let ctr: *i64 = gv_ctr()
14 gv_head("deployclass_gate -- fail-fast pipeline sequencer KAT" as *u8)
15 let a: *i64 = sys_mmap(8 * 4) as *i64
16 var i: i64 = 0
17 while i < 4 { a[i] = 0; i = i + 1 }
18 let all_ok: i64 = deployclass_gate_run(a, 4)
19 a[2] = 1
20 let fail_at: i64 = deployclass_gate_run(a, 4)
21 var t1: i64 = 0
22 if all_ok == 0 { t1 = 1 }
23 gv_check("T1 all-clean pipeline returns 0" as *u8, t1, ctr)
24 var t2: i64 = 0
25 if fail_at == 3 { t2 = 1 }
26 gv_check("T2 first failing stage reported 1-based abort point" as *u8, t2, ctr)
27 let rc: i64 = gv_verdict("PIPEGATE" as *u8, ctr, "all_ok 0 fail_at 3 steps 4" as *u8)
28 sys_exit(rc)
29 return rc
30}