code wiki / _hdl_build / nx_ws_repair.nx

nx_ws_repair.nx

buildroot/runtime/_hdl_build/nx_ws_repair.nx

4641 B101 linesdepth 4pulls 6 transitivereach 3 importersview sourcekind librarytopic ws
docsdependenciesstructsconstsfunctions

about

nx_ws_repair.nx -- WMS-R9: ledger->registry CRASH REPAIR (git's defining reflog-recovery trick). module: nishi-core.wms.ws_repair capability: CORE_COMPUTE (crash-recovery: rebuild the registry SSOT from the append-only reflog) WHAT THIS CLOSES: WMS-R4 (nx_workstream_audit) only DETECTS a lost/corrupt registry record; it does not REPAIR it. Git's defining trick is that the refs (where branches point) can be rebuilt from the reflog (the append-only history of every ref update) -- a corrupt/lost ref is not fatal because the log is the source of truth. THIS is that trick for the WMS: the WMS-R2 transition ledger (nx_ws_ledger) is the reflog; ledger_replay reconstructs the authoritative current state of every workstream; ledger_rebuild WRITES those states back into the registry store, so a wiped or stale registry is reconstructed from history rather than lost. HONEST SCOPE (rule 4, no fabrication): the reflog records the LEDGER's state vocabulary (integers; 0=TODO 1=WIP 2=VIEW 3=DONE 4=NOVEL per nx_ws_ledger_gate) and ONLY the state -- not empire/links/ deps. So a recovered record carries the reflog's NUMERIC state (not invented status labels) and is marked empire="E-RECOVERED" with "-" links (intentionally none -> never false-orphans in R4); the non-state metadata is re-enriched later from the census, exactly as git rebuilds where a ref points (the state) but not the unreachable objects. last_touched=0 ("unknown" per R1 schema) keeps rebuild IDEMPOTENT: re-running on the same reflog yields byte-identical records -> ws_put_p skips unchanged. REUSE (rule 15): ledger_replay (R2) for the authoritative state; ws_put_p (R1) for the writes (recovery is single-writer at boot -- fail-fast-on-startup means the system isn't serving yet, so the R8 inter-writer lock isn't needed here). Sovereign: nx_ws_ledger + nx_workstream_store + nx_syscalls. license_tier: ORIGINAL

dependencies 3 imports · 3 importers

nx_ws_ledger.nx nx_workstream_store.nx nx_syscalls.nx nx_ws_repair.nx nx_ws_crash_gate.nx nx_ws_exceed_gate.nx nx_ws_repair_gate.nx

imports: nx_ws_ledger.nxnx_workstream_store.nxnx_syscalls.nx

imported by: nx_ws_crash_gate.nxnx_ws_exceed_gate.nxnx_ws_repair_gate.nx

structs

none

consts

none

functions

31func wr_cat(dst: *u8, off: i64, s: *u8) -> i64
called by 2: wr_keywr_val
37func wr_catn(dst: *u8, off: i64, v: i64) -> i64
called by 2: wr_keywr_val calls 1: sys_mmap
50func wr_key(out: *u8, ws: i64) -> i64
called by 1: ledger_rebuild calls 2: wr_catwr_catn
61func wr_val(out: *u8, ws: i64, st: i64) -> i64
called by 1: ledger_rebuild calls 2: wr_catnwr_cat
77func ledger_rebuild(ledger_path: *u8, prefix: *u8, maxws: i64, outs: *i64) -> i64