code wiki / (root) / nx_swarm_tend.nx

nx_swarm_tend.nx

buildroot/runtime/nx_swarm_tend.nx

5627 B139 linesdepth 5pulls 7 transitivereach 2 importersview sourcekind tooltopic swarm
docsdependenciesstructsconstsfunctions

about

nx_swarm_tend.nx -- ACTIVE QUEUE TENDER (operator 2026-07-16: "whoever in the nishi RACI is part of the queue -- use it WELL, not fire-and-forget letting things block and get traffic jams; SOTA"). THE GAP: nx_swarm_queue reaps dead holders PASSIVELY (only when a waiter polls sq_try_grant). If a holder dies with NO waiters polling, its slot LEAKS forever; starvation + jams are invisible. My own 1.5B job queued 45min and timed out unnoticed -- the fire-and-forget failure. THE FIX: an active tender the CONDUCTOR (RACI schedule_resources|R = Responsible-for-draining) runs on a loop / on demand: * REAP: proactively DONE any HOLD whose pid is DEAD -> slots free even with no waiter polling. * DETECT: a waiter starved past a jam threshold = JAMMED (the traffic-jam alarm), the oldest wait-age reported so the PM sees pressure building BEFORE a timeout. * VERDICT: OK / DRAINING (waiters progressing) / JAMMED (starvation) -- health, not silence. tend reap + scan + report + verdict-exit (0 OK / 1 DRAINING / 2 JAMMED) Sovereign store (knowledge/store/swarm_sched) is the SSOT; PURE tend_verdict is gate-testable. license_tier: ORIGINAL

dependencies 1 imports · 2 importers

nx_swarm_queue.nx nx_swarm_tend.nx nx_swarm_tend_gate.nx nx_tend_t3_probe.nx

imports: nx_swarm_queue.nx

imported by: nx_swarm_tend_gate.nxnx_tend_t3_probe.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 tend_run tend_reap sov_get_copy sys_mmap ss_get sys_mmap ↻ ss_scan sys_mmap ↻ ss_manifest_dyn ss_scan_seglist sq_ifield ml_pid_alive sys_mmap ↻ std_itoa sys_mmap ↻ sys_openat_rd sys_close sq_mkrow std_itoa ↻ sys_now_us sys_mmap ↻ sys_clock_gettime_mono sq_put_state sq_pidkey std_itoa ↻ sov_put_str sov_put ss_begin ss_add ss_commit sys_now_us ↻ sov_slen tend_health sq_materialize

structs

none

consts

17const TEND_JAM_MS: i64 = 300000 // a waiter silent > 5min = JAMMED (data-driven default)
18const TEND_OK: i64 = 0
19const TEND_DRAINING: i64 = 1
20const TEND_JAMMED: i64 = 2

functions

23func tend_verdict(waiters: i64, oldest_wait_ms: i64, jam_ms: i64) -> i64
called by 2: tend_runmain
31func tend_reap() -> i64
76func tend_health(holders_out: *i64, oldest_ms_out: *i64) -> i64
102func tend_run() -> i64
123func main(argc: i64, argv: *i64) -> i64