nx_code_index.nx
buildroot/runtime/nx_code_index.nx
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
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
| 16 | const CI_MAGIC_1048575: i64 = 1048575 |
| 17 | const CI_MAGIC_262144: i64 = 262144 |
| 18 | const CI_MAGIC_8192: i64 = 8192 |
| 19 | const CI_MAGIC_65536: i64 = 65536 |
| 20 | const CI_MAGIC_8190: i64 = 8190 |
| 21 | const CI_MAGIC_2000: i64 = 2000 |
| 23 | const CI_NE: i64 = 896 |
| 24 | const CI_HDRCAP: i64 = 480 |
| 25 | const CI_NAMECAP: i64 = 256 |
functions
| 28 | func ci_ws(s: *u8) -> i64 |
| 35 | func ci_kv(label: *u8, v: i64) -> i64 |
| 44 | func ci_isqrt(v: i64) -> i64 called by 1: ci_cos_pm |
| 52 | func ci_cos_pm(a: *i64, b: *i64) -> i64 |
| 86 | func ci_post_embed(port: i64, body: *u8, blen: i64, resp: *u8, rescap: i64) -> i64 |
| 106 | func ci_build_body(text: *u8, tlen: i64, kindq: i64, out: *u8) -> i64 |
| 127 | func ci_find(hay: *u8, hn: i64, needle: *u8) -> i64 |
| 144 | func ci_parse_vec(resp: *u8, rlen: i64, vec: *i64, ntok_out: *i64) -> i64 |
| 191 | func ci_embed(port: i64, text: *u8, tlen: i64, kindq: i64, vec: *i64) -> i64 |
| 206 | func ci_header(path: *u8, out: *u8, cap: i64) -> i64 |
| 253 | func ci_store_ensure(store: *u8) -> i64 |
| 278 | func ci_store_load(store: *u8, buf_out: *i64) -> i64 |
| 291 | func ci_store_has(store: *u8, name: *u8) -> i64 |
| 316 | func ci_store_append(store: *u8, name: *u8, ntok: i64, vec: *i64) -> i64 |
| 333 | func ci_index_file(port: i64, store: *u8, path: *u8) -> i64 |
| 370 | func ci_index_list(port: i64, store: *u8, listfile: *u8) -> i64 |
| 408 | func ci_store_count(store: *u8) -> i64 |
| 436 | func ci_query_top1(port: i64, store: *u8, text: *u8, nameb: *u8, pm_out: *i64) -> i64 |