code wiki / _hdl_build / nx_lease.nx
nx_lease.nx
buildroot/runtime/_hdl_build/nx_lease.nx
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
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
structs
| none |
consts
| 24 | const LS_ROOT_BUILDROOT: *u8 = "buildroot/knowledge/lease/" |
| 25 | const LS_ROOT_PARENT: *u8 = "../knowledge/lease/" |
| 26 | const LS_ROOTS: i64 = 3 |
functions
| 27 | func ls_root_at(ri: i64) -> *u8 |
| 34 | func ls_probe_roots(name: *u8, rb: *u8, rsel: *i64) -> i64 |
| 64 | func main(argc: i64, argv: *i64) -> i64 |