code wiki / (root) / nx_swarm_arbitrate.nx

nx_swarm_arbitrate.nx

buildroot/runtime/nx_swarm_arbitrate.nx

6835 B119 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic swarm
docsdependenciesstructsconstsfunctions

about

nx_swarm_arbitrate.nx -- SWARM FABRIC cross-workstream RESOURCE ARBITRATION (SF-ARB): the layer that keeps COMPETING workstreams (a gen job, LLM inference, model training) sharing the ONE heterogeneous pool FAIRLY -- no workstream monopolizes, none starves, high-priority preempts low. This is the orchestration north-star's R-ORCH-4 (competing-workstream arbitration) for RESOURCES, and it FEEDS nx_resource_arbiter (which already models VRAM/RAM/CPU/GPU allocation with max-share fairness + priority + preemption but was "fed by nothing"). COMPOSES (check-before-build 2026-07-15): nx_resource_arbiter (nx_ra_new / set_budget / set_max_share / request / preempt / total_held) -- verified compiles+gates today. This organ is the FEED (pool budgets from fleet totals = the beacon telemetry) + the workstream-request driver + the fairness gate. It does NOT reimplement allocation -- that's the arbiter's job (rule 15 DRY / rule 9 single-responsibility: pack places chunks on participants; THIS shares the pool across workstreams; the arbiter allocates). ★★THE LIAR-KILLERS: (1) NO-MONOPOLY -- a workstream requesting > max-share of a resource is DENIED_MAX_ SHARE (can't take the whole pool). (2) NO-STARVATION -- after the greedy high-demand workstream is capped, a lower one still gets a (partial) grant, never zero-by-design. (3) BUDGET-HONEST -- total granted never exceeds the pool. (4) PRIORITY-PREEMPTION -- a higher-priority workstream reclaims from a lower one. (5) determinism. nx_swarm_arbitrate -- self-gate: the competing-workstream fairness scenario license_tier: ORIGINAL expect_exit:0

dependencies 1 imports · 0 importers

nx_resource_arbiter.nx nx_swarm_arbitrate.nx

imports: nx_resource_arbiter.nx

imported by: nobody (leaf or entry point)

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

main nx_ra_new sys_mmap nx_ra_set_budget nx_ra_kind_is_valid nx_ra_set_max_share nx_ra_kind_is_valid ↻ sa_puts nx_ra_request nx_ra_kind_is_valid ↻ nx_ra_total_held _ra_alloc_at nx_ra_held_by_cell _ra_alloc_at ↻ sa_report sa_puts ↻ sa_putn nx_ra_total_held ↻ nx_ra_preempt nx_ra_kind_is_valid ↻ _ra_alloc_at ↻ sa_putn ↻

structs

none

consts

22const K_MAGIC_1000000: i64 = 1000000
23const K_MAGIC_20000: i64 = 20000
24const K_MAGIC_15000: i64 = 15000
25const K_MAGIC_10000: i64 = 10000
26const K_MAGIC_8000: i64 = 8000
27const K_MAGIC_5000: i64 = 5000
28const K_MAGIC_2000: i64 = 2000
29const K_MAGIC_3000: i64 = 3000

functions

31func sa_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 2: sa_reportmain
32func sa_putn(v: i64) -> i64
called by 2: sa_reportmain
45func sa_report(name: *u8, v: i64, granted: i64) -> i64
called by 1: main calls 2: sa_putssa_putn
51func main() -> i64