code wiki / _hdl_build / nx_doccount_gate.nx

nx_doccount_gate.nx

buildroot/runtime/_hdl_build/nx_doccount_gate.nx

4281 B80 linesdepth 3pulls 4 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

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

nx_seg_store.nx nx_gate_verdict.nx nx_doccount_gate.nx

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

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_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 sys_munmap ss3_admit ss3_ann

structs

none

consts

14const DG_POISON: i64 = 1000

functions

16func main(argc: i64, argv: *i64) -> i64