code wiki / _hdl_build / nx_rag_ws_register.nx
nx_rag_ws_register.nx source
↩ module page · 64 lines · 3251 B
1// nx_rag_ws_register.nx -- register the K3-INGEST growth arc's workstreams into the WMS registry SSOT
2// (knowledge/store/ws-) so the resume manifest + other empires + AGENTS see them (operator's "get us to
3// workstreams and agents"). Additive+idempotent (rule #10): read ws:ids, append iff absent, commit
4// ws:<id> records, verify by READBACK. Mirrors nx_iolayer_ws_register (canonical writer template).
5// RAG-GROWTH (E-PLATFORM): sovereign RAG over the verified-organ corpus for the forge --
6// nx_code_index retriever + nx_forge_rag top-k pack injection LIVE; value A/B pending.
7// GROWTH-LOOP-TRAIN (E-PLATFORM): weight-level learning from the compile-verified corpus (integer
8// autograd/LoRA/distill/gguf-writer exist, UNWIRED + compute-blocked = the big rock).
9// license_tier: ORIGINAL
10import "nx_workstream_store.nx"
11import "nx_seg_store.nx"
12import "nx_syscalls.nx"
13
14const RW_IDSBUF: i64 = 262144
15const RW_STREAMS: i64 = 2
16const RW_ASCII_0: i64 = 48
17
18func rw_w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
19func rw_len(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
20
21func rw_addid(idsbuf: *u8, olenp: *i64, id: *u8) -> i64 {
22 if ws_member(idsbuf, olenp[0], id) == 1 { return 0 }
23 var o: i64 = olenp[0]
24 if o > 0 { idsbuf[o] = 9 as u8; o = o + 1 }
25 var i: i64 = 0
26 while id[i] != (0 as u8) { idsbuf[o] = id[i]; o = o + 1; i = i + 1 }
27 olenp[0] = o
28 return 1
29}
30func rw_rec(w: *i64, key: *u8, val: *u8) -> i64 { return ss_add(w, 1, key, val, rw_len(val)) }
31
32func main() -> i64 {
33 let w: *i64 = ss_begin()
34 let pq: *i64 = sys_mmap(16) as *i64
35 let lq: *i64 = sys_mmap(16) as *i64
36 let idsbuf: *u8 = sys_mmap(RW_IDSBUF)
37 let olenp: *i64 = sys_mmap(8) as *i64
38 olenp[0] = 0
39 if ws_get("ws:ids\x00" as *u8, pq, lq) == 1 {
40 let src: *u8 = pq[0] as *u8
41 let n: i64 = lq[0]
42 var i: i64 = 0
43 while i < n { idsbuf[i] = src[i]; i = i + 1 }
44 olenp[0] = n
45 }
46 rw_addid(idsbuf, olenp, "RAG-GROWTH\x00" as *u8)
47 rw_addid(idsbuf, olenp, "GROWTH-LOOP-TRAIN\x00" as *u8)
48 ss_add(w, 1, "ws:ids\x00" as *u8, idsbuf, olenp[0])
49 rw_rec(w, "ws:RAG-GROWTH\x00" as *u8, "RAG-GROWTH\tE-PLATFORM\tACTIVE\t0\tproject-nishi-kimi-k3-ingest-growth-loop-2026-07-17.md\truntime/nx_forge_rag.nx\t-\x00" as *u8)
50 rw_rec(w, "ws:GROWTH-LOOP-TRAIN\x00" as *u8, "GROWTH-LOOP-TRAIN\tE-PLATFORM\tACTIVE\t0\tproject-nishi-kimi-k3-ingest-growth-loop-2026-07-17.md\truntime/nx_nofloat_autograd.nx\t-\x00" as *u8)
51 let segid: i64 = ws_seg_next(WS_PREFIX)
52 let rc: i64 = ss_commit(WS_PREFIX, w, segid)
53 if rc != 0 { rw_w("nx_rag_ws_register: COMMIT FAILED\n\x00" as *u8); return 1 }
54 var ver: i64 = 0
55 if ws_get("ws:RAG-GROWTH\x00" as *u8, pq, lq) == 1 { ver = ver + 1 }
56 if ws_get("ws:GROWTH-LOOP-TRAIN\x00" as *u8, pq, lq) == 1 { ver = ver + 1 }
57 rw_w("nx_rag_ws_register: registered RAG-GROWTH + GROWTH-LOOP-TRAIN (E-PLATFORM); verified=\x00" as *u8)
58 let bb: *u8 = sys_mmap(8)
59 bb[0] = (RW_ASCII_0 + ver) as u8
60 sys_write(1, bb, 1)
61 rw_w("/2 readback; ws:ids updated.\n\x00" as *u8)
62 if ver == RW_STREAMS { return 0 }
63 return 1
64}