code wiki / _hdl_build / nx_lawsearch.nx
nx_lawsearch.nx
buildroot/runtime/_hdl_build/nx_lawsearch.nx
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
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
structs
| none |
consts
| 27 | const LS_MAGIC_8190: i64 = 8190 |
| 28 | const LS_MAGIC_65535: i64 = 65535 |
| 29 | const LS_MAGIC_1024: i64 = 1024 |
| 30 | const LS_MAGIC_8192: i64 = 8192 |
| 31 | const LS_MAGIC_65536: i64 = 65536 |
| 33 | const LS_WIN: i64 = 33554432 |
| 34 | const LS_MAXTOK: i64 = 192 |
| 35 | const LS_TOPK: i64 = 64 |
| 36 | const LS_MODE_644: i64 = 420 |
functions
| 38 | func ls_read(path: *u8, buf: *u8, cap: i64) -> i64 |
| 53 | func pl_find(q: *u8, from: i64, endlim: i64, lit: *u8) -> i64 called by 1: ls_field |
| 73 | func ls_field(buf: *u8, s: i64, e: i64, out: *u8, cap: i64) -> i64 |
| 101 | func main(argc: i64, argv: *i64) -> i64 |