code wiki / (root) / nx_textcut.nx

nx_textcut.nx

buildroot/runtime/nx_textcut.nx

10501 B232 linesdepth 2pulls 2 transitivereach 42 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_textcut.nx -- LIB: TOKEN-BOUNDARY-SAFE TEXT CUTTING. The estate's ONE truncation ruler. THE DEFECT THIS EXISTS TO REMOVE, MEASURED LIVE ON nishifamily.com/search 2026-08-25: a renderer that truncates at a BYTE cap cuts mid-token. The stored doc "NIST Reference Fluid Thermodynamic and Transport Properties Database (REFPROP) Version 9" rendered a title ending "...Database (RE" (72-byte cap) and a snippet BEGINNING "FPROP) Version 9". TWO independent caps in one renderer (title 72B, sentence 320B) both cut mid-word. WHY IT SURVIVED: the damage is INVISIBLE AT THE CUT SITE. A title ending "(RE" looks merely truncated -- plausible. The mid-word START it creates surfaces in the NEXT span, which reads as a snippet bug, so every investigation looked at the snippet code and found nothing wrong with it. A CUT IS A CLAIM ABOUT WHERE A TOKEN ENDS; this lib makes that claim checkable and never silently wrong -- every cut lands on a real boundary or ANNOUNCES that it could not. ALSO CLOSES A DECLARED GAP ELSEWHERE: nx_search_snippet_extract.nx names both "UTF-8 codepoint awareness (no mid-codepoint truncation)" and "Word-boundary clipping" in its V2 SCOPE (TODO) and is unwired. Treating every byte >= 128 as a token byte closes BOTH at once: a multi-byte codepoint can never be split, because a cut inside one is a cut inside a token. NO THRESHOLDS. This lib is pure STRUCTURE (what a token is), not POLICY (how much to show), so it carries no conf and nothing here is tunable -- the cap is always the CALLER's. license_tier: ORIGINAL

dependencies 1 imports · 4 importers

nx_syscalls.nx nx_textcut.nx nx_docportal_search_serve.nx nx_docportal_search_serve_snip_202 nx_docprose.nx nx_textcut_gate.nx

imports: nx_syscalls.nx

imported by: nx_docportal_search_serve.nxnx_docportal_search_serve_snip_20260912.nxnx_docprose.nxnx_textcut_gate.nx

structs

none

consts

26const TC_CH_TAB: i64 = 9
27const TC_CH_LF: i64 = 10
28const TC_CH_CR: i64 = 13
29const TC_CH_SP: i64 = 32
30const TC_CH_D0: i64 = 48
31const TC_CH_D9: i64 = 57
32const TC_CH_UA: i64 = 65
33const TC_CH_UZ: i64 = 90
34const TC_CH_US: i64 = 95
35const TC_CH_LA: i64 = 97
36const TC_CH_LZ: i64 = 122
37const TC_CH_HIGH: i64 = 128 // first non-ASCII byte: lead or continuation of a UTF-8 codepoint
41const TC_CH_DQUOTE: i64 = 34
42const TC_CH_HASH: i64 = 35
43const TC_CH_AMP: i64 = 38
44const TC_CH_SQUOTE: i64 = 39
45const TC_CH_LPAREN: i64 = 40
46const TC_CH_PLUS: i64 = 43
47const TC_CH_COMMA: i64 = 44
48const TC_CH_HYPHEN: i64 = 45
49const TC_CH_SLASH: i64 = 47
50const TC_CH_LT: i64 = 60
51const TC_CH_EQ: i64 = 61
52const TC_CH_AT: i64 = 64
53const TC_CH_LBRACK: i64 = 91
54const TC_CH_LBRACE: i64 = 123
55const TC_CH_PIPE: i64 = 124
91const TC_CH_CONT_HI: i64 = 191

functions

62func tc_stats_reset() -> i64 { tc_cuts_g = 0; tc_hardcuts_g = 0; return 0 }
called by 1: main
63func tc_cuts() -> i64 { return tc_cuts_g }
called by 1: main
64func tc_hardcuts() -> i64 { return tc_hardcuts_g }
called by 1: main
69func tc_is_wordch(c: i64) -> i64
78func tc_is_ws(c: i64) -> i64
92func tc_is_utf8_cont(c: i64) -> i64
called by 1: tc_cut
99func tc_splits_token(txt: *u8, n: i64, at: i64) -> i64
called by 3: tc_cuttc_startmain calls 1: tc_is_wordch
111func tc_is_dangling(c: i64) -> i64
called by 1: tc_cut_trim
138func tc_cut(txt: *u8, n: i64, cap: i64, exactbox: *i64) -> i64
171func tc_cut_trim(txt: *u8, n: i64, cap: i64, exactbox: *i64) -> i64
193func tc_start(txt: *u8, n: i64, off: i64) -> i64
222func tc_skip_ws(txt: *u8, n: i64, off: i64) -> i64