code wiki / _hdl_build / nx_lawsearch.nx

nx_lawsearch.nx

buildroot/runtime/_hdl_build/nx_lawsearch.nx

25218 B536 linesdepth 6pulls 9 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_lawsearch.nx -- DENSE SEMANTIC RETRIEVAL over the learnings corpus (the SOTA stage-2 unlock). WHY THIS EXISTS. The ecosystem owns a real 41MB PPMI model (knowledge/index/semppmi_v1.bin, vocab 102318, 2558014 triples) and measured dense p@1 1000 permil vs lexical 500 -- but NOTHING could query it: nx_recall_dense is a fixed-fixture proof with no argv, so the single largest retrieval asset we own was unreachable (debt 1785560370). This organ gives it a query interface, composing the CANONICAL nx_ppmi_lib rather than hand-rolling a third copy of the loader (D001 discipline -- the lib header records that two copies had already silently diverged). Sparse BM25 cannot match a synonym: "reversible" never retrieves "undoable". Our own bench sizes the gap -- BM25 ndcg@5 494 permil, fused 659, reranked 964 -- and 2026 agent-memory SOTA is hybrid sparse+dense merged by RRF then cross-encoder reranked. learn_query.ps1 already ships the sparse+RRF half; this is the dense view it fuses with. dense <query> <corpus.jsonl> <model.bin> [k] -> ranked JSON lines {score,rank,slug,text} selftest <model.bin> -> gate teeth incl. a DENSE-BEATS-LEXICAL tooth license_tier: ORIGINAL

dependencies 5 imports · 0 importers

nx_ppmi_lib.nx nx_dr_densejudge.nx nx_sovjson_lib.nx nx_syscalls.nx nx_gate_verdict.nx nx_lawsearch.nx

imports: nx_ppmi_lib.nxnx_dr_densejudge.nxnx_sovjson_lib.nxnx_syscalls.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 sj_puts sys_write sys_exit sj_vlen sys_mmap sj_lit_eq gv_ctr sys_mmap ↻ gv_head gv_puts sys_write ↻ ppl_load sys_openat_rd sys_mmap ↻ sys_read sys_close gv_check gv_puts ↻ ppl_tokenize_ids ppl_wid_range sys_mmap ↻ db_bsearch_i64 db_semhash ppl_maxsim_idf ppl_idf_w ppl_dcos ppl_cos ppl_isqrt gv_verdict gv_puts ↻ gv_num sys_mmap ↻ sys_write ↻ sys_munmap gv_journal sys_openat_append sys_mmap ↻ gv_catn sys_mmap ↻

structs

none

consts

27const LS_MAGIC_8190: i64 = 8190
28const LS_MAGIC_65535: i64 = 65535
29const LS_MAGIC_1024: i64 = 1024
30const LS_MAGIC_8192: i64 = 8192
31const LS_MAGIC_65536: i64 = 65536
33const LS_WIN: i64 = 33554432
34const LS_MAXTOK: i64 = 192
35const LS_TOPK: i64 = 64
36const LS_MODE_644: i64 = 420

functions

38func ls_read(path: *u8, buf: *u8, cap: i64) -> i64
called by 1: main calls 3: sys_openat_rdsys_readsys_close
53func pl_find(q: *u8, from: i64, endlim: i64, lit: *u8) -> i64
called by 1: ls_field
73func ls_field(buf: *u8, s: i64, e: i64, out: *u8, cap: i64) -> i64
called by 1: main calls 1: pl_find
101func main(argc: i64, argv: *i64) -> i64