code wiki / _hdl_build / nx_metrics_ring.nx

nx_metrics_ring.nx

buildroot/runtime/_hdl_build/nx_metrics_ring.nx

5295 B130 linesdepth 2pulls 2 transitivereach 5 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_metrics_ring.nx -- SOVEREIGN metrics time-series store (the TSDB the maturity census named as the supervisor domain's #1 observability gap: /status is point-in-time, there was NO history). A fixed-size binary RING (no SQL, no float, no TSV -- append-only, WRAPS at capacity so disk is BOUNDED by construction, respecting the disk-budget law). Each sample = 32 bytes: ts_sec | name_hash(FNV-1a) | verdict | fails. Library half (no main): the sampler daemon appends; the CLI + nx_heal query. license_tier: ORIGINAL

dependencies 1 imports · 3 importers

nx_syscalls.nx nx_metrics_ring.nx nx_daemon_supervisor.nx nx_metrics.nx nx_sweep_daemon_lib.nx

imports: nx_syscalls.nx

imported by: nx_daemon_supervisor.nxnx_metrics.nxnx_sweep_daemon_lib.nx

structs

none

consts

7const MR_MAGIC_2166136261: i64 = 2166136261
8const MR_MAGIC_16777619: i64 = 16777619
9const MR_MAGIC_4294967295: i64 = 4294967295
11const MR_MAGIC: i64 = 5928237 // ring header sentinel
12const MR_HDR: i64 = 64 // header bytes
13const MR_REC: i64 = 32 // record bytes: ts(8) namehash(8) verdict(8) fails(8)
14const MR_CAP: i64 = 262144 // ~8.4MB file, ~29h of 37-daemon 15s samples (bounded)
15const MR_V_SERVING: i64 = 1
16const MR_V_REFUSED: i64 = 2
17const MR_V_HUNG: i64 = 3
18const MR_V_BADRESP: i64 = 4

functions

20func mr_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
22func mr_hash(s: *u8) -> i64
called by 3: mainmainsd_load
33func mr_pread(fd: i64, off: i64, buf: *u8, n: i64) -> i64
39func mr_pwrite(fd: i64, off: i64, buf: *u8, n: i64) -> i64
called by 1: mr_append calls 2: sys_lseeksys_write
45func mr_geti(buf: *u8, o: i64) -> i64
51func mr_puti(buf: *u8, o: i64, v: i64) -> i64
called by 1: mr_append
59func mr_append(path: *u8, ts: i64, namehash: i64, verdict: i64, fails: i64) -> i64
96func mr_count(fd: i64, hdr: *u8) -> i64
called by 2: mainmr_uptime calls 2: mr_preadmr_geti
104func mr_uptime(path: *u8, namehash: i64, window_sec: i64, now: i64) -> i64