code wiki / (root) / nx_workflow_gate.nx

nx_workflow_gate.nx source

↩ module page · 50 lines · 2775 B

1// nx_workflow_gate.nx -- gates the consolidated workflow tool on a REAL fixture WMS store (authored via 2// the canonical ss_* + the FIXED ws_seg_next): board walks the ws:ids index with correct per-state 3// totals; show returns labeled fields with found/tombstoned/absent discriminated honestly. 4// Runner must clean /tmp/wfgate first. Exit 0 only on all-PASS. license_tier: ORIGINAL expect_exit: 0 5import "nx_workflow_lib.nx" 6 7const GATE_CHECKS: i64 = 5 8const DIR_MODE: i64 = 0x1ed // 0755 9const FIX_WS: i64 = 2 // workstreams authored (alpha ACTIVE, beta BLOCKED) 10const TOMB_KIND: i64 = 2 // seg-store tombstone record kind 11 12func wg_check(name: *u8, ok: i64, pass: *i64) -> i64 { 13 wf_puts("T " as *u8); wf_puts(name); wf_puts(" -> " as *u8) 14 if ok == 1 { wf_puts("PASS\n" as *u8); pass[0] = pass[0] + 1 } else { wf_puts("FAIL\n" as *u8) } 15 return 0 16} 17func wg_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } 18func wg_put(prefix: *u8, key: *u8, val: *u8, kind: i64) -> i64 { 19 let w: *i64 = ss_begin() 20 ss_add(w, kind, key, val, wg_len(val)) 21 return ss_commit(prefix, w, ws_seg_next(prefix)) 22} 23 24func main(argc: i64, argv: *i64) -> i64 { 25 let pass: *i64 = sys_mmap(16) as *i64 26 pass[0] = 0 27 sys_mkdir("/tmp/wfgate" as *u8, DIR_MODE) 28 let P: *u8 = "/tmp/wfgate/ws-" as *u8 29 // author the fixture registry per the WS record schema (TAB-separated fields) 30 wg_put(P, "ws:ids" as *u8, "alpha\tbeta" as *u8, 1) 31 wg_put(P, "ws:alpha" as *u8, "alpha\tcompiler\tACTIVE\t1784200000\tproject-alpha.md\truntime/nx_alpha.nx\t-" as *u8, 1) 32 wg_put(P, "ws:beta" as *u8, "beta\tmedia\tBLOCKED\t1784100000\t-\t-\talpha" as *u8, 1) 33 wg_put(P, "ws:gone" as *u8, "xx" as *u8, TOMB_KIND) // tombstoned (retired workstream) 34 35 // T1 board walks the index and finds both workstreams 36 wg_check("board-counts" as *u8, (wf_board(P) == FIX_WS) as i64, pass) 37 // T2 show returns a FOUND record 38 wg_check("show-found" as *u8, (wf_show(P, "alpha" as *u8) == 1) as i64, pass) 39 // T3 absent id is the store's honest -1 (neg-control) 40 wg_check("show-absent" as *u8, (wf_show(P, "nope" as *u8) == (0 - 1)) as i64, pass) 41 // T4 tombstoned (retired) id is distinct from absent 42 wg_check("show-tombstoned-distinct" as *u8, (wf_show(P, "gone" as *u8) == 0) as i64, pass) 43 // T5 the fixed ws_seg_next is UNCAPPED max+1 (1-based: 4 commits -> next is 5) 44 wg_check("ws-seg-next-uncapped" as *u8, (ws_seg_next(P) == GATE_CHECKS) as i64, pass) 45 46 wf_puts("WORKFLOW-GATE pass=" as *u8); wf_putn(pass[0]); wf_puts("/" as *u8); wf_putn(GATE_CHECKS); wf_puts(" verdict=" as *u8) 47 if pass[0] == GATE_CHECKS { wf_puts("GREEN\n" as *u8); return 0 } 48 wf_puts("RED\n" as *u8) 49 return 1 50}