code wiki / (root) / nx_model_lane_core.nx

nx_model_lane_core.nx

buildroot/runtime/nx_model_lane_core.nx

11649 B327 linesdepth 3pulls 3 transitivereach 16 importersview sourcekind librarytopic model
docsdependenciesstructsconstsfunctions

about

nx_model_lane_core.nx -- SOVEREIGN MODEL-LANE LEASE (pure core, no main; CLI = nx_model_lane, gate = nx_model_lane_gate). Eats the 2026-07-16 bug class: multiple sessions launching model-scale workloads (11-12GB dequant caches) into one WSL VM -> kernel OOM storm / VM collapse (dmesg: nx_forge_bestof OOM-killed alongside the 1.5B serve). The Nishi-owned cure: ONE lane lease file gates model-scale launches on this worker -- claim BEFORE launching, free after. Composes the proven idioms: O_EXCL create = the lock (dl_lock/rt_lock lineage, kernel-guaranteed single creator, no TOCTOU) + holder record stamped INTO the lease + staleness = holder-pid dead (via /proc/<pid>/comm) OR age>ttl + /proc/meminfo MemAvailable HEADROOM CHECK (nx_resource_arbiter DENIED_NO_BUDGET semantics at the file level: a FREE lane still refuses a claim the box cannot back). rc map: 0 ok · 10 held-by-other (live holder printed) · 11 headroom-denied · 12 bad-args · 13 free-refused-not-holder · 14 lease-corrupt (fail-loud, never steal). Record: holder|est_mb|pid|epoch_us|ttl_sec\n (pid = the WORKLOAD's pid, callers pass $$, never the claim CLI's own pid -- the CLI exits immediately). license_tier: ORIGINAL

dependencies 2 imports · 8 importers

nx_syscalls.nx nx_lib_std.nx nx_model_lane_core.nx nx_claim_core.nx nx_deploy_leash.nx nx_model_lane.nx nx_model_lane_gate.nx nx_pid_diag.nx nx_rv64_const_probe.nx nx_swarm_admit.nx nx_swarm_queue.nx

imports: nx_syscalls.nxnx_lib_std.nx

imported by: nx_claim_core.nxnx_deploy_leash.nxnx_model_lane.nxnx_model_lane_gate.nxnx_pid_diag.nxnx_rv64_const_probe.nxnx_swarm_admit.nxnx_swarm_queue.nx

structs

none

consts

19const ML_LEASE_DEFAULT: *u8 = "knowledge/status/model_lane.lease"
20const ML_OEXCL: i64 = 193 // O_CREAT|O_EXCL|O_WRONLY (dl lineage)
21const ML_MODE: i64 = 420 // 0644
22const ML_FLOOR_MB: i64 = 2048 // headroom floor the CLI enforces above est_mb

functions

34func ml_ncores() -> i64
62func ml_load1() -> i64
80func ml_load_over(load1: i64, load_max: i64) -> i64
88func ml_meminfo_avail_mb() -> i64
128func ml_pid_alive(pid: i64) -> i64
148func ml_parse(buf: *u8, n: i64, hbuf: *u8, f: *i64) -> i64
called by 2: ml_claimml_free
195func ml_try_create(path: *u8, holder: *u8, est_mb: i64, pid: i64, ttl_sec: i64) -> i64
224func ml_claim(path: *u8, holder: *u8, est_mb: i64, pid: i64, ttl_sec: i64, floor_mb: i64) -> i64
288func ml_free(path: *u8, holder: *u8) -> i64
314func ml_status(path: *u8) -> i64