nx_gpuguard.nx
buildroot/runtime/nx_gpuguard.nx
about
nx_gpuguard.nx -- GPU SERVICE RESIDENCY GUARD: the DECISION, natively.
nx_gpuguard decide <held_mb> <util_pct> <listening> <idle_ticks> [conf]
nx_gpuguard -- self-gate (teeth incl. the liar-killers)
WHY IT EXISTS, MEASURED 2026-08-14: sd-server was running WITHOUT --offload-to-cpu, so its weights
were PINNED in VRAM for the process lifetime -- 302 MiB free of 16,303 on the 5080 -- and the gen
lane had been dead for writes for hours. The launcher carrying that flag already existed, written
to the operator's 2026-08-05 directive. NOTHING CHECKED THAT THE RUNNING PROCESS WAS THE ONE THE
LAUNCHER STARTS. That is an adoption gap, and an adoption gap needs a guard, not another launcher.
★IT CHECKS THE CONDITION, NOT THE COMMAND LINE. A cmdline check answers "was it started right?";
this answers "is it behaving right?" -- which catches a bad start however it happened, survives a
flag being renamed, and is measurable from outside the process. Behaviour over configuration.
★THE JUDGEMENT IS HERE, IN THE ORGAN. The laptop-side wire may only MEASURE (footprint, utilisation,
is-the-port-bound) and ACT on the verdict. It decides nothing. The .ps1 keeper this replaces decided
"wedged vs still loading" in shell, and the .ps1 sentinel classified "is a game present" in shell;
both are exactly the shape the estate forbids -- shell doing work rather than carrying it.
★held_mb IS THE SERVICE'S OWN FOOTPRINT, NOT THE CARD'S. Judging on card-wide usage would read a
game's VRAM as our service being resident and restart an innocent, healthy engine.
Every threshold lives in knowledge/gpu_guard.conf. This organ carries NONE.
exit/verdict: 0 OK | 1 START | 2 RESTART-RESIDENT | 3 RESTART-WEDGED | 4 BUSY | 5 WAIT | 6 REFUSE
license_tier: ORIGINAL. No hw writes (Rule 26).
dependencies 1 imports · 0 importers
imports: nx_syscalls.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
| 29 | const GG_OK: i64 = 0 |
| 30 | const GG_START: i64 = 1 |
| 31 | const GG_RESTART_RESIDENT: i64 = 2 |
| 32 | const GG_RESTART_WEDGED: i64 = 3 |
| 33 | const GG_BUSY: i64 = 4 |
| 34 | const GG_WAIT: i64 = 5 |
| 35 | const GG_REFUSE: i64 = 6 |
| 37 | const GG_CFG_N: i64 = 4 |
| 38 | const GG_CFG_HOLD: i64 = 0 |
| 39 | const GG_CFG_BUSY: i64 = 1 |
| 40 | const GG_CFG_IDLE: i64 = 2 |
| 41 | const GG_CFG_WEDGE: i64 = 3 |
| 42 | const GG_CONF_DEFAULT: *u8 = "knowledge/gpu_guard.conf" |
functions
| 44 | func gg_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } called by 1: gg_puts |
| 45 | func gg_puts(s: *u8) -> i64 { sys_write(1, s, gg_len(s)); return 0 } |
| 46 | func gg_putn(v: i64) -> i64 |
| 59 | func gg_atoi(s: *u8) -> i64 called by 1: main |
| 71 | func gg_keyis(b: *u8, p: i64, len: i64, key: *u8) -> i64 called by 1: gg_slot |
| 80 | func gg_slot(b: *u8, p: i64, len: i64) -> i64 |
| 89 | func gg_rdint(b: *u8, pos: *i64, end: i64) -> i64 |
| 113 | func gg_parse(b: *u8, len: i64, cfg: *i64, seen: *i64) -> i64 |
| 147 | func gg_decide(held_mb: i64, util_pct: i64, listening: i64, idle_ticks: i64, cfg: *i64) -> i64 |
| 164 | func gg_name(v: i64) -> *u8 |
| 173 | func gg_load(path: *u8, cfg: *i64) -> i64 |
| 192 | func gg_fill_sa(sa: *u8, ip: *u8, port: i64) -> i64 |
| 226 | func gg_probe(ip: *u8, port: i64, tmo: i64) -> i64 |
| 241 | func gg_readticks(path: *u8) -> i64 |
| 250 | func gg_writeticks(path: *u8, v: i64) -> i64 |
| 272 | func gg_check(ctr: *i64, name: *u8, got: i64, want: i64) -> i64 |
| 285 | func gg_checkn(ctr: *i64, name: *u8, got: i64, want: i64) -> i64 |
| 297 | func gg_gate() -> i64 |
| 388 | func main(argc: i64, argv: *i64) -> i64 |