code wiki / (root) / nx_idemp.nx

nx_idemp.nx

buildroot/runtime/nx_idemp.nx

15874 B310 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_idemp.nx -- IS THIS GATE IDEMPOTENT? RUN IT TWICE AND COMPARE. No heuristic, no grep. WHY. Rule 10 says every operation must be safe to run twice, and the estate has been paying for the gates that are not -- three confirmed the same day (debt 1786128761): nx_segstore_uncap_gate 7/9 RED from a stale seg-2106 fixture its header told the RUNNER to clean. nx_law_warden T15 25/26 RED for hours, filed sev-7 as a broken per-plane counter. The counter was always right; /tmp/lwseg held zzlw-seg-2 and zzlw-seg-3 from an older revision of the fixture, so segamp correctly said max=4 and the assertion demanded 2. A capability guarding an OOM class sat indicted by its leftovers. nx_coa_gate THE MONEY PATH -- intermittent, with the FAILING TOOTH MOVING between runs, until 2026-07-31 root-caused as C6 registering a side in a PERSISTENT plane so C5 passed only on a virgin store. ★★★★★★A GATE THAT IS NOT IDEMPOTENT REPORTS ON ITS FIRST RUN AND LIES ABOUT EVERY RUN AFTER. ★★★★★★AN INTERMITTENT FAILURE WHOSE FAILING TOOTH MOVES IS A FIXTURE DEFECT, NOT A RACE -- A RACE USUALLY BREAKS THE SAME ASSERTION. That one distinction would have saved each of the three. WHY MEASURE INSTEAD OF SCAN. The obvious approach is to grep the 140 measured `sys_mkdir("/tmp/...")` sites for a matching cleanup. That is a PROXY: it asks whether the author wrote a pattern, not whether the gate survives a second run. It cannot see a fixture poisoned through a persistent seg-store plane (exactly nx_coa_gate's defect, where no /tmp cleanup would have helped), and it calls a gate SAFE for having an unlink list that is merely incomplete. ★★★★★★RUNNING IT TWICE IS NOT A BETTER HEURISTIC, IT IS THE DEFINITION. Ask the property directly. WHAT IT REPORTS, and the verdict IS the decision: IDEMPOTENT -- run 1 and run 2 agree on exit code AND on the passed/total tally. NON-IDEMPOTENT -- they disagree. The FIRST run's answer is the one everyone has been trusting. UNMEASURED -- the gate could not be executed twice (absent, timeout, spawn failure). NEVER folded into IDEMPOTENT: an unrunnable gate is not a clean one. ⚠DECLARED ENVELOPE, so nobody reads more into a green than it carries: - Two runs prove non-idempotency when they DISAGREE. Agreement is evidence, not proof: a gate whose fixture only poisons on the third run reads clean here. ★TWO RUNS FALSIFY; THEY DO NOT CERTIFY. Use `-n` to raise the run count when a gate is suspected and cheap. - It runs REAL gates with REAL side effects. That is the point -- the second run is the measurement -- but it means this must never be pointed at anything that mutates production beyond its fixture. The roster is verifiers only, matching /api/gate_run's own bound. usage: nx_idemp <gate-elf-path> [runs] default 2 runs license_tier: ORIGINAL Executes verifiers, writes nothing of its own. No hw writes (Rule 26).

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_guarded_run.nx nx_idemp.nx

imports: nx_syscalls.nxnx_guarded_run.nx

imported by: nobody (leaf or entry point)

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

main id_puts sys_write id_len sys_exit id_atoi id_putn id_puts ↻ 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 ↻ sys_write ↻ sys_mmap ↻ sys_now_us sys_mmap ↻ sys_clock_gettime_mono id_run_once sys_openat_wr sys_mmap ↻ nx_guarded_run sys_fork sys_dup3 sys_execve sys_exit ↻ sys_mmap ↻ sys_now_ms sys_mmap ↻ sys_clock_gettime_mono ↻

structs

none

consts

41const ID_MAGIC_100000: i64 = 100000
43const ID_DEADLINE_MS: i64 = 180000
44const ID_OUTCAP: i64 = 1048576
45const ID_PATHCAP: i64 = 1024
46const ID_MAXRUNS: i64 = 8
47const ID_DEFRUNS: i64 = 2
48const ID_MODE_TMP: i64 = 384 // 0600
49const ID_ZERO: i64 = 48
50const ID_NINE: i64 = 57
51const ID_SLASH: i64 = 47

functions

53func id_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
54func id_puts(s: *u8) -> i64 { sys_write(1, s, id_len(s)); return 0 }
called by 2: id_putnmain calls 2: sys_writeid_len
55func id_putn(v: i64) -> i64
called by 1: main calls 3: id_putssys_mmapsys_write
65func id_atoi(s: *u8) -> i64
called by 1: main
102func id_scan_num(b: *u8, n: i64, at: i64, out: *i64) -> i64
called by 1: id_tally
117func id_find(b: *u8, n: i64, pat: *u8) -> i64
called by 1: id_tally calls 1: id_len
130func id_count(b: *u8, n: i64, pat: *u8) -> i64
called by 1: id_tally calls 1: id_len
143func id_tally(b: *u8, n: i64) -> i64
202func id_run_once(path: *u8, tmpp: *u8, out: *i64) -> i64
220func main(argc: i64, argv: *i64) -> i64