code wiki / _hdl_build / nx_doccount_gate.nx
nx_doccount_gate.nx
buildroot/runtime/_hdl_build/nx_doccount_gate.nx
about
nx_doccount_gate.nx -- THE CORPUS-SIZE FAST PATH, PROVEN AGAINST THE WALK ON THE LIVE SHARD (search L5, 2026-09-14).
WHY. idf needs N, the number of doc: keys across the live segments. ss_doc_count used to WALK every .keys entry
of every segment on every query; the phase timers measured that at 324 ms of a 331 ms prep, on every query,
warm or cold -- 98 percent of prep and the largest cold term left after L0 and L3. The cut: each row carries its
own count from load time in its aux row (ss_doccount_build, one predicate ss_is_doc_key shared with the walk)
and ss_doc_count sums them, falling back to the walk when any row lacks one. Ranking is byte-identical only if
the sum IS the walk, so this gate opens the REAL shard and asserts that -- plus a poisoned-row neg-control that
proves the fast path is what answers, and a cleared-row neg-control that proves the fallback still answers.
license_tier: ORIGINAL No hw writes (Rule 26).
dependencies 2 imports · 0 importers
imports: nx_seg_store.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
| 14 | const DG_POISON: i64 = 1000 |
functions
| 16 | func main(argc: i64, argv: *i64) -> i64 |