code wiki / _hdl_build / nx_ws_crash_gate.nx

nx_ws_crash_gate.nx

buildroot/runtime/_hdl_build/nx_ws_crash_gate.nx

10777 B270 linesdepth 5pulls 8 transitivereach 0 importersview sourcekind gate/prooftopic ws
docsdependenciesstructsconstsfunctions

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

nx_ws_repair.nx nx_ws_cas.nx nx_ws_ledger.nx nx_workstream_store.nx nx_framed_append.nx nx_syscalls.nx nx_ws_crash_gate.nx

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

main sys_now_realtime_sec sys_mmap sys_clock_gettime_real sys_mmap ↻ cw_path cw_cat cw_catn sys_mmap ↻ cw_spawn sys_mmap ↻ sys_fork cw_worker sys_mmap ↻ cw_cat ↻ cw_catn ↻ cw_term ledger_append sys_now_realtime_sec ↻ sys_mmap ↻ wsl_build fa_cat fa_catn sys_mmap ↻ fa_append sys_mmap ↻ sys_openat_append sys_flock fa_write_all sys_write sys_close ws_put_locked sys_mmap ↻ wc_lockpath sys_openat_append ↻ sys_flock ↻ ws_put_p sys_mmap ↻ ws_len ss_get

structs

none

consts

35const CW_N: i64 = 12 // concurrent workers (= workstreams 0..11)
36const CW_K: i64 = 8 // transitions per worker (12*8 = 96 < 256 manifest cap)
37const CW_MAXWS: i64 = 64
38const CW_REC: i64 = 256
39const CW_LOG: *u8 = "knowledge/status/ws_crash_gate.log"

functions

42func cw_term(w: i64) -> i64 { return (w * 3 + 2) % 5 }
45func so(s: *u8) -> i64
called by 1: main calls 1: sys_write
51func son(v: i64) -> i64
called by 1: main calls 2: sys_mmapsys_write
66func cw_cat(dst: *u8, off: i64, s: *u8) -> i64
71func cw_catn(dst: *u8, off: i64, v: i64) -> i64
82func cw_atoi(s: *u8) -> i64
called by 1: cw_get_state
92func cw_path(out: *u8, tag: *u8, epoch: i64, suffix: *u8) -> i64
called by 1: main calls 2: cw_catcw_catn
103func cw_get_state(prefix: *u8, ws: i64) -> i64
118func cw_worker(reflog: *u8, regp: *u8, w: i64) -> i64
144func cw_spawn(reflog: *u8, regp: *u8) -> i64
166func cw_count_correct(prefix: *u8) -> i64
called by 1: main calls 2: cw_get_statecw_term
176func cw_count_present(prefix: *u8) -> i64
called by 1: main calls 1: cw_get_state
186func main() -> i64