code wiki / (root) / nx_sweep_daemon.nx

nx_sweep_daemon.nx

buildroot/runtime/nx_sweep_daemon.nx

12980 B239 linesdepth 4pulls 6 transitivereach 0 importersview sourcekind servicetopic sweep
docsdependenciesstructsconstsfunctions

about

nx_sweep_daemon.nx -- STANDING SWEEP daemon, CLI half (tools/ops surface). Runs the data-driven check registry on an interval, NEVER hanging (each check is deadline-killed by nx_sweep_core), serves a PLAIN-ENGLISH /status page, and dedups alerts (one line on the 0->1 red transition, silent while it stays red -- captured to the supervisor log via stdout). Supervised by nx_daemon_supervisor (a daemons.reg row, revive-armed) so it never silently dies. Verbs: once [reg] run every check once, print verdicts, exit 0 iff all PASS (gate/manual/CI) serve <port> [reg] bind :port, sweep every interval, serve /status (the standing daemon) Default registry: knowledge/sweep_checks.reg. license_tier: ORIGINAL

dependencies 1 imports · 0 importers

nx_sweep_daemon_lib.nx nx_sweep_daemon.nx

imports: nx_sweep_daemon_lib.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sv_puts sv_seq sd_new sd_mtime sys_fstatat sd_appn sd_app sd_load sc_arr vw_read sys_openat_rd sys_read sys_close sd_field sd_ws sd_build_argv sd_atoi mr_hash sd_run_all sc_arr ↻ sw_mono_ms sys_mmap sys_clock_gettime_mono sys_munmap sw_run_deadline sys_pipe2 sys_fork sys_close ↻ sys_dup3 sys_chdir sys_mmap ↻ sys_mmap ↻ sys_execve sys_exit sw_mono_ms ↻ nx_kill sys_wait4 sw_pollfd sys_poll

structs

none

consts

11const SV_ARG_VERB: i64 = 1
12const SV_ARG_PORT: i64 = 2 // serve: port
13const SV_ARG_SREG: i64 = 3 // serve: optional registry
14const SV_ARG_IVMS: i64 = 4 // serve: optional interval ms (default SV_INTERVAL_MS)
15const SV_ARG_OREG: i64 = 2 // once: optional registry
16const SV_ARGC_SERVE: i64 = 3 // serve port
17const SV_RC_USAGE: i64 = 2
18const SV_INTERVAL_MS: i64 = 300000 // 5 min between sweeps (a threshold -> named, rule 11)
22const SV_SHM_SZ: i64 = 262144 // shared snapshot page (holds the rendered status HTML)
23const SV_SEQ_I: i64 = 0 // seqlock counter (i64 index into shm)
24const SV_BLEN_I: i64 = 1 // published body length (i64 index)
25const SV_BODY_OFF: i64 = 16 // body bytes begin after the two i64 header slots
26const SV_SEQ_TRIES: i64 = 100000 // seqlock read retry cap (writer-starvation backstop)
27const SV_RESP_EXTRA: i64 = 256 // HTTP header headroom over the body
28const SV_SEQ_MOD: i64 = 2 // seqlock parity: even=committed, odd=writer-active
29const SV_RC_CHILD: i64 = 3 // status-child fatal-bind exit code
30const SV_REQ_CAP: i64 = 8192
31const SV_AF_INET: i64 = 2
32const SV_SOCK_STREAM: i64 = 1
33const SV_SOL_SOCKET: i64 = 1
34const SV_SO_REUSEADDR: i64 = 2
35const SV_PTR1: i64 = 8 // single-i64 scratch
36const SV_OPTLEN: i64 = 4 // setsockopt optlen (int)
37const SV_SADDR_LEN: i64 = 16
38const SV_BACKLOG: i64 = 16
39const SV_PORT_HI_SH: i64 = 8
40const SV_BYTE: i64 = 0xFF
41const SV_ADDR_FAM: i64 = 0 // sockaddr offset: family
42const SV_ADDR_PORT: i64 = 2 // sockaddr offset: port (big-endian)
43const SV_DEC: i64 = 10
44const SV_ASCII_0: i64 = 48
45const SV_ASCII_9: i64 = 57

functions

47func sv_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
48func sv_seq(a: *u8, b: *u8) -> i64 { var i: i64 = 0; while a[i] != (0 as u8) { if a[i] != b[i] { return 0 } i = i + 1 } if b[i] != (0 as u8) { return 0 } return 1 }
called by 1: main
49func sv_atoi(s: *u8) -> i64
called by 1: main
55func sv_print_verdict(ctx: *i64, i: i64) -> i64
called by 1: main calls 2: sc_arrsv_puts
74func sv_alerts(ctx: *i64) -> i64
called by 1: main calls 2: sc_arrsv_puts
89func sv_http_wrap(resp: *u8, cap: i64, body: *u8, blen: i64, op: *i64) -> i64
called by 1: sv_status_child calls 2: sd_appsd_appn
101func sv_shm_write(shm: *u8, html: *u8, hl: i64) -> i64
called by 1: main
113func sv_sockaddr(addr: *u8, port: i64) -> i64
called by 1: sv_status_child
122func sv_status_child(shm: *u8, port: i64) -> i64
166func main(argc: i64, argv: *i64) -> i64