code wiki / _hdl_build / nx_ws_repair_gate.nx
nx_ws_repair_gate.nx
buildroot/runtime/_hdl_build/nx_ws_repair_gate.nx
about
nx_ws_repair_gate.nx -- the REFEREE for WMS-R9 (ledger->registry crash repair).
Proves the reflog-recovery trick AND that the test can detect failure (no false green):
T1 rebuild-from-loss : build a reflog of known transitions for RP_NWS workstreams, then
ledger_rebuild into a FRESH (= wiped/lost) registry prefix. EVERY ws's
recovered state field MUST equal the reflog's final state; rebuilt==NWS;
flagged==0. (the registry was reconstructed entirely from history.)
T2 corruption-repair : overwrite ws:0 with a WRONG state (a stale/torn registry record), re-run
ledger_rebuild -> the record is REPAIRED back to the reflog's authoritative
state. (proves rebuild REPAIRS, not merely populates.)
T3 no-phantom (NEG) : a ws-id that NEVER appears in the reflog MUST NOT exist in the rebuilt
registry (rebuild never fabricates a ref it didn't see).
T4 torn-surfaced(NEG): a reflog containing a deliberately-broken record -> ledger_rebuild FLAGS
it (flagged>=1), never silently mis-applies. flagged==0 => RED.
Each artifact uses a per-run unique /tmp path (disposable; no clearing). Self-log via fa_appendz
(lock-framed, dogfoods R0b). Evidence -> knowledge/status/ws_repair_gate.log. GREEN(0) iff T1..T4.
Sovereign: nx_ws_repair + nx_ws_ledger + nx_workstream_store + nx_framed_append + nx_syscalls.
license_tier: ORIGINAL
dependencies 5 imports · 0 importers
imports: nx_ws_repair.nxnx_ws_ledger.nxnx_workstream_store.nxnx_framed_append.nxnx_syscalls.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 25 | const RP_NWS: i64 = 8 // test workstreams ws-id 0..7 |
| 26 | const RP_MAXWS: i64 = 64 |
| 27 | const RP_REC: i64 = 256 |
| 28 | const RP_LOG: *u8 = "knowledge/status/ws_repair_gate.log" |
functions
| 31 | func rp_expect(w: i64) -> i64 { return (w * 2 + 1) % 5 } called by 1: main |
| 34 | func so(s: *u8) -> i64 |
| 40 | func son(v: i64) -> i64 |
| 55 | func rp_cat(dst: *u8, off: i64, s: *u8) -> i64 |
| 60 | func rp_catn(dst: *u8, off: i64, v: i64) -> i64 |
| 73 | func rp_atoi(s: *u8) -> i64 called by 1: rp_get_state |
| 85 | func rp_path(out: *u8, tag: *u8, epoch: i64, suffix: *u8) -> i64 |
| 96 | func rp_rawline(path: *u8, s: *u8) -> i64 |
| 107 | func rp_get_state(prefix: *u8, ws: i64) -> i64 |
| 121 | func main() -> i64 |