code wiki / _hdl_build / nx_ws_board.nx

nx_ws_board.nx

buildroot/runtime/_hdl_build/nx_ws_board.nx

25893 B527 linesdepth 5pulls 8 transitivereach 4 importersview sourcekind tooltopic ws
docsdependenciesstructsconstsfunctions

about

nx_ws_board.nx -- WMS rung M2: the LIVE STATUS BOARD (derived view). module: nishi-core.wms.ws_board capability: CORE_COMPUTE (a derived, self-validating view over WMS-R1 + WMS-R2) WHAT THIS CLOSES: crash recovery used to mean reading a stale THREADS worksheet and a lossy MEMORY index by hand. This organ DERIVES the live state of every empire/stream straight from the SSOT registry (WMS-R1, nx_workstream_store) and validates freshness against the transition reflog (WMS-R2, nx_ws_ledger). Crash-recovery becomes "read the board" -- and the board is NEVER silently wrong: * if the registry is INCOMPLETE (a lost/never-committed segment) it REFUSES to render (returns -1), it does not paper over the gap. (ws_audit_complete==0 is a precondition, in the DATA PATH, not just the test.) * if the reflog overlay is TORN/OLD (replay flags any malformed line) it REJECTS the reflog-derived view (returns -3) rather than rendering it wrong. IMPEDANCE NOTE (load-bearing, Rule 4 -- every displayed fact is a real field read): R1 records store `state` as a STRING label (ACTIVE|DONE|BLOCKED|FLOATING|ABSENT). R2's reflog stores `new=` as an INTEGER (0..4). The board's PRIMARY source of truth for displayed state is the R1 string field (ws_field f=2). The R2 reflog is used ONLY as an integrity/freshness OVERLAY (replay must yield flagged==0). We do NOT re-map int->label here -- that int<->label bridge is a future rung; a fabricated mapping would violate no-false-green. SCHEMA the board surfaces (Rule 4 -- closest VERIFIED facts, no invented columns): field 1=empire 2=state 3=last_touched 5=code_link (owner/next-rung surrogate). The registry has no dedicated owner/next_rung columns; code_link(5)+deps(6) are the nearest measured facts. Inventing owner/next_rung would be a schema lie. REUSE / lineage: ws_manifest_p / ws_get_p / ws_field / ws_member / ws_audit_complete_p (nx_workstream_store, WMS-R1); ledger_replay (nx_ws_ledger, WMS-R2); fa_appendz / fa_cat / fa_catn (nx_framed_append, WMS-R0b -- the MANDATORY one-buffer-one-locked- write discipline for the file channel). Additive: no organ modified. Sovereign: imports only the WMS stack + nx_syscalls (no gcc/openssl/node). license_tier: ORIGINAL

dependencies 6 imports · 4 importers

nx_workstream_store.nx nx_itoa_lib.nx nx_ws_ledger.nx nx_framed_append.nx nx_heartbeat_str.nx nx_syscalls.nx nx_ws_board.nx nx_ws_board_gate.nx nx_ws_board_html.nx nx_ws_board_html_gate.nx nx_ws_board_live_gate.nx

imports: nx_workstream_store.nxnx_itoa_lib.nxnx_ws_ledger.nxnx_framed_append.nxnx_heartbeat_str.nxnx_syscalls.nx

imported by: nx_ws_board_gate.nxnx_ws_board_html.nxnx_ws_board_html_gate.nxnx_ws_board_live_gate.nx

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

main wb_p sys_write sys_mmap wb_board wb_board_p sys_mmap ↻ ws_audit_complete_p sys_mmap ↻ ss_open_cached ssc_init sys_mmap ↻ ssc_sig_of ss_cat sys_fstatat ssc_streq ss_open ss_open2 ssc_retire_handle ss_hget sys_mmap ↻ ss_idx_find ss_r32 ss_len ss_kcmp ws_field ws_member ws_len ledger_replay sys_mmap ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close wsl_wellformed wsl_field wsl_at sys_mmap ↻

structs

none

consts

42const WB_LOG: *u8 = "knowledge/status/ws_board.log"
43const WB_RECCAP: i64 = 512 // bounded board-record size
44const WB_MAXEMP: i64 = 64 // max empires the board rolls up (12 today)
45const WB_MAXRW: i64 = 64 // reflog state[] capacity (ledger_replay maxws)
55const WB_HB_CHANNEL: *u8 = "knowledge/status/wms_heartbeat.log" // LIVE-1 beat channel
56const WB_CFG_FRESH_KEY: *u8 = "ws:cfg:fresh_window_sec" // operator override (DATA)
57const WB_FRESH_WINDOW_DEFAULT_SEC: i64 = 86400 // bootstrap FLOOR only (Cardinal 17 lowest tier)
58const WB_SW: i64 = 6 // i64 slots per named live-stream row
59const WB_ST_ACTIVE: i64 = 1
60const WB_ST_BLOCKED: i64 = 2
63const WB_INCOMPLETE: i64 = 0 - 1 // registry audit failed -> board NOT rendered
64const WB_NOIDS: i64 = 0 - 2 // ws:ids absent -> nothing to render
65const WB_TORNREFLOG: i64 = 0 - 3 // reflog overlay torn/old -> view REJECTED
69const WB_ROWW: i64 = 6 // i64 slots per empire row

functions

71func wb_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
74func wb_streq(a: *u8, b: *u8) -> i64
85func wb_atoi(s: *u8) -> i64
called by 1: wb_live_streams_p
98func wb_count_ids(prefix: *u8) -> i64
called by 2: mainmain calls 3: ss_opensys_mmapss_hget
120func wb_cfg_int(prefix: *u8, key: *u8, defval: i64) -> i64
called by 2: mainmain calls 3: ss_opensys_mmapss_hget
145func wb_board_p(prefix: *u8, refpath: *u8,
282func wb_board(refpath: *u8, rows_out: *i64, cap: i64,
called by 1: main calls 1: wb_board_p
290func wb_emit_empire(path: *u8, empire: *u8, total: i64, done: i64, active: i64, blocked: i64) -> i64
309func wb_emit_summary(path: *u8, total: i64, done: i64, active: i64, blocked: i64, flagged: i64) -> i64
330func wb_emit_live(path: *u8, now: i64, window: i64, lsm: *i64) -> i64
349func wb_p(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 1: main calls 1: sys_write
354func wb_pn(v: i64) -> i64 { nxi_out(v); return 0 }
called by 1: main calls 1: nxi_out
368func wb_live_streams_p(prefix: *u8, hbpath: *u8, now: i64, fresh_window: i64,
453func main() -> i64