code wiki / (root) / nx_docket_gate.nx

nx_docket_gate.nx source

↩ module page · 45 lines · 2518 B

1// nx_docket_gate.nx -- INDEPENDENT gate for the docketing engine (imports the SAME shipped 2// nx_docket_lib = atlas validation edge). Tests: calendar compute, URCP Rule 6 weekend roll, 3// business-day mode, data-driven read, unknown-rule, weekend detection, no-double-roll. 4// SELF-PUBLISHES knowledge/status/office_docket_gate.log. license_tier: ORIGINAL 5 6import "nx_docket_lib.nx" 7 8func main() -> i64 { 9 var pass: i64 = 0 10 let p: *u8 = "/tmp/nx_docket_gate-" as *u8 11 dk_rule_put(p, "answer" as *u8, 21, 0, "answer" as *u8) 12 dk_rule_put(p, "appeal" as *u8, 30, 0, "appeal" as *u8) 13 dk_rule_put(p, "SOL" as *u8, 1460, 0, "statute" as *u8) 14 dk_rule_put(p, "biz5" as *u8, 5, 1, "5 biz" as *u8) 15 let t: i64 = 100 16 // T1 calendar compute (100+21=121, a Wednesday, no roll) 17 if dk_compute(p, "answer" as *u8, t) == 121 { pass = pass + 1 } 18 // T2 URCP Rule 6: 100+1460=1560 is a Sunday -> rolls to Monday 1561 19 if dk_is_weekend(1560) == 1 { if dk_compute(p, "SOL" as *u8, t) == 1561 { pass = pass + 1 } } 20 // T3 business-day mode: 5 biz days from Wed(100) skips the weekend -> 107 21 if dk_compute(p, "biz5" as *u8, t) == 107 { pass = pass + 1 } 22 // T4 data-driven: the rule's days are READ from the store (not hardcoded) 23 let md: *i64 = sys_mmap(16) as *i64 24 if dk_rule_days(p, "answer" as *u8, md) == 21 { pass = pass + 1 } 25 // T5 unknown rule -> -1 (fail-closed, never a silent wrong date) 26 if dk_compute(p, "nonexistent" as *u8, t) < 0 { pass = pass + 1 } 27 // T6 weekend detection across the week (Mon..Sun) 28 if dk_is_weekend(0) == 0 { if dk_is_weekend(4) == 0 { if dk_is_weekend(5) == 1 { if dk_is_weekend(6) == 1 { pass = pass + 1 } } } } 29 // T7 no-double-roll: appeal 100+30=130 is a Friday -> stays 130 (weekday not moved) 30 if dk_compute(p, "appeal" as *u8, t) == 130 { pass = pass + 1 } 31 32 let out: *u8 = sys_mmap(512) 33 var o: i64 = 0 34 o = mt_catcopy(out, o, "OFFICE-DOCKET-GATE tests=7 pass=" as *u8) 35 o = mt_catn(out, o, pass) 36 o = mt_catcopy(out, o, " calendar+rule6-roll+business-days+data-driven+unknown-failclosed+weekend-detect+no-double-roll VERDICT=" as *u8) 37 if pass == 7 { o = mt_catcopy(out, o, "GREEN" as *u8) } 38 if pass != 7 { o = mt_catcopy(out, o, "RED" as *u8) } 39 out[o] = 10 as u8 40 o = o + 1 41 ss_writefile("knowledge/status/office_docket_gate.log" as *u8, out, o) 42 sys_write(1, out, o) 43 if pass == 7 { return __syscall(93, 0, 0, 0, 0, 0, 0) } 44 return __syscall(93, 100 + pass, 0, 0, 0, 0, 0) 45}