code wiki / (root) / nx_heartbeat_monitor_gate.nx

nx_heartbeat_monitor_gate.nx

buildroot/runtime/nx_heartbeat_monitor_gate.nx

9575 B168 linesdepth 5pulls 5 transitivereach 0 importersview sourcekind gate/prooftopic heartbeat
docsdependenciesstructsconstsfunctions

about

nx_heartbeat_monitor_gate.nx -- the REFEREE for WMS-M1 (liveness / heartbeat monitor). Proves the nx_heartbeat_monitor detector (a) FLAGS exactly the crashed stream as STALLED, (b) NEGATIVE CONTROL: the two freshly-beating streams are NOT flagged -- a detector that returns STALLED for everything FAILS this lane; one that returns ALIVE for everything FAILS the core lane -- so the same scan call cross-checks both, (c) TAMPER: the stalled stream RESUMES beating (a fresh max-epoch beat) -> STALLED CLEARS -- proves the monitor tracks the LATEST beat, not a sticky first reading, (d) malformed line surfaced (count > 0, ws_ledger no-silent-skip discipline). No-false-green: GREEN requires ALL lanes. TIME IS INJECTED (NOW / THRESHOLD are gate constants; every beat is placed at a controlled epoch via hb_beat_at) -- the gate does NOT depend on real elapsed wall-clock, so it is deterministic and re-runnable. WRITE DISCIPLINE (the torn-line bug): the gate's OWN evidence record is assembled into ONE buffer and emitted with a SINGLE locked fa_appendz -- to a UNIQUE scratch path (epoch+pid) so concurrent gate runs never collide (eat our own dogfood). The row-by-row lines go to fd 1 (the terminal -- uncontended, same exemption the ws_ledger gate uses for stdout). Exit 0 GREEN, 1 RED. Sovereign: only nx_syscalls + nx_heartbeat_monitor. license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_heartbeat_monitor.nx nx_heartbeat_monitor_gate.nx

imports: nx_syscalls.nxnx_heartbeat_monitor.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_now_realtime_sec sys_mmap sys_clock_gettime_real gp sys_write gn sys_mmap ↻ sys_write ↻ sys_openat_wr sys_close hb_beat_at sys_mmap ↻ hbm_build fa_cat fa_catn sys_mmap ↻ fa_append sys_mmap ↻ sys_openat_append sys_flock fa_write_all sys_write ↻ sys_close ↻ sys_mmap ↻ hbm_scan hb_last_beat sys_mmap ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close ↻ hb_wellformed wsl_field wsl_at sys_mmap ↻ wsl_parse_int sys_mmap ↻

structs

none

consts

27const G_NOW: i64 = 1000 // gate-injected "current" epoch
28const G_THRESH: i64 = 60 // staleness threshold (gate parameter, not baked in detector)
29const G_EVCAP: i64 = 512 // bounded evidence record size

functions

32func gp(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 1: main calls 1: sys_write
33func gn(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m; sys_write(1,"-\x00" as *u8,1)}; let t: *u8=sys_mmap(28); 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; while i<k{bb[i]=t[k-1-i];i=i+1}; sys_write(1,bb,k); return 0 }
called by 1: main calls 2: sys_mmapsys_write
40func build_unique_tmp(buf: *u8, epoch: i64, pid: i64) -> i64
called by 1: main calls 2: fa_catfa_catn
51func main() -> i64