code wiki / (root) / nx_mediapath.nx

nx_mediapath.nx

buildroot/runtime/nx_mediapath.nx

5303 B124 linesdepth 3pulls 3 transitivereach 3 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_mediapath.nx -- self-healing BEST-MEDIA-PATH selection: the unifier. Generalizes the proven self-heal decision pattern (nx_netscope_heal: KEEP/SWITCH/GIVEUP + anti-flap hysteresis) from "best DNS resolver" to "best media path/relay", ranking candidates by MEASURED link quality (nx_linkqual lq_score) instead of reachability. So a game match or a video call given N candidate paths auto-migrates to the best-quality one when the current path degrades -- WITHOUT flapping on noise. Pure/deterministic (decide over a frozen set of LinkFlows) -> KAT-able. Integer-only, imports only nx_linkqual (-> nx_syscalls); sovereign, no new deps. Concepts: Happy-Eyeballs best-of-N + hysteresis (already researched for the resolver case); quality = the link-quality score. license_tier: ORIGINAL

dependencies 1 imports · 2 importers

nx_linkqual.nx nx_mediapath.nx nx_mediapath_test.nx nx_pathstripe.nx

imports: nx_linkqual.nx

imported by: nx_mediapath_test.nxnx_pathstripe.nx

structs

32struct MediaDecision { action: i64, target_idx: i64, target_score: i64, reason: i64 }

consts

18const MP_KEEP: i64 = 0
19const MP_SWITCH: i64 = 1
20const MP_GIVEUP: i64 = 2
22const MP_R_HEALTHY: i64 = 0 // incumbent still best -> stay
23const MP_R_DEGRADED: i64 = 1 // incumbent dropped below usable -> move to best
24const MP_R_BETTER: i64 = 2 // a meaningfully better path appeared
25const MP_R_NONE: i64 = 3 // no usable path (stuck on least-bad / no candidates)
29const MP_QUALITY_FLOOR: i64 = 40 // below = FAIR/POOR boundary = unusable
30const MP_SWITCH_MARGIN: i64 = 15 // only switch a usable path for >=15 pts gain
33const MP_DECISION_BYTES: i64 = 32

functions

37func mp_select_best(flows: *i64, n: i64) -> i64
called by 1: mp_decide calls 1: lq_score
50func mp_decide(flows: *i64, n: i64, incumbent_idx: i64, out: *MediaDecision) -> i64
called by 1: main calls 2: mp_select_bestlq_score
98func mp_render(out: *MediaDecision) -> i64