code wiki / _hdl_build / nx_ws_cas_gate.nx

nx_ws_cas_gate.nx

buildroot/runtime/_hdl_build/nx_ws_cas_gate.nx

7705 B202 linesdepth 5pulls 6 transitivereach 0 importersview sourcekind gate/prooftopic ws
docsdependenciesstructsconstsfunctions

about

nx_ws_cas_gate.nx -- the REFEREE for WMS-R8 (concurrent-SSOT-safe registry write). Proves ws_put_locked defeats the concurrent-writer LOST-UPDATE race, AND proves the test can DETECT lost updates (the mandatory negative control): GOOD lane: NWORKERS fork, each ws_put_locked's NPER distinct keys into a FRESH /tmp store. After join, ALL NWORKERS*NPER keys MUST be retrievable -> ZERO lost updates. BAD lane (NEG-CONTROL): the SAME concurrency, SAME distinct keys, but the UNLOCKED ws_put_p -> concurrent segid + manifest.txt RMW collisions LOSE updates -> retrievable < total. If the bad lane loses NOTHING, the detector is worthless -> RED (no false green). Each lane uses its OWN per-run unique prefix under /tmp (epoch-stamped) so every run starts on a pristine store -- /tmp is disposable, so no clearing/unlink is needed (mirrors the R0 gate's /tmp/fa_*.log discipline). Verification uses ss_open ONCE + ss_hget per key (zero per-call IO, the same snapshot discipline the R4 audit was hardened to). The evidence line is one assembled record written via fa_appendz -> it DOGFOODS the restored R0b lock-framed primitive (no torn self-log -- closing the gap the critic flagged on earlier gates). Evidence -> knowledge/status/ws_cas_gate.log. GREEN (exit 0) iff good==total AND bad<total; else RED (exit 1). Sovereign: nx_ws_cas + nx_workstream_store + nx_seg_store + nx_framed_append + nx_syscalls. license_tier: ORIGINAL

dependencies 5 imports · 0 importers

nx_ws_cas.nx nx_workstream_store.nx nx_seg_store.nx nx_framed_append.nx nx_syscalls.nx nx_ws_cas_gate.nx

imports: nx_ws_cas.nxnx_workstream_store.nxnx_seg_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 ↻ cas_prefix cg_cat cg_catn sys_mmap ↻ cas_spawn sys_mmap ↻ sys_fork cas_worker sys_mmap ↻ cg_key cg_cat ↻ cg_catn ↻ cg_cat ↻ cg_catn ↻ ws_put_locked sys_mmap ↻ wc_lockpath sys_openat_append sys_flock ws_put_p sys_mmap ↻ ws_len ss_get sys_mmap ↻ ss_scan ss_begin ss_begin_cap ss_add ss_add2 ss_len ws_seg_next ss_next_segid ss_commit ss_segid_ok sys_mmap ↻

structs

none

consts

25const CAS_NWORKERS: i64 = 12
26const CAS_NPER: i64 = 12 // 12*12 = 144 commits/lane (< the 256 manifest cap)
27const CAS_REC_CAP: i64 = 256
28const CAS_LOG: *u8 = "knowledge/status/ws_cas_gate.log"

functions

31func so(s: *u8) -> i64
called by 1: main calls 1: sys_write
37func son(v: i64) -> i64
called by 1: main calls 2: sys_mmapsys_write
52func cg_cat(dst: *u8, off: i64, s: *u8) -> i64
58func cg_catn(dst: *u8, off: i64, v: i64) -> i64
71func cg_key(out: *u8, w: i64, i: i64) -> i64
82func cas_worker(prefix: *u8, w: i64, locked: i64) -> i64
102func cas_spawn(prefix: *u8, locked: i64) -> i64
125func cas_retrievable(prefix: *u8) -> i64
called by 1: main calls 4: ss_opensys_mmapcg_keyss_hget
145func cas_prefix(out: *u8, tag: *u8, epoch: i64) -> i64
called by 1: main calls 2: cg_catcg_catn
155func main() -> i64