code wiki / _hdl_build / nx_clock_status_gate.nx
nx_clock_status_gate.nx source
↩ module page · 40 lines · 2698 B
1// nx_clock_status_gate.nx -- proves the clock STATUS logic (the consolidation payoff: one view of every periodic
2// job). clk_due_in = ticks until a job fires (<=0 = due now); clk_twin_ok = whether the job's organ is actually
3// blessed/present (so an un-deployable job is surfaced, never hidden). Liar-killed: a real blessed organ reads OK,
4// a bogus path reads MISSING; due-in is exact. Harness-run, sovereign, no shell. license_tier: ORIGINAL expect_exit: 0
5import "nx_clock_sched.nx"
6import "nx_syscalls.nx"
7import "nx_gate_verdict.nx"
8
9func w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
10func wn(v: i64) -> i64 { var m: i64=v; if m<0{w("-" as *u8);m=0-m} let t:*u8=sys_mmap(24); var k:i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i:i64=0; let o:*u8=sys_mmap(24); while i<k{o[i]=t[k-1-i];i=i+1} sys_write(1,o,k); return 0 }
11
12func main(argc: i64, argv: *i64) -> i64 {
13 w("=== nx_clock_status_gate -- due-in + organ-twin presence ===\n" as *u8)
14 var pass: i64=0; var tot: i64=0
15
16 // T1 due_in = next_due - now (ticks until the job fires; <=0 means due now)
17 tot=tot+1
18 if clk_due_in(3,1)==2 { if clk_due_in(3,3)==0 { if clk_due_in(5,1)==4 { if clk_due_in(2,5)== (0-3) {
19 pass=pass+1; w(" PASS due_in exact: 3@1=2, 3@3=0(DUE), 5@1=4, 2@5=-3(overdue)\n" as *u8)
20 } else { w(" FAIL overdue\n" as *u8) } } else { w(" FAIL 5@1\n" as *u8) } } else { w(" FAIL 3@3\n" as *u8) } } else { w(" FAIL 3@1\n" as *u8) }
21
22 // T2 twin presence: a blessed organ exists; a bogus path is flagged MISSING (an un-deployable job is surfaced)
23 tot=tot+1
24 if clk_twin_ok("_offc/nx_clock_marker.elf" as *u8)==1 {
25 if clk_twin_ok("_offc/__definitely_not_a_real_organ__.elf" as *u8)==0 {
26 pass=pass+1; w(" PASS twin check: blessed organ=OK, missing organ=flagged (not hidden)\n" as *u8)
27 } else { w(" FAIL missing organ read as present\n" as *u8) }
28 } else { w(" FAIL blessed organ read as missing (run nx_bless nx_clock_marker first)\n" as *u8) }
29
30 w("nx_clock_status_gate pass=" as *u8); wn(pass); w("/" as *u8); wn(tot)
31 // MIGRATED onto nx_gate_verdict by nx_gate_dry_apply (D001, minimal form): every check
32 // row above is untouched, so the PASS/FAIL vector cannot change; only the hand-rolled
33 // verdict emission is replaced by the ONE shared base class. Proven by nx_gate_migrate verify.
34 let ctr__dry: *i64 = gv_ctr()
35 ctr__dry[0] = pass
36 ctr__dry[1] = tot
37 let rc__dry: i64 = gv_verdict("CLOCK-STATUS-GATE" as *u8, ctr__dry, "status shows due-in + flags un-blessed jobs honestly)" as *u8)
38 sys_exit(rc__dry)
39 return rc__dry
40}