code wiki / _hdl_build / nx_wflow_cli_gate.nx

nx_wflow_cli_gate.nx source

↩ module page · 73 lines · 3890 B

1// nx_wflow_cli_gate.nx -- gate for the file-driven production path (wf_lines_load + wf_fire_files): 2// definitions as DATA FILES, validated whole before anything runs. THE PM COMPOSITION PROOF: firing 3// `venue-booked` runs the REAL vizsla docgen organ (agreement .docx built + filed on the doc store) 4// then notify -> run DONE, all through the demo data files a human can edit. ONE fork. 5// Neg-controls: missing file loud -1; a bad ruleset file (unknown action) refuses whole; durable dedup 6// on refire. license_tier: ORIGINAL expect_exit: 0 7import "nx_wflow_engine.nx" 8import "nx_gate_verdict.nx" 9 10func cgl_n(led: *u8, ridtok: *u8, st: *u8) -> i64 { 11 let szp: *i64 = sys_mmap(8) as *i64 12 let b: *u8 = wf_readall(led, szp) 13 if (b as i64) == 0 { return 0 - 1 } 14 return wf_lines_with2(b, szp[0], ridtok, st) 15} 16 17func main() -> i64 { 18 p("=== NX-WFLOW-CLI GATE (definitions as data files; PM composition: venue-booked -> real docgen -> notify) ===\n" as *u8) 19 var ok: i64 = 1 20 let now: i64 = wf_now() 21 let led: *u8 = sys_mmap(128) 22 var lo: i64 = 0 23 lo = wf_cat(led, lo, "/tmp/wfcli_" as *u8) 24 lo = wf_catn(led, lo, now) 25 lo = wf_cat(led, lo, ".log" as *u8) 26 led[lo] = 0 as u8 27 28 // T1 file loaders: demo files parse (comments skipped), missing file refuses loud 29 let arr: *i64 = sys_mmap(8 * 64) as *i64 30 let nf: i64 = wf_lines_load("knowledge/wflow/demo.flows" as *u8, arr, 64) 31 let nst: i64 = wf_lines_load("knowledge/wflow/demo.steps" as *u8, arr, 64) 32 let miss: i64 = wf_lines_load("/tmp/wflow_no_such_defs_file" as *u8, arr, 64) 33 p(" T1 flows=" as *u8); pn(nf); p(" steps=" as *u8); pn(nst); p(" missing=" as *u8); pn(miss); p("\n" as *u8) 34 if nf != 1 { ok = 0 } 35 if nst != 2 { ok = 0 } 36 if miss != (0 - 1) { ok = 0 } 37 38 // T2 bad definitions file refuses WHOLE (unknown action row) 39 let badp: *u8 = sys_mmap(128) 40 var bo: i64 = 0 41 bo = wf_cat(badp, bo, "/tmp/wfcli_bad_" as *u8) 42 bo = wf_catn(badp, bo, now) 43 badp[bo] = 0 as u8 44 wf_append(badp, "z1|1|explode|-|boom|1\n" as *u8) 45 let rb: i64 = wf_fire_files("knowledge/wflow/demo.flows" as *u8, badp, led, "-" as *u8, "venue-booked~id=B1" as *u8) 46 p(" T2 badDefs rc=" as *u8); pn(rb); p("\n" as *u8) 47 if rb != (0 - 1) { ok = 0 } 48 49 // T3 THE PM COMPOSITION: fire venue-booked through the DATA FILES -> real docgen organ -> notify -> DONE 50 let rc: i64 = wf_fire_files("knowledge/wflow/demo.flows" as *u8, "knowledge/wflow/demo.steps" as *u8, led, "knowledge/wflow/connectors.conf" as *u8, "venue-booked~venue=pavilion~id=D1" as *u8) 51 let d1: i64 = cgl_n(led, " rid=D1.pm1 " as *u8, "status=DONE" as *u8) 52 let o1: i64 = cgl_n(led, " rid=D1.pm1 " as *u8, "status=OK" as *u8) 53 p(" T3 fire started=" as *u8); pn(rc); p(" done=" as *u8); pn(d1); p(" okSteps=" as *u8); pn(o1); p("\n" as *u8) 54 if rc != 1 { ok = 0 } 55 if d1 != 1 { ok = 0 } 56 if o1 != 2 { ok = 0 } 57 58 // T4 durable dedup through the file path 59 let r2: i64 = wf_fire_files("knowledge/wflow/demo.flows" as *u8, "knowledge/wflow/demo.steps" as *u8, led, "knowledge/wflow/connectors.conf" as *u8, "venue-booked~venue=pavilion~id=D1" as *u8) 60 p(" T4 refire rc=" as *u8); pn(r2); p("\n" as *u8) 61 if r2 != (0 - 100) { ok = 0 } 62 63 p("NX-WFLOW-CLI-GATE ledger=" as *u8); p(led); p(" forks=1 " as *u8) 64 // MIGRATED onto nx_gate_verdict by nx_gate_dry_apply (D001, minimal form): every check 65 // row above is untouched, so the PASS/FAIL vector cannot change; only the hand-rolled 66 // verdict emission is replaced by the ONE shared base class. Proven by nx_gate_migrate verify. 67 let ctr__dry: *i64 = gv_ctr() 68 ctr__dry[0] = ok 69 ctr__dry[1] = 1 70 let rc__dry: i64 = gv_verdict("WFLOW-CLI-GATE" as *u8, ctr__dry, "teeth unchanged; verdict emission migrated onto the shared base class" as *u8) 71 sys_exit(rc__dry) 72 return rc__dry 73}