nx_pulse_worker.nx
buildroot/runtime/nx_pulse_worker.nx
about
nx_pulse_worker.nx -- LANE WORKER: NAS-owned schedule -> laptop execution (operator 2026-07-16: the
autograde pulse "is supposed to be nishi ecosystem native using the nas" -- the Windows scheduled task
built earlier the same day was REJECTED and deleted; this organ replaces it).
DESIGN (every piece an ecosystem piece; zero Windows constructs; zero inbound ports):
* THE NAS OWNS THE SCHEDULE AS DATA: https://nishifamily.com/evidence/autograde/pulse_policy.txt
(edited any time via /api/upload + /api/promote_content). Keys: enabled=0|1, mode=interval|daily,
interval_min=N, daily_utc_hour=H.
* THIS worker polls that policy OUTBOUND over sovereign TLS (forks _offc/nx_mgmt_client.elf GET --
the proven WSL->edge lane) and fires only when the NAS policy says due. The laptop is the executor
because the grader organs + ledgers live on this box's build lane; the schedule truth is the NAS's.
* A FIRE = fork the proven payload bench/autograde_pulse.sh (autograde gate -> dashboard ship -> the
script appends its own PULSE start/done rows). Worker appends a PWRK audit row per fire.
* FAIL-CLOSED: policy unreachable / status!=200 / enabled!=1 / unparsable => NO fire.
* RATE-LIMITED BY CONSTRUCTION: never fires within 1800s of the last PULSE start, whatever the
policy says -- a crashed ship or an operator typo (interval_min=0) cannot rapid-fire the loop.
* UPGRADE PATH: when the swarm worker-agent lane lands, this worker pulls hub-queued jobs instead of
a polled policy file -- same shape, richer plumbing (job kinds, permissions, QUEUE-when-busy).
usage: nx_pulse_worker [poll_seconds] [oneshot] -- poll default 120; any 3rd arg = one cycle then exit.
MUST be launched from the nxc2 checkout root (relative _offc/ + bench/ paths).
HANG-PROOF (debt eaten 2026-07-16): both child forks ride nx_guarded_run (WNOHANG poll + wall-clock
deadline + SIGKILL + reap, gate-proven) -- a wedged TLS fetch or stuck payload can no longer freeze
the daemon; it is killed at the deadline and the cycle fails CLOSED (no fire on unknown policy).
Child stdout rides a pipe drained AFTER exit -- safe because both outputs are far below the 64KB
pipe buffer (policy ~1KB, pulse log ~4KB); a runaway writer blocks and the deadline reaps it.
expect_exit: 0 license_tier: ORIGINAL
dependencies 1 imports · 0 importers
imports: nx_guarded_run.nx
imported by: nobody (leaf or entry point)
structs
| none |
consts
| 29 | const K_MAGIC_999999: i64 = 999999 |
| 30 | const K_MAGIC_20000: i64 = 20000 |
| 31 | const K_MAGIC_65535: i64 = 65535 |
| 32 | const K_MAGIC_16000: i64 = 16000 |
| 33 | const K_MAGIC_1800: i64 = 1800 |
| 34 | const K_MAGIC_86400: i64 = 86400 |
| 35 | const K_MAGIC_3600: i64 = 3600 |
| 36 | const K_MAGIC_300000: i64 = 300000 |
| 37 | const K_MAGIC_262143: i64 = 262143 |
| 38 | const K_MAGIC_65536: i64 = 65536 |
| 39 | const K_MAGIC_16384: i64 = 16384 |
| 40 | const K_MAGIC_262144: i64 = 262144 |
functions
| 51 | func w(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: wn |
| 52 | func wn(v: i64) -> i64 |
| 67 | func slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } called by 1: find_last |
| 69 | func find_last(hay: *u8, hn: i64, needle: *u8) -> i64 calls 1: slen |
| 86 | func pint_at(hay: *u8, hn: i64, p: i64) -> i64 |
| 112 | func pw_atoi(s: *u8) -> i64 |
| 123 | func bcat(b: *u8, off: i64, s: *u8) -> i64 |
| 129 | func bcatn(b: *u8, off: i64, v: i64) -> i64 calls 1: sys_munmap |
| 143 | func pw_now() -> i64 calls 1: sys_clock_gettime_real |
| 150 | func pw_run_guarded(path: *u8, argv: *i64, deadline_ms: i64, out: *u8, cap: i64, olenbox: *i64) -> i64 |
| 178 | func pw_fetch_policy(res: *i64) -> i64 |
| 207 | func pw_led_read() -> i64 |
| 221 | func pw_last(n: i64, marker: *u8) -> i64 |
| 230 | func pw_due(res: *i64, now: i64, lastdone: i64, laststart: i64) -> i64 |
| 250 | func pw_fire() -> i64 |
| 258 | func pw_append(now: i64, rc: i64) -> i64 |
| 273 | func main(argc: i64, argv: *i64) -> i64 |