nx_incumbent_lib.nx
buildroot/runtime/nx_incumbent_lib.nx
about
nx_incumbent_lib.nx -- THE ONE RULER FOR A RUNG CONTRACT'S INCUMBENTS AND THE RECORD'S REJECTIONS (engineshift ES28).
Operator 2026-09-14, on the search R0 review: "this is the stuff we need the search and nishi estate to do
proactively not rely on you treasure hunting." A prior seat rebuilt the R0 rerank arm as a learned fusion over
PPMI while the estate already held the trained dense embedding (knowledge/index/embed_v1.bin), the lib that
scores with it (nx_dr_densejudge) and, in that lib's own header, the MEASURED REJECTION of exactly that fusion
(DR-13). The reviewing seat found all three by glob and header reads: a retrieval failure, not a discovery.
nx_capsearch ranks registered tools and libs by name, title and grammar; it cannot see a header's prose, a data
asset, or a rejection. This lib answers a rung's contract from the record itself, and nx_compare_rank prints the
answer on every open rung so no seat starts a build from its own memory.
THE INDEX (a derived artefact, stamped, refused when stale): one row per organ source in the two runtime roots
org|<name>|<root>|<header words, lowercase, unique, first 12 bytes each>|<knowledge/ paths the header names>|<rejection lines>
and one per data asset under knowledge/index: asset|<name>|<name words>
headed by # NX-DERIVED incumbent index generated_at=<epoch> files=<n> head_truncated=<n> assets=<n> corpus_complete=<0|1>
The HEADER of an organ is its leading comment block (the // lines before the first code line); its words, its
basename parts and its column-0 func names are one bag. A header longer than the read window is COUNTED
(head_truncated), never silently cut. A bag word is kept to 12 bytes for display; no key or match reads past 8.
THE MATCH: the contract terms are the rung's title, symbol and note tokenised to lowercase runs of letters and
digits at least min_tok long, deduplicated by their MATCH PREFIX (rerank and reranker are one term, beat and
beats are one term); an all-digit term is DROPPED and counted (a number is a measurement, never a capability word:
measured 2026-09-14, the 321 in "321 permille" matched three throwaway test organs at a rare-token weight). A term
matches a bag word when their leading bytes agree -- the first morph_long bytes for a term at least that long,
else the WHOLE term (mine~miner is the prefix rule nx_capsearch measured on its gold set at 4 bytes; here the
4-byte key only narrows the posting chain, because measured on 2026-09-14 the 4-byte cut made dense match density
and wired match wire). Each matched term weighs idf_scale / (idf_base + df), df
being the number of organs carrying it (the weighting nx_capsearch ships), and a term carried by more than
df_max_permil of the organs is DROPPED as non-discriminating and COUNTED, so no stop-word list is hand-written:
the corpus decides which words say nothing. An organ's score is the sum over its distinct matched terms, and a
term that also hits the organ's own NAME parts adds its idf a second time: the name is the organ's own
declaration of what it is, a second piece of evidence weighed like the first (the rule nx_capsearch's known-good
tooltop applies, a stem hit on the name counted beside a hit in the title). MEASURED 2026-09-14 on the live tree
(20,820 organs): ranking by a name TIER first put an organ named for two process words (wired, exceed) second
for R0 at a tiny weight, so the name hit is weighed, never sorted on. The rung's own organ is excluded.
THE LIST IS THE ANSWER, NEVER A THRESHOLD: the top topn organs print with their name hits, score and matched
terms, then the data assets those headers name plus assets whose own name matches a term, then the rejection
lines those headers carry. PRIOR-REJECTIONS is its own axis: beyond the top organs, every organ whose NAME carries
a contract term and whose header records a rejection is listed (capped by rej_orgs, overflow counted), because a
rejection on an organ named for the contract's own word is the record answering the contract -- that is how R0
dependencies 1 imports · 3 importers
imports: nx_syscalls.nx
imported by: nx_compare_rank.nxnx_incumbent_gate.nxnx_incumbents.nx
structs
| none |
consts
| 50 | const INC_I64: i64 = 8 |
| 51 | const INC_NL: i64 = 10 |
| 52 | const INC_CR: i64 = 13 |
| 53 | const INC_TAB: i64 = 9 |
| 54 | const INC_PIPE: i64 = 124 |
| 55 | const INC_SPACE: i64 = 32 |
| 56 | const INC_SLASH: i64 = 47 |
| 57 | const INC_SEMI: i64 = 59 |
| 58 | const INC_EQ: i64 = 61 |
| 59 | const INC_HASHCH: i64 = 35 |
| 60 | const INC_DOT: i64 = 46 |
| 61 | const INC_COLON: i64 = 58 |
| 62 | const INC_LPAREN: i64 = 40 |
| 63 | const INC_RPAREN: i64 = 41 |
| 64 | const INC_COMMA: i64 = 44 |
| 65 | const INC_DQUOTE: i64 = 34 |
| 66 | const INC_SQUOTE: i64 = 39 |
| 67 | const INC_RBRACK: i64 = 93 |
| 68 | const INC_GT: i64 = 62 |
| 69 | const INC_MINUS: i64 = 45 |
| 70 | const INC_A: i64 = 97 |
| 71 | const INC_Z: i64 = 122 |
| 72 | const INC_UA: i64 = 65 |
| 73 | const INC_UZ: i64 = 90 |
| 74 | const INC_D0: i64 = 48 |
| 75 | const INC_D9: i64 = 57 |
| 76 | const INC_CH_N: i64 = 110 |
| 77 | const INC_CH_X: i64 = 120 |
| 78 | const INC_CASE_DELTA: i64 = 32 |
| 79 | const INC_KEY_BYTES: i64 = 8 // a key packs up to 8 leading bytes into one i64; no match reads past 8 |
| 80 | const INC_WORD_KEEP: i64 = 12 // a bag word or a term is kept to 12 bytes for display |
| 81 | const INC_BYTE_BITS: i64 = 8 |
| 82 | const INC_HASH_MUL: i64 = 1099511628211 // an odd multiplier for the packed key (the FNV-1a prime) |
| 83 | const INC_HASH_SHIFT: i64 = 29 |
| 84 | const INC_NAME_CAP: i64 = 256 |
| 85 | const INC_PATH_CAP: i64 = 1024 |
| 86 | const INC_NUM_CAP: i64 = 32 |
| 87 | const INC_DIRBUF: i64 = 65536 // the getdents window nx_presubmit_lib uses (PS_DIRBUF) |
| 88 | const INC_SETCAP: i64 = 4096 // per-file word set slots (a header carries hundreds of words, never thousands) |
| 89 | const INC_HASH_MIN: i64 = 1024 |
| 90 | const INC_CONF_A: *u8 = "knowledge/incumbent.conf" |
| 91 | const INC_CONF_B: *u8 = "../knowledge/incumbent.conf" |
| 92 | const INC_REJ_A: *u8 = "knowledge/incumbent_reject.conf" |
| 93 | const INC_REJ_B: *u8 = "../knowledge/incumbent_reject.conf" |
| 94 | const INC_INDEX_A: *u8 = "knowledge/status/incumbent_index.txt" |
| 95 | const INC_INDEX_B: *u8 = "../knowledge/status/incumbent_index.txt" |
| 96 | const INC_TMP_SUFFIX: *u8 = ".tmp" |
| 97 | const INC_ROOT_RT_A: *u8 = "buildroot/runtime" |
| 98 | const INC_ROOT_HDL_A: *u8 = "buildroot/runtime/_hdl_build" |
| 99 | const INC_ASSET_A: *u8 = "knowledge/index" |
| 100 | const INC_ROOT_RT_B: *u8 = "runtime" |
| 101 | const INC_ROOT_HDL_B: *u8 = "runtime/_hdl_build" |
| 102 | const INC_ASSET_B: *u8 = "../knowledge/index" |
| 103 | const INC_HEAD_MARK: *u8 = "# NX-DERIVED incumbent index generated_at=" |
| 104 | const INC_ORG_TAG: *u8 = "org|" |
| 105 | const INC_ASSET_TAG: *u8 = "asset|" |
| 106 | const INC_KNOW: *u8 = "knowledge/" |
| 107 | const INC_FUNC: *u8 = "func " |
| 108 | const INC_FUNC_LEN: i64 = 5 |
| 109 | const INC_REJ_SEP: *u8 = ";; " |
| 110 | const INC_ORG_FIELDS: i64 = 6 |
| 111 | const INC_ASSET_FIELDS: i64 = 3 |
| 112 | const INC_ROW_SLACK: i64 = 1024 // per row beyond the header window: name, root, separators, asset paths |
| 114 | const INC_D_HEAD_BYTES: i64 = 8192 |
| 115 | const INC_D_MORPH_LONG: i64 = 6 |
| 116 | const INC_D_MORPH_SHORT: i64 = 4 |
| 117 | const INC_D_MIN_TOK: i64 = 3 |
| 118 | const INC_D_TOPN: i64 = 8 |
| 119 | const INC_D_DF_MAX_PERMIL: i64 = 250 |
| 120 | const INC_D_IDF_SCALE: i64 = 1000000 |
| 121 | const INC_D_IDF_BASE: i64 = 3 |
| 122 | const INC_D_REJ_PER_ORG: i64 = 2 |
| 123 | const INC_D_REJ_LINE_CAP: i64 = 160 |
| 124 | const INC_D_INDEX_MAX_AGE_S: i64 = 172800 |
| 125 | const INC_D_MAX_TERMS: i64 = 62 |
| 126 | const INC_D_REJ_ORGS: i64 = 8 |
| 127 | const INC_PERMIL: i64 = 1000 |
| 129 | const INC_C_HEAD_BYTES: i64 = 0 |
| 130 | const INC_C_MORPH_LONG: i64 = 1 |
| 131 | const INC_C_MORPH_SHORT: i64 = 2 |
| 132 | const INC_C_MIN_TOK: i64 = 3 |
| 133 | const INC_C_TOPN: i64 = 4 |
| 134 | const INC_C_DF_MAX_PERMIL: i64 = 5 |
| 135 | const INC_C_IDF_SCALE: i64 = 6 |
| 136 | const INC_C_IDF_BASE: i64 = 7 |
| 137 | const INC_C_REJ_PER_ORG: i64 = 8 |
| 138 | const INC_C_REJ_LINE_CAP: i64 = 9 |
| 139 | const INC_C_INDEX_MAX_AGE_S: i64 = 10 |
| 140 | const INC_C_MAX_TERMS: i64 = 11 |
| 141 | const INC_C_SRC: i64 = 12 // 1 conf file read, 0 defaults |
| 142 | const INC_C_REJ_ORGS: i64 = 13 // organs listed under PRIOR-REJECTIONS beyond the top organs |
| 143 | const INC_C_N: i64 = 14 |
| 145 | const INC_G_BUF: i64 = 0 |
| 146 | const INC_G_N: i64 = 1 |
| 147 | const INC_G_ROWS: i64 = 2 |
| 148 | const INC_G_R_NAME: i64 = 3 |
| 149 | const INC_G_R_ROOT: i64 = 4 |
| 150 | const INC_G_R_WORDS: i64 = 5 |
| 151 | const INC_G_R_ASSETS: i64 = 6 |
| 152 | const INC_G_R_REJ: i64 = 7 |
| 153 | const INC_G_ASSETS: i64 = 8 |
| 154 | const INC_G_A_NAME: i64 = 9 |
| 155 | const INC_G_A_WORDS: i64 = 10 |
| 156 | const INC_G_HCAP: i64 = 11 |
| 157 | const INC_G_HKEY: i64 = 12 |
| 158 | const INC_G_HHEAD: i64 = 13 |
| 159 | const INC_G_PWORD: i64 = 14 |
| 160 | const INC_G_PROW: i64 = 15 |
| 161 | const INC_G_PNEXT: i64 = 16 |
| 162 | const INC_G_NPOST: i64 = 17 |
| 163 | const INC_G_GEN: i64 = 18 |
| 164 | const INC_G_FILES: i64 = 19 |
| 165 | const INC_G_TRUNC: i64 = 20 |
| 166 | const INC_G_COMPLETE: i64 = 21 |
| 167 | const INC_G_STATE: i64 = 22 |
| 168 | const INC_G_AGE: i64 = 23 |
| 169 | const INC_G_PATH: i64 = 24 |
| 170 | const INC_G_SEEN: i64 = 25 // per-row scratch stamp for df counting |
| 171 | const INC_G_SCORE: i64 = 26 |
| 172 | const INC_G_MASK: i64 = 27 |
| 173 | const INC_G_TIER: i64 = 28 // per-row scratch: contract terms hitting the organ's name parts |
| 174 | const INC_G_NIDF: i64 = 29 // per-row scratch: the idf of the terms hitting the organ's name parts |
| 175 | const INC_G_N_SLOTS: i64 = 30 |
| 177 | const INC_S_FRESH: i64 = 0 |
| 178 | const INC_S_STALE: i64 = 1 |
| 179 | const INC_S_ABSENT: i64 = 2 |
| 180 | const INC_S_MALFORMED: i64 = 3 |
| 182 | const INC_R_N: i64 = 0 |
| 183 | const INC_R_ROW: i64 = 1 |
| 184 | const INC_R_SCORE: i64 = 2 |
| 185 | const INC_R_MASK: i64 = 3 |
| 186 | const INC_R_NTERMS: i64 = 4 |
| 187 | const INC_R_TERMS: i64 = 5 |
| 188 | const INC_R_TOFF: i64 = 6 |
| 189 | const INC_R_DROPPED: i64 = 7 |
| 190 | const INC_R_DROPMASK: i64 = 8 |
| 191 | const INC_R_OVER: i64 = 9 |
| 192 | const INC_R_MATCHED: i64 = 10 |
| 193 | const INC_R_TIER: i64 = 11 |
| 194 | const INC_R_NUMERIC: i64 = 12 // all-digit terms dropped |
| 195 | const INC_R_TIDF: i64 = 13 // per-term idf weight (0 when dropped or unmatched) |
| 196 | const INC_R_N_SLOTS: i64 = 14 |
| 198 | const INC_E_FILES: i64 = 0 |
| 199 | const INC_E_TRUNC: i64 = 1 |
| 200 | const INC_E_ASSETS: i64 = 2 |
| 201 | const INC_E_COMPLETE: i64 = 3 |
| 202 | const INC_E_GEN: i64 = 4 |
| 203 | const INC_E_BYTES: i64 = 5 |
| 204 | const INC_E_N: i64 = 6 |
| 206 | const INC_B_CONF: i64 = 0 |
| 207 | const INC_B_ENV: i64 = 1 |
| 208 | const INC_B_REJ: i64 = 2 |
| 209 | const INC_B_NREJ: i64 = 3 |
| 210 | const INC_B_SET: i64 = 4 |
| 211 | const INC_B_ROOT: i64 = 5 |
| 212 | const INC_B_NAME: i64 = 6 |
| 213 | const INC_B_WORD: i64 = 7 |
| 214 | const INC_B_POS: i64 = 8 |
| 215 | const INC_B_CAND: i64 = 9 |
| 216 | const INC_B_HEAD: i64 = 10 |
| 217 | const INC_B_N: i64 = 11 |
| 219 | const INC_V_ASTART: i64 = 0 |
| 220 | const INC_V_NA: i64 = 1 |
| 221 | const INC_V_N: i64 = 2 |
| 222 | const INC_NONE: i64 = 0 - 1 |
| 223 | const INC_CLOCK_WORDS: i64 = 2 |
functions
| 228 | func inc_slen(s: *u8) -> i64 |
| 233 | func inc_cat(d: *u8, o: i64, s: *u8) -> i64 |
| 241 | func inc_catb(d: *u8, o: i64, cap: i64, s: *u8) -> i64 |
| 248 | func inc_catn(d: *u8, o: i64, cap: i64, v: i64) -> i64 |
| 263 | func inc_streq(a: *u8, b: *u8) -> i64 |
| 269 | func inc_starts(s: *u8, pre: *u8) -> i64 |
| 275 | func inc_lend(buf: *u8, n: i64, p: i64) -> i64 |
| 282 | func inc_wend(buf: *u8, n: i64, p: i64) -> i64 |
| 289 | func inc_contains(s: *u8, n: i64, needle: *u8) -> i64 |
| 302 | func inc_is_alnum(b: i64) -> i64 called by 1: inc_next_word |
| 308 | func inc_is_digit(b: i64) -> i64 |
| 313 | func inc_lower(b: i64) -> i64 called by 1: inc_next_word |
| 318 | func inc_atoi(s: *u8, off: i64) -> i64 |
| 329 | func inc_kv_int(s: *u8, key: *u8) -> i64 |
| 342 | func inc_now() -> i64 |
| 348 | func inc_ends_nx(nm: *u8, l: i64) -> i64 |
| 356 | func inc_organ_name(path: *u8, out: *u8) -> i64 |
| 369 | func inc_listed(buf: *u8, from: i64, o: i64, name: *u8) -> i64 |
| 385 | func inc_cwd_is_nishihost() -> i64 |
| 393 | func inc_conf_take(c: *i64, ln: *u8, key: *u8, slot: i64) -> i64 |
| 399 | func inc_conf_load() -> *i64 |
| 451 | func inc_reject_load(count: *i64) -> *u8 |
| 476 | func inc_reject_nth(rej: *u8, k: i64) -> *u8 called by 1: inc_row_for |
| 486 | func inc_next_word(s: *u8, n: i64, pos: *i64, out: *u8) -> i64 |
| 507 | func inc_key(w: *u8, take: i64) -> i64 |
| 514 | func inc_hash(k: i64, cap: i64) -> i64 |
| 522 | func inc_list_dir(dir: *u8, names: *u8, want: i64, srconly: i64) -> i64 called by 2: inc_fill_namesinc_index_build calls 9: sys_openat_rdsys_mmapsys_getdents64dirent_nameinc_sleninc_ends_nx+3 |
| 556 | func inc_read_head(path: *u8, buf: *u8, cap: i64) -> i64 |
| 571 | func inc_set_add(set: *i64, cap: i64, w: *u8) -> i64 |
| 585 | func inc_bag_emit(b: *i64, s: *u8, n: i64, out: *u8, o: i64, firstp: *i64) -> i64 |
| 605 | func inc_head_end(hb: *u8, got: i64, cap: i64, trunc: *i64) -> i64 |
| 626 | func inc_path_stop(b: i64) -> i64 called by 1: inc_row_for |
| 641 | func inc_row_for(b: *i64, path: *u8, out: *u8, o: i64) -> i64 called by 1: inc_index_build calls 13: inc_read_headinc_organ_nameinc_catsys_mmapinc_head_endinc_bag_emit+7 |
| 748 | func inc_asset_row(b: *i64, name: *u8, out: *u8, o: i64) -> i64 |
| 764 | func inc_publish(out_path: *u8, head: *u8, rows: *u8, rows_len: i64) -> i64 |
| 787 | func inc_fill_names(dir: *u8, cnt: i64, srconly: i64, env: *i64) -> *u8 |
| 793 | func inc_index_build(c: *i64, root_a: *u8, root_b: *u8, asset_dir: *u8, out_path: *u8) -> *i64 |
| 867 | func inc_split(ln: *u8, fld: *i64, maxf: i64) -> i64 called by 1: inc_load_path |
| 877 | func inc_hput(g: *i64, key: i64, word: i64, row: i64) -> i64 |
| 900 | func inc_hfind(g: *i64, key: i64) -> i64 |
| 913 | func inc_state_name(s: i64) -> *u8 |
| 920 | func inc_load_path(c: *i64, path: *u8, now: i64) -> *i64 |
| 1040 | func inc_load(c: *i64) -> *i64 |
| 1050 | func inc_term_hits(c: *i64, term: *u8, tlen: i64, word: *u8) -> i64 |
| 1061 | func inc_name_hits(c: *i64, r: *i64, name: *u8, w: *u8, pos: *i64, out2: *i64) -> i64 |
| 1086 | func inc_match(g: *i64, c: *i64, title: *u8, sym: *u8, note: *u8, excl: *u8) -> *i64 called by 3: rk_incumbentsmainmain calls 10: sys_mmapinc_sleninc_catinc_next_wordinc_is_digitinc_term_hits+4 |
| 1219 | func inc_asset_hits(c: *i64, r: *i64, ws: *u8) -> i64 |
| 1243 | func inc_render_assets(g: *i64, row: i64, out: *u8, o: i64, cap: i64, v: *i64) -> i64 |
| 1264 | func inc_render_rej(g: *i64, row: i64, out: *u8, o: i64, cap: i64, v: *i64) -> i64 |
| 1278 | func inc_rej_cand(g: *i64, r: *i64, row: i64) -> i64 called by 1: inc_render |
| 1290 | func inc_render(g: *i64, c: *i64, r: *i64, rid: *u8, out: *u8, cap: i64) -> i64 called by 3: rk_incumbentsmainmain calls 9: inc_catbinc_catninc_catsys_mmapinc_rej_candinc_render_assets+3 |
| 1405 | func inc_envelope(g: *i64, out: *u8, cap: i64) -> i64 |