nx_ws_ledger.nx
buildroot/runtime/nx_ws_ledger.nx
about
nx_ws_ledger.nx -- WMS-R2: the workstream TRANSITION LEDGER (reflog).
module: nishi-core.wms.ws_ledger
capability: CORE_COMPUTE (append-only transition ledger built ON WMS-R0)
WHAT THIS CLOSES: a workstream's life is a sequence of state changes
(TODO->WIP->VIEW->DONE ...). We need an append-only LEDGER (a reflog) that
records EVERY transition durably AND lets us REPLAY the log to rebuild the
current state of every workstream. Two correctness hazards:
1) concurrent writers tearing the log (the WMS-R0 root cause) -- defeated
here by emitting each transition as ONE framed record via fa_append.
2) a corrupt/torn entry being SILENTLY skipped during replay -- defeated
here by FLAGGING (counting) any malformed line instead of dropping it.
REUSE / lineage:
- fa_append / fa_cat / fa_catn (nx_framed_append.nx, WMS-R0): the atomic
single-write framing primitive -> each transition = exactly one write().
- the byte-scan line parser + token matcher idiom is lifted from
nx_reconcile.nx / nx_framed_append_gate.count_torn.
- sys_read_file (nx_syscalls.nx): whole-file replay read.
Sovereign: only nx_syscalls + nx_framed_append. Additive: no organ modified.
Additive-only data (Cardinal 13): the ledger is append-only; ledger_append
NEVER mutates prior bytes, history is sacred -> replay/rollback/audit work.
license_tier: ORIGINAL
dependencies 2 imports · 11 importers
diagram shows first 10 each side; +0 more imports, +1 more importers in the complete lists below.
imports: nx_syscalls.nxnx_framed_append.nx
imported by: nx_boot_revive.nxnx_boot_revive_m6_gate.nxnx_heartbeat_monitor.nxnx_ws_board.nxnx_ws_board_gate.nxnx_ws_board_html_gate.nxnx_ws_crash_gate.nxnx_ws_exceed_gate.nxnx_ws_ledger_gate.nxnx_ws_repair.nxnx_ws_repair_gate.nx
structs
| none |
consts
| 28 | const WSL_RECCAP: i64 = 256 // bounded record size (matches R0 RECCAP) |
functions
| 37 | func wsl_build(buf: *u8, ws: i64, old_st: i64, new_st: i64, |
| 63 | func ledger_append(path: *u8, ws: i64, old_st: i64, new_st: i64, called by 8: mainmainmaincw_workerex_lworkergood_worker+2 calls 4: sys_now_realtime_secsys_mmapwsl_buildfa_append |
| 73 | func wsl_at(b: *u8, pos: i64, le: i64, pat: *u8, plen: i64) -> i64 called by 1: wsl_field |
| 85 | func wsl_parse_int(b: *u8, pos: i64, le: i64, adv: *i64) -> i64 called by 1: wsl_field |
| 102 | func wsl_field(b: *u8, ls: i64, le: i64, key: *u8, klen: i64) -> i64 |
| 122 | func wsl_wellformed(b: *u8, ls: i64, le: i64) -> i64 called by 1: ledger_replay |
| 172 | func ledger_replay(path: *u8, state: *i64, outs: *i64, maxws: i64) -> i64 called by 5: br_replay_resumewb_board_pmainmainledger_rebuild calls 4: sys_mmapsys_read_filewsl_wellformedwsl_field |