code wiki / (root) / nx_code_index_tool_register.nx

nx_code_index_tool_register.nx source

↩ module page · 25 lines · 2459 B

1// nx_code_index_tool_register.nx -- register nx_code_index (sovereign SEMANTIC ORGAN RETRIEVAL) into 2// the discovery registry -> mcp__nishi__nx_code_index, so EVERY session/agent can retrieve the most 3// relevant VERIFIED organs from our own codebase for a task (RAG over the verified-organ corpus), the 4// retriever the forge's RAG pack (nx_forge_rag) consumes. READ-BROAD per exposure_policy (query is 5// read-only). Idempotent; verifies by READBACK. expect_exit: 0 license_tier: ORIGINAL 6import "nx_tool_registry.nx" 7 8func sr_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 9 10func main() -> i64 { 11 sr_puts("=== nx_code_index_tool_register -- semantic organ retrieval into the discovery registry ===\n" as *u8) 12 let w: i64 = tool_register("nx_code_index" as *u8, 13 "Sovereign SEMANTIC ORGAN RETRIEVAL (RAG over our verified NishiLang codebase): embed a natural-language task via the no-float coder serve POST /embed (jina-code recipe) and integer-cosine scan a binary NXCI1 index of verified organs to return the most relevant one. Use it to find a WORKING verified exemplar before writing new code -- the retriever the forge RAG pack (nx_forge_rag) consumes. VERBS: query <store> <port> \"<text>\" -> top-1 organ name + per-mille cosine; build <listfile> <store> <port> -> index the organs listed in <listfile>. Requires the coder serve live on <port> (POST /embed) and a built index store. Proven live: query 'close a failed coding task into a compile verified training pair' -> nx_forge_cascade (781pm), unrelated organs far below." as *u8, 14 "over /mcp: tools/call name=nx_code_index arguments={argv:[\"query\",\"knowledge/store/code_index_v0\",\"8032\",\"<task text>\"]}. Build an index first if none exists: {argv:[\"build\",\"<listfile>\",\"knowledge/store/<name>\",\"8032\"]}. exit 0; the result is the '[ci] TOP1 <name> pm=..' line." as *u8, 15 "GREEN (nx_code_embed_gate retrieval 3/3 diagonal; live 15-organ index built + query discriminates correctly)" as *u8) 16 let p: *i64 = sys_mmap(8) as *i64 17 let l: *i64 = sys_mmap(8) as *i64 18 let g: i64 = tool_get("nx_code_index" as *u8, p, l) 19 if w == 0 { if g == 1 { if l[0] > 0 { 20 sr_puts("verdict=GREEN (nx_code_index discoverable -> mcp__nishi__nx_code_index stub)\n" as *u8) 21 sys_exit(0); return 0 22 } } } 23 sr_puts("REGISTER FAILED\nverdict=RED\n" as *u8) 24 sys_exit(1); return 1 25}