nx_sweep_core.nx
buildroot/runtime/nx_sweep_core.nx
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
imports: nx_syscalls.nx
imported by: nx_sweep_daemon_lib.nx
structs
| none |
consts
| 9 | const SW_TIMEOUT: i64 = 0 - 100 // child killed on the deadline |
| 10 | const SW_SPAWN_ERR: i64 = 0 - 101 // pipe/fork failed |
| 11 | const SW_POLLIN: i64 = 1 // poll events: data-to-read |
| 12 | const SW_SIGKILL: i64 = 9 |
| 13 | const SW_MS_PER_S: i64 = 1000 |
| 14 | const SW_NS_PER_MS: i64 = 1000000 |
| 15 | const SW_POLL_TICK: i64 = 200 // max ms per poll wait (re-checks the deadline this often) |
| 16 | const SW_REAP_TICK: i64 = 5 // ms between WNOHANG reap polls after EOF |
| 17 | const SW_FD_MASK: i64 = 0xFFFFFFFF |
| 18 | const SW_B0: i64 = 0xFF // byte masks for the 32-bit pollfd fd field |
| 19 | const SW_SH8: i64 = 8 |
| 20 | const SW_SH16: i64 = 16 |
| 21 | const SW_SH24: i64 = 24 |
| 22 | const SW_POLLFD_BYTES: i64 = 8 // struct pollfd = {int fd; short events; short revents} |
| 23 | const SW_PF_EV: i64 = 4 // events offset |
| 25 | const SW_V_PASS: i64 = 0 |
| 26 | const SW_V_FAIL: i64 = 1 |
| 27 | const SW_V_TIMEOUT: i64 = 2 |
| 28 | const SW_V_ERROR: i64 = 3 |
| 29 | const SW_PTRPAIR: i64 = 16 // scratch for a two-i64 struct (timespec / fds / wait-status) |
| 30 | const SW_EXEC_FAIL: i64 = 127 // child exit code when execve fails (bad path / not ELF) |
| 31 | const SW_FD_STDOUT: i64 = 1 |
| 32 | const SW_FD_STDERR: i64 = 2 |
| 33 | const SW_NFDS_1: i64 = 1 // poll: exactly one fd |
| 34 | const SW_SCR_PF: i64 = 16 // scratch offset: pollfd (after fds[2]) |
| 35 | const SW_SCR_STP: i64 = 24 // scratch offset: wait-status (after pollfd) |
| 36 | const SW_SCR_MIN: i64 = 40 // minimum caller scratch bytes |
functions
| 41 | func sw_mono_ms() -> i64 |
| 49 | func sw_verdict(rc: i64, expect: i64) -> i64 called by 1: sd_run_all |
| 57 | func sw_pollfd(pf: *u8, fd: i64) -> i64 called by 1: sw_run_deadline |
| 72 | func sw_run_deadline(path: *u8, argv: *i64, cwd: *u8, out: *u8, cap: i64, outlen: *i64, deadline_ms: i64, scr: *u8) -> i64 |