code wiki / (root) / nx_gauge_lib.nx

nx_gauge_lib.nx

buildroot/runtime/nx_gauge_lib.nx

7661 B161 linesdepth 3pulls 3 transitivereach 66 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_gauge_lib.nx -- CE9 (codeeffectiveness sm_gauge_alarm): THE ONE RULER for a GAUGE HEARTBEAT -- written by the beat that measures a gauge, read by the /compare emitter that renders it, and driven in-process by its gate, so the writer and the reader cannot disagree about what STALE, BLIND or ABSENT mean: one classifier, one file shape, one renderer. THE STAMP is the estate's dead-man heartbeat shape -- `ts=<epoch>` FIRST, the way nx_http_probe_lib.hp_write_stamp writes it and nx_cron_watch reads it -- followed by the gauge fields on the same line: ts=<epoch> gauge=<n> axes_known=<k> axes_total=<t> cadence_s=<c> Truncate-written in ONE sys_write: a reader that catches a partial write sees a shorter ts, i.e. an OLDER stamp, which fails in the safe direction. hp_write_stamp is not composed only because it carries ts alone and a gauge needs its axes beside it; the SHAPE is identical so the cron dead-man's switch can watch this file with no change. STATES (ga_state), decided in this order so the most alarming truth wins: ABSENT no readable stamp: nothing has measured, or the writer died before its first beat STALE age > max_age, or age < 0 (a future stamp is clock skew: UNOBSERVABLE, never fresh) BLIND axes_known < axes_total: an axis abstained, and the number beside it acquits nothing FRESH inside max_age with every axis observed max_age is DERIVED from the writer's cadence (GA_MISSED_BEATS beats): one missed beat is tolerated, the second is blindness. ga_render prints the gauge VALUE only when the state is FRESH -- a stale gauge reads STALE on the page and never as zero, which is the rung's accept rule. A stamp whose cadence field is absent judges STALE by construction. license_tier: ORIGINAL No hw writes.

dependencies 2 imports · 15 importers

nx_sovjson_lib.nx nx_syscalls.nx nx_gauge_lib.nx nx_compare_shared_fit_lib_20260910 nx_gauge_gate.nx nx_goalmap_lib.nx nx_goalmap_record_gate.nx nx_seat.nx nx_stepsolve_gate.nx nx_stepsolve_lib.nx nx_swcompare_evidence_lib_t138.nx nx_swcompare_growth_candidate_2026 nx_swcompare_heading_lib_20260907.

diagram shows first 10 each side; +0 more imports, +5 more importers in the complete lists below.

imports: nx_sovjson_lib.nxnx_syscalls.nx

imported by: nx_compare_shared_fit_lib_20260910.nxnx_gauge_gate.nxnx_goalmap_lib.nxnx_goalmap_record_gate.nxnx_seat.nxnx_stepsolve_gate.nxnx_stepsolve_lib.nxnx_swcompare_evidence_lib_t138.nxnx_swcompare_growth_candidate_20260910.nxnx_swcompare_heading_lib_20260907.nxnx_swcompare_ladder_candidate.nxnx_swcompare_lib.nxnx_swcompare_preview_lib_t56.nxnx_swcompare_production_lib_20260907.nxnx_swcompare_release_candidate.nx

structs

none

consts

24const GA_STAMP_PROD: *u8 = "knowledge/status/seat_gauge.stamp"
25const GA_LINE: i64 = 512
26const GA_MODE644: i64 = 420
27const GA_NL: i64 = 10
28const GA_SP: i64 = 32
29const GA_EQ: i64 = 61
30const GA_D0: i64 = 48
31const GA_D9: i64 = 57
32const GA_WORD: i64 = 8
33const GA_MISSED_BEATS: i64 = 2 // derived bar: the second missed beat is blindness, the first is tolerated
35const GA_FRESH: i64 = 0
36const GA_STALE: i64 = 1
37const GA_BLIND: i64 = 2
38const GA_ABSENT: i64 = 3
40const GA_F_TS: i64 = 0
41const GA_F_GAUGE: i64 = 1
42const GA_F_KNOWN: i64 = 2
43const GA_F_TOTAL: i64 = 3
44const GA_F_CADENCE: i64 = 4
45const GA_F_SLOTS: i64 = 8

functions

47func ga_max_age(cadence_s: i64) -> i64 { return cadence_s * GA_MISSED_BEATS }
50func ga_field(q: *u8, n: i64, key: *u8) -> i64
called by 1: ga_stamp_read calls 2: sj_vlensj_atoi_span
80func ga_stamp_write(path: *u8, now: i64, gauge: i64, known: i64, total: i64, cadence_s: i64) -> i64
97func ga_stamp_read(path: *u8, f: *i64) -> i64
114func ga_state(now: i64, ts: i64, max_age: i64, known: i64, total: i64) -> i64
called by 1: ga_judge
122func ga_state_name(st: i64) -> *u8
130func ga_render(d: *u8, p0: i64, st: i64, age: i64, max_age: i64, gauge: i64, known: i64, total: i64) -> i64
155func ga_judge(path: *u8, now: i64, cadence_s: i64, f: *i64) -> i64