code wiki / _hdl_build / nx_mgmt_snapshot.nx

nx_mgmt_snapshot.nx

buildroot/runtime/_hdl_build/nx_mgmt_snapshot.nx

8015 B180 linesdepth 2pulls 2 transitivereach 3 importersview sourcekind librarytopic mgmt
docsdependenciesstructsconstsfunctions

about

nx_mgmt_snapshot.nx -- R1b: the LIVE health-snapshot PRODUCER for the sovereign management plane. It turns raw ground-truth (a proc/log FEED that the READ-ONLY `nx_aw_hostctl snapfeed` sub emits on the NAS) into the canonical snapshot that nx_mgmt_api's /api/health + /api/services parse (md_* at nx_mgmt_api.nx): SUP <n> SVC <name> <port> <state UP|DOWN> <procs> <rwin> <rtot> This is what makes /api/health REAL (reasons-backed OK/DEGRADED) instead of forever UNKNOWN/no-snapshot. THE false-positive fix (live-proven 2026-06-29): a supervisor LINEAGE is counted as a SESSION-LEADER (pid == sid). The supervisor's reader-keeper child shares the `supervise` argv AND the parent's sid but has pid != sid, so it is NOT miscounted as a 2nd supervisor -> the healthy state yields SUP 1, and mc_is_duel(1)=0. A GENUINE duel = two distinct session leaders -> SUP 2 -> mc_is_duel(2)=1. We count lineages here (the DATA layer's job) so the CORE rule mc_is_duel stays a pure threshold (see nx_mgmt_core.nx:15-18). PURE synth (ss_*, imports only nx_syscalls) => gates in ISOLATION with fixtures (the loose-coupling payoff). The live wiring (hostctl `snapfeed` read-only sub -> ss_synth -> write the snapfile that /api/health reads) is the deploy-coupled adapter; this organ is the logic it will call. license_tier: ORIGINAL FEED grammar (one record per line; the NAS adapter, which owns the canonical service<->proc map, emits it): SVCPORT <canon> <port> -- declare a supervised service + the port it should serve PROC <pid> <ppid> <sid> <canon> -- a live process tagged with its canonical service ("supervisor" for the supervisor lineage) RESTART <canon> -- one guard-restart of <canon> seen within the crash-loop window

dependencies 1 imports · 2 importers

nx_syscalls.nx nx_mgmt_snapshot.nx nx_mgmt_snapshot_gate.nx nx_mgmt_snapshot_run.nx

imports: nx_syscalls.nx

imported by: nx_mgmt_snapshot_gate.nxnx_mgmt_snapshot_run.nx

structs

none

consts

24const SS_MAXSVC: i64 = 64

functions

27func ss_eol(b: *u8, n: i64, start: i64) -> i64
called by 2: ss_synthmain
35func ss_split(b: *u8, ls: i64, le: i64, offs: *i64, lens: *i64, maxf: i64) -> i64
called by 2: ss_synthmain
51func ss_atoi(b: *u8, off: i64, len: i64) -> i64
called by 2: ss_synthmain
58func ss_tok_eq(b: *u8, off: i64, len: i64, s: *u8) -> i64
called by 1: ss_synth
68func ss_slice_eq(a: *u8, ao: i64, al: i64, b: *u8, bo: i64, bl: i64) -> i64
called by 1: ss_synth
75func ss_cat(d: *u8, o: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { d[o] = s[i]; o = o + 1; i = i + 1 } return o }
76func ss_cat_slice(d: *u8, o: i64, src: *u8, off: i64, len: i64) -> i64 { var i: i64 = 0; while i < len { d[o] = src[off + i]; o = o + 1; i = i + 1 } return o }
called by 1: ss_synth
79func ss_catn(d: *u8, o: i64, v: i64) -> i64
called by 2: ss_synthmain calls 1: sys_mmap
91func ss_synth(feed: *u8, n: i64, out: *u8) -> i64