code wiki / (root) / nx_dstate_gate.nx

nx_dstate_gate.nx

buildroot/runtime/nx_dstate_gate.nx

13373 B269 linesdepth 5pulls 6 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_gate_verdict.nx nx_tool_run.nx nx_dstate_gate.nx

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

main gv_ctr sys_mmap nxa_die sys_write sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ gv_head gv_puts sys_write ↻ gv_puts ↻ sys_mkdir sys_unlinkat dg_write_text sys_openat_wr sys_write ↻ sys_close dg_exists sys_mmap ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_munmap sys_close ↻ gv_check gv_puts ↻ sys_mmap ↻ dg_run

structs

none

consts

35const DG_SUBJECT_DEFAULT: *u8 = "_offc/nx_dstate.elf"
38const DG_EXIT_SAMPLED: i64 = 0
39const DG_EXIT_UNMEASURED: i64 = 3
40const DG_EXIT_REFUSED: i64 = 4
41const DG_EXEC_FAILED: i64 = 127
44const DG_DIR: *u8 = "/tmp/nx_dstate_gate"
45const DG_CONF_LOW: *u8 = "/tmp/nx_dstate_gate/low.conf"
46const DG_CONF_HIGH: *u8 = "/tmp/nx_dstate_gate/high.conf"
47const DG_CONF_HZ: *u8 = "/tmp/nx_dstate_gate/hz.conf"
48const DG_CONF_ABSENT: *u8 = "/tmp/nx_dstate_gate/does_not_exist.conf"
51const DG_CEIL_BELOW_ANY_LOAD: i64 = 0
53const DG_CEIL_UNREACHABLE: i64 = 1000000
56const DG_HZ_NONDEFAULT: i64 = 50
60const DG_BUILTIN_CEIL_DOCUMENTED: i64 = 1600
61const DG_HZ_DEFAULT_DOCUMENTED: i64 = 100
63const DG_CAPTURE_CAP: i64 = 262144
64const DG_ARGV_SLOTS: i64 = 4
65const DG_WORD_BYTES: i64 = 8
66const DG_MODE_DIR: i64 = 493 // 0755
67const DG_ASCII_ZERO: i64 = 48
68const DG_ASCII_NINE: i64 = 57
69const DG_DECIMAL: i64 = 10
70const DG_MISS: i64 = 0 - 1

functions

72func dg_write_text(path: *u8, s: *u8) -> i64
82func dg_exists(path: *u8) -> i64
called by 1: main calls 2: sys_mmapsys_read_file
89func dg_run(subject: *u8, confpath: *u8, out: *u8, outlen: *i64) -> i64
called by 1: main calls 2: sys_mmaptr_run_capture
97func dg_has(buf: *u8, n: i64, needle: *u8) -> i64
called by 1: main
112func dg_int_after(buf: *u8, n: i64, key: *u8) -> i64
called by 1: main
141func main(argc: i64, argv: *i64) -> i64