nx_textcut.nx
buildroot/runtime/nx_textcut.nx
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
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
| 26 | const TC_CH_TAB: i64 = 9 |
| 27 | const TC_CH_LF: i64 = 10 |
| 28 | const TC_CH_CR: i64 = 13 |
| 29 | const TC_CH_SP: i64 = 32 |
| 30 | const TC_CH_D0: i64 = 48 |
| 31 | const TC_CH_D9: i64 = 57 |
| 32 | const TC_CH_UA: i64 = 65 |
| 33 | const TC_CH_UZ: i64 = 90 |
| 34 | const TC_CH_US: i64 = 95 |
| 35 | const TC_CH_LA: i64 = 97 |
| 36 | const TC_CH_LZ: i64 = 122 |
| 37 | const TC_CH_HIGH: i64 = 128 // first non-ASCII byte: lead or continuation of a UTF-8 codepoint |
| 41 | const TC_CH_DQUOTE: i64 = 34 |
| 42 | const TC_CH_HASH: i64 = 35 |
| 43 | const TC_CH_AMP: i64 = 38 |
| 44 | const TC_CH_SQUOTE: i64 = 39 |
| 45 | const TC_CH_LPAREN: i64 = 40 |
| 46 | const TC_CH_PLUS: i64 = 43 |
| 47 | const TC_CH_COMMA: i64 = 44 |
| 48 | const TC_CH_HYPHEN: i64 = 45 |
| 49 | const TC_CH_SLASH: i64 = 47 |
| 50 | const TC_CH_LT: i64 = 60 |
| 51 | const TC_CH_EQ: i64 = 61 |
| 52 | const TC_CH_AT: i64 = 64 |
| 53 | const TC_CH_LBRACK: i64 = 91 |
| 54 | const TC_CH_LBRACE: i64 = 123 |
| 55 | const TC_CH_PIPE: i64 = 124 |
| 91 | const TC_CH_CONT_HI: i64 = 191 |
functions
| 62 | func tc_stats_reset() -> i64 { tc_cuts_g = 0; tc_hardcuts_g = 0; return 0 } called by 1: main |
| 63 | func tc_cuts() -> i64 { return tc_cuts_g } called by 1: main |
| 64 | func tc_hardcuts() -> i64 { return tc_hardcuts_g } called by 1: main |
| 69 | func tc_is_wordch(c: i64) -> i64 |
| 78 | func tc_is_ws(c: i64) -> i64 |
| 92 | func tc_is_utf8_cont(c: i64) -> i64 called by 1: tc_cut |
| 99 | func tc_splits_token(txt: *u8, n: i64, at: i64) -> i64 |
| 111 | func tc_is_dangling(c: i64) -> i64 called by 1: tc_cut_trim |
| 138 | func tc_cut(txt: *u8, n: i64, cap: i64, exactbox: *i64) -> i64 |
| 171 | func tc_cut_trim(txt: *u8, n: i64, cap: i64, exactbox: *i64) -> i64 |
| 193 | func tc_start(txt: *u8, n: i64, off: i64) -> i64 |
| 222 | func tc_skip_ws(txt: *u8, n: i64, off: i64) -> i64 called by 10: dsv_snippet_spandsv_resultdss_api_searchdsv_snippet_spandsv_resultdss_api_search+4 calls 1: tc_is_ws |