code wiki / _hdl_build / nx_ws_crash_gate.nx
nx_ws_crash_gate.nx
buildroot/runtime/_hdl_build/nx_ws_crash_gate.nx
about
nx_ws_crash_gate.nx -- WMS-R10: the END-TO-END CRASH INTEGRATION TEST (the capstone).
This is the scenario that STARTED the whole arc -- "claude froze and crashed, find out where we
were" -- proven a NON-EVENT. It composes every durability rung at once:
R0/R0b framed-append floor : concurrent workers record transitions to the REFLOG with zero tear
R2 transition ledger : the append-only reflog = the durable source of truth
R8 ws_put_locked : concurrent workers also update the LIVE registry, no lost updates
R9 ledger_rebuild : after the crash WIPES the registry, the reflog rebuilds it
FLOW: NWORKERS fork; worker w writes NTRANS transitions for workstream w to BOTH the reflog
(ledger_append) AND the live registry (ws_put_locked), ending at a deterministic terminal state.
Then we simulate a CRASH that loses the derived registry (a fresh, empty registry prefix) while the
append-only reflog survives -- the realistic failure mode. Recovery = ledger_rebuild(reflog -> new
registry). The end-to-end claim: EVERY workstream's state is recovered, NOTHING is lost.
ASSERTIONS (no false green):
T1 floor-held : reflog has exactly NWORKERS*NTRANS lines AND flagged==0 (R0 held under
concurrency -> the history we recover from is complete and untorn).
T2 live-consistent : the concurrently-built LIVE registry has all NWORKERS workstreams at their
correct terminal state (R8 lost no update across the shared manifest RMW).
T3 recovery-complete : after the crash (wiped registry), ledger_rebuild restores all NWORKERS
workstreams with correct terminal states (recovered==N AND correct==N).
T4 load-bearing(NEG) : a wiped registry that is NOT rebuilt has ZERO of the N workstreams -- so
the recovery is what saves them; if this showed N, the test would be vacuous.
GREEN(0) iff T1..T4. Self-log via fa_appendz (dogfoods R0b). Evidence -> ws_crash_gate.log.
Sovereign: nx_ws_repair + nx_ws_cas + nx_ws_ledger + nx_workstream_store + nx_framed_append + nx_syscalls.
license_tier: ORIGINAL
dependencies 6 imports · 0 importers
imports: nx_ws_repair.nxnx_ws_cas.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
| 35 | const CW_N: i64 = 12 // concurrent workers (= workstreams 0..11) |
| 36 | const CW_K: i64 = 8 // transitions per worker (12*8 = 96 < 256 manifest cap) |
| 37 | const CW_MAXWS: i64 = 64 |
| 38 | const CW_REC: i64 = 256 |
| 39 | const CW_LOG: *u8 = "knowledge/status/ws_crash_gate.log" |
functions
| 42 | func cw_term(w: i64) -> i64 { return (w * 3 + 2) % 5 } |
| 45 | func so(s: *u8) -> i64 |
| 51 | func son(v: i64) -> i64 |
| 66 | func cw_cat(dst: *u8, off: i64, s: *u8) -> i64 |
| 71 | func cw_catn(dst: *u8, off: i64, v: i64) -> i64 |
| 82 | func cw_atoi(s: *u8) -> i64 called by 1: cw_get_state |
| 92 | func cw_path(out: *u8, tag: *u8, epoch: i64, suffix: *u8) -> i64 |
| 103 | func cw_get_state(prefix: *u8, ws: i64) -> i64 |
| 118 | func cw_worker(reflog: *u8, regp: *u8, w: i64) -> i64 |
| 144 | func cw_spawn(reflog: *u8, regp: *u8) -> i64 |
| 166 | func cw_count_correct(prefix: *u8) -> i64 |
| 176 | func cw_count_present(prefix: *u8) -> i64 |
| 186 | func main() -> i64 |