code wiki / _hdl_build / nx_capaxes_derive.nx
nx_capaxes_derive.nx source
↩ module page · 288 lines · 12420 B
1// nx_capaxes_derive.nx -- DERIVES capability axis vectors from a LIVE source and ranks the rocks.
2//
3// WHY (operator 2026-07-30): the census is "gamed on coverage to 1000permil but with below toy quality"
4// and partial capabilities are "treated as completed capabilities not as things that need a full living
5// iteration loop to determine biggest rocks". nx_capaxes_lib made the SHAPE measurable; this closes the
6// loop by feeding it real numbers and emitting the rock order.
7//
8// SOURCE (composition, not reimplementation -- the nx_debt_view pattern): fork nx_sota_status and read its
9// per-domain rows. Every domain it lists carries local .matrix evidence, so GROUNDING is real for these
10// (unlike nx_cap_census, which reports "vs 0 SOTA-src" for every row = an EMPTY comparator, debt 1785465147).
11//
12// AXES SET HERE, and what is HONESTLY NOT YET WIRED:
13// coverage <- the row's own cov= figure MEASURED
14// evidence <- 0, because every row nx_sota_status prints with MEASURED
15// a cov= figure sits in its CLAIM-ONLY block
16// (PROVEN is 0/40, so no row scores above this)
17// grounding <- CAX_FULL: the domain HAS a .matrix comparator MEASURED
18// quality <- UNMEASURED (-1), needs the ecomat maturity grade
19// scale <- UNMEASURED (-1), needs the gate envelope N
20// adoption <- UNMEASURED (-1), needs the nx_wirecensus join
21// -1 is NOT a silent 0 and the lib proves it can never become the minimum (nx_capaxes_gate T3).
22// Three axes measured is a FLOOR, declared in the envelope -- never presented as the whole picture.
23//
24// THE POINT: with evidence=0 the headline is 0 no matter how high coverage climbs, so LEVERAGE is what
25// orders the work -- and leverage IS the coverage claim. A domain asserting cov=1000 with zero executable
26// evidence is the BIGGEST rock, not the most finished one. That inverts the gamed ranking exactly.
27//
28// nx_capaxes_derive [topN] exit 0 ok | 4 capture-fail
29// license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0
30import "nx_capaxes_lib.nx"
31import "nx_tool_run.nx"
32
33const CD_CAP: i64 = 262144
34const CD_MAXDOM: i64 = 128
35const CD_NAMEW: i64 = 40
36const CD_ELF: *u8 = "/volume1/homes/elderwesto/nishihost/nx_sota_status.elf" as *u8
37// The ADOPTION axis, derived by nx_adopt and stamped so nobody re-runs a 17,559-file scan for one number.
38// Reading a stamp instead of forking the census is what keeps this organ inside the /api/gate_run deadline.
39const CD_STAMP: *u8 = "knowledge/status/adopt_census.stamp" as *u8
40const CD_ADOPT_KEY_LEN: i64 = 16
41
42func cd_match(buf: *u8, at: i64, end: i64, pat: *u8, pl: i64) -> i64 {
43 if at + pl > end { return 0 }
44 var k: i64 = 0
45 while k < pl {
46 if buf[at + k] != pat[k] { return 0 }
47 k = k + 1
48 }
49 return 1
50}
51
52func cd_num_at(buf: *u8, at: i64, end: i64) -> i64 {
53 var v: i64 = 0
54 var i: i64 = at
55 var any: i64 = 0
56 while i < end {
57 let c: i64 = buf[i] as i64
58 if c < 48 { i = end }
59 else {
60 if c > 57 { i = end }
61 else {
62 v = v * 10 + (c - 48)
63 any = 1
64 i = i + 1
65 }
66 }
67 }
68 if any == 0 { return CAX_UNMEASURED }
69 return v
70}
71
72func main(argc: i64, argv: *i64) -> i64 {
73 var topn: i64 = 20
74 if argc > 1 { topn = cax_atoi(argv[1] as *u8) }
75 if topn <= 0 { topn = 20 }
76
77 let out: *u8 = sys_mmap(CD_CAP + 16)
78 let olen: *i64 = sys_mmap(16) as *i64
79 let rc: i64 = tr_run1(CD_ELF, 0 as *u8, out, CD_CAP, olen)
80 let n: i64 = olen[0]
81 if rc == 127 {
82 cax_puts("CAPAXES-DERIVE verdict=CAPTURE-FAIL exec-127\n" as *u8)
83 return 4
84 }
85 if n <= 0 {
86 cax_puts("CAPAXES-DERIVE verdict=CAPTURE-FAIL empty\n" as *u8)
87 return 4
88 }
89
90 let names: *u8 = sys_mmap(CD_MAXDOM * CD_NAMEW + 16)
91 let covs: *i64 = sys_mmap(CD_MAXDOM * 8 + 16) as *i64
92 let rocks: *i64 = sys_mmap(CD_MAXDOM * 8 + 16) as *i64
93 var nd: i64 = 0
94
95 var ls: i64 = 0
96 var i: i64 = 0
97 while i <= n {
98 var isend: i64 = 0
99 if i == n { isend = 1 } else { if out[i] == (10 as u8) { isend = 1 } }
100 if isend == 1 {
101 var j: i64 = ls
102 var covpos: i64 = 0 - 1
103 while j < i {
104 if cd_match(out, j, i, "cov=" as *u8, 4) == 1 {
105 covpos = j + 4
106 j = i
107 } else { j = j + 1 }
108 }
109 if covpos > 0 {
110 if nd < CD_MAXDOM {
111 var s: i64 = ls
112 while s < i {
113 if out[s] == (32 as u8) { s = s + 1 } else { s = i }
114 }
115 s = ls
116 while s < i {
117 if out[s] != (32 as u8) { s = i } else { s = s + 1 }
118 }
119 var t: i64 = ls
120 while t < i {
121 if out[t] == (32 as u8) { t = t + 1 } else { t = i + 1 }
122 }
123 var st: i64 = ls
124 while st < i {
125 if out[st] == (32 as u8) { st = st + 1 }
126 else { st = i + 1 }
127 }
128 var b: i64 = ls
129 while b < i {
130 if out[b] == (32 as u8) { b = b + 1 } else { b = i + 2 }
131 }
132 var p0: i64 = ls
133 while p0 < i {
134 if out[p0] == (32 as u8) { p0 = p0 + 1 } else { p0 = i + 3 }
135 }
136 var start: i64 = ls
137 var scan: i64 = ls
138 var found: i64 = 0
139 while scan < i {
140 if found == 0 {
141 if out[scan] != (32 as u8) {
142 start = scan
143 found = 1
144 }
145 }
146 scan = scan + 1
147 }
148 var w: i64 = 0
149 let slot: i64 = (names as i64) + nd * CD_NAMEW
150 var q: i64 = start
151 while q < i {
152 if out[q] == (32 as u8) { q = i }
153 else {
154 if w < CD_NAMEW - 1 {
155 let dst: *u8 = (slot + w) as *u8
156 dst[0] = out[q]
157 w = w + 1
158 }
159 q = q + 1
160 }
161 }
162 let term: *u8 = (slot + w) as *u8
163 term[0] = 0 as u8
164 if w > 0 {
165 covs[nd] = cd_num_at(out, covpos, i)
166 nd = nd + 1
167 }
168 }
169 }
170 ls = i + 1
171 }
172 i = i + 1
173 }
174
175 // ⚠SUPERSEDED-RANKING BANNER (added 2026-07-31 by the capgraph arc). Nothing below is removed --
176 // Rule 25, this organ's axis-shape work is still correct and still worth reading. What is WRONG is
177 // its ROCK ORDER: with evidence hardcoded 0 every headline is 0, so the rank falls back to leverage,
178 // and leverage here IS the coverage claim. Ranking by claim size was MEASURED to be inverted.
179 // Leaving two rulers answering the same question with opposite answers is the "the other file keeps
180 // answering" hazard; a reader who finds this one first would mine the wrong rock. So it now says so.
181 cax_puts("### SUPERSEDED RANKING -- READ THIS BEFORE ACTING ON THE ORDER BELOW ###\n" as *u8)
182 cax_puts(" This organ ranks by the COVERAGE CLAIM. That order was MEASURED to be INVERTED:\n" as *u8)
183 cax_puts(" workermesh (cov=1000) ranks #1 here and gates NOTHING -- it is #9 on the measured graph,\n" as *u8)
184 cax_puts(" where leverage is DOWNSTREAM MASS, not claim size. Use `nx_capgraph_derive` for the rock\n" as *u8)
185 cax_puts(" order and `nx_capgraph_derive progress` for movement. The AXIS SHAPE below is still valid.\n" as *u8)
186 cax_puts("###\n\n" as *u8)
187 cax_puts("=== CAPAXES-DERIVE: axis profiles from nx_sota_status (live) ===\n" as *u8)
188 cax_puts("domains_parsed=" as *u8)
189 cax_puti(nd)
190 cax_puts("\n\n" as *u8)
191
192 var v: *i64 = sys_mmap(128) as *i64
193 var d: i64 = 0
194 while d < nd {
195 v[CAX_A_COVER] = covs[d]
196 v[CAX_A_QUALITY] = CAX_UNMEASURED
197 v[CAX_A_SCALE] = CAX_UNMEASURED
198 v[CAX_A_EVIDENCE] = 0
199 v[CAX_A_ADOPT] = CAX_UNMEASURED
200 v[CAX_A_GROUND] = CAX_FULL
201 rocks[d] = cax_rock(v, CAX_N, covs[d])
202 d = d + 1
203 }
204
205 cax_puts("-- BIGGEST ROCKS (rank = (1000 - min_axis) x leverage, leverage = the coverage CLAIM) --\n" as *u8)
206 cax_puts(" a domain claiming the MOST coverage with ZERO evidence is the BIGGEST rock, not the most done.\n\n" as *u8)
207 var shown: i64 = 0
208 while shown < topn {
209 var best: i64 = 0 - 1
210 var k: i64 = 0
211 while k < nd {
212 if rocks[k] >= 0 {
213 if best < 0 { best = k }
214 else { if rocks[k] > rocks[best] { best = k } }
215 }
216 k = k + 1
217 }
218 if best < 0 { shown = topn }
219 else {
220 cax_puti(shown + 1)
221 cax_puts(". " as *u8)
222 cax_puts(((names as i64) + best * CD_NAMEW) as *u8)
223 cax_puts(" " as *u8)
224 v[CAX_A_COVER] = covs[best]
225 v[CAX_A_QUALITY] = CAX_UNMEASURED
226 v[CAX_A_SCALE] = CAX_UNMEASURED
227 v[CAX_A_EVIDENCE] = 0
228 v[CAX_A_ADOPT] = CAX_UNMEASURED
229 v[CAX_A_GROUND] = CAX_FULL
230 cax_kv("coverage" as *u8, covs[best])
231 cax_kv("evidence" as *u8, 0)
232 cax_kv("headline_MIN" as *u8, cax_headline(v, CAX_N))
233 cax_kv("skew" as *u8, cax_skew(v, CAX_N))
234 cax_puts("starved=" as *u8)
235 cax_puts(cax_axis_name(cax_min_idx(v, CAX_N)))
236 cax_puts(" " as *u8)
237 cax_kv("rock" as *u8, rocks[best])
238 cax_kv("mean_would_have_read" as *u8, cax_mean(v, CAX_N))
239 cax_puts("\n" as *u8)
240 rocks[best] = 0 - 1
241 shown = shown + 1
242 }
243 }
244
245 // ---- THE ECOSYSTEM ITSELF, PROFILED AS ONE CAPABILITY ----
246 // Every axis below comes from a LIVE source, none is asserted: coverage = the mean of the domain cov=
247 // figures parsed above; evidence = 0 because nx_sota_status reports PROVEN 0/40 and every row it prints
248 // with a cov= figure sits in CLAIM-ONLY; adoption = nx_adopt's stamped adoption_permil; grounding = FULL
249 // because these domains carry .matrix comparators. quality and scale stay -1 UNMEASURED and are excluded
250 // from the MIN by construction, so this profile is a FLOOR -- wiring them can only lower it.
251 let stamp_len: *i64 = sys_mmap(16) as *i64
252 let stamp: *u8 = sys_read_file(CD_STAMP, stamp_len)
253 var adoption: i64 = CAX_UNMEASURED
254 let sn: i64 = stamp_len[0]
255 if sn > 0 {
256 var si: i64 = 0
257 while si < sn {
258 if cd_match(stamp, si, sn, "adoption_permil=" as *u8, CD_ADOPT_KEY_LEN) == 1 {
259 adoption = cd_num_at(stamp, si + CD_ADOPT_KEY_LEN, sn)
260 si = sn
261 } else {
262 si = si + 1
263 }
264 }
265 }
266 var covsum: i64 = 0
267 var d2: i64 = 0
268 while d2 < nd {
269 covsum = covsum + covs[d2]
270 d2 = d2 + 1
271 }
272 var covmean: i64 = CAX_UNMEASURED
273 if nd > 0 { covmean = covsum / nd }
274 v[CAX_A_COVER] = covmean
275 v[CAX_A_QUALITY] = CAX_UNMEASURED
276 v[CAX_A_SCALE] = CAX_UNMEASURED
277 v[CAX_A_EVIDENCE] = 0
278 v[CAX_A_ADOPT] = adoption
279 v[CAX_A_GROUND] = CAX_FULL
280 cax_puts("\n-- THE ECOSYSTEM ITSELF, PROFILED AS ONE CAPABILITY (every axis from a live source) --\n" as *u8)
281 cax_report(v, CAX_N, 1)
282
283 cax_puts("\nenvelope: per-domain rows measure 3of6 (coverage/evidence/grounding); quality+scale+adoption=-1,\n" as *u8)
284 cax_puts(" excluded from the MIN by construction (nx_capaxes_gate T3), NEVER counted as 0. This is a\n" as *u8)
285 cax_puts(" DECLARED FLOOR, not the whole picture: wiring ecomat quality + wirecensus adoption can only\n" as *u8)
286 cax_puts(" LOWER these headlines, never raise them. source=nx_sota_status fork-capture, no reimplementation.\n" as *u8)
287 return 0
288}