code wiki / _hdl_build / nx_claims.nx
nx_claims.nx
buildroot/runtime/_hdl_build/nx_claims.nx
about
nx_claims.nx -- SESSION-CLAIMS AS AN ECOSYSTEM CAPABILITY (ws=ws-intel2, 2026-07-20).
Eats debt 1784408445 (claims protocol shell-only via WSL) + feeds 1784408708 (claims hub
to NAS = standup claim-holder liveness): claim/beat/release/walk become MCP tools/call
verbs on an append-only NAS journal -- peers of nx_ws_sync (journal) / nx_ws_cycle (phase).
HOLDERSHIP IS DERIVED, NEVER STORED (evidence law): latest CLAIM not RELEASEd by its
holder = the claim; freshness = latest CLAIM/BEAT ts by that holder vs its TTL ->
HELD | EXPIRED (crash-expiry BY CONSTRUCTION -- a dead session's claim self-expires,
the F214 lease semantics) | FREE (released) | ABSENT. Claim on a contended resource is
REFUSED fail-closed (exit 3) -- never silently stolen; an EXPIRED claim is claimable.
Frame: <ts>\t<VERB>\t<resource>\t<actor>\t<ttl>\t<note> VERB in {CLAIM, BEAT, RELEASE}
SCALE LAW: windowed reads + declared envelope (window_bytes/truncated/claims_capped).
license_tier: ORIGINAL No hw writes (Rule 26).
claim <journal> <resource> <actor> <ttl_sec> <note> -> HELD | CONTENDED(3)
beat <journal> <resource> <actor> <note> -> BEAT | NOT-HOLDER(3)
release <journal> <resource> <actor> <note> -> RELEASED | NOT-HOLDER(3)
state <journal> <resource> -> ONE-LINE probe: state=HELD|EXPIRED|FREE|ABSENT holder=..
(seq543/seq552: lets nx_seat checkout classify NOT-HOLDER honestly; exit 0 always)
walk <journal> -> JSON all resources
reap <journal> <reaper> <note> -> F214: release ONLY provably-EXPIRED claims
(age>ttl by the claim's OWN ttl field) + ORPHAN-REAPED audit note; idempotent; exit 0
selftest <scratch-journal> -> gate T1..T8 (caller pre-cleans)
dependencies 2 imports · 0 importers
imports: nx_syscalls.nxnx_gate_verdict.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
| 24 | const CL_MAGIC_4096: i64 = 4096 |
| 25 | const CL_MAGIC_2000: i64 = 2000 |
| 26 | const CL_MAGIC_200000: i64 = 200000 |
| 27 | const CL_MAGIC_5000: i64 = 5000 |
| 29 | const CL_WIN: i64 = 4194304 |
| 30 | const CL_OUT: i64 = 262144 |
| 31 | const CL_SOFT: i64 = 49152 |
| 32 | const CL_NOTE_MAX: i64 = 200 |
| 33 | const CL_NAME_MAX: i64 = 120 |
functions
| 35 | func cl_cat(d: *u8, o: i64, s: *u8) -> i64 { var p: i64=o; var i: i64=0; while s[i]!=(0 as u8){ d[p]=s[i]; p=p+1; i=i+1 } return p } |
| 36 | func cl_catn(d: *u8, o: i64, v: i64) -> i64 |
| 48 | func cl_vlen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } |
| 49 | func cl_atoi_z(s: *u8) -> i64 { var v: i64=0; var i: i64=0; while s[i]!=(0 as u8){ let c: i64=s[i] as i64; if c>=48 { if c<=57 { v=v*10+(c-48) } } i=i+1 } return v } called by 1: main |
| 50 | func cl_read(path: *u8, buf: *u8, cap: i64) -> i64 |
| 60 | func cl_append(journal: *u8, ts: i64, verb: *u8, res: *u8, actor: *u8, ttl: i64, note: *u8) -> i64 called by 3: cl_reapcl_selftestmain calls 7: sys_now_realtime_secsys_mmapcl_catncl_catsys_openat_appendsys_write+1 |
| 92 | func cl_le(q: *u8, i: i64, n: i64) -> i64 |
| 98 | func cl_col(q: *u8, ls: i64, le: i64, c: i64, out: *i64) -> i64 |
| 114 | func cl_lit_eq(q: *u8, s: i64, e: i64, lit: *u8) -> i64 |
| 120 | func cl_span_eq(q: *u8, s1: i64, e1: i64, s2: i64, e2: i64) -> i64 |
| 126 | func cl_atoi(q: *u8, s: i64, e: i64) -> i64 called by 1: cl_state |
| 134 | func cl_state(q: *u8, cx: *i64, res_s: i64, res_e: i64, out: *i64) -> i64 |
| 181 | func cl_state_name(st: i64) -> *u8 |
| 188 | func cl_res_seen(q: *u8, upto: i64, r_s: i64, r_e: i64) -> i64 |
| 199 | func cl_res_span_lit(q: *u8, cx: *i64, res: *u8, out: *i64) -> i64 |
| 211 | func cl_note_span(q: *u8, cx: *i64, res_s: i64, res_e: i64, out: *i64) -> i64 |
| 228 | func cl_jesc(d: *u8, o: i64, q: *u8, s: i64, e: i64, maxb: i64) -> i64 |
| 242 | func cl_key(d: *u8, o: i64, name: *u8) -> i64 |
| 252 | func cl_qlit(d: *u8, o: i64, s: *u8) -> i64 |
| 259 | func cl_emit_res(d: *u8, o: i64, q: *u8, cx: *i64, r_s: i64, r_e: i64) -> i64 |
| 300 | func cl_walk_json(q: *u8, cx: *i64, d: *u8) -> i64 |
| 382 | func cl_hesc(d: *u8, o: i64, q: *u8, s: i64, e: i64, maxb: i64) -> i64 |
| 396 | func cl_page_html(q: *u8, cx: *i64, d: *u8) -> i64 |
| 480 | func cl_find(d: *u8, dn: i64, lit: *u8) -> i64 |
| 498 | func cl_span_z(q: *u8, s: i64, e: i64, d: *u8, cap: i64) -> i64 called by 1: cl_reap |
| 505 | func cl_reap(journal: *u8, q: *u8, cx: *i64, reaper: *u8, note: *u8) -> i64 |
| 569 | func cl_selftest(journal: *u8) -> i64 |
| 701 | func main(argc: i64, argv: *i64) -> i64 |