code wiki / _hdl_build / nx_gate_loop.nx

nx_gate_loop.nx

buildroot/runtime/_hdl_build/nx_gate_loop.nx

10050 B278 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tooltopic gate
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_gate_loop.nx

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

main gl_atoi gl_acquire_lock gl_read_pidfile sys_mmap sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close gl_pid_alive sys_mmap ↻ gl_cat gl_cat_n sys_mmap ↻ sys_openat_rd ↻ sys_close ↻ sys_openat_wr sys_mmap ↻ gl_cat_n ↻ gl_getpid sys_mmap ↻ sys_read_file ↻ sys_write sys_close ↻ sys_write ↻ gl_loop gl_run_sentinel sys_fork sys_openat_wr ↻ sys_dup3 sys_mmap ↻ sys_execve sys_exit sys_wait4 gl_beat_line sys_openat_append sys_mmap ↻ gl_cat ↻

structs

none

consts

20const GL_DEFAULT_BEAT_MS: i64 = 1800000 // 30 min
21const GL_LOG: i64 = 0

functions

23func 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 }
24func gl_cat_n(dst: *u8, off: i64, v: i64) -> i64
38func gl_atoi(s: *u8) -> i64
called by 1: main
67func gl_getpid() -> i64
88func gl_pid_alive(pid: i64) -> i64
102func gl_read_pidfile(path: *u8) -> i64
121func gl_acquire_lock() -> i64
138func gl_run_sentinel() -> i64
157func gl_beat_line(beat: i64, rc: i64) -> i64
178func gl_run_journey() -> i64
200func gl_loop(beat_ms: i64, n_beats: i64) -> i64
227func main(argc: i64, argv: *i64) -> i64