nx_dstate_gate.nx
buildroot/runtime/nx_dstate_gate.nx
about
nx_dstate_gate.nx -- THE GATE FOR nx_dstate'S ADMISSION CEILING: conf-sourced, announced, and bitten.
SUBJECT: the nx_dstate ELF, forked for real. nx_dstate's contract is a FOUR-STATE EXIT -- 0 SAMPLED /
3 UNMEASURED / 4 ADMISSION-REFUSED -- and /api/gate_run derives verdicts from exit codes, so every tooth
here asserts an EXIT CODE, and the content teeth additionally read what the subject printed.
WHY THIS GATE EXISTS (2026-08-22): nx_dstate has read `admit_load_centi` from knowledge/dstate.conf since
2026-08-14 and PRINTED its source on every run -- and knowledge/dstate.conf never existed in either
knowledge tree, so every run in the organ's history executed on its built-in default while the header
promised a conf. A documented knob with no file behind it is a magic number with a nicer comment. The
conf now exists; this gate is what keeps it load-bearing: a conf-sourced ceiling must be READ, ANNOUNCED
as `src=conf path=<the file actually read>`, and must CHANGE BEHAVIOUR -- a ceiling below the measured
load refuses the walk (exit 4), a ceiling above it admits (exit 0). An absent conf falls back to the
built-in AND SAYS SO (`src=builtin-default`), because a refusal to look and a fallback must never be silent.
THE ANTI-VACUITY TOOTH IS T2: it asserts the low fixture's ceiling is actually BELOW the measured load,
read from the subject's own output. Without it, T3's "refuses" could pass on a box whose load happened to
be zero -- for the wrong reason. A RIGHT EXIT CODE FOR THE WRONG REASON IS THE MOST EASILY ACCEPTED
FALSE PROOF THERE IS.
THE NEGATIVE CONTROLS are gv_bite pairs: (absent conf announces builtin) vs (present conf does not), and
(user_hz from conf is echoed) vs (no user_hz row leaves the default). A guard that announces builtin on
every run would pass the first half of each pair and fail the second.
FIXTURES ARE ASSEMBLED AT RUNTIME under /tmp/nx_dstate_gate/ and nothing here shares a fixture with a
production beat (the production conf is knowledge/dstate.conf; this gate never reads or writes it).
Subject outputs are unlinked at SETUP -- a gate that is not idempotent reports on its first run and lies
about every run after.
license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0
dependencies 3 imports · 0 importers
imports: nx_syscalls.nxnx_gate_verdict.nxnx_tool_run.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
| 35 | const DG_SUBJECT_DEFAULT: *u8 = "_offc/nx_dstate.elf" |
| 38 | const DG_EXIT_SAMPLED: i64 = 0 |
| 39 | const DG_EXIT_UNMEASURED: i64 = 3 |
| 40 | const DG_EXIT_REFUSED: i64 = 4 |
| 41 | const DG_EXEC_FAILED: i64 = 127 |
| 44 | const DG_DIR: *u8 = "/tmp/nx_dstate_gate" |
| 45 | const DG_CONF_LOW: *u8 = "/tmp/nx_dstate_gate/low.conf" |
| 46 | const DG_CONF_HIGH: *u8 = "/tmp/nx_dstate_gate/high.conf" |
| 47 | const DG_CONF_HZ: *u8 = "/tmp/nx_dstate_gate/hz.conf" |
| 48 | const DG_CONF_ABSENT: *u8 = "/tmp/nx_dstate_gate/does_not_exist.conf" |
| 51 | const DG_CEIL_BELOW_ANY_LOAD: i64 = 0 |
| 53 | const DG_CEIL_UNREACHABLE: i64 = 1000000 |
| 56 | const DG_HZ_NONDEFAULT: i64 = 50 |
| 60 | const DG_BUILTIN_CEIL_DOCUMENTED: i64 = 1600 |
| 61 | const DG_HZ_DEFAULT_DOCUMENTED: i64 = 100 |
| 63 | const DG_CAPTURE_CAP: i64 = 262144 |
| 64 | const DG_ARGV_SLOTS: i64 = 4 |
| 65 | const DG_WORD_BYTES: i64 = 8 |
| 66 | const DG_MODE_DIR: i64 = 493 // 0755 |
| 67 | const DG_ASCII_ZERO: i64 = 48 |
| 68 | const DG_ASCII_NINE: i64 = 57 |
| 69 | const DG_DECIMAL: i64 = 10 |
| 70 | const DG_MISS: i64 = 0 - 1 |
functions
| 72 | func dg_write_text(path: *u8, s: *u8) -> i64 |
| 82 | func dg_exists(path: *u8) -> i64 |
| 89 | func dg_run(subject: *u8, confpath: *u8, out: *u8, outlen: *i64) -> i64 |
| 97 | func dg_has(buf: *u8, n: i64, needle: *u8) -> i64 called by 1: main |
| 112 | func dg_int_after(buf: *u8, n: i64, key: *u8) -> i64 called by 1: main |
| 141 | func main(argc: i64, argv: *i64) -> i64 |