code wiki / (root) / nx_gate_lib.nx

nx_gate_lib.nx

buildroot/runtime/nx_gate_lib.nx

6955 B161 linesdepth 3pulls 3 transitivereach 5 importersview sourcekind tooltopic gate
docsdependenciesstructsconstsfunctions

about

nx_gate_lib.nx -- THE SHARED BASE FOR GATE ORGANS (gl_*), authored 2026-07-25 to eat debt seq938. WHY THIS EXISTS: nx_feed_gate, nx_p384_ecdh_gate and nx_tls12_prf_gate were each written with a PRIVATE copy of the same six helpers (slen/puts/putn/bcat/bcatn/contains) under three different prefixes -- fdg_ / pkg_ / tpg_. That is the exact drift the flip family already paid to fix with nx_flip_lib.nx's fx_* base: a fix to one copy fixes ONE gate, and the family silently diverges. Same mistake, same cure. It also fixes the contract every gate member must honour, so a new gate inherits it instead of re-deriving it: (1) print FAILURES ONLY -- a roster of PASS lines buries the failure the gate exists to surface, and the plan-runner snippet cap (200B) will truncate it away entirely. (2) emit a `verdict=GREEN|RED pass=N/M` anchor LAST so the D001 judge and the beat can read it. (3) counts[0]=total counts[1]=pass, so a case can never be "counted" without being adjudicated. (4) a case asserts BOTH an exit code AND a required output substring -- an exit code alone lets a silently-wrong organ pass, and a substring alone lets a crashed one pass. license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 2 imports · 5 importers

nx_syscalls.nx nx_tool_run.nx nx_gate_lib.nx nx_feed_gate.nx nx_flip_gate.nx nx_gate_rollup.nx nx_p384_ecdh_gate.nx nx_tls12_prf_gate.nx

imports: nx_syscalls.nxnx_tool_run.nx

imported by: nx_feed_gate.nxnx_flip_gate.nxnx_gate_rollup.nxnx_p384_ecdh_gate.nxnx_tls12_prf_gate.nx

structs

none

consts

21const GL_OUTCAP: i64 = 1048576 // per-case fork capture (1 MiB: some probed pages exceed 64KB)
22const GL_BUF: i64 = 262144
23const GL_AVCAP: i64 = 192
24const GL_SCRATCH: i64 = 32
25const GL_EXIT_RED: i64 = 1

functions

27func gl_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 1: gl_puts
28func gl_puts(s: *u8) -> i64 { sys_write(1, s, gl_slen(s)); return 0 }
29func gl_putn(v: i64) -> i64
43func gl_bcat(b: *u8, o: i64, s: *u8) -> i64
50func gl_bcatn(b: *u8, o: i64, v: i64) -> i64
called by 3: fdg_bcatngl_casegl_log calls 1: sys_mmap
63func gl_contains(h: *u8, n: i64, needle: *u8) -> i64
called by 2: fdg_containsgl_case
85func gl_check(nm: *u8, ok: i64, counts: *i64) -> i64
called by 2: pkg_checktpg_check calls 1: gl_puts
93func gl_case(nm: *u8, path: *u8, av: *i64, want_exit: i64, want_sub: *u8,
113func gl_av1(path: *u8, a1: *u8) -> *i64
calls 1: sys_mmap
126func gl_log(path: *u8, banner: *u8, counts: *i64) -> i64
148func gl_verdict(banner: *u8, counts: *i64, ref: *u8, pb: *u8, po: i64) -> i64
called by 1: main calls 3: gl_putsgl_putnsys_write
161func main() -> i64 { return 0 }