code wiki / _hdl_build / nx_restart_strategy.nx
nx_restart_strategy.nx
buildroot/runtime/_hdl_build/nx_restart_strategy.nx
about
nx_restart_strategy.nx -- S-CLASS supervision restart strategy (operator: "get those s class exceed stable ...
we arent s class stable compared to aws"). PURE decision logic (no syscalls -> unit-gateable offline), grounded
in the researched SOTA (knowledge/library/rel_erlang_otp.txt = OTP supervisor restart-INTENSITY; rel_backoff.txt
= exponential backoff + jitter; rel_circuit_breaker.txt = contain a failing component). THE GAP IT CLOSES: today
nx_hostctl restarts a crashing daemon FOREVER (the gallery/vroom crash-loops spin + spam logs + burn CPU). The
S-class rule (Erlang OTP): a child may restart at most MaxR times within MaxT seconds; exceed that and the
supervisor STOPS restarting it = QUARANTINE + escalate, so the failure is CONTAINED (bounded blast radius) and a
human/alert is engaged instead of an infinite loop. Restarts are spaced by EXPONENTIAL BACKOFF (capped + jittered)
so a flapping dependency gets time to recover and N daemons don't thunder-herd. license_tier: ORIGINAL
dependencies 0 imports · 1 importers
imports: none
imported by: nx_restart_strategy_gate.nx
structs
| none |
consts
| 11 | const RS_RESTART: i64 = 0 // within intensity -> restart (after the backoff delay) |
| 12 | const RS_QUARANTINE: i64 = 1 // crash-loop: restart intensity exceeded -> STOP restarting, escalate (contain it) |
functions
| 16 | func rs_restarts_in_window(times: *i64, n: i64, now: i64, window_sec: i64) -> i64 called by 1: rs_should_restart |
| 28 | func rs_decide(restarts_in_window: i64, max_restarts: i64) -> i64 called by 1: rs_should_restart |
| 35 | func rs_backoff_ms(attempt: i64, base_ms: i64, cap_ms: i64) -> i64 called by 1: main |
| 50 | func rs_jitter_ms(d: i64, seed: i64) -> i64 called by 1: main |
| 60 | func rs_should_restart(times: *i64, n: i64, now: i64, window_sec: i64, max_restarts: i64) -> i64 |