code wiki / _hdl_build / nx_ws_board.nx
nx_ws_board.nx
buildroot/runtime/_hdl_build/nx_ws_board.nx
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
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
structs
| none |
consts
| 42 | const WB_LOG: *u8 = "knowledge/status/ws_board.log" |
| 43 | const WB_RECCAP: i64 = 512 // bounded board-record size |
| 44 | const WB_MAXEMP: i64 = 64 // max empires the board rolls up (12 today) |
| 45 | const WB_MAXRW: i64 = 64 // reflog state[] capacity (ledger_replay maxws) |
| 55 | const WB_HB_CHANNEL: *u8 = "knowledge/status/wms_heartbeat.log" // LIVE-1 beat channel |
| 56 | const WB_CFG_FRESH_KEY: *u8 = "ws:cfg:fresh_window_sec" // operator override (DATA) |
| 57 | const WB_FRESH_WINDOW_DEFAULT_SEC: i64 = 86400 // bootstrap FLOOR only (Cardinal 17 lowest tier) |
| 58 | const WB_SW: i64 = 6 // i64 slots per named live-stream row |
| 59 | const WB_ST_ACTIVE: i64 = 1 |
| 60 | const WB_ST_BLOCKED: i64 = 2 |
| 63 | const WB_INCOMPLETE: i64 = 0 - 1 // registry audit failed -> board NOT rendered |
| 64 | const WB_NOIDS: i64 = 0 - 2 // ws:ids absent -> nothing to render |
| 65 | const WB_TORNREFLOG: i64 = 0 - 3 // reflog overlay torn/old -> view REJECTED |
| 69 | const WB_ROWW: i64 = 6 // i64 slots per empire row |
functions
| 71 | func wb_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 74 | func wb_streq(a: *u8, b: *u8) -> i64 |
| 85 | func wb_atoi(s: *u8) -> i64 called by 1: wb_live_streams_p |
| 98 | func wb_count_ids(prefix: *u8) -> i64 |
| 120 | func wb_cfg_int(prefix: *u8, key: *u8, defval: i64) -> i64 |
| 145 | func wb_board_p(prefix: *u8, refpath: *u8, called by 4: wb_boardmainwbh_emit_pmain calls 7: sys_mmapws_audit_complete_pledger_replayss_openss_hgetws_field+1 |
| 282 | func wb_board(refpath: *u8, rows_out: *i64, cap: i64, |
| 290 | func wb_emit_empire(path: *u8, empire: *u8, total: i64, done: i64, active: i64, blocked: i64) -> i64 |
| 309 | func wb_emit_summary(path: *u8, total: i64, done: i64, active: i64, blocked: i64, flagged: i64) -> i64 |
| 330 | func wb_emit_live(path: *u8, now: i64, window: i64, lsm: *i64) -> i64 |
| 349 | func 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 } |
| 354 | func wb_pn(v: i64) -> i64 { nxi_out(v); return 0 } |
| 368 | func wb_live_streams_p(prefix: *u8, hbpath: *u8, now: i64, fresh_window: i64, |
| 453 | func main() -> i64 |