nx_framed_append_gate.nx
buildroot/runtime/nx_framed_append_gate.nx
about
nx_framed_append_gate.nx -- the REFEREE for WMS-R0 (atomic framed-append).
Proves the nx_framed_append primitive defeats concurrent-appender tearing, AND
proves the test can actually DETECT tearing (the mandatory negative control).
GOOD lane: N workers fork concurrently, each emits NRECS records via the NEW
single-write primitive fa_append(GOODPATH, ...). Expect ZERO torn
lines and ALL N*NRECS lines present (nothing lost, nothing torn).
BAD lane (NEGATIVE CONTROL): the SAME concurrency, but each record is emitted
the OLD way -- a SEQUENCE of separate sys_write() calls per record.
O_APPEND only makes ONE write atomic, not the sequence, so workers
interleave -> torn lines MUST appear. bad_torn == 0 => the detector
is worthless => RED (no false green).
TAMPER: an oversized record (rec_len+1 > cap) must be REJECTED with -2,
never silently written/torn.
A line is WELL-FORMED iff it starts "FA w=" AND the bytes just before its '\n'
are "END" AND it contains exactly one " END" token. Any interleaving violates
one of those -> counted as torn. Output: rows -> stdout + the evidence log
knowledge/status/framed_append_gate.log, then a final verdict line. Exit 0 on
GREEN, 1 on RED. Sovereign: only nx_syscalls + nx_framed_append.
license_tier: ORIGINAL
dependencies 2 imports · 0 importers
imports: nx_syscalls.nxnx_framed_append.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
| 26 | const NWORKERS: i64 = 16 // concurrency (raised so the neg-control tears robustly) |
| 27 | const NRECS: i64 = 300 // records per worker |
| 28 | const RECCAP: i64 = 256 // bounded record size for the primitive |
functions
| 31 | func gp(logfd: i64, s: *u8) -> i64 |
| 38 | func gn(logfd: i64, v: i64) -> i64 |
| 55 | func build_rec(buf: *u8, wid: i64, seq: i64, pid: i64) -> i64 |
| 68 | func good_worker(wid: i64) -> i64 |
| 84 | func bad_worker(wid: i64) -> i64 |
| 122 | func spawn_all(which: i64) -> i64 |
| 151 | func count_torn(path: *u8, outs: *i64) -> i64 |
| 220 | func main() -> i64 |