code wiki / _hdl_build / nx_ecomat_target_emit_gate.nx
nx_ecomat_target_emit_gate.nx source
↩ module page · 41 lines · 2605 B
1// nx_ecomat_target_emit_gate.nx -- proves the maturity gaps become work CORRECTLY from the NATIVE store,
2// without touching the real queue. Seeds a test store; NEGATIVE CONTROLS: T2/T3 idempotency (already-queued
3// ids do not re-emit), T4 the cur<bar guard (an all-at-bar store emits 0). license_tier: ORIGINAL
4import "nx_ecomat_lib.nx"
5
6func main() -> i64 {
7 var fails: i64 = 0
8 // test store: alpha(cur2<bar4), beta(cur1<bar4), gamma(cur4>=bar4 -> no target)
9 let w: *i64 = ss_begin()
10 ec_seed_one(w, 0, 0, 1, 2, 4, 9, 1, "alpha" as *u8, "b" as *u8, "n" as *u8)
11 ec_seed_one(w, 1, 0, 1, 1, 4, 8, 1, "beta" as *u8, "b" as *u8, "n" as *u8)
12 ec_seed_one(w, 2, 0, 1, 4, 4, 7, 1, "gamma" as *u8, "b" as *u8, "n" as *u8)
13 ss_commit("/tmp/ecomat_et" as *u8, w, sys_now_realtime_sec())
14 let empty: *u8 = "" as *u8
15 // T1: empty queue -> 2 (alpha,beta below bar; gamma at bar -> none)
16 let n1: i64 = et_count_targets_store("/tmp/ecomat_et" as *u8, empty, 0)
17 _p("T1 fresh queue : targets=" as *u8); _fn(1, n1); _p(" (expect 2)\n" as *u8)
18 if n1 != 2 { fails = fails + 1 }
19 // T2 idempotency: queue holds GEN-MAT-alpha + GEN-MAT-beta -> 0
20 let q2: *u8 = "GEN-MAT-alpha row\nGEN-MAT-beta row\n" as *u8
21 let n2: i64 = et_count_targets_store("/tmp/ecomat_et" as *u8, q2, el_len(q2))
22 _p("T2 both queued : targets=" as *u8); _fn(1, n2); _p(" (expect 0: idempotent)\n" as *u8)
23 if n2 != 0 { fails = fails + 1 }
24 // T3 partial: queue holds only GEN-MAT-alpha -> 1 (beta still emits)
25 let q3: *u8 = "GEN-MAT-alpha row\n" as *u8
26 let n3: i64 = et_count_targets_store("/tmp/ecomat_et" as *u8, q3, el_len(q3))
27 _p("T3 one queued : targets=" as *u8); _fn(1, n3); _p(" (expect 1)\n" as *u8)
28 if n3 != 1 { fails = fails + 1 }
29 // T4 NEG-CONTROL: an all-at-bar store -> 0 (the cur<bar guard is load-bearing)
30 let w2: *i64 = ss_begin()
31 ec_seed_one(w2, 0, 0, 1, 4, 4, 9, 1, "alpha" as *u8, "b" as *u8, "n" as *u8)
32 ec_seed_one(w2, 1, 0, 1, 5, 4, 8, 1, "beta" as *u8, "b" as *u8, "n" as *u8)
33 ss_commit("/tmp/ecomat_et2" as *u8, w2, sys_now_realtime_sec())
34 let n4: i64 = et_count_targets_store("/tmp/ecomat_et2" as *u8, empty, 0)
35 _p("T4 neg-ctrl atbar: targets=" as *u8); _fn(1, n4); _p(" (expect 0)\n" as *u8)
36 if n4 != 0 { fails = fails + 1 }
37 if fails == 0 { _p("GATE nx_ecomat_target_emit verdict=GREEN pass=4/4 (native store; idempotency + below-bar guard)\n" as *u8); sys_exit(0); return 0 }
38 _p("GATE nx_ecomat_target_emit verdict=RED fails=" as *u8); _fn(1, fails); _p("\n" as *u8)
39 sys_exit(1)
40 return 1
41}