code wiki / (root) / nx_code_index.nx

nx_code_index.nx

buildroot/runtime/nx_code_index.nx

16672 B480 linesdepth 7pulls 12 transitivereach 4 importersview sourcekind librarytopic code
docsdependenciesstructsconstsfunctions

about

nx_code_index.nx -- E-ARC e3 (2026-07-15): SEMANTIC ORGAN RETRIEVAL for the forge (pure core; CLI = nx_code_index_cli.nx, gate = nx_code_index_gate.nx -- the CRM idiom). INDEX: per source file, embed "FILE: <basename>" + the leading comment header via the LIVE no-float coder serve POST /embed (127.0.0.1:<port>, jina recipe arXiv:2508.21290, kind=passage), append a record to a sovereign binary store. QUERY: embed kind=query, integer-cosine scan, top-1. STORE NXCI1 (sovereign binary, no TSV): magic 8B "NXCI1\n\0\0" then records [nlen i64][name nlen bytes][ntok i64][vec CI_NE i64]. IDEMPOTENT: a name already present is SKIPPED on build (crash-resumable re-runs, rule 10). OVERFLOW LAW: cosine pre-scales both vecs by the SAME pow2 so max|e| <= 2^20 (raw q24 elements reach ~2^29 and their squares would overflow i64 across 896 dims). Production embeds run on OUR BASE coder weights (jina-tuned = benchmark oracle only, cc-by-nc). license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 3 imports · 4 importers

nx_forge_model.nx nx_connect.nx nx_lib_std.nx nx_code_index.nx nx_code_index_cli.nx nx_code_index_gate.nx nx_embed_gpu_live_gate.nx nx_forge_rag.nx

imports: nx_forge_model.nxnx_connect.nxnx_lib_std.nx

imported by: nx_code_index_cli.nxnx_code_index_gate.nxnx_embed_gpu_live_gate.nxnx_forge_rag.nx

structs

none

consts

16const CI_MAGIC_1048575: i64 = 1048575
17const CI_MAGIC_262144: i64 = 262144
18const CI_MAGIC_8192: i64 = 8192
19const CI_MAGIC_65536: i64 = 65536
20const CI_MAGIC_8190: i64 = 8190
21const CI_MAGIC_2000: i64 = 2000
23const CI_NE: i64 = 896
24const CI_HDRCAP: i64 = 480
25const CI_NAMECAP: i64 = 256

functions

28func ci_ws(s: *u8) -> i64
35func ci_kv(label: *u8, v: i64) -> i64
44func ci_isqrt(v: i64) -> i64
called by 1: ci_cos_pm
52func ci_cos_pm(a: *i64, b: *i64) -> i64
called by 2: ci_query_top1main calls 1: ci_isqrt
86func ci_post_embed(port: i64, body: *u8, blen: i64, resp: *u8, rescap: i64) -> i64
106func ci_build_body(text: *u8, tlen: i64, kindq: i64, out: *u8) -> i64
called by 1: ci_embed calls 1: fc_json_esc_bytes
127func ci_find(hay: *u8, hn: i64, needle: *u8) -> i64
called by 2: ci_parse_vecmain
144func ci_parse_vec(resp: *u8, rlen: i64, vec: *i64, ntok_out: *i64) -> i64
called by 2: ci_embedlb_embed calls 1: ci_find
191func ci_embed(port: i64, text: *u8, tlen: i64, kindq: i64, vec: *i64) -> i64
206func ci_header(path: *u8, out: *u8, cap: i64) -> i64
called by 1: ci_index_file calls 1: sys_read
253func ci_store_ensure(store: *u8) -> i64
called by 1: ci_index_list calls 2: sys_readsys_openat_wr
278func ci_store_load(store: *u8, buf_out: *i64) -> i64
291func ci_store_has(store: *u8, name: *u8) -> i64
called by 1: ci_index_file calls 2: ci_store_loadstd_slen
316func ci_store_append(store: *u8, name: *u8, ntok: i64, vec: *i64) -> i64
333func ci_index_file(port: i64, store: *u8, path: *u8) -> i64
370func ci_index_list(port: i64, store: *u8, listfile: *u8) -> i64
408func ci_store_count(store: *u8) -> i64
called by 2: mainmain calls 1: ci_store_load
436func ci_query_top1(port: i64, store: *u8, text: *u8, nameb: *u8, pm_out: *i64) -> i64