code wiki / _hdl_build / nx_lease.nx

nx_lease.nx

buildroot/runtime/_hdl_build/nx_lease.nx

18110 B281 linesdepth 7pulls 7 transitivereach 2 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_lease.nx -- THE SOVEREIGN LEASE PRIMITIVE (eats debt seq12/D002: "WMS write lane unlocked = race debt; claims/lease it"). Advisory TTL leases for contended write lanes (ws_put / planes / MEMORY-class shared state): ACQUIRE is atomic (mkdirat -- EEXIST = held), takeover of a stale or released lease is CAS-VERIFIED (write own stamp via tmp+renameat, read back, own nonce wins -- last-writer-wins + verify = the loser backs off), RELEASE flips the stamp to released and NEVER unlinks or rmdirs (the never-unlink-lock law: lock dirs are additive; a released stamp is the reusable slot). Self-mkdirs knowledge/lease (rule 20). Stamp = one line: held|released<TAB>owner<TAB>epoch<TAB>ttl<TAB>nonce Stale = state held AND now > epoch + ttl (the HOLDER's declared ttl -- crash-safe by construction: a dead holder's lease self-expires; no daemon needed). nx_lease acquire <name> <owner> <ttl-sec> exit 0 ACQUIRED | 3 BUSY (holder shown) | 4 io nx_lease release <name> <owner> exit 0 RELEASED | 3 REFUSED not-holder | 4 io nx_lease check <name> exit 0 prints stamp | 1 free nx_lease selftest 7 teeth, verdict=GREEN/RED, exit 0/5 name grammar [a-zA-Z0-9_-] only (deny slash/dot/traversal by construction). expect_exit: 0 license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 1 imports · 2 importers

nx_lease_lib.nx nx_lease.nx nx_arbiter_gate.nx nx_gate_mutation_sweep.nx

imports: nx_lease_lib.nx

imported by: nx_arbiter_gate.nxnx_gate_mutation_sweep.nx

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

main ls_werr sys_write ls_slen ls_name_ok ls_acquire ls_mkdir ls_acquire_root ls_mkdir ↻ 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 ↻ ls_dirpath_root ls_cat ls_pid sys_now_realtime_sec sys_mmap ↻ sys_clock_gettime_real ls_claim sys_mmap ↻ ls_cat ↻ ls_catn sys_mmap ↻ sys_now_realtime_sec ↻ ls_open_excl sys_write ↻ sys_close ls_claim_takeover

structs

none

consts

24const LS_ROOT_BUILDROOT: *u8 = "buildroot/knowledge/lease/"
25const LS_ROOT_PARENT: *u8 = "../knowledge/lease/"
26const LS_ROOTS: i64 = 3

functions

27func ls_root_at(ri: i64) -> *u8
called by 2: ls_probe_rootsmain
34func ls_probe_roots(name: *u8, rb: *u8, rsel: *i64) -> i64
64func main(argc: i64, argv: *i64) -> i64