code wiki / _hdl_build / nx_capreg_health_run.nx
nx_capreg_health_run.nx source
↩ module page · 22 lines · 1403 B
1// nx_capreg_health_run.nx -- the health organ's production driver: one fork = check -> heal-if-RED ->
2// recheck on the REAL registry, durable verdict line appended to knowledge/status/capreg_health.log.
3// This is the unit the Conductor pulse / gate loop / boot hook forks on a schedule -- the manual
4// crash-repair this arc ran by hand, now self-running. Run from the repo root. license_tier: ORIGINAL
5import "nx_capreg_health.nx"
6import "nx_syscalls.nx"
7
8func main() -> i64 {
9 let lp: *u8 = "/tmp/nishi_cap_registry.log" as *u8
10 let jp: *u8 = "knowledge/status/cap_registry_durable.log" as *u8
11 let out: *i64 = sys_mmap(32) as *i64
12 let green: i64 = ch_run(lp, jp, out)
13 ch_report("knowledge/status/capreg_health.log" as *u8, out, green)
14 th2_w("CAPREGHEALTH pre=" as *u8); th2_n(out[0])
15 th2_w(" healed=" as *u8); th2_n(out[1])
16 th2_w(" post=" as *u8); th2_n(out[2])
17 if green == 1 { th2_w(" verdict=GREEN\n" as *u8); sys_exit(0) }
18 th2_w(" verdict=RED\n" as *u8); sys_exit(1)
19 return 1
20}
21func th2_w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
22func th2_n(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m==0{sys_write(1,"0" as *u8,1); return 0} let t: *u8=sys_mmap(28); var k: i64=0; while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1} sys_write(1,bb,k); return 0 }