code wiki / (root) / nx_daemon_budget_gate.nx

nx_daemon_budget_gate.nx

buildroot/runtime/nx_daemon_budget_gate.nx

6471 B131 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind gate/prooftopic daemon
docsdependenciesstructsconstsfunctions

about

nx_daemon_budget_gate.nx -- REGRESSION PROOF for the self-retiring-daemon class (debt seq882, 2026-07-25). THE DEFECT IT LOCKS OUT: 44 sovereign daemons run `while served < budget { accept... } sys_exit(0)`. A supervised daemon launched with a SMALL finite budget therefore RETIRES ITSELF -- and nx_hostctl's guard (nx_hostctl.nx:798) reads the repeated exits as a crash-loop and BACKS OFF, so the surface goes genuinely DOWN while `status` still prints UP. Measured live: the gallery gateway, the wiki/hub/torrent/gen gateways, the main OPAQUE login daemon AND the mgmt API itself were all launched with budget=5000. That is the root cause of the operator-reported "gallery wont let me login" AND of the chronic mgmt/MCP transport flake. nx_docportal_search_serve.nx:303 documents this same failure being diagnosed on 2026-07-03 -- fixed there and never swept. This gate exists so it can never silently return. WHY ASSERT ON BYTES, NOT ON INTENT: an author-optimism check ("we fixed it") is not evidence. Each tooth greps the actual launch-command constant. T8 greps the LIVE DEPLOYED BINARY, not just source -- this session proved that class of lie twice (a carve-out banked in memory as "landed in source" was NOT in source, and a deployed gallery thumbnailer predated its own fix by three weeks). Source-GREEN + binary-RED = NOT SHIPPED. T9 is the MUTATION tooth: it fails if the exact bad literal ever reappears, so a revert cannot pass quietly. Run from the nishihost CWD (the tools daemon fork-execs it there). license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_daemon_budget_gate.nx

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

main sys_mmap dbg_puts sys_write dbg_slen dbg_putn sys_mmap ↻ sys_write ↻ dbg_slurp sys_openat_rd sys_read sys_close dbg_tooth dbg_contains dbg_slen ↻ dbg_puts ↻ dbg_tooth_absent dbg_contains ↻ dbg_puts ↻

structs

none

consts

21const DBG_CAP: i64 = 1048576
22const DBG_MIN_BUDGET: i64 = 1000000

functions

24func dbg_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
25func dbg_puts(s: *u8) -> i64 { sys_write(1, s, dbg_slen(s)); return 0 }
26func dbg_putn(v: i64) -> i64
called by 1: main calls 2: sys_mmapsys_write
41func dbg_slurp(path: *u8, buf: *u8, cap: i64) -> i64
called by 1: main calls 3: sys_openat_rdsys_readsys_close
54func dbg_contains(hay: *u8, hn: i64, needle: *u8) -> i64
called by 2: dbg_toothdbg_tooth_absent calls 1: dbg_slen
69func dbg_tooth(buf: *u8, n: i64, needle: *u8, label: *u8, pass: *i64) -> i64
called by 1: main calls 2: dbg_containsdbg_puts
78func dbg_tooth_absent(buf: *u8, n: i64, needle: *u8, label: *u8, pass: *i64) -> i64
called by 1: main calls 2: dbg_containsdbg_puts
86func main(argc: i64, argv: *i64) -> i64