code wiki / _hdl_build / nx_exclprobe.nx

nx_exclprobe.nx

buildroot/runtime/_hdl_build/nx_exclprobe.nx

3352 B64 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_exclprobe.nx -- DOES O_CREAT|O_EXCL VIA __syscall ACTUALLY WORK HERE? (2026-08-07) WHY THIS EXISTS. The async job lane assigns ids by probing whether `_jobs/job_<id>.done` EXISTS, but a RUNNING job has no `.done`, so two tools/call in the same second get the IDENTICAL id and the loser's receipt is overwritten (observed live: two nx_debt add both returned id=1786110674). The correct fix is an ATOMIC reservation, and `dl_lock` in nx_dispatch_lease already does exactly that with __syscall(SYS_OPENAT, AT_FDCWD, path, 193, 420, 0, 0). But banked memory warns that LITERAL __syscall numbers are rv64->x86 TRANSLATED, which would make 257 mean something else entirely -- and I am not shipping that into the daemon that serves /mcp on a guess after two outages today. ★ VERIFY A PRIMITIVE IN A THROWAWAY BEFORE PUTTING IT IN THE THING EVERYTHING ELSE DEPENDS ON. This organ answers it decisively and touches nothing but /tmp. nx_exclprobe -> JSON {first_create, second_create, verdict} EXPECTED IF THE PRIMITIVE IS SOUND: first >= 0 (we created it), second < 0 (EEXIST refused us). If BOTH succeed, O_EXCL is not being honoured and the whole approach is unusable. If BOTH fail, the syscall number is being translated and 257 is not openat here. license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_exclprobe.nx

imports: nx_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_unlinkat sys_close sys_openat_rd xw sys_write xn 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_exit ↻

structs

none

consts

19const XP_SYS_OPENAT: i64 = 257
20const XP_AT_FDCWD: i64 = 0 - 100
21const XP_OEXCL: i64 = 193 // O_CREAT(0x40)|O_EXCL(0x80)|O_WRONLY(0x1)
22const XP_MODE: i64 = 420 // 0644
23const XP_PATH: *u8 = "/tmp/nx_exclprobe.claim" as *u8

functions

25func xw(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 1: main calls 1: sys_write
26func xn(v: i64) -> i64
called by 1: main calls 2: sys_mmapsys_write
39func main() -> i64