code wiki / _hdl_build / nx_toolrun_trunc_gate.nx

nx_toolrun_trunc_gate.nx

buildroot/runtime/_hdl_build/nx_toolrun_trunc_gate.nx

6205 B135 linesdepth 5pulls 7 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_sovjson_lib.nx nx_gate_verdict.nx nx_tool_run.nx nx_toolrun_trunc_gate.nx

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

main sj_lit_eq sj_vlen tg_emit 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 ↻ sys_write ↻ sj_atoi_z sys_exit ↻ gv_ctr sys_mmap ↻ gv_head gv_puts sys_write ↻ sys_mmap ↻ tg_run sys_mmap ↻ sj_catn sys_mmap ↻ tr_run_capture_tr tr_run_capture_core tr_run_capture_core_owned tr_run_capture_core_eviden sys_mmap_shared tr_clock_ms sys_munmap sys_pipe2

structs

none

consts

24const TG_N: i64 = 3000
25const TG_BUF: i64 = 65536
26const TG_TMO: i64 = 5000
27const TG_FILL: i64 = 65

functions

29func tg_emit(n: i64) -> i64
called by 1: main calls 2: sys_mmapsys_write
38func tg_run(self: *u8, n: i64, cap: i64, outlen: *i64, trunc: *i64) -> i64
51func tg_diag(label: *u8, rc: i64, got: i64, tr: i64) -> i64
called by 1: main calls 4: sys_mmapsj_catsj_catnsj_puts
67func main(argc: i64, argv: *i64) -> i64