code wiki / _hdl_build / nx_gate_loop.nx
nx_gate_loop.nx
buildroot/runtime/_hdl_build/nx_gate_loop.nx
about
nx_gate_loop.nx -- TEAM-OWNED loop daemon that runs nx_gate_sentinel on a
cadence (GAME arc step G5: "wire the sentinel into the loop cadence so
grades refresh with no human/LLM trigger"). Closes the loop-monitor
lesson from [[project-self-running-loop-governed-ingest-2026-06-05]]: a
loop must have a MONITORED OUTPUT CHANNEL -- every beat appends one line
to /tmp/nishi_game_gate_loop.log, and the sentinel itself escalates
regressions to the PM review log, so a DRY or STALLED loop is visible in
the logs, not silent.
Usage (from nxc2 repo root):
nx_gate_loop.elf # production: 30-min beat, forever, daemonized
nx_gate_loop.elf <beat_ms> # custom beat, forever, daemonized
nx_gate_loop.elf <beat_ms> <n_beats> # TEST MODE: n beats, FOREGROUND (no daemonize)
Daemonized = fork + setsid; the launcher returns immediately and the loop
survives the launching terminal (pattern from the sites-daemon arc).
license_tier: ORIGINAL
dependencies 1 imports · 0 importers
imports: nx_syscalls.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
| 20 | const GL_DEFAULT_BEAT_MS: i64 = 1800000 // 30 min |
| 21 | const GL_LOG: i64 = 0 |
functions
| 23 | func gl_cat(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { dst[off+i] = s[i]; i = i + 1 } return off + i } |
| 24 | func gl_cat_n(dst: *u8, off: i64, v: i64) -> i64 |
| 38 | func gl_atoi(s: *u8) -> i64 called by 1: main |
| 67 | func gl_getpid() -> i64 |
| 88 | func gl_pid_alive(pid: i64) -> i64 |
| 102 | func gl_read_pidfile(path: *u8) -> i64 |
| 121 | func gl_acquire_lock() -> i64 |
| 138 | func gl_run_sentinel() -> i64 |
| 157 | func gl_beat_line(beat: i64, rc: i64) -> i64 called by 1: gl_loop calls 7: sys_openat_appendsys_mmapgl_catgl_cat_nsys_now_realtime_secsys_write+1 |
| 178 | func gl_run_journey() -> i64 |
| 200 | func gl_loop(beat_ms: i64, n_beats: i64) -> i64 called by 1: main calls 10: gl_run_sentinelgl_beat_linegl_run_journeysys_openat_appendsys_mmapgl_cat+4 |
| 227 | func main(argc: i64, argv: *i64) -> i64 |