code wiki / _hdl_build / nx_stem_bound_gate.nx
nx_stem_bound_gate.nx
buildroot/runtime/_hdl_build/nx_stem_bound_gate.nx
about
nx_stem_bound_gate.nx -- THE STEM RUN BOUND, PROVEN OVER EVERY TERM OF THE LIVE DICTIONARY (search prep cut, 2026-09-14).
WHY. dss_stem_expand (nx_docportal_search_seg.nx) finds every dictionary term whose stem equals the query
term's stem by walking the sorted run of terms sharing the stem's first 3 bytes and stemming each one. The
phase timers in /api/search named that walk as 0.33-0.40 s of every cold query, CPU in nx_stem per run entry
(a prefetch pass over the same run measured no gain). Widening the run key from 3 bytes to qsn-1 bytes makes
the walk a SUBSET of the old run, and it is exact ONLY IF: for every dictionary term w, w and stem(w) share
at least len(stem(w))-1 leading bytes. Porter rewrites suffixes only, and the rewrites that can change a byte
inside the stem's span (y to i, biliti to ble) touch at most its LAST byte -- but that is an argument about
the textbook, and the estate's stemmer is nx_stem. So this gate does not argue: it walks EVERY term of EVERY
live segment (no sample), stems each with the same nx_stem the scorer calls, and counts the terms that violate
the bound. One violation is RED and the cut does not ship; the violators are printed as the worklist.
The predicate is a pure function so KAT and neg-control teeth pin its arithmetic before the census runs. The
shard path probes the manifest to survive the buildroot cwd anchor (nx_livemap_fast_gate's lesson); argv[1]
overrides the prefix. license_tier: ORIGINAL No hw writes (Rule 26).
dependencies 3 imports · 0 importers
imports: nx_seg_store.nxnx_stem.nxnx_gate_verdict.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
| 21 | const SB_TOKBUF: i64 = 4096 |
| 22 | const SB_MAXTERM: i64 = 40 // the expansion walk stems only terms shorter than this (dss_stem_expand) |
| 23 | const SB_NARROW: i64 = 5 // stems of this length or more get a wider key than the old 3 bytes |
| 24 | const SB_SHOW: i64 = 12 // violators printed; the COUNT is always the whole population |
functions
| 27 | func sb_shares(term: *u8, tl: i64, stem: *u8, sl: i64) -> i64 called by 1: main |
| 39 | func main(argc: i64, argv: *i64) -> i64 |