code wiki / (root) / nx_swarm_admit.nx

nx_swarm_admit.nx

buildroot/runtime/nx_swarm_admit.nx

3964 B101 linesdepth 4pulls 4 transitivereach 1 importersview sourcekind tooltopic swarm
docsdependenciesstructsconstsfunctions

about

nx_swarm_admit.nx -- THE GENERAL ECOSYSTEM ADMISSION CAPABILITY (operator 2026-07-16: host- oversubscription control is the SWARM's job as the cluster scheduler, not a forge hack). Any workstream's heavy launcher (forge model decode, codec, image-gen, training, a big build) calls admit BEFORE starting; the swarm returns GRANT/QUEUE/DENY from LIVE host telemetry so the box never hits the load-105 collision (two uncoordinated model workloads). Supersedes the forge- specific nx_model_lane by generalizing it: workstream+kind keyed, telemetry-backed, one verdict. sa_verdict(load1, ncpu, avail_mb, est_mb, floor_mb, held, max_conc) -- PURE, gate-testable: DENY_LOAD if load1>=ncpu · DENY_RAM if avail<est+floor · QUEUE if held>=max_conc · else GRANT. Composes nx_model_lane_core (proven /proc telemetry: ml_load1/ml_ncores/ml_meminfo_avail_mb) -- DRY, no reinvention. RUNG 2 = fairness via nx_resource_arbiter (nx_ra_request) + auto cross-proc holder ledger; RUNG 3 = beacon nb_loadavg_milli canonical source + MCP-expose on the swarm plane. admit <workstream> <kind> <est_mb> <held> <max_conc> exit = verdict (0 GRANT/1 QUEUE/2/3 DENY) license_tier: ORIGINAL

dependencies 1 imports · 1 importers

nx_model_lane_core.nx nx_swarm_admit.nx nx_swarm_admit_gate.nx

imports: nx_model_lane_core.nx

imported by: nx_swarm_admit_gate.nx

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

main std_putln std_puts std_slen sys_write std_streq std_atoi sa_admit_live ml_load1 sys_mmap sys_openat_rd sys_read sys_close ml_ncores sys_mmap ↻ sys_openat_rd ↻ sys_read ↻ sys_close ↻ ml_meminfo_avail_mb sys_mmap ↻ sys_openat_rd ↻ sys_read ↻ sys_close ↻ std_slen ↻ sa_verdict std_puts ↻ std_pdec sys_mmap ↻ std_itoa sys_mmap ↻ sys_write ↻ std_putln ↻ sa_verdict_name

structs

none

consts

16const SA_GRANT: i64 = 0
17const SA_QUEUE: i64 = 1
18const SA_DENY_LOAD: i64 = 2
19const SA_DENY_RAM: i64 = 3
20const SA_FLOOR_MB: i64 = 2048 // headroom floor above est (data-driven default; overridable later via svc-config)

functions

23func sa_verdict(load1: i64, ncpu: i64, avail_mb: i64, est_mb: i64, floor_mb: i64, held: i64, max_conc: i64) -> i64
called by 2: sa_admit_livemain
34func sa_verdict_name(v: i64) -> *u8
called by 1: sa_admit_live
43func sa_admit_live(workstream: *u8, kind: *u8, est_mb: i64, held: i64, max_conc: i64) -> i64
69func main(argc: i64, argv: *i64) -> i64