code wiki / (root) / nx_sts_cas_gate.nx

nx_sts_cas_gate.nx

buildroot/runtime/nx_sts_cas_gate.nx

9828 B237 linesdepth 5pulls 7 transitivereach 0 importersview sourcekind gate/prooftopic sts
docsdependenciesstructsconstsfunctions

about

nx_sts_cas_gate.nx -- does an UNLOCKED sts_seed writer LIE ABOUT SUCCEEDING? nx_sts_lock_gate already proves the lost-row race exists (1 of 6 rows survive unlocked). It counts SURVIVING ROWS, and that is the one thing it cannot use to tell the two outcomes apart: SILENT CLOBBER : sts_seed returns a row count, the caller believes it wrote, and the row is gone. LOUD REFUSAL : sts_seed returns negative, the caller KNOWS it did not write, and can retry. Both leave fewer rows in the plane. Only one of them is a data-loss defect; the other is ordinary backpressure. So this gate measures the thing that actually matters: SILENT LOSS = (writers that were TOLD they succeeded) - (rows actually present) Pre-guard that is 5 of 6: six writers each get a success return, one row exists. Every one of those five callers has already moved on, logged success, and returned a row id nobody will ever read. A CAS/generation guard cannot make more rows survive -- the writes genuinely conflict -- but it can drive SILENT LOSS to ZERO, which converts an invisible corruption into a retryable error. NON-VACUITY: if every writer succeeds AND every row survives, nothing raced and the gate says VACUOUS rather than GREEN. A concurrency gate that never triggers the race proves nothing. license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0

dependencies 4 imports · 0 importers

nx_store_seed_lib.nx nx_seg_store.nx nx_syscalls.nx nx_gate_verdict.nx nx_sts_cas_gate.nx

imports: nx_store_seed_lib.nxnx_seg_store.nxnx_syscalls.nxnx_gate_verdict.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main g_p sys_write sys_mmap nxa_die sys_write ↻ sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ g_arm sys_mmap ↻ sts_seed sts_pfxhash ss_begin_cap sys_mmap ↻ sts_mm sys_mmap ↻ sts_werr sys_write ↻ sys_exit ↻ sts_rowkey ss_catn sys_mmap ↻ ss_add ss_add2 ss_w32 ss_len ss_catn ↻ ss_commit_cas ss_segid_ok ss_commit_body

structs

none

consts

27const G_N: i64 = 6
28const G_CAP: i64 = 262144
29const G_WIDEN_MS: i64 = 150
30const G_NL: i64 = 10
31const G_EXIT_SHIFT: i64 = 8
32const G_EXIT_MASK: i64 = 255

functions

34func g_p(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 2: g_nummain calls 1: sys_write
35func g_num(v: i64) -> i64
called by 1: main calls 3: g_psys_mmapsys_write
46func g_rows(prefix: *u8) -> i64
59func g_worker(prefix: *u8, id: i64) -> i64
76func g_arm(prefix: *u8, claims: *i64) -> i64
111func g_worker_fast(prefix: *u8, id: i64) -> i64
121func g_arm_fast(prefix: *u8, claims: *i64) -> i64
148func main(argc: i64, argv: *i64) -> i64