code wiki / _hdl_build / nx_stem_bound_gate.nx

nx_stem_bound_gate.nx

buildroot/runtime/_hdl_build/nx_stem_bound_gate.nx

7904 B136 linesdepth 3pulls 5 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

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

nx_seg_store.nx nx_stem.nx nx_gate_verdict.nx nx_stem_bound_gate.nx

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

main gv_ctr 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 ↻ gv_head gv_puts sys_write ↻ gv_check gv_puts ↻ sb_shares gv_puts ↻ ss_open2 ss_open3 sys_now_us sys_mmap ↻ sys_clock_gettime_mono sys_mmap ↻ ss_manifest_dyn ss_manifest_file_dyn sys_mmap ↻ ss_cat ss_readall sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close

structs

none

consts

21const SB_TOKBUF: i64 = 4096
22const SB_MAXTERM: i64 = 40 // the expansion walk stems only terms shorter than this (dss_stem_expand)
23const SB_NARROW: i64 = 5 // stems of this length or more get a wider key than the old 3 bytes
24const SB_SHOW: i64 = 12 // violators printed; the COUNT is always the whole population

functions

27func sb_shares(term: *u8, tl: i64, stem: *u8, sl: i64) -> i64
called by 1: main
39func main(argc: i64, argv: *i64) -> i64