code wiki / (root) / nx_svc_budget_gate.nx

nx_svc_budget_gate.nx

buildroot/runtime/nx_svc_budget_gate.nx

7676 B143 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

about

nx_svc_budget_gate.nx -- REGRESSION PROOF for the self-retiring-service class (debt seq882, 2026-07-25). THE DEFECT IT LOCKS OUT: 44 sovereign services run `while served < budget { accept... } sys_exit(0)`. One 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 2026-07-25: the gallery gateway, the wiki/hub/torrent/gen gateways, the main OPAQUE login (:9091) 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 diagnosed on 2026-07-03 -- fixed there, never swept. This gate exists so it can never silently return. WHY IT ASSERTS ON BYTES, NOT INTENT: "we fixed it" is author optimism, not evidence. Each tooth greps the actual launch-command constant. T8 greps the LIVE DEPLOYED BINARY, not just source -- this session proved that lie twice (a carve-out banked in memory as "landed in source" was NOT in source; a deployed gallery thumbnailer predated its own fix by three weeks). Source-GREEN + binary-RED = NOT SHIPPED. T9/T10 are MUTATION teeth: they fail if the exact bad literal reappears, so a revert cannot pass quietly. Named _svc_ not _daemon_ deliberately: md_promote_deny substring-blocks "daemon" so real daemons are forced through the health-checked /api/deploy. This is a one-shot organ, so the honest name is the promotable one. Run from the nishihost CWD (the tools daemon fork-execs it there). license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_gate_verdict.nx nx_svc_budget_gate.nx

imports: nx_syscalls.nxnx_gate_verdict.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 gv_ctr sys_mmap ↻ sbg_puts sys_write sbg_slen sbg_putn sys_mmap ↻ sys_write ↻ sbg_slurp sys_openat_rd sys_read sys_close sbg_tooth sbg_contains sbg_slen ↻ gv_check gv_puts sys_write ↻ gv_check ↻ sbg_tooth_absent sbg_contains ↻ gv_check ↻ gv_verdict gv_puts ↻ gv_num sys_mmap ↻ sys_write ↻ sys_munmap gv_journal sys_openat_append sys_mmap ↻ gv_catn sys_mmap ↻ sys_munmap ↻ sys_now_realtime_sec sys_mmap ↻ sys_clock_gettime_real gv_cat

structs

none

consts

25const SBG_CAP: i64 = 1048576
26const SBG_MIN_BUDGET: i64 = 1000000

functions

28func sbg_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
29func sbg_puts(s: *u8) -> i64 { sys_write(1, s, sbg_slen(s)); return 0 }
called by 1: main calls 2: sys_writesbg_slen
30func sbg_putn(v: i64) -> i64
called by 1: main calls 2: sys_mmapsys_write
45func sbg_slurp(path: *u8, buf: *u8, cap: i64) -> i64
called by 1: main calls 3: sys_openat_rdsys_readsys_close
58func sbg_contains(hay: *u8, hn: i64, needle: *u8) -> i64
called by 2: sbg_toothsbg_tooth_absent calls 1: sbg_slen
75func sbg_tooth(buf: *u8, n: i64, needle: *u8, label: *u8, pass: *i64, ctr: *i64) -> i64
called by 1: main calls 2: sbg_containsgv_check
83func sbg_tooth_absent(buf: *u8, n: i64, needle: *u8, label: *u8, pass: *i64, ctr: *i64) -> i64
called by 1: main calls 2: sbg_containsgv_check
91func main(argc: i64, argv: *i64) -> i64