code wiki / _hdl_build / nx_search_cli.nx

nx_search_cli.nx

buildroot/runtime/_hdl_build/nx_search_cli.nx

7913 B179 linesdepth 5pulls 8 transitivereach 0 importersview sourcekind tooltopic search
docsdependenciesstructsconstsfunctions

about

nx_search_cli.nx -- ASSIGNMENT E (tutored): the search engine's FRONT DOOR over the DURABLE index. The harvest (nx_library_harvest_v2) proved build->persist; until now nothing user-facing QUERIED that artifact -- the index was provably correct and practically dark. This is the live path: argv terms -> load knowledge/index/library.idx (NO rebuild: build-once-query-forever) -> inverted-index postings shortlist the candidate docids -> docmap names their files -> the Engineer-wired bm_* BM25 ranker (x1e6 fixed-point, the _hdl_build nx_bm25.nx that shadows runtime's on this lane) scores them -> "score path" per hit. Distinct from nx_library_search.nx (the Researcher's IN-MEMORY corpus ranker; no main, no persistence) -- one capability per module. BM25 stats (avgdl/IDF) are computed over the CANDIDATE set; corpus-wide stats stored at harvest = the next rung when the corpus outgrows reading candidates whole. Usage: nx_search_cli.sov.elf <term> [term ...] license_tier: ORIGINAL

dependencies 3 imports · 0 importers

nx_search_inverted_persist.nx nx_itoa_lib.nx nx_bm25.nx nx_search_cli.nx

imports: nx_search_inverted_persist.nxnx_itoa_lib.nxnx_bm25.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sc_puts nx_inv_load sys_read_file sys_openat_rd sys_lseek sys_mmap sys_read sys_close sc_load_docmap sys_read_file ↻ sc_strlen sc_fold nx_inv_query_term nx_inv_hash_bytes_lower nx_inv_lookup_slot nx_inv_slot_at nx_inv_slot_hash nx_inv_slot_postings_count nx_inv_slot_postings_offse nx_inv_slot_write_cursor sc_num nxi_out nxi_fd sys_mmap ↻ ccz_cat_num sys_write sys_munmap sys_read_file ↻ bm_token_count bm_score re_count re_strlen bm_idf_micro bm_ln_micro bm_df re_has re_find re_strlen ↻ bm_sat_milli

structs

none

consts

14const LS_MAGIC_1000000: i64 = 1000000
15const LS_MAGIC_10000: i64 = 10000
17const LS_MAX_DOCS: i64 = 4096
18const LS_MAX_TERMS: i64 = 8
19const LS_ROWID_CAP: i64 = 1024
20const LS_TOP_K: i64 = 10

functions

22func sc_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 1: main
27func sc_num(v: i64) -> i64 { nxi_out(v); return 0 }
called by 2: sc_scoremain calls 1: nxi_out
28func sc_strlen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
called by 1: main
34func sc_fold(s: *u8, n: i64) -> i64
called by 1: main
45func sc_score(v: i64) -> i64
called by 1: main calls 1: sc_num
58func sc_load_docmap(path: *u8, paths_out: *i64, cap: i64) -> i64
called by 1: main calls 1: sys_read_file
77func main(argc: i64, argv: *i64) -> i64