code wiki / _hdl_build / nx_k3_arch_census.nx
nx_k3_arch_census.nx source
↩ module page · 170 lines · 7805 B
1// nx_k3_arch_census.nx -- SOVEREIGN K3-CLASS ARCHITECTURE COVERAGE CENSUS (operator 2026-07-18: "big
2// rocks that move us to state of the art ... benchmarked honestly ... flagged for research opps to go
3// beyond state of the art and what to look for in our fetches"). The session opened on the Kimi-K3
4// question; this is its MEASURE-FIRST rock. Grades OUR sovereign no-float coverage of each K3-SPECIFIC
5// innovation (serve + train) against the honest evidence, LIAR-KILLED: a HAVE/PARTIAL claim with
6// evidence "none"/"SET-ME" is forced to GAP (can't score coverage without a shipped gate behind it).
7// Emits every effective-GAP as a RESEARCH candidate with its fetch guidance. DATA-DRIVEN (rule 11):
8// reads knowledge/store/k3feat- (7 cols: id feature serve train evidence k3_mech research_fetch);
9// edit a row + reseed -> the board regenerates, never stale. Fail-closed on an unseeded store.
10// nx_k3_arch_census [featprefix] [mode] mode json (default) | board
11// license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0
12import "nx_store_seed_lib.nx"
13import "nx_seg_store.nx"
14import "nx_syscalls.nx"
15
16const KC_CAP: i64 = 1048576
17const KC_OUT: i64 = 262144
18const KC_NL: i64 = 10
19const KC_TAB: i64 = 9
20const KC_NCOL: i64 = 7
21const KC_PAIR: i64 = 2
22const KC_SPB: i64 = 128
23const KC_STDERR: i64 = 2
24const KC_EXIT_IO: i64 = 1
25// col indices
26const KC_ID: i64 = 0
27const KC_FEAT: i64 = 1
28const KC_SERVE: i64 = 2
29const KC_TRAIN: i64 = 3
30const KC_EVID: i64 = 4
31const KC_MECH: i64 = 5
32const KC_FETCH: i64 = 6
33
34func kc_w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
35func kc_werr(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(KC_STDERR,s,n); return 0 }
36func kc_cols(q: *u8, ls: i64, le: i64, sp: *i64) -> i64 {
37 var c: i64 = 0
38 var p: i64 = ls
39 while c < KC_NCOL {
40 var e: i64 = p
41 var s: i64 = 1
42 while s == 1 { if e >= le { s = 0 } else { if q[e] == (KC_TAB as u8) { s = 0 } else { e = e + 1 } } }
43 sp[c*KC_PAIR] = p
44 sp[c*KC_PAIR+1] = e
45 c = c + 1
46 if e >= le { return c }
47 p = e + 1
48 }
49 return c
50}
51func kc_sl_eq(q: *u8, a: i64, b: i64, s: *u8) -> i64 {
52 var n: i64 = 0
53 while s[n] != (0 as u8) { n = n + 1 }
54 if b - a != n { return 0 }
55 var i: i64 = 0
56 while i < n { if q[a+i] != s[i] { return 0 } i = i + 1 }
57 return 1
58}
59// claim string -> points (HAVE 2, PARTIAL 1, else 0)
60func kc_pts(q: *u8, a: i64, b: i64) -> i64 {
61 if kc_sl_eq(q, a, b, "HAVE" as *u8) == 1 { return 2 }
62 if kc_sl_eq(q, a, b, "PARTIAL" as *u8) == 1 { return 1 }
63 return 0
64}
65// evidence "none"/"SET-ME" -> no proof -> liar-kill (1 = kill to GAP)
66func kc_noevid(q: *u8, a: i64, b: i64) -> i64 {
67 if kc_sl_eq(q, a, b, "none" as *u8) == 1 { return 1 }
68 if kc_sl_eq(q, a, b, "SET-ME" as *u8) == 1 { return 1 }
69 if b - a == 0 { return 1 }
70 return 1 - 1
71}
72func kc_cat_sl(d: *u8, o: i64, q: *u8, a: i64, b: i64) -> i64 {
73 var oo: i64 = o
74 var i: i64 = a
75 while i < b { var c: i64 = q[i]; if c == 34 { c = 39 } if c == 92 { c = 47 } if c < 32 { c = 32 } d[oo] = c as u8; oo = oo + 1; i = i + 1 }
76 return oo
77}
78
79func main(argc: i64, argv: *i64) -> i64 {
80 var fpx: *u8 = "knowledge/store/k3feat-" as *u8
81 if argc > 1 { fpx = argv[1] as *u8 }
82 let fb: *u8 = sys_mmap(KC_CAP)
83 let fn: i64 = sts_load(fpx, fb, KC_CAP)
84 if fn <= 0 { kc_werr("k3feat store unseeded (fail-closed): seed via nx_store_put knowledge/store/k3feat-\n" as *u8); sys_exit(KC_EXIT_IO); return KC_EXIT_IO }
85 let sp: *i64 = sys_mmap(KC_SPB) as *i64
86 let out: *u8 = sys_mmap(KC_OUT)
87
88 var have: i64 = 0
89 var tot: i64 = 0
90 var nfeat: i64 = 0
91 var ngap: i64 = 0
92 var npartial: i64 = 0
93 var nfull: i64 = 0
94 var killed: i64 = 0
95 var o: i64 = 0
96 o = ss_cat(out, o, "{\x22k3_arch_census\x22:\x22v1\x22,\x22source\x22:\x22knowledge/store/k3feat-\x22,\x22features\x22:[" as *u8)
97 var research_o: i64 = 0
98 let resb: *u8 = sys_mmap(KC_OUT)
99 var nres: i64 = 0
100
101 var i: i64 = 0
102 while i < fn {
103 var le: i64 = i
104 var s: i64 = 1
105 while s == 1 { if le >= fn { s = 0 } else { if fb[le] == (KC_NL as u8) { s = 0 } else { le = le + 1 } } }
106 if le > i { if kc_cols(fb, i, le, sp) >= KC_NCOL {
107 nfeat = nfeat + 1
108 // liar-kill: no evidence -> both effective GAP
109 let noev: i64 = kc_noevid(fb, sp[KC_EVID*KC_PAIR], sp[KC_EVID*KC_PAIR+1])
110 var sv: i64 = kc_pts(fb, sp[KC_SERVE*KC_PAIR], sp[KC_SERVE*KC_PAIR+1])
111 var tr: i64 = kc_pts(fb, sp[KC_TRAIN*KC_PAIR], sp[KC_TRAIN*KC_PAIR+1])
112 if noev == 1 { if sv + tr > 0 { killed = killed + 1 } sv = 0; tr = 0 }
113 have = have + sv + tr
114 tot = tot + 4
115 let eff: i64 = sv + tr
116 if eff == 0 { ngap = ngap + 1 } else { if eff >= 3 { nfull = nfull + 1 } else { npartial = npartial + 1 } }
117 if nfeat > 1 { out[o] = 44 as u8; o = o + 1 }
118 o = ss_cat(out, o, "{\x22id\x22:\x22" as *u8)
119 o = kc_cat_sl(out, o, fb, sp[KC_ID*KC_PAIR], sp[KC_ID*KC_PAIR+1])
120 o = ss_cat(out, o, "\x22,\x22feature\x22:\x22" as *u8)
121 o = kc_cat_sl(out, o, fb, sp[KC_FEAT*KC_PAIR], sp[KC_FEAT*KC_PAIR+1])
122 o = ss_cat(out, o, "\x22,\x22serve_pts\x22:" as *u8)
123 o = ss_catn(out, o, sv)
124 o = ss_cat(out, o, ",\x22train_pts\x22:" as *u8)
125 o = ss_catn(out, o, tr)
126 o = ss_cat(out, o, ",\x22effective\x22:\x22" as *u8)
127 if eff == 0 { o = ss_cat(out, o, "GAP" as *u8) } else { if eff >= 3 { o = ss_cat(out, o, "STRONG" as *u8) } else { o = ss_cat(out, o, "PARTIAL" as *u8) } }
128 o = ss_cat(out, o, "\x22,\x22liar_killed\x22:" as *u8)
129 if noev == 1 { o = ss_cat(out, o, "1" as *u8) } else { o = ss_cat(out, o, "0" as *u8) }
130 o = ss_cat(out, o, "}" as *u8)
131 // effective GAP -> research candidate w/ fetch
132 if eff == 0 {
133 if nres > 0 { resb[research_o] = 44 as u8; research_o = research_o + 1 }
134 resb[research_o] = 34 as u8; research_o = research_o + 1
135 research_o = kc_cat_sl(resb, research_o, fb, sp[KC_ID*KC_PAIR], sp[KC_ID*KC_PAIR+1])
136 research_o = ss_cat(resb, research_o, ": " as *u8)
137 research_o = kc_cat_sl(resb, research_o, fb, sp[KC_FETCH*KC_PAIR], sp[KC_FETCH*KC_PAIR+1])
138 resb[research_o] = 34 as u8; research_o = research_o + 1
139 nres = nres + 1
140 }
141 } }
142 i = le + 1
143 }
144 let pm: i64 = (have * 1000) / tot
145 o = ss_cat(out, o, "],\x22coverage\x22:{\x22points\x22:" as *u8)
146 o = ss_catn(out, o, have)
147 o = ss_cat(out, o, ",\x22total\x22:" as *u8)
148 o = ss_catn(out, o, tot)
149 o = ss_cat(out, o, ",\x22permille\x22:" as *u8)
150 o = ss_catn(out, o, pm)
151 o = ss_cat(out, o, ",\x22features\x22:" as *u8)
152 o = ss_catn(out, o, nfeat)
153 o = ss_cat(out, o, ",\x22strong\x22:" as *u8)
154 o = ss_catn(out, o, nfull)
155 o = ss_cat(out, o, ",\x22partial\x22:" as *u8)
156 o = ss_catn(out, o, npartial)
157 o = ss_cat(out, o, ",\x22gap\x22:" as *u8)
158 o = ss_catn(out, o, ngap)
159 o = ss_cat(out, o, ",\x22liar_killed\x22:" as *u8)
160 o = ss_catn(out, o, killed)
161 o = ss_cat(out, o, "},\x22research_opps\x22:[" as *u8)
162 var ri: i64 = 0
163 while ri < research_o { out[o] = resb[ri]; o = o + 1; ri = ri + 1 }
164 o = ss_cat(out, o, "],\x22honest_headline\x22:\x22K3-specific innovations measured vs OUR sovereign no-float coverage; GAPs are the F-4xx research/build backlog -- MoE+MLA family shipped is the doorstep, the K3 deltas are the climb\x22}" as *u8)
165 out[o] = KC_NL as u8
166 o = o + 1
167 sys_write(1, out, o)
168 sys_exit(0)
169 return 0
170}