nx_sweep_daemon_lib.nx
buildroot/runtime/nx_sweep_daemon_lib.nx
about
nx_sweep_daemon_lib.nx -- STANDING SWEEP, library half: parse the data-driven check registry, run every
check under its deadline (via nx_sweep_core -- timeout-kill so the sweep never hangs), hold results in
memory, and render a PLAIN-ENGLISH status page (per the dashboards-speak-plain-English doctrine:
questions + YES/NOT-YET/TIMED-OUT chips, never ledger keys). Data-driven: a check = one registry row,
never code. Callable by the gate (run_all in-process) and the daemon (serve loop). license_tier: ORIGINAL
dependencies 3 imports · 2 importers
imports: nx_sweep_core.nxnx_vsz_watchdog_core.nxnx_metrics_ring.nx
imported by: nx_sweep_daemon.nxnx_sweep_daemon_gate.nx
structs
| none |
consts
| 10 | const SD_MAX_CHECKS: i64 = 64 // registry capacity |
| 11 | const SD_REG_CAP: i64 = 131072 // registry file read cap |
| 12 | const SD_LINE_CAP: i64 = 4096 // one row |
| 13 | const SD_FIELD_CAP: i64 = 2048 // one field |
| 14 | const SD_ARGV_MAX: i64 = 24 // argv slots per check (matches the compiler's arg cap) |
| 15 | const SD_OUT_CAP: i64 = 65536 // captured stdout per check |
| 16 | const SD_PIPE: i64 = 124 // '|' |
| 17 | const SD_NL: i64 = 10 // '\n' |
| 18 | const SD_HASH: i64 = 35 // '#' |
| 19 | const SD_SPACE: i64 = 32 // ' ' |
| 20 | const SD_TAB: i64 = 9 // '\t' |
| 21 | const SD_ASCII_0: i64 = 48 // '0' |
| 22 | const SD_ASCII_9: i64 = 57 // '9' |
| 23 | const SD_DEC: i64 = 10 |
| 25 | const SD_COL_NAME: i64 = 0 |
| 26 | const SD_COL_Q: i64 = 1 |
| 27 | const SD_COL_CWD: i64 = 2 |
| 28 | const SD_COL_ARGV: i64 = 3 |
| 29 | const SD_COL_TMO: i64 = 4 |
| 30 | const SD_COL_EXPECT: i64 = 5 |
| 34 | const SC_N: i64 = 0 // check count |
| 35 | const SC_NAME: i64 = 1 // -> name string ptrs |
| 36 | const SC_Q: i64 = 2 // -> question string ptrs |
| 37 | const SC_CWD: i64 = 3 // -> cwd string ptrs |
| 38 | const SC_ARGV: i64 = 4 // -> argv vector ptrs |
| 39 | const SC_TMO: i64 = 5 // deadline ms |
| 40 | const SC_EXPECT: i64 = 6 // expected exit |
| 41 | const SC_VERDICT: i64 = 7 // last verdict |
| 42 | const SC_EXIT: i64 = 8 // last raw exit/sentinel |
| 43 | const SC_MS: i64 = 9 // last duration ms |
| 44 | const SC_RED: i64 = 10 // consecutive non-PASS (alert dedup) |
| 45 | const SC_HASH: i64 = 11 // -> per-check FNV-1a name hash (the metrics-ring key) |
| 46 | const SC_UPTIME: i64 = 12 // -> per-check uptime permille over the window (-1 = no history) |
| 47 | const SC_ACC_UP: i64 = 13 // -> scratch: per-check "up" sample count this refresh |
| 48 | const SC_ACC_TOT: i64 = 14 // -> scratch: per-check total sample count this refresh |
| 49 | const SC_ARRAYS: i64 = 15 // slots 0..14 = count + 14 per-check arrays (the sd_new loop bound) |
| 52 | const SC_OUT: i64 = 15 // -> capture buffer (SD_OUT_CAP) |
| 53 | const SC_OLEN: i64 = 16 // -> outlen cell (one i64) |
| 54 | const SC_OP: i64 = 17 // -> render/http offset cell (one i64) |
| 55 | const SC_CORE: i64 = 18 // -> core scratch for sw_run_deadline (fds/pf/stp) |
| 56 | const SC_STAT: i64 = 19 // -> statbuf/ring-read scratch (SD_STATBUF bytes: mtime probe + ring hdr/rec) |
| 57 | const SC_MTIME: i64 = 20 // VALUE slot: registry mtime at last successful load (hot-reload gate) |
| 58 | const SC_TOTAL: i64 = 21 // ctx cell count |
| 59 | const SD_STATBUF: i64 = 256 // struct stat scratch (also holds ring hdr 64 + rec 32) |
| 60 | const SD_STAT_MT: i64 = 11 // st_mtim.tv_sec = i64[11] of struct stat (the ccz_mtime idiom) |
| 61 | const SC_WORD: i64 = 8 // bytes per i64 |
| 62 | const SD_PTR1: i64 = 8 // single-i64 scratch cell |
| 63 | const SD_CORE_SCR: i64 = 64 // sw_run_deadline scratch: fds(16)+pf(8)+stp(16), rounded up |
| 64 | const SD_UPWINDOW_S: i64 = 86400 // uptime window = 24h (a threshold -> named, rule 11) |
| 65 | const SD_PERMILLE: i64 = 1000 // permille scale |
| 66 | const SD_NODATA: i64 = 0 - 1 // uptime sentinel: no samples in window |
| 68 | const MR_H_WIDX: i64 = 24 // header: write index |
| 69 | const MR_H_WRAP: i64 = 32 // header: wrapped flag |
| 70 | const MR_R_HASH: i64 = 8 // record: name-hash field |
| 71 | const MR_R_VERD: i64 = 16 // record: verdict field |
| 72 | const MR_WRAPPED: i64 = 1 // wrapped-flag value |
functions
| 74 | func sd_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } called by 1: gg_idx |
| 76 | func sc_arr(ctx: *i64, k: i64) -> *i64 { return ctx[k] as *i64 } |
| 77 | func sc_n(ctx: *i64) -> i64 { return ctx[SC_N] } |
| 80 | func sd_new() -> *i64 |
| 102 | func sd_mtime(ctx: *i64, path: *u8) -> i64 |
| 110 | func sd_now_sec(ctx: *i64) -> i64 |
| 116 | func sd_reload_if_changed(ctx: *i64, reg_path: *u8) -> i64 |
| 125 | func sd_ws(c: i64) -> i64 { if c == SD_SPACE { return 1 } if c == SD_TAB { return 1 } return 0 } called by 1: sd_field |
| 127 | func sd_field(line: *u8, ll: i64, k: i64) -> *u8 |
| 164 | func sd_atoi(s: *u8) -> i64 called by 1: sd_load |
| 177 | func sd_build_argv(argstr: *u8) -> *i64 called by 1: sd_load |
| 196 | func sd_load(ctx: *i64, reg_path: *u8) -> i64 |
| 244 | func sd_run_all(ctx: *i64) -> i64 |
| 279 | func sd_ring_scan(ctx: *i64, ring: *u8, now: i64, window: i64) -> i64 |
| 320 | func sd_sample(ctx: *i64, ring: *u8, now: i64, window: i64) -> i64 |
| 346 | func sd_app(buf: *u8, op: *i64, cap: i64, src: *u8) -> i64 |
| 357 | func sd_appn(buf: *u8, op: *i64, cap: i64, v: i64) -> i64 |
| 380 | func sd_render_status(ctx: *i64, buf: *u8, cap: i64) -> i64 |