code wiki / (root) / nx_learn_rank.nx

nx_learn_rank.nx

buildroot/runtime/nx_learn_rank.nx

19972 B424 linesdepth 6pulls 10 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_learn_rank.nx -- the learnings-rail ranker, COMPOSED not rebuilt. module: nishi-core.learn.rank depends: fx.nx, syscalls.nx, nx_bm25.nx, nx_rrf.nx, nx_rank_fused.nx capability: CORE_COMPUTE WHY THIS EXISTS AND WHY IT IS SMALL: nishi-ops/learn/nx_rank.ps1 implements BM25 + RRF + a severity blend in PowerShell -- judgement in shell, which the standing order forbids. The obvious remedy is "write a ranking organ", and that is WRONG: measured 2026-08-16 (corpus_complete=1) the estate already ships nx_bm25 (+_lib,+_gate), nx_rrf, nx_rank_fused (+test), nx_intlog (+gate) and nx_bm25_naive as a brute-force oracle. A third BM25 would be the duplicate-ruler defect -- the very one nx_rank.ps1's OWN header cites (nx_ppmi_lib's two silently-diverged copies of one routine) as its reason for existing. So this file contains NO ranking mathematics. It is a DRIVER: read a corpus, call the incumbents, apply the declared blend, print an order. CONTRACT (pre-declared BEFORE the first run, so the result cannot rationalise the design): the top-N ORDER emitted here must equal nx_rank.ps1's top-N order on the same fixture. SCORES may differ -- Q16.16 fixed point here vs IEEE doubles there -- but ORDER is the contract. INPUT corpus file, one doc per line: <rank>\t<slug>\t<text> rank is the severity 1..star_max; a malformed line is SKIPPED AND COUNTED, never guessed. OUTPUT one line per hit: <rank>\t<slug>\t<q16.16 score> then a DECLARED envelope line. nx_learn_rank <corpus> <topN> <conf> <query words...> exit: 0 ranked (possibly zero hits) | 2 usage | 4 corpus unreadable license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 1 imports · 0 importers

nx_rank_fused.nx nx_learn_rank.nx

imports: nx_rank_fused.nx

imported by: nobody (leaf or entry point)

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

main lr_e lr_hundredths lr_slen lr_conf_get lr_slen ↻ nx_bm25_score 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 ↻ 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 sys_munmap nx_rank_order_desc nx_rrf_add fx_from_frac lr_stem_into lr_is_tok lr_n

structs

none

consts

44const LR_DEF_BLEND_REL_NUM: i64 = 100 // blend_relevance 1.00, held as hundredths so the conf's
45const LR_DEF_BLEND_SEV_NUM: i64 = 35 // blend_severity 0.35, decimal text parses without floats
46const LR_DEF_STAR_MAX: i64 = 6
52const LR_DEF_STEM_PREFIX: i64 = 6
53const LR_HUNDRED: i64 = 100
54const LR_TAB: i64 = 9
55const LR_NL: i64 = 10
56const LR_MAXDOCS: i64 = 20000
57const LR_MAXTERMS: i64 = 64

functions

59func lr_p(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
60func lr_e(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(2, s, n); return 0 }
called by 1: main
61func lr_n(fd: i64, v: i64) -> i64
called by 1: main
74func lr_byte(fd: i64, c: i64) -> i64 { let b: *u8 = sys_mmap(1); b[0] = c as u8; sys_write(fd, b, 1); return 0 }
called by 1: main
75func lr_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 2: lr_conf_getmain
80func lr_hundredths(s: *u8, n: i64) -> i64
called by 1: main
103func lr_conf_get(buf: *u8, n: i64, key: *u8, out: *u8, outcap: i64) -> i64
called by 1: main calls 1: lr_slen
153func lr_is_tok(c: i64) -> i64
called by 1: lr_stem_into
165func lr_stem_into(dst: *u8, src: *u8, n: i64, plen: i64) -> i64
called by 1: main calls 1: lr_is_tok
197func main(argc: i64, argv: *i64) -> i64