nx_gate_lib.nx
buildroot/runtime/nx_gate_lib.nx
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
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
| 21 | const GL_OUTCAP: i64 = 1048576 // per-case fork capture (1 MiB: some probed pages exceed 64KB) |
| 22 | const GL_BUF: i64 = 262144 |
| 23 | const GL_AVCAP: i64 = 192 |
| 24 | const GL_SCRATCH: i64 = 32 |
| 25 | const GL_EXIT_RED: i64 = 1 |
functions
| 27 | func 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 |
| 28 | func gl_puts(s: *u8) -> i64 { sys_write(1, s, gl_slen(s)); return 0 } |
| 29 | func gl_putn(v: i64) -> i64 |
| 43 | func gl_bcat(b: *u8, o: i64, s: *u8) -> i64 |
| 50 | func gl_bcatn(b: *u8, o: i64, v: i64) -> i64 |
| 63 | func gl_contains(h: *u8, n: i64, needle: *u8) -> i64 |
| 85 | func gl_check(nm: *u8, ok: i64, counts: *i64) -> i64 |
| 93 | func gl_case(nm: *u8, path: *u8, av: *i64, want_exit: i64, want_sub: *u8, |
| 113 | func gl_av1(path: *u8, a1: *u8) -> *i64 calls 1: sys_mmap |
| 126 | func gl_log(path: *u8, banner: *u8, counts: *i64) -> i64 |
| 148 | func gl_verdict(banner: *u8, counts: *i64, ref: *u8, pb: *u8, po: i64) -> i64 |
| 161 | func main() -> i64 { return 0 } |