code wiki / _hdl_build / nx_token_counter_gate.nx

nx_token_counter_gate.nx

buildroot/runtime/_hdl_build/nx_token_counter_gate.nx

2706 B40 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind gate/prooftopic token
docsdependenciesstructsconstsfunctions

about

nx_token_counter_gate.nx -- proves the LLM token estimate is sane and, critically, that pack_text NEVER exceeds the token budget (the guarantee that makes "fit a book into an LLM" safe) + marks truncation honestly when the document doesn't fully fit (and does NOT mark it when it does). license_tier: ORIGINAL

dependencies 1 imports · 0 importers

nx_token_counter.nx nx_token_counter_gate.nx

imports: nx_token_counter.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main tok_estimate tc_isspace pack_text tok_estimate ↻ tc_cat tc_catn sys_mmap tg_contains tg_slen tg_slen ↻ tg_w tg_slen ↻

structs

none

consts

none

functions

6func tg_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
called by 3: tg_containstg_wmain
7func tg_contains(b: *u8, n: i64, pat: *u8) -> i64
called by 1: main calls 1: tg_slen
13func tg_w(s: *u8) -> i64 { sys_write(1, s, tg_slen(s)); return 0 }
called by 1: main calls 1: tg_slen
15func main() -> i64