nx_heartbeat_monitor_gate.nx
buildroot/runtime/nx_heartbeat_monitor_gate.nx
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
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
structs
| none |
consts
| 27 | const G_NOW: i64 = 1000 // gate-injected "current" epoch |
| 28 | const G_THRESH: i64 = 60 // staleness threshold (gate parameter, not baked in detector) |
| 29 | const G_EVCAP: i64 = 512 // bounded evidence record size |
functions
| 32 | func gp(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 33 | func 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 } |
| 40 | func build_unique_tmp(buf: *u8, epoch: i64, pid: i64) -> i64 |
| 51 | func main() -> i64 |