code wiki / (root) / nx_ws_ledger.nx

nx_ws_ledger.nx

buildroot/runtime/nx_ws_ledger.nx

8142 B204 linesdepth 3pulls 3 transitivereach 19 importersview sourcekind librarytopic ws
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_framed_append.nx nx_ws_ledger.nx nx_boot_revive.nx nx_boot_revive_m6_gate.nx nx_heartbeat_monitor.nx nx_ws_board.nx nx_ws_board_gate.nx nx_ws_board_html_gate.nx nx_ws_crash_gate.nx nx_ws_exceed_gate.nx nx_ws_ledger_gate.nx nx_ws_repair.nx

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

28const WSL_RECCAP: i64 = 256 // bounded record size (matches R0 RECCAP)

functions

37func wsl_build(buf: *u8, ws: i64, old_st: i64, new_st: i64,
called by 1: ledger_append calls 2: fa_catfa_catn
63func ledger_append(path: *u8, ws: i64, old_st: i64, new_st: i64,
73func wsl_at(b: *u8, pos: i64, le: i64, pat: *u8, plen: i64) -> i64
called by 1: wsl_field
85func wsl_parse_int(b: *u8, pos: i64, le: i64, adv: *i64) -> i64
called by 1: wsl_field
102func wsl_field(b: *u8, ls: i64, le: i64, key: *u8, klen: i64) -> i64
122func wsl_wellformed(b: *u8, ls: i64, le: i64) -> i64
called by 1: ledger_replay
172func ledger_replay(path: *u8, state: *i64, outs: *i64, maxws: i64) -> i64