code wiki / _hdl_build / nx_ws_cas_gate.nx
nx_ws_cas_gate.nx
buildroot/runtime/_hdl_build/nx_ws_cas_gate.nx
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
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
structs
| none |
consts
| 25 | const CAS_NWORKERS: i64 = 12 |
| 26 | const CAS_NPER: i64 = 12 // 12*12 = 144 commits/lane (< the 256 manifest cap) |
| 27 | const CAS_REC_CAP: i64 = 256 |
| 28 | const CAS_LOG: *u8 = "knowledge/status/ws_cas_gate.log" |
functions
| 31 | func so(s: *u8) -> i64 |
| 37 | func son(v: i64) -> i64 |
| 52 | func cg_cat(dst: *u8, off: i64, s: *u8) -> i64 |
| 58 | func cg_catn(dst: *u8, off: i64, v: i64) -> i64 |
| 71 | func cg_key(out: *u8, w: i64, i: i64) -> i64 |
| 82 | func cas_worker(prefix: *u8, w: i64, locked: i64) -> i64 |
| 102 | func cas_spawn(prefix: *u8, locked: i64) -> i64 |
| 125 | func cas_retrievable(prefix: *u8) -> i64 |
| 145 | func cas_prefix(out: *u8, tag: *u8, epoch: i64) -> i64 |
| 155 | func main() -> i64 |