nx_swarm_place.nx
buildroot/runtime/nx_swarm_place.nx
about
nx_swarm_place.nx -- SWARM FABRIC placement brain (SF-R2): given the fleet snapshot (NODE rows
from nx_swarm_beat) pick the best node for a chunky job. The 2025/26 radar's #1+#2 gaps
(energy-aware 98 + load-aware 65) in one organ. GREENFIELD: pure integer cost model over the
beacon's live truth; freshness is a HARD gate (you cannot place on stale truth -- inherits the
beat store's liveness liar-killers); battery politeness EXCLUDES (never cook a phone/laptop);
thermal sheds (heavy penalty, still schedulable in an emergency); unknown (-1) sensors are
NEUTRAL (honest-absent must not punish a node that cannot report).
nx_swarm_place pick <snap> <window_sec> [conf] rank + pick; prints per-node verdicts + winner
nx_swarm_place [gate] self-gate (8 tests incl liar-killers)
CONF (rule 11, data-driven -- knowledge/swarm/place.conf ships the live lever; bootstrap
defaults compiled as the last tier of the config hierarchy): lines "key value":
w_load 600 · w_mem 400 · shed_temp_mc 85000 · batt_floor_pct 20
SCORE (0..1000): base = (w_load*load_headroom + w_mem*mem_headroom)/(w_load+w_mem);
load_headroom = 1000-lpc clamped; mem_headroom = (100-mem_used_pct)*10 clamped;
temp_mc >= shed → base/10. EXCLUDED: stale/forged ts · batt < floor · malformed row.
Ties: first-in-snap wins (deterministic). license_tier: ORIGINAL expect_exit:0
dependencies 3 imports · 0 importers
imports: nx_syscalls.nxnx_framed_append.nxnx_swarm_lib.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
| 22 | const SP_MAGIC_85000: i64 = 85000 |
| 23 | const SP_MAGIC_1024: i64 = 1024 |
| 24 | const SP_MAGIC_3600: i64 = 3600 |
| 25 | const SP_MAGIC_90000: i64 = 90000 |
| 26 | const SP_MAGIC_40000: i64 = 40000 |
| 27 | const SP_MAGIC_7200000000: i64 = 7200000000 |
| 29 | const SP_SNAP_CAP: i64 = 65536 |
| 30 | const SP_CONF_CAP: i64 = 4096 |
functions
| 32 | func sp_puts(s: *u8) -> i64 { sys_write(1, s, fa_len(s)); return 0 } |
| 34 | func sp_eq(a: *u8, b: *u8) -> i64 |
| 42 | func sp_starts(buf: *u8, n: i64, p: i64, key: *u8) -> i64 called by 1: sp_conf_load |
| 54 | func sp_conf_load(path: *u8, c: *i64) -> i64 |
| 85 | func sp_score(f: *i64, now: i64, window_sec: i64, c: *i64, why: *i64) -> i64 |
| 106 | func sp_pick(snap: *u8, window_sec: i64, confpath: *u8, wname: *u8, wcap: i64) -> i64 |
| 180 | func sp_mkrow(dst: *u8, name: *u8, lpc: i64, memu: i64, ts: i64, temp: i64, batt: i64) -> i64 |
| 200 | func sp_wfile(path: *u8, buf: *u8, n: i64) -> i64 |
| 209 | func sp_gate() -> i64 |
| 316 | func main(argc: i64, argv: *i64) -> i64 |