code wiki / (root) / nx_sweep_core.nx

nx_sweep_core.nx

buildroot/runtime/nx_sweep_core.nx

6727 B136 linesdepth 2pulls 2 transitivereach 3 importersview sourcekind librarytopic sweep
docsdependenciesstructsconstsfunctions

about

nx_sweep_core.nx -- STANDING-SWEEP core (library). The SOTA property a naive sweep lacks: it NEVER HANGS. Each check runs in a forked child whose stdout/stderr are captured, under a SINGLE wall-clock DEADLINE; if the child overruns it is SIGKILLed and the check verdict is TIMEOUT -- one slow/wedged check can never stall the whole sweep. Pure + gate-testable: sw_run_deadline is the primitive, sw_verdict maps (rc, expect) -> verdict. Data-driven: checks come from a registry the daemon parses, never hardcoded. license_tier: ORIGINAL

dependencies 1 imports · 1 importers

nx_syscalls.nx nx_sweep_core.nx nx_sweep_daemon_lib.nx

imports: nx_syscalls.nx

imported by: nx_sweep_daemon_lib.nx

structs

none

consts

9const SW_TIMEOUT: i64 = 0 - 100 // child killed on the deadline
10const SW_SPAWN_ERR: i64 = 0 - 101 // pipe/fork failed
11const SW_POLLIN: i64 = 1 // poll events: data-to-read
12const SW_SIGKILL: i64 = 9
13const SW_MS_PER_S: i64 = 1000
14const SW_NS_PER_MS: i64 = 1000000
15const SW_POLL_TICK: i64 = 200 // max ms per poll wait (re-checks the deadline this often)
16const SW_REAP_TICK: i64 = 5 // ms between WNOHANG reap polls after EOF
17const SW_FD_MASK: i64 = 0xFFFFFFFF
18const SW_B0: i64 = 0xFF // byte masks for the 32-bit pollfd fd field
19const SW_SH8: i64 = 8
20const SW_SH16: i64 = 16
21const SW_SH24: i64 = 24
22const SW_POLLFD_BYTES: i64 = 8 // struct pollfd = {int fd; short events; short revents}
23const SW_PF_EV: i64 = 4 // events offset
25const SW_V_PASS: i64 = 0
26const SW_V_FAIL: i64 = 1
27const SW_V_TIMEOUT: i64 = 2
28const SW_V_ERROR: i64 = 3
29const SW_PTRPAIR: i64 = 16 // scratch for a two-i64 struct (timespec / fds / wait-status)
30const SW_EXEC_FAIL: i64 = 127 // child exit code when execve fails (bad path / not ELF)
31const SW_FD_STDOUT: i64 = 1
32const SW_FD_STDERR: i64 = 2
33const SW_NFDS_1: i64 = 1 // poll: exactly one fd
34const SW_SCR_PF: i64 = 16 // scratch offset: pollfd (after fds[2])
35const SW_SCR_STP: i64 = 24 // scratch offset: wait-status (after pollfd)
36const SW_SCR_MIN: i64 = 40 // minimum caller scratch bytes

functions

41func sw_mono_ms() -> i64
49func sw_verdict(rc: i64, expect: i64) -> i64
called by 1: sd_run_all
57func sw_pollfd(pf: *u8, fd: i64) -> i64
called by 1: sw_run_deadline
72func sw_run_deadline(path: *u8, argv: *i64, cwd: *u8, out: *u8, cap: i64, outlen: *i64, deadline_ms: i64, scr: *u8) -> i64