code wiki / _hdl_build / nx_toolrun_trunc_gate.nx
nx_toolrun_trunc_gate.nx
buildroot/runtime/_hdl_build/nx_toolrun_trunc_gate.nx
about
nx_toolrun_trunc_gate.nx -- BITE-PROOF for tr_run_capture_tr's truncation discriminator (2026-08-08).
SUBJECT: tr_drain_tr / tr_run_capture_tr in runtime/nx_tool_run.nx, added for debt 1786235483 --
the three legacy drain loops exit on `total >= cap` and return success with outlen[0] == cap, which
is byte-for-byte identical to a child that emitted EXACTLY cap bytes. 51+ call sites.
***WHY THE FIXTURE STRADDLES THE BOUNDARY.*** A test whose child output is smaller than the cap can
never reach the branch under test -- it would pass against a stub that hardcodes FIT. So the teeth
are cap=N-1 (must report CUT) and cap=N exactly (must report FIT). The second is the one that a
trivial wrong implementation -- "buffer full therefore truncated" -- CANNOT pass.
THE CHILD IS THIS GATE ITSELF (`emit <n>` writes exactly n bytes), so the fixture is deterministic
and needs no sibling organ. If argv[0] does not resolve, the child exits 127 and the teeth FAIL
loudly rather than passing vacuously.
nx_toolrun_trunc_gate -> run the teeth
nx_toolrun_trunc_gate emit <n> -> child fixture: emit exactly n bytes
license_tier: ORIGINAL expect_exit: 0 No hw writes (Rule 26).
dependencies 4 imports · 0 importers
imports: nx_syscalls.nxnx_sovjson_lib.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
| 24 | const TG_N: i64 = 3000 |
| 25 | const TG_BUF: i64 = 65536 |
| 26 | const TG_TMO: i64 = 5000 |
| 27 | const TG_FILL: i64 = 65 |
functions
| 29 | func tg_emit(n: i64) -> i64 |
| 38 | func tg_run(self: *u8, n: i64, cap: i64, outlen: *i64, trunc: *i64) -> i64 |
| 51 | func tg_diag(label: *u8, rc: i64, got: i64, tr: i64) -> i64 |
| 67 | func main(argc: i64, argv: *i64) -> i64 |