code wiki / (root) / nx_statuscensus_lib.nx

nx_statuscensus_lib.nx

buildroot/runtime/nx_statuscensus_lib.nx

16859 B335 linesdepth 2pulls 2 transitivereach 2 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_statuscensus_lib.nx -- TS11 (/compare/trafficsafety): STATUS ANALYTICS + THE NON-EMPTY-200 SLA GAUGE, the LIB. OPERATOR 2026-09-05: "analytics on our 404s and 503s and all other statuses including undefined, and we need to make sure we are getting to the point we have 99 percent and above 200 code slas with confirmed non empty expected delivery." This lib is the ONE classifier; nx_statuscensus (program) runs it over the live journals and nx_statuscensus_gate drives it over fixtures IN-PROCESS, so the gate and the beat cannot disagree on a bucket. It EXTENDS the two journals the estate already writes -- no second request log: EDGE sites_telemetry.log (nx_sites_telemetry.nx, one row per connection, append-only, 489 MB on 2026-09-05, so the census reads a DECLARED TAIL WINDOW, never the whole file): ts=<us> acc=<L|N> vh=<id> hs=<us> by=<bytes> rc=<0|-N> vh=71 is the edge's own synthesized 503/504 (backend refused, edge window overrun, outcome-unknown, deadline), vh=22 is the edge 404, rc<0 is a TLS handshake that never reached HTTP: there IS no status for that row and it is counted UNDEFINED, never folded into a code. vh=70 is a PROXIED backend reply: the edge row carries its bytes but NOT its status, so it counts DELIVERED-BY-BYTES and is ALSO counted on a separate axis edge_proxied_unstatused= (the size of the blind spot); the owed rung is a st=<code> field on the emitter so a proxied 500 with a body stops reading as a 200. TOOLS knowledge/status/actlog.jrnl (ta_actlog_x): <ts> TAB mcp TAB <tool> TAB call TAB <status> TAB tools/call lane=<l> exit=<n> bytes=<n> dur_ms=<n>. lane=async status=started rows are RECEIPTS (the job's own result lands in _jobs/); a row with exit=0 and bytes>0 is DELIVERED; bytes=0 is EMPTY; exit!=0 is ERROR even when bytes>0 (an error body is not a delivery). PARTITIONS SUM (printed as edge_partition_sum= / act_partition_sum=), UNDEFINED is its own bucket, a window under min_rows reports UNOBSERVED and does not vote, and the SLA permil is DELIVERED over ALL rows -- an empty 200 is not a delivery. Verdict LAST line: GREEN rc 0 / RED rc 1 / UNOBSERVED rc 3. license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 1 imports · 2 importers

nx_syscalls.nx nx_statuscensus_lib.nx nx_statuscensus.nx nx_statuscensus_gate.nx

imports: nx_syscalls.nx

imported by: nx_statuscensus.nxnx_statuscensus_gate.nx

structs

none

consts

27const SC_CONF_PATH: *u8 = "knowledge/statuscensus.conf"
30const SC_WINDOW_DEFAULT: i64 = 8388608
31const SC_SLA_MIN_DEFAULT: i64 = 990 // the operator's bar: 99 percent and above
32const SC_MINROWS_DEFAULT: i64 = 100 // below this a window is UNOBSERVED, never a pass
33const SC_VH_SYNTH: i64 = 71 // nx_sites_daemon_v2: edge-synthesized 503/504
34const SC_VH_404: i64 = 22 // nx_sites_daemon_v2: edge 404
35const SC_VH_PROXIED: i64 = 70 // nx_sites_daemon_v2: proxied backend reply, status not journaled
36const SC_SEEK_SET: i64 = 0
37const SC_SEEK_END: i64 = 2
38const SC_MODE_0644: i64 = 420
39const SC_NUMBUF: i64 = 32
40const SC_TAB: i64 = 9
41const SC_NL: i64 = 10
42const SC_MINUS: i64 = 45
43const SC_HASH: i64 = 35
44const SC_ZERO: i64 = 48
45const SC_NINE: i64 = 57
191const E_TOTAL: i64 = 0
192const E_DELIV: i64 = 1
193const E_EMPTY: i64 = 2
194const E_404: i64 = 3
195const E_SYNTH: i64 = 4
196const E_UNDEF: i64 = 5
197const E_PROXIED: i64 = 6 // SEPARATE AXIS, not a partition member (a proxied row is also DELIVERED or EMPTY)
198const E_SLOTS: i64 = 8
228const A_TOTAL: i64 = 0
229const A_DELIV: i64 = 1
230const A_EMPTY: i64 = 2
231const A_ERROR: i64 = 3
232const A_RECEIPT: i64 = 4
233const A_SLOTS: i64 = 8

functions

47func sc_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
48func sc_fputs(fd: i64, s: *u8) -> i64 { sys_write(fd, s, sc_slen(s)); return 0 }
49func sc_fputn(fd: i64, v: i64) -> i64
62func sc_puts(s: *u8) -> i64 { return sc_fputs(1, s) }
called by 1: sc_run calls 1: sc_fputs
63func sc_putn(v: i64) -> i64 { return sc_fputn(1, v) }
calls 1: sc_fputn
66func sc_eol(buf: *u8, i: i64, n: i64) -> i64
73func sc_has(buf: *u8, s: i64, e: i64, key: *u8) -> i64
86func sc_count(buf: *u8, s: i64, e: i64, key: *u8) -> i64
called by 1: main calls 1: sc_slen
99func sc_find_num(buf: *u8, s: i64, e: i64, key: *u8, out: *i64) -> i64
129func sc_tabwrap(s: *u8) -> *u8
called by 1: sc_census_act calls 2: sc_slensys_mmap
143func sc_read_tail(path: *u8, window: i64, lenbox: *i64) -> *u8
172func sc_conf(key: *u8, dflt: i64, srcbox: *i64) -> i64
200func sc_census_edge(buf: *u8, s0: i64, n: i64, c: *i64) -> i64
235func sc_census_act(buf: *u8, s0: i64, n: i64, c: *i64) -> i64
257func sc_permil(num: i64, den: i64) -> i64 { if den <= 0 { return 0 - 1 } return (num * 1000) / den }
called by 1: sc_run
260func sc_report(fd: i64, ec: *i64, ac: *i64, window: i64, wsrc: i64, slamin: i64, minrows: i64, elen: i64, alen: i64, everdict: *u8, averdict: *u8, epm: i64, apm: i64, verdict: *u8) -> i64
287func sc_run(telpath: *u8, actpath: *u8, statuspath: *u8, tmppath: *u8, logpath: *u8, window: i64, wsrc: i64, slamin: i64, minrows: i64) -> i64