code wiki / _hdl_build / nx_clock_status_gate.nx

nx_clock_status_gate.nx source

↩ module page · 32 lines · 2315 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" 7 8func w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 9func 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 } 10 11func main(argc: i64, argv: *i64) -> i64 { 12 w("=== nx_clock_status_gate -- due-in + organ-twin presence ===\n" as *u8) 13 var pass: i64=0; var tot: i64=0 14 15 // T1 due_in = next_due - now (ticks until the job fires; <=0 means due now) 16 tot=tot+1 17 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) { 18 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) 19 } 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) } 20 21 // T2 twin presence: a blessed organ exists; a bogus path is flagged MISSING (an un-deployable job is surfaced) 22 tot=tot+1 23 if clk_twin_ok("_offc/nx_clock_marker.elf" as *u8)==1 { 24 if clk_twin_ok("_offc/__definitely_not_a_real_organ__.elf" as *u8)==0 { 25 pass=pass+1; w(" PASS twin check: blessed organ=OK, missing organ=flagged (not hidden)\n" as *u8) 26 } else { w(" FAIL missing organ read as present\n" as *u8) } 27 } else { w(" FAIL blessed organ read as missing (run nx_bless nx_clock_marker first)\n" as *u8) } 28 29 w("nx_clock_status_gate pass=" as *u8); wn(pass); w("/" as *u8); wn(tot) 30 if pass==tot { w(" verdict=GREEN (status shows due-in + flags un-blessed jobs honestly)\n" as *u8); sys_exit(0); return 0 } 31 w(" verdict=RED\n" as *u8); sys_exit(1); return 1 32}