nx_compare_shared_fit_lib_20260910.nx source
↩ module page · 2622 lines · 178761 B
1// AUTO-EXTRACTED shared base (nx_oo_extract). license_tier: ORIGINAL No hw writes (Rule 26).
2// functions: w,wc,wn,wj,wq,kv_s,kv_n,c_read,streq,starts,scopy,splitpipe,wnote,rp_base,rp_publish,rp_json,refs_pass
3import "nx_syscalls.nx"
4import "nx_symdecl_lib.nx"
5import "nx_market_ladder_lib.nx"
6import "nx_brand_tokens.nx" // the estate's design-token SSOT -- sc_theme_pass composes it, never a second parser
7import "nx_lineconf_lib.nx" // line-anchored conf reader, ONE owner -- never a private key=value parser
8import "nx_estate_path.nx" // THE ONE probe order for a status artifact -- a stamp written from the serving root must resolve from CWD=buildroot (gauge_pass, gaps_pass)
9import "nx_imgattr_lib.nx" // the ONE definition of how an attribute value and an img tag are written
10import "nx_evprofile_lib.nx" // THE ONE READER of the /compare evidence stamp -- evj_pass below PROJECTS
11import "nx_bench_receipt_lib.nx" // THE ONE READER of a <dom>.bench benchmark receipt -- bench_pass below RENDERS it (2026-09-01)
12import "nx_barfresh_lib.nx" // THE ONE bar-age ruler (2026-09-06) -- plan_pass renders each sotatarget with its sotabar month and freshness state
13import "nx_compare_growth_json.nx"
14import "nx_ladder_lib.nx" // THE ONE ladder ruler (2026-09-06) -- plan_pass renders the targets, the rung-role table and the NOT DECLARED notice
15import "nx_gauge_lib.nx" // THE ONE gauge-heartbeat ruler (codeeffectiveness CE9, 2026-09-06) -- gauge_pass below RENDERS a <dom>.gauge row with the SAME classifier the writing beat uses, so a stale gauge reads STALE and never zero
16 // it into api.json. Its closure adds NOTHING new to this lib: nx_lineconf_lib
17 // above already imports nx_estate_path, and nx_swcompare_matrix already
18 // imports both this base AND nx_evprofile_lib and compiles, so the two
19 // symbol sets are proven compatible rather than assumed so.
20func w(fd: i64, s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(fd, s, n); return 0 }
21func wc(fd: i64, code: i64) -> i64 { let t: *u8 = sys_mmap(2); t[0] = code as u8; sys_write(fd, t, 1); return 0 }
22func wn(fd: i64, v: i64) -> i64 {
23 var m: i64 = v; if m < 0 { w(fd, "-" as *u8); m = 0 - m }
24 let t: *u8 = sys_mmap(24); var k: i64 = 0; if m == 0 { t[0] = 48 as u8; k = 1 }
25 while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 }
26 let o: *u8 = sys_mmap(24); var i: i64 = 0; while i < k { o[i] = t[k-1-i]; i = i + 1 } sys_write(fd, o, k); return 0
27}
28func wj(fd: i64, s: *u8) -> i64 {
29 var i: i64 = 0
30 while s[i] != (0 as u8) { let c: i64 = s[i] as i64
31 if c == 34 { wc(fd, 92); wc(fd, 34) } else { if c == 92 { wc(fd, 92); wc(fd, 92) } else { if c < 32 { wc(fd, 32) } else { wc(fd, c) } } }
32 i = i + 1 }
33 return 0
34}
35func wq(fd: i64) -> i64 { wc(fd, 34); return 0 }
36func kv_s(fd: i64, key: *u8, val: *u8) -> i64 { wq(fd); w(fd, key); wq(fd); wc(fd, 58); wq(fd); wj(fd, val); wq(fd); return 0 }
37func kv_n(fd: i64, key: *u8, v: i64) -> i64 { wq(fd); w(fd, key); wq(fd); wc(fd, 58); wn(fd, v); return 0 }
38func c_read(path: *u8, buf: *u8, cap: i64) -> i64 {
39 let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 - 1 }
40 var tot: i64 = 0
41 while tot < cap { let r: i64 = sys_read(fd, (buf as i64 + tot) as *u8, cap - tot); if r <= 0 { break } tot = tot + r }
42 sys_close(fd); return tot
43}
44func streq(a: *u8, b: *u8) -> i64 { var i: i64 = 0; while a[i] != (0 as u8) { if a[i] != b[i] { return 0 } i = i + 1 } if b[i] != (0 as u8) { return 0 } return 1 }
45func starts(s: *u8, pfx: *u8) -> i64 { var i: i64 = 0; while pfx[i] != (0 as u8) { if s[i] != pfx[i] { return 0 } i = i + 1 } return 1 }
46func scopy(dst: *u8, doff: i64, src: *u8) -> i64 { var i: i64 = 0; while src[i] != (0 as u8) { dst[doff+i] = src[i]; i = i + 1 } return doff + i }
47func splitpipe(s: *u8, fld: *i64, maxf: i64) -> i64 {
48 var c: i64 = 1; fld[0] = s as i64; var i: i64 = 0
49 while s[i] != (0 as u8) { if s[i] == (124 as u8) { s[i] = 0 as u8; if c < maxf { fld[c] = (s as i64) + i + 1; c = c + 1 } } i = i + 1 }
50 return c
51}
52func wnote(fd: i64, s: *u8) -> i64 {
53 var i: i64 = 0
54 while s[i] != (0 as u8) {
55 var emitted: i64 = 0
56 if s[i] == (91 as u8) { if s[i+1] == (64 as u8) {
57 var kl: i64 = 0
58 while s[i+2+kl] != (0 as u8) { if s[i+2+kl] == (93 as u8) { break } kl = kl + 1 }
59 if s[i+2+kl] == (93 as u8) { if kl > 0 {
60 w(fd, "<a class='cite' href='" as *u8); wc(fd, 35); w(fd, "ref-" as *u8)
61 var q: i64 = 0
62 while q < kl { wc(fd, s[i+2+q] as i64); q = q + 1 }
63 w(fd, "'>[" as *u8)
64 q = 0
65 while q < kl { wc(fd, s[i+2+q] as i64); q = q + 1 }
66 w(fd, "]</a>" as *u8)
67 i = i + 2 + kl + 1
68 emitted = 1
69 } }
70 } }
71 // ESCAPE THE TAG DELIMITERS, AND DELIBERATELY NOT '&'. Note prose is PROSE, so a '<' in it must
72 // render as TEXT: emitted raw it injects a live element into the published page. MEASURED
73 // 2026-08-26 -- a browser note reading "an <img> is an INLINE_BLOCK" emitted a real empty <img>,
74 // which took that page to a11y-issues=1 and made its whole-page asset claim UNPROVABLE, because
75 // the verifier counted an img tag whose src it could never resolve. One funnel, so both
76 // generators and every domain are fixed at once.
77 // '&' IS LEFT ALONE ON PURPOSE: 48 notes across the fleet (corpus_complete=1) carry intentional
78 // entities such as —, and escaping it would publish those literally on all 48. That is the
79 // imprecision chosen here, named rather than left for the next reader to rediscover.
80 if emitted == 0 {
81 let c: i64 = s[i] as i64
82 if c == 60 { w(fd, "<" as *u8) } else { if c == 62 { w(fd, ">" as *u8) } else { wc(fd, c) } }
83 i = i + 1
84 }
85 }
86 return 0
87}
88// ---- RIVAL-CLAIM PROVENANCE (2026-09-05) ----------------------------------------------------------------
89// Every Yes, Best or Part code in a rival column is a CLAIM about someone else's product, and until this
90// pass those codes were feature-observation reads with nothing behind them: the refs gate proves every
91// declared reference is cited and every mark resolves, but nothing asked whether a row that grades a rival
92// cites anything at all. Measured while evaluating DanceXR against charsim: eleven rows of rival codes typed
93// from a vendor read, zero marks, indistinguishable on the page from a row backed by a pinned mirror.
94// ONE classifier here, read by both generators (the refs_pass precedent), so the split cannot drift:
95// RV_NONE every rival code is 0 -- the row claims nothing about a rival
96// RV_CITED at least one rival code is non-zero AND the note carries a reference mark ( [@key] )
97// RV_UNCITED at least one rival code is non-zero and the note carries no mark: an observation read
98// A mark proves a mirror exists and is pinned (the refs gate's job); it does not prove the mirror SUPPORTS
99// the code -- that residual is stated on the page, never hidden behind the badge.
100const RV_NONE: i64 = 0
101const RV_CITED: i64 = 1
102const RV_UNCITED: i64 = 2
103func rv_code(s: *u8) -> i64 {
104 var v: i64 = 0
105 var any: i64 = 0
106 var i: i64 = 0
107 while s[i] != (0 as u8) { let c: i64 = s[i] as i64; if c >= 48 { if c <= 57 { v = v * 10 + (c - 48); any = 1 } } i = i + 1 }
108 if any == 0 { return 0 }
109 return v
110}
111func rv_note_cited(note: *u8) -> i64 {
112 var i: i64 = 0
113 while note[i] != (0 as u8) { if note[i] == (91 as u8) { if note[i+1] == (64 as u8) { return 1 } } i = i + 1 }
114 return 0
115}
116func rv_class(note: *u8, rf: *i64, rr: i64, stride: i64, ncol: i64) -> i64 {
117 var claims: i64 = 0
118 var cj: i64 = 0
119 while cj < ncol { if rv_code(rf[rr*stride + 4 + cj] as *u8) != 0 { claims = claims + 1 } cj = cj + 1 }
120 if claims == 0 { return RV_NONE }
121 if rv_note_cited(note) == 1 { return RV_CITED }
122 return RV_UNCITED
123}
124// the SOTA dialect grades with letters: B = Best, Y = Yes, ~ = Part are positive claims about a rival; N and blank are not.
125// ONE claim rule per dialect, ONE note rule for both, so the two generators cannot split on what counts as a claim.
126func rv_grade_claims(g: *u8) -> i64 { if g[0] == (66 as u8) { return 1 } if g[0] == (89 as u8) { return 1 } if g[0] == (126 as u8) { return 1 } return 0 }
127func rv_class_grades(note: *u8, rf: *i64, rr: i64, stride: i64, first: i64, count: i64) -> i64 {
128 var claims: i64 = 0
129 var cj: i64 = 0
130 while cj < count { if rv_grade_claims(rf[rr*stride + first + cj] as *u8) == 1 { claims = claims + 1 } cj = cj + 1 }
131 if claims == 0 { return RV_NONE }
132 if rv_note_cited(note) == 1 { return RV_CITED }
133 return RV_UNCITED
134}
135func rv_name(c: i64) -> *u8 {
136 if c == RV_CITED { return "CITED" as *u8 }
137 if c == RV_UNCITED { return "UNCITED" as *u8 }
138 return "NONE" as *u8
139}
140
141func rp_base(p: *u8) -> *u8 {
142 var i: i64 = 0
143 var last: i64 = 0
144 while p[i] != (0 as u8) { if p[i] == (47 as u8) { last = i + 1 } i = i + 1 }
145 return ((p as i64) + last) as *u8
146}
147func rp_publish(mir: *u8, dom: *u8) -> i64 {
148 let src: *u8 = sys_mmap(700)
149 var so: i64 = scopy(src, 0, "../" as *u8)
150 so = scopy(src, so, mir); src[so] = 0 as u8
151 let ln: *i64 = sys_mmap(16) as *i64
152 let body: *u8 = sys_read_file(src, ln)
153 if (body as i64) == 0 { return 0 }
154 if ln[0] <= 0 { return 0 }
155 let dir: *u8 = sys_mmap(700)
156 var dd: i64 = scopy(dir, 0, "../sites/nishifamily/compare/" as *u8)
157 dd = scopy(dir, dd, dom); dd = scopy(dir, dd, "/refs" as *u8); dir[dd] = 0 as u8
158 sys_mkdir(dir, MODE_0755)
159 let fin: *u8 = sys_mmap(700)
160 var fo: i64 = scopy(fin, 0, dir); fo = scopy(fin, fo, "/" as *u8); fo = scopy(fin, fo, rp_base(mir)); fin[fo] = 0 as u8
161 let tmp: *u8 = sys_mmap(700)
162 var to2: i64 = scopy(tmp, 0, fin); to2 = scopy(tmp, to2, ".tmp" as *u8); tmp[to2] = 0 as u8
163 let fd: i64 = sys_openat_wr(tmp, MODE_0644)
164 if fd < 0 { sys_free_file(body, ln[0]); return 0 }
165 let wrote: i64 = sys_write(fd, body, ln[0])
166 sys_close(fd)
167 sys_free_file(body, ln[0])
168 if wrote != ln[0] { return 0 }
169 if sys_renameat(tmp, fin) < 0 { return 0 }
170 return 1
171}
172
173// ---- THE REDISTRIBUTION GATE, ADDED 2026-08-25 ----
174// rp_publish above copies a stored third-party mirror into the PUBLIC docroot, and rp_html then links
175// it as "read in our library". THAT IS REDISTRIBUTION OF SOMEONE ELSE'S WORK, and until today nothing
176// on that path asked whether the licence permits it -- on 80 of the 84 domains carrying a .refs file.
177// The .refs `class` field is a SOURCE-TYPE vocabulary (published-paper, vendor-doc, dataset...), never
178// a rights vocabulary, so it could not have answered the question even in principle.
179//
180// RIGHTS ARE DATA (knowledge/refs_redistribute.conf), never code: clearing a class costs a row edit
181// AFTER someone reads a licence, not a rebuild. The encoding matches nx_licgate_lib and nx_acquire_lib
182// (0 NO / 1 REVIEW / 2 YES) so the three rulers cannot disagree about direction.
183const RP_NO: i64 = 0
184const RP_REVIEW: i64 = 1
185const RP_YES: i64 = 2
186const RP_KEYCAP: i64 = 128
187
188// AN ABSENT ROW IS A REFUSAL, NOT A PERMISSION. lcf_int_of returns LCF_MISS (negative) for a missing
189// key, so a class nobody has adjudicated -- including a brand-new vocabulary word arriving in a future
190// .refs file -- can never show up as an accidental YES. Silence is never permission.
191func rp_may_republish(cls: *u8) -> i64 {
192 let key: *u8 = sys_mmap(RP_KEYCAP)
193 var k: i64 = scopy(key, 0, "class_" as *u8)
194 k = scopy(key, k, cls); key[k] = 0 as u8
195 let v: i64 = lcf_int_of("knowledge/refs_redistribute.conf" as *u8, key)
196 if v < 0 { return RP_NO }
197 if v > RP_YES { return RP_NO }
198 return v
199}
200
201// THE GATE IN FRONT OF THE COPIER.
202// arm=0 (today) is MEASURE-ONLY: behaviour is byte-identical to before, so no published page changes
203// and no link disappears. That is the ONLY way to land this without silently stripping a link from 80
204// domains in a single regen. arm=1 ENFORCES, and flipping it is an OPERATOR decision about a public
205// surface -- the conf says so in its own words.
206// A missing or non-numeric arm row reads LCF_MISS (negative), which is not 1, so a corrupted conf
207// fails toward TODAY'S behaviour rather than toward an unannounced fleet-wide link removal. That is
208// deliberately the opposite default from rp_may_republish: an unreadable POLICY must not silently
209// change a public surface, while an unadjudicated CLASS must never grant a right.
210func rp_publish_gated(mir: *u8, dom: *u8, cls: *u8) -> i64 {
211 let arm: i64 = lcf_int_of("knowledge/refs_redistribute.conf" as *u8, "arm" as *u8)
212 if arm == 1 {
213 if rp_may_republish(cls) != RP_YES { return 0 }
214 }
215 return rp_publish(mir, dom)
216}
217
218func rp_json(fld: *i64, count: i64) -> i64 {
219 if count == 0 { wc(1, 44); wq(1); w(1, "refs" as *u8); wq(1); wc(1, 58); wc(1, 91) } else { wc(1, 44) }
220 wc(1, 123)
221 kv_s(1, "key" as *u8, fld[1] as *u8); wc(1, 44)
222 kv_s(1, "cite" as *u8, fld[2] as *u8); wc(1, 44)
223 kv_s(1, "url" as *u8, fld[3] as *u8); wc(1, 44)
224 kv_s(1, "mirror" as *u8, fld[4] as *u8); wc(1, 44)
225 kv_s(1, "pin" as *u8, fld[5] as *u8); wc(1, 44)
226 kv_s(1, "accessed" as *u8, fld[6] as *u8); wc(1, 44)
227 kv_s(1, "class" as *u8, fld[7] as *u8); wc(1, 44)
228 kv_s(1, "grounds" as *u8, fld[8] as *u8)
229 wc(1, 125)
230 return 0
231}
232// ---- rp_html LIFTED INTO THE BASE 2026-08-23 (lane L). It was a byte-identical copy in BOTH generators
233// while refs_pass here called it as a dangling callback, so nothing else could import this lib (a gate
234// composing watch_pass failed to link on rp_html). One copy now; the only per-generator difference --
235// the section header prose -- travels as the hdr argument. ----
236func rp_html(fld: *i64, count: i64, dom: *u8, hdr: *u8) -> i64 {
237 if count == 0 { w(1, hdr) }
238 w(1, "<li id='ref-" as *u8); w(1, fld[1] as *u8); w(1, "'><span class='rkey'>[" as *u8); w(1, fld[1] as *u8); w(1, "]</span> " as *u8)
239 w(1, fld[2] as *u8)
240 w(1, " <span class='rlinks'><a href='" as *u8); w(1, fld[3] as *u8); w(1, "'>publisher</a>" as *u8)
241 if streq(fld[4] as *u8, "-" as *u8) == 0 {
242 if rp_publish_gated(fld[4] as *u8, dom, fld[7] as *u8) == 1 {
243 w(1, " · <a href='/compare/" as *u8); w(1, dom); w(1, "/refs/" as *u8); w(1, rp_base(fld[4] as *u8)); w(1, "'><b>read in our library</b></a> <code>" as *u8); w(1, fld[4] as *u8); w(1, "</code>" as *u8)
244 } else {
245 w(1, " · mirror <code>" as *u8); w(1, fld[4] as *u8); w(1, "</code>" as *u8)
246 }
247 }
248 if streq(fld[5] as *u8, "-" as *u8) == 0 { w(1, " · pin <code>" as *u8); w(1, fld[5] as *u8); w(1, "</code>" as *u8) }
249 if streq(fld[6] as *u8, "-" as *u8) == 0 { w(1, " · accessed " as *u8); w(1, fld[6] as *u8) }
250 w(1, " · <span class='rgrade'>" as *u8); w(1, fld[7] as *u8); w(1, "</span></span>" as *u8)
251 w(1, "<span class='rg'>Grounds: " as *u8); w(1, fld[8] as *u8); w(1, "</span></li>\n" as *u8)
252 return 0
253}
254func refs_pass(path: *u8, bufz: *u8, capz: i64, mode: i64, dom: *u8, hdr: *u8) -> i64 {
255 // SAME CAP, SAME REMOVAL (2026-08-28, debt 1787937117): the HTML refs render was called with the
256 // 20479-byte plan buffer while the api.json render got a larger one, so on any board whose .refs
257 // exceeds 20479 the page and the JSON disagreed about how many references exist -- 7 of them
258 // measured, aesthetictwin worst at 37446. Size from the file, never from the caller.
259 var fsz: i64 = 0
260 let szfd: i64 = sys_openat_rd(path)
261 if szfd < 0 { return 0 }
262 fsz = sys_lseek(szfd, 0, 2)
263 sys_close(szfd)
264 if fsz <= 0 { return 0 }
265 let buf: *u8 = sys_mmap(fsz + 1)
266 let n: i64 = c_read(path, buf, fsz)
267 if n <= 0 { return 0 }
268 buf[n] = 0 as u8
269 let fld: *i64 = sys_mmap(200) as *i64
270 var count: i64 = 0
271 var p: i64 = 0
272 while p < n {
273 var e: i64 = p
274 while e < n { if buf[e] == (10 as u8) { break } e = e + 1 }
275 buf[e] = 0 as u8
276 let line: *u8 = (buf as i64 + p) as *u8
277 p = e + 1
278 var skip: i64 = 0
279 if line[0] == (0 as u8) { skip = 1 }
280 if line[0] == (35 as u8) { skip = 1 }
281 if skip == 0 {
282 let nf: i64 = splitpipe(line, fld, 12)
283 if streq(fld[0] as *u8, "ref" as *u8) == 1 { if nf >= 9 {
284 if mode == 1 { rp_html(fld, count, dom, hdr) }
285 if mode == 2 { rp_json(fld, count) }
286 count = count + 1
287 } }
288 }
289 }
290 if count > 0 { if mode == 1 { w(1, "</ol>\n" as *u8) } else { if mode == 2 { wc(1, 93) } } }
291 return count
292}
293
294// ---- PLAN RENDERING, LIFTED INTO THE BASE 2026-08-22 (rung DG5) ------------------------------------
295// WHY THIS MOVED. plan_pass lived INSIDE nx_swcompare_matrix, so a domain whose page is emitted by the
296// SOTA generator had its .plan admitted as data and then NEVER RENDERED. Proven with full coverage
297// (matches=0, files=11, corpus_complete=1): the tool plane's own computed build order was invisible on
298// its own page, which is why nx_compare_rank looked like it had nothing to say there.
299// This follows the refs_pass precedent exactly -- ONE renderer in the base, BOTH generators call it --
300// so the two surfaces cannot drift into two different plan dialects. A second copy in the sota generator
301// would have been the duplicate-ruler defect, and it would have drifted on the first row kind either
302// generator added.
303// dstate and wlow come WITH it, not after it: NishiLang resolves identifiers in TEXTUAL ORDER, so a lib
304// function cannot call a helper defined later in the importing program. A partial lift does not compile.
305const SWL_DSTATE_CAP: i64 = 20480 // .debtstate sidecar read buffer. The NUL slot is DERIVED (CAP - 1)
306 // rather than a second hand-counted constant beside it: two numbers
307 // describing one buffer drift silently and the parser then reads the
308 // wrong window while still compiling.
309
310// Print what the DEBT PLANE says about an id: open, eaten, or not filed in this scope at all. The state
311// file is `id<TAB>state` per line, refreshed by the regen before any page is emitted.
312func dstate(fd: i64, id: *u8, ds: *u8, dn: i64) -> i64 {
313 if dn <= 0 { return 0 }
314 var i: i64 = 0
315 while i < dn {
316 var e: i64 = i
317 while e < dn { if ds[e] == (10 as u8) { break } e = e + 1 }
318 var k: i64 = 0
319 var ok: i64 = 1
320 var stop: i64 = 0
321 while stop == 0 {
322 if i + k >= e { stop = 1 } else {
323 let c: i64 = ds[i+k] as i64
324 if c == 9 { stop = 1 } else {
325 let ic: i64 = id[k] as i64
326 if ic == 0 { ok = 0; stop = 1 } else { if ic != c { ok = 0; stop = 1 } else { k = k + 1 } }
327 }
328 }
329 }
330 if ok == 1 { if (id[k] as i64) == 0 {
331 var s: i64 = i + k
332 if s < e { if ds[s] == (9 as u8) { s = s + 1 } }
333 w(fd, "<span class='pstate'>" as *u8)
334 var q: i64 = s
335 while q < e { wc(fd, ds[q] as i64); q = q + 1 }
336 w(fd, "</span>" as *u8)
337 return 1
338 } }
339 i = e + 1
340 }
341 // NOT "not filed". The lookup is scoped to THIS domain, so a debt filed under another scope is
342 // absent here while being perfectly real in the plane. Saying "not filed" publishes a false negative
343 // about a colleague's open work.
344 w(fd, "<span class='pstate note'>not in this scope</span>" as *u8)
345 return 0
346}
347// lowercase into a search-key attribute; single AND double quotes neutralised so they cannot close it.
348// wlow writes a lowercase SEARCH TOKEN into a single-quoted data- attribute. It already neutralised
349// both quote characters, which is why the gallery's data-t survived the caption apostrophe that
350// destroyed its sibling alt on the same tag -- HALF A LAW, APPLIED IN ONE ATTRIBUTE AND NOT THE OTHER.
351// It still passed the three markup-significant bytes through raw, so the same hole stood open for any
352// caption carrying an ampersand or an angle bracket. It now hands its result to the ONE attribute
353// escaper rather than carrying a second, weaker copy of that decision (2026-08-26).
354// The bare character codes are gone with it: they are the IA_ identities now.
355func wlow(fd: i64, s: *u8) -> i64 {
356 let n: i64 = ia_slen(s)
357 let low: *u8 = sys_mmap(n + 1)
358 var i: i64 = 0
359 while i < n {
360 var c: i64 = s[i] as i64
361 if c >= IA_UPPER_A { if c <= IA_UPPER_Z { c = c + IA_CASE_DELTA } }
362 if c == IA_SQ { c = IA_SP }
363 if c == IA_DQ { c = IA_SP }
364 low[i] = c as u8
365 i = i + 1
366 }
367 low[n] = 0 as u8
368 let need: i64 = n * IA_MAX_EXPANSION + IA_SEP_AND_NUL
369 let b: *u8 = sys_mmap(need)
370 let tr: *i64 = sys_mmap(IA_SLOT_BYTES) as *i64
371 ia_esc_attr(b, 0, low, need, tr)
372 w(fd, b)
373 return 0
374}
375// ---- LADDER TO SOTA helpers (2026-09-06), defined BEFORE plan_pass because NishiLang resolves in textual order ----
376// Both take SPANS precomputed before the walk: plan_pass's walk NUL-terminates lines and splitpipe zeroes pipes in place,
377// so a field re-parsed at render time on an already-walked line would read one truncated field. The bytes of the fields
378// themselves are untouched, so a span captured first is still readable when its consumer row arrives later in the file.
379// the month and freshness state of the sotabar row whose id is `id`, printed after the target's "dated by <id>"
380func swl_bar_state(fd: i64, buf: *u8, bidoff: *i64, bidlen: *i64, bym: *i64, bst: *i64, nb: i64, id: *u8) -> i64 {
381 var i: i64 = 0
382 while i < nb {
383 if ld_span_is(buf, bidoff[i], bidlen[i], id) == 1 {
384 w(fd, " = " as *u8)
385 if bym[i] == BF_NONE { w(fd, "MALFORMED MONTH" as *u8) } else {
386 let ymb: *u8 = sys_mmap(12)
387 bf_ym_write(ymb, 0, bym[i])
388 w(fd, ymb)
389 }
390 w(fd, " " as *u8); w(fd, bf_state_name(bst[i]))
391 return 1
392 }
393 i = i + 1
394 }
395 w(fd, " = NO SUCH SOTABAR ROW, UNDATED" as *u8)
396 return 0
397}
398// the deps field of the rung row whose id is `id` (what the rung stands on), or a dash
399func swl_rung_deps(fd: i64, buf: *u8, ridoff: *i64, ridlen: *i64, rdoff: *i64, rdlen: *i64, nr: i64, id: *u8) -> i64 {
400 var i: i64 = 0
401 while i < nr {
402 if ld_span_is(buf, ridoff[i], ridlen[i], id) == 1 {
403 if rdlen[i] > 0 { sys_write(fd, (buf as i64 + rdoff[i]) as *u8, rdlen[i]) } else { w(fd, "-" as *u8) }
404 return 1
405 }
406 i = i + 1
407 }
408 w(fd, "-" as *u8)
409 return 0
410}
411// A release date comes from a complete positive decimal epoch, never filtered digits.
412const SWL_RELEASE_I64_MAX: i64 = 9223372036854775807
413func swl_release_epoch(s: *u8) -> i64 {
414 if (s as i64) == 0 { return 0 }
415 if s[0] == (0 as u8) { return 0 }
416 var v: i64 = 0
417 var i: i64 = 0
418 while s[i] != (0 as u8) {
419 let c: i64 = s[i] as i64
420 if c < 48 { return 0 }
421 if c > 57 { return 0 }
422 let d: i64 = c - 48
423 if v > (SWL_RELEASE_I64_MAX - d) / 10 { return 0 }
424 v = v * 10 + d
425 i = i + 1
426 }
427 return v
428}
429// Equal timestamps preserve append-order corrections; older rows cannot replace newer ones.
430func swl_release_candidate(epoch: *u8, kind: *u8, entry: *u8, current: i64, now: i64) -> i64 {
431 if (kind as i64) == 0 { return 0 }
432 if (entry as i64) == 0 { return 0 }
433 if entry[0] == (0 as u8) { return 0 }
434 if streq(kind, "land" as *u8) != 1 { return 0 }
435 let candidate: i64 = swl_release_epoch(epoch)
436 if candidate <= 0 { return 0 }
437 if candidate < current { return 0 }
438 if candidate > now { return 0 }
439 return candidate
440}
441
442// Explicit heading ownership: old render APIs delegate level 2; grouped consumers select level 3.
443// attrs is a caller-owned static HTML attribute literal, never source data.
444func sc_heading_level(level: i64) -> i64 { if level<1 { return 2 }; if level>6 { return 2 }; return level }
445func sc_heading_open(fd: i64, level: i64, attrs: *u8) -> i64 {
446 w(fd, "<h" as *u8); wn(fd, sc_heading_level(level)); w(fd, attrs); w(fd, ">" as *u8); return 0
447}
448func sc_heading_close(fd: i64, level: i64) -> i64 {
449 w(fd, "</h" as *u8); wn(fd, sc_heading_level(level)); w(fd, ">" as *u8); return 0
450}
451
452// Shared plan tables retain their semantics inside a named keyboard-scroll region.
453func sc_plan_table_open(fd: i64, label: *u8) -> i64 {
454 w(fd, "<div class='table-scroll plan-table-scroll' role='region' tabindex='0' aria-label='" as *u8); w(fd, label); w(fd, "'><table class='pl'>" as *u8); return 0
455}
456func sc_plan_table_close(fd: i64) -> i64 { w(fd, "</tbody></table></div>" as *u8); return 0 }
457
458func plan_pass(path: *u8, bufz: *u8, capz: i64, phase: i64) -> i64 { return plan_pass_heading(path, bufz, capz, phase, 2) }
459// Only rendered rows change the active table; ignored metadata cannot split a table.
460func sc_plan_row_table(phase: i64, kind: *u8, fields: i64) -> i64 {
461 if phase == 1 {
462 if streq(kind, "biz" as *u8) == 1 { if fields >= 5 { return 3 } }
463 if streq(kind, "ladder" as *u8) == 1 { if fields >= 6 { return 4 } }
464 if streq(kind, "pos" as *u8) == 1 { if fields >= 2 { return 0 } }
465 if streq(kind, "goal" as *u8) == 1 { if fields >= 2 { return 0 } }
466 if streq(kind, "answer" as *u8) == 1 { if fields >= 4 { return 0 } }
467 if streq(kind, "bar" as *u8) == 1 { if fields >= 6 { return 0 } }
468 if streq(kind, "unit" as *u8) == 1 { if fields >= 2 { return 0 } }
469 }
470 if phase == 2 {
471 if streq(kind, "rung" as *u8) == 1 { if fields >= 8 { return 1 } }
472 if streq(kind, "ms" as *u8) == 1 { if fields >= 5 { return 2 } }
473 if streq(kind, "rungrole" as *u8) == 1 { if fields >= 5 { return 6 } }
474 if streq(kind, "sotatarget" as *u8) == 1 { if fields >= 6 { return 0 } }
475 }
476 if phase == 3 {
477 if streq(kind, "debt" as *u8) == 1 { if fields >= 5 { return 1 } }
478 if streq(kind, "risk" as *u8) == 1 { if fields >= 4 { return 2 } }
479 if streq(kind, "log" as *u8) == 1 { if fields >= 5 { return 5 } }
480 }
481 return 0 - 1
482}
483
484func plan_pass_heading(path: *u8, bufz: *u8, capz: i64, phase: i64, heading_level: i64) -> i64 {
485 // THE 20479-BYTE CAP IS REMOVED, NOT RAISED (2026-08-28, debt 1787937117). The caller handed us a
486 // guessed buffer whose cap silently short-read every .plan over 20479 bytes -- 8 of 93 measured,
487 // browser worst at 63614 -- publishing a PREFIX whose lost rows are always the NEWEST, announced
488 // nowhere. A ceiling that has to be guessed is a defect generator in both directions, and for a FILE
489 // read there is no guess to make: size the buffer from the file itself (lseek END), like sys_read_file.
490 // bufz/capz are kept only so every existing call site still compiles; they are deliberately unused.
491 var fsz: i64 = 0
492 let szfd: i64 = sys_openat_rd(path)
493 if szfd < 0 { return 0 }
494 fsz = sys_lseek(szfd, 0, 2)
495 sys_close(szfd)
496 if fsz <= 0 { return 0 }
497 let buf: *u8 = sys_mmap(fsz + 1)
498 let n: i64 = c_read(path, buf, fsz)
499 if n <= 0 { return 0 }
500 buf[n] = 0 as u8
501 let fld: *i64 = sys_mmap(200) as *i64
502 // the plane's view of each debt id, refreshed by the regen before this page was emitted.
503 // Derived from the plan path so the two files cannot drift apart by name.
504 let dsbuf: *u8 = sys_mmap(SWL_DSTATE_CAP)
505 var dsn: i64 = 0
506 if phase == 3 {
507 let dsp: *u8 = sys_mmap(600)
508 var dq: i64 = 0
509 while path[dq] != (0 as u8) { dsp[dq] = path[dq]; dq = dq + 1 }
510 var cut: i64 = dq
511 while cut > 0 { if dsp[cut] == (46 as u8) { break } cut = cut - 1 }
512 if cut > 0 { dq = cut }
513 dq = scopy(dsp, dq, ".debtstate" as *u8)
514 dsp[dq] = 0 as u8
515 dsn = c_read(dsp, dsbuf, SWL_DSTATE_CAP - 1)
516 if dsn < 0 { dsn = 0 }
517 }
518 var active_table: i64 = 0
519 var log_heading_seen: i64 = 0
520 var in_rung: i64 = 0
521 var in_ms: i64 = 0
522 var in_biz: i64 = 0
523 var in_lad: i64 = 0
524 var in_log: i64 = 0
525 var release_epoch: i64 = 0
526 let release_now: i64 = sys_now_realtime_sec()
527 var release_entry: *u8 = 0 as *u8
528 var release_rung: *u8 = 0 as *u8
529 // LADDER TO SOTA (2026-09-06): classify the sotabar/barscan and sotatarget/rungrole rows ONCE, before the walk below
530 // NUL-terminates lines and zeroes pipes in place, and bank the spans the render helpers read (see swl_bar_state).
531 let bfnb: i64 = bf_count_rows(buf, n, BF_BAR_TAG)
532 let bfoff: *i64 = sys_mmap((bfnb + 1) * 8) as *i64
533 let bfym: *i64 = sys_mmap((bfnb + 1) * 8) as *i64
534 let bfst: *i64 = sys_mmap((bfnb + 1) * 8) as *i64
535 let bfseen: *i64 = sys_mmap((bfnb + 1) * 8) as *i64
536 let bfc: *i64 = sys_mmap(BF_C_N * 8) as *i64
537 let bfcur: i64 = bf_now_ym()
538 bf_classify(buf, n, bfcur, bfoff, bfym, bfst, bfseen, bfc)
539 let bidoff: *i64 = sys_mmap((bfnb + 1) * 8) as *i64
540 let bidlen: *i64 = sys_mmap((bfnb + 1) * 8) as *i64
541 let sfo: *i64 = sys_mmap(8) as *i64
542 var sbi: i64 = 0
543 while sbi < bfnb { let sbe: i64 = bf_line_end(buf, n, bfoff[sbi]); bidlen[sbi] = bf_field(buf, bfoff[sbi], sbe, BF_F_BAR_ID, sfo); bidoff[sbi] = sfo[0]; sbi = sbi + 1 }
544 let ldnt: i64 = bf_count_rows(buf, n, LD_TARGET_TAG)
545 let ldnr: i64 = bf_count_rows(buf, n, LD_RUNG_TAG)
546 let ldc: *i64 = sys_mmap(LD_N_COUNT * 8) as *i64
547 let ldtoff: *i64 = sys_mmap((ldnt + 1) * 8) as *i64
548 let ldtcls: *i64 = sys_mmap((ldnt + 1) * 8) as *i64
549 let ldtst: *i64 = sys_mmap((ldnt + 1) * 8) as *i64
550 let ldroff: *i64 = sys_mmap((ldnr + 1) * 8) as *i64
551 let ldrrole: *i64 = sys_mmap((ldnr + 1) * 8) as *i64
552 let ldrtgt: *i64 = sys_mmap((ldnr + 1) * 8) as *i64
553 let ldrst: *i64 = sys_mmap((ldnr + 1) * 8) as *i64
554 ld_classify(buf, n, ldtoff, ldtcls, ldtst, ldroff, ldrrole, ldrtgt, ldrst, ldc)
555 let ldv: i64 = ld_verdict(ldc)
556 let ridoff: *i64 = sys_mmap((ldnr + 1) * 8) as *i64
557 let ridlen: *i64 = sys_mmap((ldnr + 1) * 8) as *i64
558 let rdoff: *i64 = sys_mmap((ldnr + 1) * 8) as *i64
559 let rdlen: *i64 = sys_mmap((ldnr + 1) * 8) as *i64
560 var sri: i64 = 0
561 while sri < ldnr { let sre: i64 = bf_line_end(buf, n, ldroff[sri]); ridlen[sri] = bf_field(buf, ldroff[sri], sre, LD_F_R_ID, sfo); ridoff[sri] = sfo[0]; rdlen[sri] = bf_field(buf, ldroff[sri], sre, LD_F_R_DEPS, sfo); rdoff[sri] = sfo[0]; sri = sri + 1 }
562 var in_tgt: i64 = 0
563 var in_role: i64 = 0
564 if phase == 1 { w(1, "<div class='exec-grid'>\n" as *u8) }
565 var p: i64 = 0
566 while p < n {
567 var e: i64 = p
568 while e < n { if buf[e] == (10 as u8) { break } e = e + 1 }
569 buf[e] = 0 as u8
570 let line: *u8 = (buf as i64 + p) as *u8
571 p = e + 1
572 var skip: i64 = 0
573 if line[0] == (0 as u8) { skip = 1 }
574 if line[0] == (35 as u8) { skip = 1 }
575 if skip == 0 {
576 let nf: i64 = splitpipe(line, fld, 20)
577 let kind: *u8 = fld[0] as *u8
578 let next_table: i64 = sc_plan_row_table(phase, kind, nf)
579 if next_table >= 0 { if next_table != active_table {
580 if active_table != 0 { sc_plan_table_close(1); w(1, "\n" as *u8) }
581 in_rung = 0; in_ms = 0; in_biz = 0; in_lad = 0; in_log = 0; in_role = 0
582 active_table = next_table
583 } }
584 if phase == 1 {
585 if streq(kind, "log" as *u8) == 1 { if nf == 5 {
586 let candidate: i64 = swl_release_candidate(fld[1] as *u8, fld[3] as *u8, fld[4] as *u8, release_epoch, release_now)
587 if candidate > 0 {
588 release_epoch = candidate
589 release_rung = fld[2] as *u8
590 release_entry = fld[4] as *u8
591 }
592 } }
593 if streq(kind, "pos" as *u8) == 1 { if nf >= 2 { w(1, "<p class='lead'><b>Where we are.</b> " as *u8); wnote(1, fld[1] as *u8); w(1, "</p>\n" as *u8) } }
594 if streq(kind, "goal" as *u8) == 1 { if nf >= 2 { w(1, "<p class='lead'><b>Where we need to go.</b> " as *u8); wnote(1, fld[1] as *u8); w(1, "</p>\n" as *u8) } }
595 if streq(kind, "answer" as *u8) == 1 { if nf >= 4 {
596 w(1, "<div class='answer'><b>" as *u8); w(1, fld[1] as *u8); w(1, ": " as *u8); w(1, fld[2] as *u8); w(1, ".</b> " as *u8); wnote(1, fld[3] as *u8); w(1, "</div>\n" as *u8) } }
597 if streq(kind, "bar" as *u8) == 1 { if nf >= 6 {
598 w(1, "<p class='lead'><b>Research bar.</b> <a href='" as *u8); w(1, fld[2] as *u8); w(1, "'>" as *u8); w(1, fld[1] as *u8); w(1, "</a> is measured on " as *u8); w(1, fld[3] as *u8)
599 w(1, ". Theirs: <b>" as *u8); wnote(1, fld[4] as *u8); w(1, "</b>. Ours: " as *u8); wnote(1, fld[5] as *u8); w(1, ".</p>\n" as *u8) } }
600 if streq(kind, "unit" as *u8) == 1 { if nf >= 2 { w(1, "<div class='meth'><b>The unit.</b> " as *u8); w(1, fld[1] as *u8); w(1, "</div>\n" as *u8) } }
601 // biz|axis|position|figures|decision -- the BUSINESS CASE row kind (investment, opportunity
602 // cost, market, competitive position, go-to-market, buy-vs-build). Rendered as one table in
603 // the executive layer; biz rows belong LAST in a plan's phase-1 block so the table closes clean.
604 if streq(kind, "biz" as *u8) == 1 { if nf >= 5 {
605 if in_biz == 0 { sc_heading_open(1, heading_level, "" as *u8); w(1, "Business case" as *u8); sc_heading_close(1, heading_level); w(1, "\n" as *u8); sc_plan_table_open(1, "Business case" as *u8); w(1, "<thead><tr><th>Axis</th><th>Position</th><th>Figures</th><th>Decision</th></tr></thead><tbody>\n" as *u8); in_biz = 1 }
606 w(1, "<tr><td><b>" as *u8); w(1, fld[1] as *u8); w(1, "</b></td><td>" as *u8); wnote(1, fld[2] as *u8)
607 w(1, "</td><td class='ct'>" as *u8); wnote(1, fld[3] as *u8); w(1, "</td><td>" as *u8); wnote(1, fld[4] as *u8); w(1, "</td></tr>\n" as *u8) } }
608 // ladder|level|best_in_class|have|grow|verdict -- the MARKET-ENTRY LADDER row kind (2026-08-24): per level
609 // (hobbyist to research leader) what best-in-class looks like from the mirrored record, what the estate measures
610 // today, what must grow, and the ENTER or HOLD or GROW-FIRST verdict. Rendered as one table after the business
611 // case; ladder rows belong LAST in a plan's phase-1 block. The verdict is DATA here; ml_entry_verdict computes it.
612 if streq(kind, "ladder" as *u8) == 1 { if nf >= 6 {
613 if in_lad == 0 { sc_heading_open(1, heading_level, "" as *u8); w(1, "Market-entry ladder" as *u8); sc_heading_close(1, heading_level); w(1, "\n" as *u8); sc_plan_table_open(1, "Market-entry ladder" as *u8); w(1, "<thead><tr><th>Level</th><th>Best in class (Aug 2026)</th><th>What we have</th><th>What must grow</th><th>Verdict</th></tr></thead><tbody>\n" as *u8); in_lad = 1 }
614 w(1, "<tr><td><b>" as *u8); w(1, fld[1] as *u8); w(1, "</b></td><td>" as *u8); wnote(1, fld[2] as *u8)
615 w(1, "</td><td>" as *u8); wnote(1, fld[3] as *u8); w(1, "</td><td>" as *u8); wnote(1, fld[4] as *u8)
616 w(1, "</td><td class='ct'>" as *u8); wnote(1, fld[5] as *u8)
617 // the COMPUTED verdict beside the authored one (nx_market_ladder_lib, the one ruler the CLI uses)
618 if nf >= 7 { ml_render_computed_html(1, path, fld[6] as *u8) }
619 w(1, "</td></tr>\n" as *u8) } }
620 }
621 if phase == 3 {
622 if streq(kind, "debt" as *u8) == 1 { if nf >= 5 {
623 if in_rung == 0 { sc_heading_open(1, heading_level, "" as *u8); w(1, "Debt register" as *u8); sc_heading_close(1, heading_level); w(1, "\n" as *u8); sc_plan_table_open(1, "Debt register" as *u8); w(1, "<thead><tr><th>Id</th><th class='r'>Sev</th><th>What it is</th><th>Unblock</th></tr></thead><tbody>\n" as *u8); in_rung = 1 }
624 w(1, "<tr><td class='ct'>" as *u8); w(1, fld[1] as *u8)
625 // STATE COMES FROM THE PLANE, NEVER FROM THIS ROW. An id the plane does not know is a
626 // page-local note wearing the shape of a filed debt, and saying so is the honest move.
627 dstate(1, fld[1] as *u8, dsbuf, dsn)
628 w(1, "</td><td class='r'>" as *u8); w(1, fld[2] as *u8)
629 w(1, "</td><td>" as *u8); wnote(1, fld[3] as *u8); w(1, "</td><td>" as *u8); wnote(1, fld[4] as *u8); w(1, "</td></tr>\n" as *u8) } }
630 if streq(kind, "risk" as *u8) == 1 { if nf >= 4 {
631 if in_ms == 0 { sc_heading_open(1, heading_level, "" as *u8); w(1, "Risk register" as *u8); sc_heading_close(1, heading_level); w(1, "\n" as *u8); sc_plan_table_open(1, "Risk register" as *u8); w(1, "<thead><tr><th>Risk</th><th>Likelihood x impact</th><th>Mitigation</th></tr></thead><tbody>\n" as *u8); in_ms = 1 }
632 w(1, "<tr><td>" as *u8); wnote(1, fld[1] as *u8); w(1, "</td><td class='ct'>" as *u8); w(1, fld[2] as *u8)
633 w(1, "</td><td>" as *u8); wnote(1, fld[3] as *u8); w(1, "</td></tr>\n" as *u8) } }
634 // log|<epoch>|<rung>|<kind>|<text> -- THE WORKED PLAN ON THE BOARD (operator 2026-09-02: a crash must
635 // leave a ledger here, not a transcript to mine). Every leg appends what it measured, landed,
636 // retracted, learned and left queued, per rung; rendered newest-last, each row linking to its rung.
637 if streq(kind, "log" as *u8) == 1 { if nf >= 5 {
638 if in_log == 0 { if log_heading_seen == 0 { sc_heading_open(1, heading_level, " id='worklog'" as *u8); w(1, "Release history and work log" as *u8); sc_heading_close(1, heading_level); w(1, "\n<div class='meth'><b>The worked plan, on the board.</b> Every leg appends what it measured, landed, retracted, learned and left queued, per rung, so a crash leaves the next seat a ledger here rather than a transcript to mine. Kinds: measure, land, retract, lesson, queue. Newest last.</div>\n" as *u8); log_heading_seen = 1 } else { sc_heading_open(1, heading_level, "" as *u8); w(1, "Release history continued" as *u8); sc_heading_close(1, heading_level); w(1, "\n" as *u8) } sc_plan_table_open(1, "Release history and work log" as *u8); w(1, "<thead><tr><th>When</th><th>Rung</th><th>Kind</th><th>Entry</th></tr></thead><tbody>\n" as *u8); in_log = 1 }
639 let lep: *u8 = fld[1] as *u8
640 var lv: i64 = 0
641 var li: i64 = 0
642 while lep[li] != (0 as u8) { let lc: i64 = lep[li] as i64; if lc >= 48 { if lc <= 57 { lv = lv*10 + (lc-48) } } li = li + 1 }
643 let ldb: *u8 = sys_mmap(32)
644 let ldn: i64 = bd_ymd(lv, ldb, 0)
645 ldb[ldn] = 0 as u8
646 w(1, "<tr><td class='ct'>" as *u8); w(1, ldb); w(1, "</td><td class='ct'><a href='#" as *u8); wlow(1, fld[2] as *u8); w(1, "'>" as *u8); w(1, fld[2] as *u8)
647 w(1, "</a></td><td class='ct'>" as *u8); w(1, fld[3] as *u8); w(1, "</td><td>" as *u8); wnote(1, fld[4] as *u8); w(1, "</td></tr>\n" as *u8) } }
648 }
649 if phase == 2 {
650 if streq(kind, "rung" as *u8) == 1 { if nf >= 8 {
651 if in_rung == 0 { sc_plan_table_open(1, "Capability roadmap" as *u8); w(1, "<thead><tr><th>Rung</th><th>Closes with</th><th>Definition of done (pre-declared)</th><th>Executor</th><th class='r'>Est.</th></tr></thead><tbody>\n" as *u8); in_rung = 1 }
652 w(1, "<tr id='" as *u8); wlow(1, fld[1] as *u8); w(1, "'><td><b>" as *u8); w(1, fld[2] as *u8); w(1, "</b> (" as *u8); w(1, fld[1] as *u8); w(1, ")" as *u8)
653 if streq(fld[7] as *u8, "-" as *u8) == 0 { w(1, "<br><span class='ct'>after " as *u8); w(1, fld[7] as *u8); w(1, "</span>" as *u8) }
654 w(1, "</td><td class='ct'>" as *u8); w(1, fld[3] as *u8); w(1, "</td><td>" as *u8); wnote(1, fld[4] as *u8)
655 w(1, "</td><td><span class='ex'>" as *u8); w(1, fld[5] as *u8); w(1, "</span></td><td class='r'>" as *u8); w(1, fld[6] as *u8); w(1, " u</td></tr>\n" as *u8) } }
656 // LADDER TO SOTA (2026-09-06): the dated targets, judged by the bar-age ruler, then the rung-role table.
657 // sotatarget and rungrole rows belong AFTER the rung and ms rows in a plan so the ladder renders beneath them.
658 if streq(kind, "sotatarget" as *u8) == 1 { if nf >= 6 {
659 if in_tgt == 0 { sc_heading_open(1, heading_level, " id='ladder'" as *u8); w(1, "Ladder to SOTA" as *u8); sc_heading_close(1, heading_level); w(1, "\n<div class='meth'><b>Two dated targets, and every rung's role toward them.</b> Best in class is the proven, deployed leader today; the frontier is the research edge as of its month. Each target is dated by a sotabar row and judged against the current month by the bar-age ruler (FRESH, ATTESTED with the fallback month named, or refused). Each rung is substrate (what the target's own methods consume), an arm (a sovereign arm that triangulates without competing for the number), a contender (its done-rule is a number against the target) or superseded (kept as capability, retired as a claim), and carries the rungs it stands on.</div>\n" as *u8); in_tgt = 1 }
660 w(1, "<div class='answer'><b>" as *u8); w(1, fld[2] as *u8); w(1, " (" as *u8); w(1, fld[1] as *u8); w(1, "), dated by " as *u8); w(1, fld[3] as *u8)
661 swl_bar_state(1, buf, bidoff, bidlen, bfym, bfst, bfnb, fld[3] as *u8)
662 w(1, ".</b> " as *u8); wnote(1, fld[4] as *u8)
663 w(1, " <span class='ct'>ref " as *u8); w(1, fld[5] as *u8); w(1, "</span></div>\n" as *u8) } }
664 if streq(kind, "rungrole" as *u8) == 1 { if nf >= 5 {
665 if in_tgt == 0 { sc_heading_open(1, heading_level, " id='ladder'" as *u8); w(1, "Ladder to SOTA" as *u8); sc_heading_close(1, heading_level); w(1, "\n" as *u8); in_tgt = 1 }
666 if in_role == 0 { sc_plan_table_open(1, "Rung roles and prerequisites" as *u8); w(1, "<thead><tr><th>Rung</th><th>Role</th><th>Toward</th><th>Stands on</th><th>Why</th></tr></thead><tbody>\n" as *u8); in_role = 1 }
667 w(1, "<tr><td class='ct'><a href='#" as *u8); wlow(1, fld[1] as *u8); w(1, "'>" as *u8); w(1, fld[1] as *u8); w(1, "</a></td><td class='ct'>" as *u8); w(1, fld[2] as *u8); w(1, "</td><td class='ct'>" as *u8); w(1, fld[3] as *u8); w(1, "</td><td class='ct'>" as *u8)
668 swl_rung_deps(1, buf, ridoff, ridlen, rdoff, rdlen, ldnr, fld[1] as *u8)
669 w(1, "</td><td>" as *u8); wnote(1, fld[4] as *u8); w(1, "</td></tr>\n" as *u8) } }
670 if streq(kind, "ms" as *u8) == 1 { if nf >= 5 {
671 if in_ms == 0 { sc_heading_open(1, heading_level, "" as *u8); w(1, "Milestones" as *u8); sc_heading_close(1, heading_level); w(1, "\n" as *u8); sc_plan_table_open(1, "Milestones" as *u8); w(1, "<thead><tr><th>Milestone</th><th>Rungs</th><th class='r'>Cumulative</th></tr></thead><tbody>\n" as *u8); in_ms = 1 }
672 w(1, "<tr><td><b>" as *u8); w(1, fld[1] as *u8); w(1, "</b> · " as *u8); w(1, fld[2] as *u8); w(1, "</td><td class='ct'>" as *u8); w(1, fld[4] as *u8)
673 w(1, "</td><td class='r'>" as *u8); w(1, fld[3] as *u8); w(1, " u</td></tr>\n" as *u8) } }
674 }
675 }
676 }
677 if active_table != 0 { sc_plan_table_close(1); w(1, "\n" as *u8) }
678 if phase == 1 {
679 w(1, "<section class='meth' id='release-summary'>" as *u8); sc_heading_open(1, heading_level, "" as *u8); w(1, "Latest recorded release" as *u8); sc_heading_close(1, heading_level)
680 if release_epoch > 0 {
681 let date: *u8 = sys_mmap(32)
682 let date_len: i64 = bd_ymd(release_epoch, date, 0)
683 date[date_len] = 0 as u8
684 w(1, "<p><b>" as *u8); w(1, date); w(1, "</b> · " as *u8)
685 wnote(1, release_rung); w(1, "</p><p>" as *u8); wnote(1, release_entry)
686 w(1, "</p><p><a href='#worklog'>Release history and work log</a></p>" as *u8)
687 } else {
688 w(1, "<p>No valid dated release entry is recorded for this domain.</p>" as *u8)
689 }
690 w(1, "<p>Release entries describe recorded changes; they do not establish that every capability passed evaluation.</p></section>\n</div>\n" as *u8)
691 }
692 if phase == 2 {
693 // THE TWO VERDICTS, FROM THE RULERS, ON EVERY PAGE WITH A PLAN (2026-09-06). A board that has not declared its
694 // ladder is TOLD so on its own page: an undeclared target is exactly how a seat climbed toward a 2014 bar for a day.
695 w(1, "<div class='meth' id='ladderverdict'><b>Ladder verdict.</b> " as *u8)
696 if ldv == LD_EXIT_NOLADDER {
697 w(1, "<b>NOT DECLARED.</b> This board names no dated best-in-class or frontier target and no rung roles (sotatarget and rungrole rows on its plan); the ranker labels it NO-LADDER until it does, and until then its rungs climb toward a target nobody has written down." as *u8)
698 } else {
699 w(1, "targets " as *u8); wn(1, ldc[LD_N_TARGETS]); w(1, " (best in class " as *u8); wn(1, ldc[LD_N_BIC]); w(1, ", frontier " as *u8); wn(1, ldc[LD_N_FRONTIER]); w(1, ", undated " as *u8); wn(1, ldc[LD_N_UNDATED])
700 w(1, "); rungs " as *u8); wn(1, ldc[LD_N_RUNGS]); w(1, ", placed " as *u8); wn(1, ldc[LD_N_PLACED]); w(1, " (substrate " as *u8); wn(1, ldc[LD_N_SUBSTRATE]); w(1, ", arm " as *u8); wn(1, ldc[LD_N_ARM]); w(1, ", contender " as *u8); wn(1, ldc[LD_N_CONTENDER]); w(1, ", superseded " as *u8); wn(1, ldc[LD_N_SUPERSEDED]); w(1, "), unplaced " as *u8); wn(1, ldc[LD_N_UNPLACED]); w(1, "; verdict <b>" as *u8); w(1, ld_verdict_name(ldv)); w(1, "</b>" as *u8)
701 if ldv == LD_EXIT_PARTIAL { w(1, " -- half-declared: the ranker refuses this board until every target is dated and every rung has a role" as *u8) }
702 }
703 w(1, " Bars: " as *u8); wn(1, bfc[BF_C_BARS]); w(1, " (fresh " as *u8); wn(1, bfc[BF_C_FRESH]); w(1, ", attested " as *u8); wn(1, bfc[BF_C_ATTESTED]); w(1, ", stale " as *u8); wn(1, bfc[BF_C_STALE]); w(1, ", unattested " as *u8); wn(1, bfc[BF_C_UNATTESTED]); w(1, "), verdict <b>" as *u8); w(1, bf_verdict_name(bf_verdict(bfc))); w(1, "</b> against the current month " as *u8)
704 let cymb: *u8 = sys_mmap(12)
705 bf_ym_write(cymb, 0, bfcur)
706 w(1, cymb); w(1, ".</div>\n" as *u8)
707 }
708 return 1
709}
710// ---- WATCH CONTRACTS, MEASURED, FOR EVERY PAGE KIND (2026-08-23, lane L) ----
711// A sota-class page renders <dom>.sota (hand-graded cells) while the ranker reads <dom>.matrix, so a
712// sota domain that also carries a .matrix NEVER FLIPPED on the page when a watch symbol landed
713// (measured on /compare/lang: LN2 landed, the regen republished the page at an IDENTICAL byte size).
714// watch_pass renders the .matrix's symbol rows with their status MEASURED by the one ruler
715// (nx_symdecl_lib sd_declared) -- the same function the matrix generator, the ranker and the regen's
716// comparewatch plane use -- so the page, the plane and the ranker cannot disagree by construction.
717// Writes to fd (a gate captures it through a file), mode 1 = HTML section, mode 2 = JSON array value.
718// An absent .matrix writes NOTHING and returns 0 (a byte-identical emit for every domain without one).
719// Returns the number of symbol rows rendered; the partition it prints must sum to that number.
720const WP_ST_LANDED: i64 = 1
721const WP_ST_WATCHING: i64 = 2
722const WP_ST_PRESENT: i64 = 3
723const WP_ST_MISSING: i64 = 4
724const WP_ST_ABSENT: i64 = 5
725func wp_status_text(st: i64) -> *u8 {
726 if st == WP_ST_LANDED { return "LANDED" as *u8 }
727 if st == WP_ST_WATCHING { return "WATCHING" as *u8 }
728 if st == WP_ST_PRESENT { return "PRESENT" as *u8 }
729 if st == WP_ST_MISSING { return "MISSING" as *u8 }
730 return "ABSENT" as *u8
731}
732func wp_status_class(st: i64) -> *u8 {
733 if st == WP_ST_LANDED { return "me" as *u8 }
734 if st == WP_ST_PRESENT { return "me" as *u8 }
735 if st == WP_ST_WATCHING { return "pa" as *u8 }
736 return "ab" as *u8
737}
738// classify ONE matrix row: organ + symbol field -> status. Measured, never read from the spelling.
739func wp_classify(organ: *u8, sym: *u8, rule_out: *i64) -> i64 {
740 rule_out[0] = 0
741 if streq(sym, "_ABSENT_" as *u8) == 1 { return WP_ST_ABSENT }
742 if starts(sym, "_ABSENT_:" as *u8) == 1 {
743 if sd_present(organ, (sym as i64 + 9) as *u8, rule_out) == 1 { return WP_ST_LANDED }
744 return WP_ST_WATCHING
745 }
746 if sd_present(organ, sym, rule_out) == 1 { return WP_ST_PRESENT }
747 return WP_ST_MISSING
748}
749func watch_pass(mpath: *u8, fd: i64, mode: i64) -> i64 {
750 let ln: *i64 = sys_mmap(16) as *i64
751 let b: *u8 = sys_read_file(mpath, ln)
752 if (b as i64) == 0 { return 0 }
753 let n: i64 = ln[0]
754 if n <= 0 { if mode == 2 { wc(fd, 91); wc(fd, 93) } return 0 }
755 // field capacity derived from the widest row (pipes + 1), never a fixed count
756 var maxf: i64 = 2
757 var pc: i64 = 0
758 var i: i64 = 0
759 while i < n { if b[i] == (124 as u8) { pc = pc + 1 } if b[i] == (10 as u8) { if pc + 1 > maxf { maxf = pc + 1 } pc = 0 } i = i + 1 }
760 if pc + 1 > maxf { maxf = pc + 1 }
761 let fld: *i64 = sys_mmap((maxf + 1) * 8) as *i64
762 let rl: *i64 = sys_mmap(16) as *i64
763 var rows: i64 = 0
764 var c_landed: i64 = 0
765 var c_watching: i64 = 0
766 var c_present: i64 = 0
767 var c_missing: i64 = 0
768 var c_absent: i64 = 0
769 var opened: i64 = 0
770 var p: i64 = 0
771 while p < n {
772 var e: i64 = p
773 while e < n { if b[e] == (10 as u8) { break } e = e + 1 }
774 b[e] = 0 as u8
775 let line: *u8 = (b as i64 + p) as *u8
776 p = e + 1
777 var skip: i64 = 0
778 if line[0] == (0 as u8) { skip = 1 }
779 if line[0] == (35 as u8) { skip = 1 }
780 if line[0] == (64 as u8) { skip = 1 }
781 if skip == 0 {
782 let nf: i64 = splitpipe(line, fld, maxf)
783 if nf >= 4 {
784 let label: *u8 = fld[0] as *u8
785 let organ: *u8 = fld[1] as *u8
786 let sym: *u8 = fld[2] as *u8
787 let note: *u8 = fld[nf - 1] as *u8
788 if sym[0] != (0 as u8) {
789 let st: i64 = wp_classify(organ, sym, rl)
790 if st == WP_ST_LANDED { c_landed = c_landed + 1 }
791 if st == WP_ST_WATCHING { c_watching = c_watching + 1 }
792 if st == WP_ST_PRESENT { c_present = c_present + 1 }
793 if st == WP_ST_MISSING { c_missing = c_missing + 1 }
794 if st == WP_ST_ABSENT { c_absent = c_absent + 1 }
795 var symtext: *u8 = sym
796 if starts(sym, "_ABSENT_:" as *u8) == 1 { symtext = (sym as i64 + 9) as *u8 }
797 if mode == 1 {
798 if opened == 0 {
799 w(fd, "<h2 class='ghead' id='watch'>Watch contracts (measured)</h2>\n<div class='meth'><b>Not a claim, a measurement.</b> Each row names an organ and a symbol; the status is re-measured on every publish by the one ruler the ranker and the hive plane use, and the rule it applied is printed beside it: <b>decl</b> a top-level declaration in a NishiLang organ (a comment or a call site does not count), <b>jsdecl</b> a JS declaration form, <b>exists</b> the organ itself (the symbol is its name), <b>marker</b> a literal the organ carries, <b>data</b> a token in a data file. LANDED / PRESENT = measured present, WATCHING = the named contract is still open, MISSING = the row names something its organ does not carry, ABSENT = no contract named.</div>\n" as *u8); sc_plan_table_open(fd, "Watch contracts" as *u8); w(fd, "<thead><tr><th>Axis</th><th>Organ</th><th>Symbol</th><th>Status</th><th>Note</th></tr></thead><tbody>\n" as *u8)
800 opened = 1
801 }
802 w(fd, "<tr><td><b>" as *u8); w(fd, label); w(fd, "</b></td><td class='ct'>" as *u8); w(fd, organ)
803 w(fd, "</td><td class='ct'>" as *u8); w(fd, symtext); w(fd, "</td><td><span class='st " as *u8); w(fd, wp_status_class(st)); w(fd, "'>" as *u8); w(fd, wp_status_text(st))
804 w(fd, "</span>" as *u8)
805 if rl[0] > 0 { w(fd, " <span class='ct'>" as *u8); w(fd, sd_rule_name(rl[0])); w(fd, "</span>" as *u8) }
806 w(fd, "</td><td>" as *u8); wnote(fd, note); w(fd, "</td></tr>\n" as *u8)
807 }
808 if mode == 2 {
809 if opened == 0 { wc(fd, 91); opened = 1 } else { wc(fd, 44) }
810 wc(fd, 123)
811 kv_s(fd, "label" as *u8, label); wc(fd, 44)
812 kv_s(fd, "organ" as *u8, organ); wc(fd, 44)
813 kv_s(fd, "symbol" as *u8, symtext); wc(fd, 44)
814 kv_s(fd, "status" as *u8, wp_status_text(st)); wc(fd, 44)
815 kv_s(fd, "rule" as *u8, sd_rule_name(rl[0])); wc(fd, 44)
816 kv_s(fd, "note" as *u8, note)
817 wc(fd, 125)
818 }
819 rows = rows + 1
820 }
821 }
822 }
823 }
824 if mode == 1 { if opened == 1 {
825 sc_plan_table_close(fd); w(fd, "\n<p class='foot'>watch rows=" as *u8); wn(fd, rows)
826 w(fd, " landed=" as *u8); wn(fd, c_landed); w(fd, " watching=" as *u8); wn(fd, c_watching)
827 w(fd, " present=" as *u8); wn(fd, c_present); w(fd, " missing=" as *u8); wn(fd, c_missing)
828 w(fd, " absent=" as *u8); wn(fd, c_absent); w(fd, " (partition sums)</p>\n" as *u8)
829 } }
830 if mode == 2 { if opened == 1 { wc(fd, 93) } else { wc(fd, 91); wc(fd, 93) } }
831 sys_free_file(b, n)
832 return rows
833}
834
835// ---- PERSON / PRODUCT / PLACE, MEASURED (operator 2026-08-24: "all our compares should have [UI analysis]
836// and august 2026 researched sota ... to tell us how to build a better site than our competitors ... person
837// via privacy and superior cx, product ... design and longevity and features, place ... ease of navigation
838// and ability to accomplish the desired task"). ONE renderer in the base, both generators call it -- the
839// refs_pass / watch_pass precedent. Reads knowledge/compare/<dom>.pppstate, the artefact nx_ppp_probe writes
840// after running ONE ruler on OUR live surface AND on every rival's live front door named in <dom>.ppp:
841// ppp|<col>|<label>|<url>|<json> last line = "# asof=... surfaces=N probed=K ruler=nx_ppp_probe"
842// The page prints per-axis permil AND the raw counts beside it, so the derivation can be argued with, and the
843// direction of the gap per rival is computed HERE from the numbers -- never typed by a seat. A domain with no
844// .pppstate prints a NAMED absence (the worklist: every compare carries this layer; a page not yet measured
845// says so in its own words). Self-contained scoped <style> so it renders in BOTH generators regardless of
846// their page CSS; colours reference the page theme vars with rgb() fallbacks. -1 = unobserved (scores zero
847// for that rule, never acquitted).
848const PL_MAXROWS: i64 = 32
849// first integer value of "<key>": at or after `from`; -999 = key absent (distinct from a real -1 unobserved)
850func pl_jint(buf: *u8, n: i64, from: i64, key: *u8) -> i64 {
851 var klen: i64 = 0
852 while key[klen] != (0 as u8) { klen = klen + 1 }
853 var i: i64 = from
854 var at: i64 = 0 - 1
855 while i + klen <= n {
856 var k: i64 = 0
857 var m: i64 = 1
858 while k < klen { if buf[i + k] != key[k] { m = 0; k = klen } else { k = k + 1 } }
859 if m == 1 { at = i; i = n } else { i = i + 1 }
860 }
861 if at < 0 { return 0 - 999 }
862 var j: i64 = at + klen
863 var neg: i64 = 0
864 if j < n { if buf[j] == (45 as u8) { neg = 1; j = j + 1 } }
865 var v: i64 = 0
866 var got: i64 = 0
867 while j < n {
868 let c: i64 = buf[j] as i64
869 if c >= 48 { if c <= 57 { v = v * 10 + (c - 48); got = 1; j = j + 1 } else { j = n } } else { j = n }
870 }
871 if got == 0 { return 0 - 999 }
872 if neg == 1 { return 0 - v }
873 return v
874}
875// offset of the literal `name` inside buf, or 0 (name is chosen to be unique in the row json)
876func pl_off(buf: *u8, n: i64, name: *u8) -> i64 {
877 var nl: i64 = 0
878 while name[nl] != (0 as u8) { nl = nl + 1 }
879 var i: i64 = 0
880 while i + nl <= n {
881 var k: i64 = 0
882 var m: i64 = 1
883 while k < nl { if buf[i + k] != name[k] { m = 0; k = nl } else { k = k + 1 } }
884 if m == 1 { return i }
885 i = i + 1
886 }
887 return 0
888}
889func pl_cell(fd: i64, v: i64) -> i64 {
890 if v == 0 - 999 { w(fd, "<td class='ct'>-</td>" as *u8); return 0 }
891 if v < 0 { w(fd, "<td class='ct'>unobs</td>" as *u8); return 0 }
892 w(fd, "<td class='r'>" as *u8); wn(fd, v); w(fd, "</td>" as *u8)
893 return 0
894}
895func ppp_pass(dom: *u8, fd: i64, mode: i64) -> i64 { return ppp_pass_heading(dom, fd, mode, 2) }
896func ppp_pass_heading(dom: *u8, fd: i64, mode: i64, heading_level: i64) -> i64 {
897 let sp: *u8 = sys_mmap(600)
898 var o: i64 = scopy(sp, 0, "knowledge/compare/" as *u8)
899 o = scopy(sp, o, dom); o = scopy(sp, o, ".pppstate" as *u8); sp[o] = 0 as u8
900 let ln: *i64 = sys_mmap(16) as *i64
901 let b: *u8 = sys_read_file(sp, ln)
902 if (b as i64) == 0 {
903 if mode == 2 { w(fd, "{\"measured\":false}" as *u8); return 0 }
904 sc_heading_open(fd, heading_level, " class='ghead' id='ppp'" as *u8); w(fd, "Person · product · place — not yet measured for this domain" as *u8); sc_heading_close(fd, heading_level); w(fd, "\n<div class='meth'><b>Every compare carries this layer.</b> Declare <code>knowledge/compare/" as *u8); w(fd, dom)
905 w(fd, ".ppp</code> (rows <code>surface|nishi or c1..c4|label|url|connect</code> naming OUR live surface and each rival's front door), run <code>nx_ppp_probe domain " as *u8); w(fd, dom)
906 w(fd, "</code>, and this section fills itself on the next beat: the same ruler on both sides — privacy and CX (third-party hosts, tracker classes, cookies, security headers), design and longevity (design hygiene, computed WCAG contrast, render-blocking resources, unsized media, script weight, theme and motion queries), findability (landmarks, skip link, on-site search, breadcrumb, headings, internal links).</div>\n" as *u8)
907 return 0
908 }
909 let n: i64 = ln[0]
910 if n <= 0 { sys_free_file(b, n); if mode == 2 { w(fd, "{\"measured\":false}" as *u8) } return 0 }
911 // the stamp is the LAST non-empty line; capture it BEFORE the parser NUL-splits anything
912 var ls: i64 = n
913 if ls > 0 { if b[ls - 1] == (10 as u8) { ls = ls - 1 } }
914 while ls > 0 { if b[ls - 1] == (10 as u8) { break } ls = ls - 1 }
915 let stamp: i64 = (b as i64) + ls
916 var se: i64 = ls
917 while se < n { if b[se] == (10 as u8) { break } se = se + 1 }
918 b[se] = 0 as u8
919 // collect data-row offsets (lines beginning 'p' = 'ppp|')
920 let roff: *i64 = sys_mmap(PL_MAXROWS * 8) as *i64
921 let rlen: *i64 = sys_mmap(PL_MAXROWS * 8) as *i64
922 var rows: i64 = 0
923 var p: i64 = 0
924 while p < ls {
925 var e: i64 = p
926 while e < ls { if b[e] == (10 as u8) { break } e = e + 1 }
927 if b[p] == (112 as u8) { if rows < PL_MAXROWS { roff[rows] = p; rlen[rows] = e - p; rows = rows + 1 } }
928 p = e + 1
929 }
930 let fld: *i64 = sys_mmap(8 * 8) as *i64
931 if mode == 2 {
932 w(fd, "{\"stamp\":\"" as *u8); wj(fd, stamp as *u8); w(fd, "\",\"surfaces\":[" as *u8)
933 var rj: i64 = 0
934 var emitted: i64 = 0
935 while rj < rows {
936 b[roff[rj] + rlen[rj]] = 0 as u8
937 let line: *u8 = (b as i64 + roff[rj]) as *u8
938 let nf: i64 = splitpipe(line, fld, 5)
939 if nf >= 5 {
940 if emitted > 0 { wc(fd, 44) }
941 w(fd, fld[4] as *u8)
942 emitted = emitted + 1
943 }
944 rj = rj + 1
945 }
946 w(fd, "]}" as *u8)
947 sys_free_file(b, n)
948 return rows
949 }
950 // ---- mode 1: HTML ----
951 w(fd, "<style>.pppsec{overflow-x:auto;margin:6px 0 2px}.pppt{border-collapse:collapse;width:100%;font-size:12.5px;min-width:760px}.pppt th{text-align:left;padding:8px 9px 8px 0;border-bottom:1px solid var(--fg,rgb(26,26,28));color:var(--mut,rgb(120,126,134));font-size:10px;letter-spacing:.06em;text-transform:uppercase;white-space:nowrap}.pppt td{border-bottom:1px solid var(--line,rgb(219,216,208));padding:9px 9px 9px 0;vertical-align:top;line-height:1.4}.pppt td.r{text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap}.pppt td.ct{font-family:var(--mono,ui-monospace,Consolas,monospace);font-size:11px;color:var(--mut,rgb(120,126,134))}.pppt tr.ours td{background:var(--tint,rgba(120,90,220,.06))}.pppt tr.ours td.ni b{color:var(--ac,rgb(88,64,180))}.pppt a{color:var(--ac,rgb(88,64,180));text-decoration:none}</style>\n" as *u8)
952 sc_heading_open(fd, heading_level, " class='ghead' id='ppp'" as *u8); w(fd, "Person · product · place — the same ruler on our live surface and on theirs" as *u8); sc_heading_close(fd, heading_level); w(fd, "\n" as *u8)
953 w(fd, "<div class='meth'><b>Measured on both sides, from the bytes a first visitor receives.</b> <code>nx_ppp_probe</code> fetched every surface below over the sovereign TLS stack and scored three axes by declared rules, each a count against a published Aug-2026 bar. <b>Person</b> (privacy + CX): third-party asset/script hosts, the tracker classes The Markup's Blacklight tests for, consent-banner markers, <code>Set-Cookie</code> on the first consent-less response (the CNIL bar), the OWASP secure headers. <b>Product</b> (design + longevity): design-system hygiene (/12), computed WCAG 2.2 contrast over the page's real colour tokens, the static Core-Web-Vitals predictors (render-blocking css/js, unsized media — the source-visible causes of poor LCP/CLS), script count, dark-mode and reduced-motion queries, canonical URL. <b>Place</b> (findability + task): nav/main/footer landmarks, a skip link, on-site search, breadcrumb, exactly one h1, internal links, lang, viewport, title. Envelope: static HTML plus response headers, no render, no script execution — a client-rendered app is graded on what a no-JS first visitor receives, which is the progressive-enhancement bar itself. <b>unobs</b> = the probe could not see that sub-measure and scored it zero rather than acquit. Stamp: <code>" as *u8)
954 w(fd, stamp as *u8); w(fd, "</code></div>\n" as *u8)
955 w(fd, "<div class='pppsec'><table class='pppt'><thead><tr><th>Surface</th><th class='r'>Person</th><th class='r'>Product</th><th class='r'>Place</th><th class='r'>3p script hosts</th><th class='r'>trackers</th><th class='r'>set-cookie</th><th class='r'>sec hdr /5</th><th class='r'>design /12</th><th class='r'>contrast fails</th><th class='r'>blocking css+js</th><th class='r'>unsized img</th><th class='r'>scripts</th><th class='r'>KB</th><th>nav main skip search crumb</th></tr></thead><tbody>\n" as *u8)
956 var ours_pe: i64 = 0 - 1
957 var ours_pr: i64 = 0 - 1
958 var ours_pl: i64 = 0 - 1
959 var best_pe: i64 = 0 - 1
960 var best_pr: i64 = 0 - 1
961 var best_pl: i64 = 0 - 1
962 var rr: i64 = 0
963 while rr < rows {
964 b[roff[rr] + rlen[rr]] = 0 as u8
965 let line: *u8 = (b as i64 + roff[rr]) as *u8
966 let nf: i64 = splitpipe(line, fld, 5)
967 if nf >= 5 {
968 let col: *u8 = fld[1] as *u8
969 let label: *u8 = fld[2] as *u8
970 let url: *u8 = fld[3] as *u8
971 let js: *u8 = fld[4] as *u8
972 var jn: i64 = 0
973 while js[jn] != (0 as u8) { jn = jn + 1 }
974 var ours: i64 = 0
975 if streq(col, "nishi" as *u8) == 1 { ours = 1 }
976 if ours == 1 { w(fd, "<tr class='ours'><td class='ni'><b>" as *u8) } else { w(fd, "<tr><td><b>" as *u8) }
977 w(fd, label); w(fd, "</b><br><a href='" as *u8); w(fd, url); w(fd, "' rel='nofollow'><span class='ct'>" as *u8); w(fd, url); w(fd, "</span></a></td>" as *u8)
978 let unreach: i64 = pl_jint(js, jn, 0, "\"unreachable\":" as *u8)
979 if unreach != 0 - 999 {
980 w(fd, "<td colspan='13'>UNREACHABLE (probe code " as *u8); wn(fd, unreach); w(fd, ") — no measurement, no score; re-run the probe rather than infer a number</td></tr>\n" as *u8)
981 } else {
982 let sp_pe: i64 = pl_off(js, jn, "\"person\":{" as *u8)
983 let sp_pr: i64 = pl_off(js, jn, "\"product\":{" as *u8)
984 let sp_pl: i64 = pl_off(js, jn, "\"place\":{" as *u8)
985 let pe: i64 = pl_jint(js, jn, sp_pe, "\"score_permil\":" as *u8)
986 let pr: i64 = pl_jint(js, jn, sp_pr, "\"score_permil\":" as *u8)
987 let pl: i64 = pl_jint(js, jn, sp_pl, "\"score_permil\":" as *u8)
988 if ours == 1 {
989 if pe > ours_pe { ours_pe = pe }
990 if pr > ours_pr { ours_pr = pr }
991 if pl > ours_pl { ours_pl = pl }
992 } else {
993 if pe > best_pe { best_pe = pe }
994 if pr > best_pr { best_pr = pr }
995 if pl > best_pl { best_pl = pl }
996 }
997 pl_cell(fd, pe); pl_cell(fd, pr); pl_cell(fd, pl)
998 pl_cell(fd, pl_jint(js, jn, sp_pe, "\"third_party_script_hosts\":" as *u8))
999 pl_cell(fd, pl_jint(js, jn, sp_pe, "\"tracker_hits\":" as *u8))
1000 pl_cell(fd, pl_jint(js, jn, sp_pe, "\"set_cookie\":" as *u8))
1001 pl_cell(fd, pl_jint(js, jn, sp_pe, "\"sec_headers\":" as *u8))
1002 pl_cell(fd, pl_jint(js, jn, sp_pr, "\"design_hygiene\":" as *u8))
1003 pl_cell(fd, pl_jint(js, jn, sp_pr, "\"contrast_fails\":" as *u8))
1004 let bc: i64 = pl_jint(js, jn, sp_pr, "\"blocking_css\":" as *u8)
1005 let bj: i64 = pl_jint(js, jn, sp_pr, "\"blocking_js\":" as *u8)
1006 if bc < 0 { pl_cell(fd, bc) } else { if bj < 0 { pl_cell(fd, bj) } else { pl_cell(fd, bc + bj) } }
1007 pl_cell(fd, pl_jint(js, jn, sp_pr, "\"unsized_media\":" as *u8))
1008 pl_cell(fd, pl_jint(js, jn, sp_pr, "\"script_tags\":" as *u8))
1009 let bytes: i64 = pl_jint(js, jn, 0, "\"bytes\":" as *u8)
1010 if bytes > 0 { w(fd, "<td class='r'>" as *u8); wn(fd, bytes / 1024); w(fd, "</td>" as *u8) } else { w(fd, "<td class='ct'>-</td>" as *u8) }
1011 w(fd, "<td class='r ct'>" as *u8)
1012 wn(fd, pl_jint(js, jn, sp_pl, "\"nav\":" as *u8)); wc(fd, 32); wn(fd, pl_jint(js, jn, sp_pl, "\"main\":" as *u8)); wc(fd, 32)
1013 wn(fd, pl_jint(js, jn, sp_pl, "\"skip_link\":" as *u8)); wc(fd, 32); wn(fd, pl_jint(js, jn, sp_pl, "\"site_search\":" as *u8)); wc(fd, 32)
1014 wn(fd, pl_jint(js, jn, sp_pl, "\"breadcrumb\":" as *u8)); w(fd, "</td></tr>\n" as *u8)
1015 }
1016 }
1017 rr = rr + 1
1018 }
1019 w(fd, "</tbody></table></div>\n" as *u8)
1020 // the direction of the gap, computed from the numbers above
1021 w(fd, "<div class='meth'><b>Where to beat them, from the numbers.</b> " as *u8)
1022 if ours_pe >= 0 { if best_pe >= 0 {
1023 w(fd, "PERSON ours " as *u8); wn(fd, ours_pe); w(fd, " vs best rival " as *u8); wn(fd, best_pe)
1024 if ours_pe > best_pe { w(fd, " — we lead; hold it (zero third-party hosts, zero trackers, headers 5/5 is the ceiling). " as *u8) } else { w(fd, " — behind: the higher-scoring rival shows which privacy rule we lose. " as *u8) }
1025 } }
1026 if ours_pr >= 0 { if best_pr >= 0 {
1027 w(fd, "PRODUCT ours " as *u8); wn(fd, ours_pr); w(fd, " vs best rival " as *u8); wn(fd, best_pr)
1028 if ours_pr > best_pr { w(fd, " — we lead on measurable hygiene; the perceptual premium is a judged rung, not this ruler. " as *u8) } else { w(fd, " — behind: design/12, contrast, blocking, unsized and scripts name the rule. " as *u8) }
1029 } }
1030 if ours_pl >= 0 { if best_pl >= 0 {
1031 w(fd, "PLACE ours " as *u8); wn(fd, ours_pl); w(fd, " vs best rival " as *u8); wn(fd, best_pl)
1032 if ours_pl > best_pl { w(fd, " — we lead on the findability floor; task completion by a real user is the next ruler. " as *u8) } else { w(fd, " — behind: nav main skip search crumb, in that order. " as *u8) }
1033 } }
1034 w(fd, "Re-measured by the beat; nothing here is typed by a seat.</div>\n" as *u8)
1035 sys_free_file(b, n)
1036 return rows
1037}
1038
1039// ============================================================================
1040// SC THEME PASS (2026-08-25) -- ONE palette, emitted from the estate's TOKEN SSOT
1041// (nx_brand_tokens), for BOTH domain generators. It is lifted HERE for the same
1042// reason plan_pass, dstate and wlow were lifted here: this module is the base class
1043// the two generators already share, so a palette that lives here CANNOT drift
1044// between them. Two hand-landed dark blocks in two files is the duplicate-ruler
1045// defect wearing a stylesheet.
1046//
1047// WHY IT EXISTS. Measured 2026-08-25 against the LIVE pages, not inherited:
1048// /compare/search scored theme-aware 0/2 and prefers-color-scheme occurred ZERO
1049// times in 79,499 bytes of matrix source. The dark PALETTE was already authored and
1050// already shipping as html[data-theme='dark'] -- it was simply unreachable from the
1051// operating system's own preference. ***A THEME THAT EXISTS BUT CANNOT BE REACHED
1052// WITHOUT HUNTING FOR A CHIP IS A CAPABILITY THE PAGE IS PAYING FOR AND NOT
1053// DELIVERING.*** Nothing here invents a palette, so no contrast pair moved: the dark
1054// values below are byte-identical to the literal they replace, which makes the dark
1055// rendering unchanged BY CONSTRUCTION rather than by inspection.
1056//
1057// ***THE DARK VALUES ARE DECLARED ONCE AND EMITTED TWICE.*** The same parsed rows go
1058// out under html[data-theme='dark'] (the chip) AND under the media query (the OS
1059// preference). Keeping two copies in step is exactly how a chip theme and an auto
1060// theme drift apart; here a drift is not merely unlikely, it is UNREPRESENTABLE --
1061// there is only one copy of the data, and it is re-SELECTED, never re-PARSED, so the
1062// SSOT keeps its 3-pipe field rule, its bt_ident_safe/bt_value_safe injection screens
1063// and its silent-skip semantics. A second brand parser here would be a second ruler.
1064//
1065// ***THE MEDIA BLOCK IS GUARDED :root:not([data-theme]) AND THAT GUARD IS LOAD-BEARING.***
1066// This page ships a three-way switcher (paper/ink/dark) whose sett() calls
1067// setAttribute('data-theme', n) for ALL THREE values -- paper INCLUDED -- and a boot
1068// script restores the stored choice before first paint. But PAPER IS THE BARE :root
1069// DEFAULT: there is no html[data-theme='paper'] rule to out-rank anything. So an
1070// UNGUARDED @media(prefers-color-scheme:dark){:root{...}} would carry EQUAL
1071// specificity to that default and sit LATER in the cascade, and would therefore
1072// repaint a user who had just explicitly chosen Paper on an OS-dark machine. Every
1073// explicit choice sets the attribute, so :not([data-theme]) makes all three chips win
1074// over the OS preference with ONE selector, while a visitor who has chosen nothing
1075// still gets their system preference. ***A DARK BLOCK ADDED WITHOUT FIRST ASKING
1076// WHETHER THE PAGE ALREADY HAS A THEME SWITCHER SILENTLY OVERRIDES AN EXPLICIT USER
1077// CHOICE -- AND FROM THE USER'S SIDE THAT IS INDISTINGUISHABLE FROM A BROKEN BUTTON.***
1078// nx_brand_tokens' bt_emit_dark_root_buf emits the UNGUARDED selector, which is
1079// CORRECT for a page with no switcher (nx_games_page). The difference is the switcher,
1080// not the SSOT, so the fix belongs at this call site and NOT in the shared emitter.
1081//
1082// BREAKPOINTS ARE THE ESTATE'S ONE LADDER, NOT A THIRD SET. 860/640 are taken from
1083// sites/nishifamily/nishi-ds.css section 5 RESPONSIVE -- the same two numbers
1084// nx_games_page adopted, for the same reason: a third ladder would be a duplicate
1085// ruler wearing a constant and nothing downstream could tell the two apart. They
1086// redefine TOKENS ONLY, never components: a token carries no paint, so a breakpoint
1087// cannot restyle anything the page did not already opt into by reading that token.
1088//
1089// MEMORY: the two scratch buffers are deliberately NOT munmap'd per call -- this is a
1090// one-shot page emitter that exits, and sc_theme_pass is called exactly once per page.
1091// Declared rather than left silent.
1092const SC_TOKCAP: i64 = 16384
1093const SC_BP_MD: i64 = 860
1094const SC_BP_SM: i64 = 640
1095
1096// The compare palette AS DATA. Light rows first, then the dark overrides. A token with
1097// NO dark row is theme-independent by construction -- that is why --nx-font-mono and
1098// the layout tokens carry none: a monospace stack and a wrap width are not chrome.
1099func sc_brand() -> *u8 {
1100 return "token|color|bg|rgb(243,241,236)\ntoken|color|fg|rgb(26,26,28)\ntoken|color|accent|rgb(88,64,180)\ntoken|color|panel|rgb(249,247,243)\ntoken|color|soft|rgb(236,233,226)\ntoken|color|tint|rgb(236,233,226)\ntoken|color|line|rgb(219,216,208)\ntoken|color|mut|rgb(92,96,104)\ntoken|color|faint|rgb(138,141,148)\ntoken|color|gk|rgb(60,64,72)\ntoken|color|goff|rgb(198,195,187)\ntoken|color|ghalf|rgb(122,126,134)\ntoken|color|codebg|rgb(229,226,218)\ntoken|color|ok|rgb(26,127,55)\ntoken|color|part|rgb(178,106,0)\ntoken|color|absent|rgb(179,38,30)\ntoken|color|exceed|rgb(130,80,223)\ntoken|font|mono|ui-monospace,Consolas,monospace\ntoken|layout|wrap|clamp(20rem,95vw,110rem)\ntoken|layout|gutter|clamp(14px,3vw,28px)\ntoken|layout|measure|66ch\ntoken|layout|capmin|27rem\ntoken|layout|capgap|clamp(10px,1.6vw,20px)\ntoken|layout|rail|13rem\ndark|color|bg|rgb(16,18,23)\ndark|color|fg|rgb(226,229,235)\ndark|color|accent|rgb(171,152,238)\ndark|color|panel|rgb(23,26,34)\ndark|color|soft|rgb(30,34,43)\ndark|color|tint|rgb(23,26,34)\ndark|color|line|rgb(43,47,56)\ndark|color|mut|rgb(139,146,158)\ndark|color|faint|rgb(100,107,119)\ndark|color|gk|rgb(168,175,186)\ndark|color|goff|rgb(58,63,73)\ndark|color|ghalf|rgb(120,127,138)\ndark|color|codebg|rgb(35,39,48)\ndark|color|ok|rgb(121,224,167)\ndark|color|part|rgb(255,166,120)\ndark|color|absent|rgb(118,130,154)\ndark|color|exceed|rgb(255,209,122)\n" as *u8
1101}
1102
1103// The SSOT's own dark wrapper, named once so its LENGTH is DERIVED and never
1104// hand-counted beside the literal -- a hand-counted length is a second copy of the
1105// string's shape and the two drift silently.
1106func sc_dark_open() -> *u8 { return "@media(prefers-color-scheme:dark){:root{\n" as *u8 }
1107func sc_dark_close() -> *u8 { return "}}\n" as *u8 }
1108
1109func sc_theme_pass(fd: i64) -> i64 {
1110 let bd: *u8 = sc_brand()
1111 let bn: i64 = bt_len(bd)
1112 let tb: *u8 = sys_mmap(SC_TOKCAP)
1113 // ---- light :root, straight from the SSOT ----
1114 let lw: i64 = bt_emit_root_buf(bd, bn, tb, SC_TOKCAP)
1115 if lw < 0 { w(2, "FATAL sc_theme_pass: brand parsed ZERO light tokens -- refusing to emit a page with no palette\n" as *u8); sys_exit(2); return 2 }
1116 // bt_app SATURATES at cap instead of failing, so an undersized buffer truncates the
1117 // palette mid-block and still returns a POSITIVE count. ***A CAP REACHED IN SILENCE
1118 // BECOMES A MEASUREMENT NOBODY KNOWS IS PARTIAL*** -- refuse at the boundary instead.
1119 if lw >= SC_TOKCAP - 1 { w(2, "FATAL sc_theme_pass: light block reached SC_TOKCAP -- this palette is TRUNCATED, not complete\n" as *u8); sys_exit(2); return 2 }
1120 sys_write(fd, tb, lw)
1121 // ---- page-local ALIASES over the SSOT names: one indirection, so a brand DATA edit
1122 // re-themes the whole page and every rule below keeps reading the short name it
1123 // always read. They are var() REFERENCES, not copies, so they resolve at use time --
1124 // which is why ONE alias block serves paper, ink, dark and the OS preference alike.
1125 w(fd, ":root{--bg:var(--nx-color-bg);--fg:var(--nx-color-fg);--ac:var(--nx-color-accent);--panel:var(--nx-color-panel);--soft:var(--nx-color-soft);--tint:var(--nx-color-tint);--line:var(--nx-color-line);--mut:var(--nx-color-mut);--faint:var(--nx-color-faint);--gk:var(--nx-color-gk);--goff:var(--nx-color-goff);--ghalf:var(--nx-color-ghalf);--codebg:var(--nx-color-codebg);--mono:var(--nx-font-mono);--y:var(--nx-color-ok);--p:var(--nx-color-part);--n:var(--nx-color-absent);--ex:var(--nx-color-exceed)}\n" as *u8)
1126 // ---- dark: ONE parse, TWO selectors ----
1127 let dw: i64 = bt_emit_dark_root_buf(bd, bn, tb, SC_TOKCAP)
1128 // bt_emit_dark_root_buf returns 0 (never negative) when the brand carries no dark
1129 // rows, so this guard is <= 0. A < 0 guard here would be a tooth that CANNOT FIRE.
1130 if dw <= 0 { w(2, "FATAL sc_theme_pass: brand carries NO dark override -- the page would ship theme-blind\n" as *u8); sys_exit(2); return 2 }
1131 if dw >= SC_TOKCAP - 1 { w(2, "FATAL sc_theme_pass: dark block reached SC_TOKCAP -- TRUNCATED, not complete\n" as *u8); sys_exit(2); return 2 }
1132 let op: *u8 = sc_dark_open()
1133 let ol: i64 = bt_len(op)
1134 let cl: i64 = bt_len(sc_dark_close())
1135 // The re-selection is only valid if the SSOT still emits the wrapper we expect. If it
1136 // ever changes, slicing past a stale prefix would emit a CORRUPT block that still
1137 // looks like CSS -- so verify the prefix and refuse loudly rather than guess.
1138 var gi: i64 = 0
1139 while gi < ol { if tb[gi] != op[gi] { w(2, "FATAL sc_theme_pass: nx_brand_tokens changed its dark wrapper -- re-selecting it would corrupt the block\n" as *u8); sys_exit(2); return 2 } gi = gi + 1 }
1140 let rs: i64 = ol
1141 let re: i64 = dw - cl
1142 if re <= rs { w(2, "FATAL sc_theme_pass: dark block carried no rows between its wrapper\n" as *u8); sys_exit(2); return 2 }
1143 let rb: *u8 = sys_mmap(SC_TOKCAP)
1144 var k: i64 = 0
1145 while rs + k < re { rb[k] = tb[rs + k]; k = k + 1 }
1146 w(fd, "html[data-theme='dark']{\n" as *u8)
1147 sys_write(fd, rb, k)
1148 w(fd, "}\n" as *u8)
1149 w(fd, "@media(prefers-color-scheme:dark){:root:not([data-theme]){\n" as *u8)
1150 sys_write(fd, rb, k)
1151 w(fd, "}}\n" as *u8)
1152 // ---- breakpoints: TOKENS ONLY, on the estate's one ladder ----
1153 w(fd, "@media (max-width:" as *u8); wn(fd, SC_BP_MD); w(fd, "px){:root{--nx-layout-gutter:clamp(12px,3.6vw,18px)}}\n" as *u8)
1154 w(fd, "@media (max-width:" as *u8); wn(fd, SC_BP_SM); w(fd, "px){:root{--nx-layout-wrap:100%;--nx-layout-gutter:12px}}\n" as *u8)
1155 return 0
1156}
1157
1158// ---- sc_layout_pass: THE ONE LAYOUT EMITTER FOR EVERY COMPARE PAGE (2026-08-31) ----
1159// WHY THIS EXISTS. The body rule was hand-copied into SEVEN generators and had already drifted to
1160// SIX different page widths (960/980/1000/1040/1080/1180) -- the duplicate-ruler defect living in
1161// emitted CSS, where nothing compares the copies. Worse, the two layout TOKENS the SSOT publishes
1162// (--nx-layout-wrap/--nx-layout-gutter) were DEFINED on every page and REFERENCED by none of the
1163// sota-class ones: they hardcoded max-width:980px and a second clamp() straight over the top.
1164// ***A TOKEN DEFINED AND NEVER READ IS NOT A DESIGN SYSTEM, IT IS DEAD BYTES THAT LOOK LIKE ONE***
1165// -- and the page it governed rendered as one narrow column down the middle of a 1920px display.
1166//
1167// FULL CANVAS WITHOUT UNREADABLE PROSE. These are two different width budgets and the fix is to stop
1168// spending one on the other. The PAGE takes a fluid clamp (95vw, capped) so the LAYOUT uses the
1169// display; PROSE keeps its own measure cap (--nx-layout-measure, 66ch) applied to the text element
1170// itself, never to its container. Surplus width therefore cannot lengthen a line -- it has nowhere
1171// to go except into more capability cards side by side, which is more information on screen rather
1172// than a 200-character sentence.
1173//
1174// WHY SC_CAP_SPLIT IS A CONST AND NOT A TOKEN. Every other layout number here is a --nx-layout-*
1175// token, per rule 11. This one CANNOT be: a CSS container/media query CONDITION does not accept
1176// var(), so the threshold must reach the stylesheet as a literal. A named const emitted through wn()
1177// is the same guarantee by the only mechanism CSS allows -- it is not an exception to the rule, it is
1178// the rule honoured where var() is structurally unavailable. 496px is where a card can seat the
1179// 13rem rail beside a main column still wider than the rail; below it the card stacks.
1180//
1181// CONTAINER QUERY, NOT A BREAKPOINT, FOR THE CARD. The same .cap renders one-per-row on a phone and
1182// three-across on a desktop, so its reflow depends on ITS OWN width, not the window's. @container is
1183// Baseline Widely Available (2025-08-14). The container-name is declared explicitly and queried by
1184// name: an unresolvable container silently falls back to small-viewport units rather than erroring,
1185// so the anonymous form would fail as a confident wrong answer.
1186const SC_CAP_SPLIT: i64 = 496
1187// Shared production sections preserve all domain detail and existing deep links.
1188func sc_production_open(fd: i64, id: *u8, title: *u8, purpose: *u8) -> i64 {
1189 w(fd, "<section class='production-section' aria-labelledby='" as *u8); w(fd, id); w(fd, "'>\n<h2 class='production-title' id='" as *u8); w(fd, id); w(fd, "'>" as *u8); w(fd, title); w(fd, "</h2>\n<p class='production-purpose'>" as *u8); w(fd, purpose); w(fd, "</p>\n<div class='production-detail'>\n" as *u8)
1190 return 0
1191}
1192func sc_production_close(fd: i64) -> i64 { w(fd, "</div></section>\n" as *u8); return 0 }
1193
1194func sc_layout_pass(fd: i64) -> i64 {
1195 w(fd, ".production-section{margin-block:3em;border-top:1px solid var(--line);padding-top:1.5em}.production-title{font-size:clamp(1.6rem,3vw,2.5rem);line-height:1.15;letter-spacing:-.025em;margin:0 0 .5em;scroll-margin-top:1em}.production-purpose{max-width:var(--nx-layout-measure);color:var(--mut);margin:0 0 2em}.production-detail{min-width:0}.production-detail h3{font-size:1.25rem;margin-top:2em}.production-detail h4{font-size:1.1rem}.production-nav{display:flex;flex-wrap:wrap;gap:.5em;padding:1em 0;border-block:1px solid var(--line);margin:2em 0}.production-nav a{display:block;padding:.6em .9em;text-decoration:none;border:1px solid var(--line);border-radius:.4em}.production-nav a:hover,.production-nav a:focus-visible{background:var(--panel);text-decoration:underline}.production-detail>*{min-width:0;max-width:100%}\n" as *u8)
1196 // page shell -- reads the SSOT tokens, so a brand DATA edit re-widths every compare page at once
1197 w(fd, "*{box-sizing:border-box}html{scrollbar-gutter:stable}\n" as *u8)
1198 w(fd, "body{background:var(--bg);font-family:-apple-system,Segoe UI,Roboto,sans-serif;max-width:var(--nx-layout-wrap);margin:0 auto;padding:0 var(--nx-layout-gutter) 6vh;color:var(--fg);line-height:1.6;font-size:1rem}\n" as *u8)
1199 // min-width:0 defeats the min-content floor that grid/flex children carry by default. Without it a
1200 // single wide table forces every ancestor wider than its track and THE PAGE scrolls sideways --
1201 // the overflow lands on the document, which is the one place it must never land.
1202 w(fd, "main{min-width:0}main>*{min-width:0;max-width:100%}table{max-width:100%}\n" as *u8)
1203 // long unbroken identifiers (organ names, hashes, paths) are the only real width bombs on these
1204 // pages; break them where they occur instead of letting them set the table's minimum width
1205 w(fd, ".pl .ct,.ev code,.rlinks code,.watch{overflow-wrap:anywhere}\n" as *u8)
1206 // ---- PROSE MEASURE: ONE cap for the prose blocks BOTH archetypes emit ----
1207 // THE REGRESSION THIS FUNCTION CAUSED, AND WHY THE FIX LANDS HERE. Widening body from a fixed 980px
1208 // to a fluid clamp is right for the LAYOUT and wrong for PROSE unless the prose carries its own cap.
1209 // Matrix learned that on 2026-08-25 and capped .meth/.lead/.answer/.verdict at 72ch. Sota never
1210 // received it: measured over the whole corpus, 72ch occurs 5 times in the estate and ALL FIVE are in
1211 // nx_swcompare_matrix (coverage_complete=1 corpus_complete=1 over 23,407 files). So sota's .meth --
1212 // the ~1,100-character "How this is scored" block, the FIRST prose a reader meets -- went from
1213 // inheriting 980px (~130 characters a line) to inheriting up to 1760px (~240), roughly 3x the WCAG
1214 // 1.4.8 (AAA) 80-character ceiling. ***A FIX THAT LIVES IN ONE ORGAN AND NOT ITS SIBLING IS HALF A
1215 // FIX***, and widening the canvas converted this one from latent to acute.
1216 //
1217 // WHY THE TOKEN AND NOT A SECOND 72ch. --nx-layout-measure is already the SSOT's declared prose
1218 // measure and is already read by .cap-note. Hard-coding 72ch a second time -- in the SHARED lib, no
1219 // less -- is the duplicate-ruler defect this extraction exists to remove, and nothing downstream
1220 // could tell the two copies apart. It does NOT overrule matrix: matrix emits its own .meth/.verdict
1221 // rules AFTER this one at equal specificity, so matrix still renders at 72ch and its emitted bytes
1222 // are unchanged. Only sota, which carried NO cap at all, changes. .lead and .answer are deliberately
1223 // NOT here -- they are matrix-only classes already carrying their own 72ch, so listing them would
1224 // add a second ruler for a page that already has one.
1225 w(fd, ".lead,.answer,.meth,.verdict{max-width:var(--nx-layout-measure);text-wrap:pretty}\n" as *u8)
1226 w(fd, ".exec-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,var(--nx-layout-capmin)),1fr));gap:var(--nx-layout-capgap);align-items:start;margin:var(--nx-layout-capgap) 0}.exec-grid>*{min-width:0;overflow-wrap:anywhere}.exec-grid>.lead,.exec-grid>.answer,.exec-grid>.meth{max-width:min(100%,var(--nx-layout-measure));margin:0}.exec-grid>h2,.exec-grid>h3,.exec-grid>table{grid-column:1/-1}.table-scroll{max-width:100%;overflow-x:auto;overscroll-behavior-inline:contain}.table-scroll>table{max-width:none;min-width:100%;width:max-content}.table-scroll th,.table-scroll td{white-space:nowrap}.table-scroll th:first-child,.table-scroll td:first-child{white-space:normal;width:var(--nx-layout-capmin);min-width:min(100vw - 2 * var(--nx-layout-gutter),var(--nx-layout-capmin));max-width:var(--nx-layout-capmin)}.table-scroll:focus-visible{outline:3px solid var(--ac);outline-offset:2px}\n" as *u8)
1227 // ---- the capability board: a responsive multi-column grid ----
1228 // auto-FILL, never auto-fit: auto-fit collapses the empty tracks and stretches a lone card across
1229 // the whole canvas, which re-creates at component scale the exact single-wide-column defect this
1230 // function exists to remove. min(100%,...) inside minmax is load-bearing: the auto-repeat count is
1231 // computed from the track MINIMUM, so a bare minmax(27rem,1fr) overflows any container narrower
1232 // than 27rem instead of dropping to one column.
1233 w(fd, ".caps{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,var(--nx-layout-capmin)),1fr));gap:var(--nx-layout-capgap);align-items:start;margin:6px 0}\n" as *u8)
1234 // the category headings are emitted INSIDE .caps, so they are grid items too and must span the row
1235 w(fd, ".caps>.ghead{grid-column:1/-1}\n" as *u8)
1236 // THE CARD IS SCOPED .caps>.cap, NOT BARE .cap, FOR THE SAME REASON .ghead ABOVE IS. "cap" is an
1237 // overloaded name in this estate and a bare rule in a SHARED lib claims it globally. Measured over
1238 // the whole corpus (coverage_complete=1 corpus_complete=1, 23,407 files) there are four other
1239 // holders: nx_swcompare_crm:64 and nx_swcompare_sending:65 both emit <td class='cap'> inside a <tr>,
1240 // and _hdl_build/nx_rewards:175 emits <span class='cap'> -- none of them a child of .caps, so the
1241 // child combinator excludes all three BY CONSTRUCTION. That matters because the roadmap is to
1242 // convert those generators onto this emitter, and display:grid landing on a <td> overrides
1243 // display:table-cell and destroys the table. Scoping costs 6 bytes and removes the trap before
1244 // anyone can walk into it.
1245 //
1246 // ***THIS IS NOT A COMPLETE FENCE AND MUST NOT BE READ AS ONE.*** The same census found a FIFTH
1247 // holder that the child combinator does NOT exclude: nx_compare_unified:281 emits
1248 // <div class='caps'> with <span class='cap on'> as its DIRECT CHILDREN, so .caps>.cap matches its
1249 // chip row exactly. It is harmless today -- nx_compare_unified does not call sc_layout_pass (the
1250 // four callers, RE-CENSUSED 2026-08-31 at coverage_complete=1 corpus_complete=1 over 23,407 files,
1251 // are nx_swcompare_sota, nx_swcompare_matrix, nx_swcompare_hub and nx_swcompare_watch_gate -- an
1252 // earlier revision of this comment said THREE and omitted hub. LINE NUMBERS ARE DELIBERATELY NOT
1253 // CITED HERE: hub's call site moved 729 -> 863 while this comment was being written, so a line
1254 // citation would rot faster than the fact it carries -- re-derive it with a grep for the symbol.
1255 // That undercount is load-bearing, not cosmetic: this enumeration IS the whole basis for calling the
1256 // collision harmless, so a fence that miscounts its own callers asserts a gap it never measured) -- but
1257 // whoever converts nx_compare_unified inherits a live collision, and a chip is not a card. Naming
1258 // the residual here rather than in a report nobody re-reads: a count without a worklist is not
1259 // actionable, and a fence published as "done" is worse than one published with its gap.
1260 w(fd, ".caps>.cap{container-type:inline-size;container-name:nxcap;display:grid;grid-template-columns:minmax(0,1fr) minmax(0,var(--nx-layout-rail));gap:6px 18px;padding:14px 16px;border:1px solid var(--line);border-radius:14px;background:var(--panel);align-items:start;min-width:0}\n" as *u8)
1261 w(fd, ".caps>.cap>.capmain,.caps>.cap>.capside{grid-column:1/-1}.capmain{min-width:0}.cap-note{max-width:var(--nx-layout-measure);text-wrap:pretty}\n" as *u8)
1262 w(fd, ".capside{display:flex;flex-direction:row;flex-wrap:wrap;align-items:center;gap:8px}.rw{max-width:100%}\n" as *u8)
1263 w(fd, "@container nxcap (min-width:" as *u8); wn(fd, SC_CAP_SPLIT); w(fd, "px){.caps>.cap>.capmain{grid-column:1;grid-row:1}.caps>.cap>.capside{grid-column:2;grid-row:1;flex-direction:column;align-items:flex-end}.caps>.cap .rw{justify-content:flex-end;max-width:var(--nx-layout-rail)}}\n" as *u8)
1264 w(fd, ".production-detail{overflow-wrap:anywhere}.lead,.answer,.meth,.verdict{overflow-wrap:anywhere}.production-detail .legend .m{display:inline-block;max-width:100%;white-space:normal}.plan-table-scroll>table{width:100%;min-width:var(--nx-layout-measure);max-width:none}.plan-table-scroll th,.plan-table-scroll td{white-space:normal;overflow-wrap:anywhere}.plan-table-scroll th:first-child,.plan-table-scroll td:first-child{width:auto;min-width:0;max-width:none}.exec-grid>.plan-table-scroll{grid-column:1/-1}.plan-table-scroll th,.plan-table-scroll td.ct{overflow-wrap:normal}.plan-table-scroll th{white-space:nowrap}" as *u8)
1265 sg_css(fd)
1266 return 0
1267}
1268
1269// ---- THE EVIDENCE PROFILE AS MACHINE-READABLE DATA (2026-08-31, frontier F1208) -------------------
1270// ONE RENDERER IN THE BASE, BOTH GENERATORS CALL IT -- the refs_pass / plan_pass precedent exactly. The
1271// HTML band (ev_pass, in nx_swcompare_matrix) and this JSON projection read THE SAME stamp through THE
1272// SAME reader, nx_evprofile_lib, so a board page and its api.json cannot disagree about that domain's
1273// gaps: there is one artifact and one parser, and this function only PROJECTS what evp_parse already
1274// read. THE GENERATOR ADDS A READER, NEVER A MEASUREMENT -- every field below is already materialised
1275// verbatim on knowledge/status/evstamp_<domain>.verdict by nx_swcompare_evidence.
1276//
1277// ABSTAIN, NEVER ACQUIT -- AND HERE THE ABSTAIN PATH IS THE COMMON PATH. 92 of the 95 live stamps are
1278// v1 (measured 2026-08-31), so the branch that emits NO NUMBERS is the one nearly every board takes,
1279// and it is therefore the one that has to be right: a v1 stamp carries none of the profile keys,
1280// evp_parse leaves every slot -1, and writing a 0 there would publish a gapless board for a domain
1281// nobody ever measured. AN ALWAYS-ZERO FIELD READS AS EVIDENCE.
1282// The evidence key is emitted on EVERY path, including the abstentions. An ABSENT key is
1283// indistinguishable from an emitter that never shipped, so the abstention is published as a VALUE --
1284// status UNKNOWN / UNSTAMPED / AMBIGUOUS -- and never as a silence.
1285//
1286// NO SCALAR GRADE, DELIBERATELY. Counts WITH their denominators, the partition sums, and the list of
1287// gap classes that FIRE. A stored scalar is a field a seat can edit; a counted partition is not, and
1288// any consumer can recompute whatever ranking it wants from these numbers at read time.
1289//
1290// NO PATH IS BUILT HERE. evp_load composes ep_artifact_path, so this behaves identically whether the
1291// generator was launched from the estate root or -- as nx_compare_regen launches it -- from buildroot,
1292// whose knowledge/status holds ZERO evstamp files. A bare relative read there would confidently render
1293// no-evidence for all 96 domains.
1294func evj_class(fired: i64, name: *u8, n: *i64) -> i64 {
1295 if fired != 1 { return 0 }
1296 if n[0] > 0 { wc(1, 44) }
1297 wq(1); wj(1, name); wq(1)
1298 n[0] = n[0] + 1
1299 return 1
1300}
1301
1302func evj_pass(dom: *u8) -> i64 {
1303 let buf: *u8 = sys_mmap(EVP_STAMP_CAP)
1304 let pathout: *u8 = sys_mmap(EVP_PATH_CAP)
1305 let flags: *i64 = sys_mmap(8 * EVP_NFLAG) as *i64
1306 let n: i64 = evp_load(dom, buf, EVP_STAMP_CAP, pathout, flags)
1307 wc(1, 44); wq(1); w(1, "evidence" as *u8); wq(1); wc(1, 58); wc(1, 123)
1308 kv_s(1, "producer" as *u8, "nx_swcompare_evidence" as *u8); wc(1, 44)
1309 kv_s(1, "reader" as *u8, "nx_evprofile_lib" as *u8); wc(1, 44)
1310 // Two different files answering to one name is REFUSED, not silently decided: ep_open_rd probes the
1311 // caller CWD first on purpose, so a stray copy beside the generator would win, and win silently.
1312 if n == EVP_RC_AMBIGUOUS {
1313 kv_s(1, "evidence_status" as *u8, "AMBIGUOUS" as *u8); wc(1, 44)
1314 kv_s(1, "source" as *u8, pathout); wc(1, 44)
1315 kv_s(1, "note" as *u8, "two different files answer to one stamp name -- one under the generator working directory, one at the estate root, and their bytes differ. No reader may pick one, so no numbers are published." as *u8)
1316 wc(1, 125)
1317 return 0
1318 }
1319 if n < 0 {
1320 kv_s(1, "evidence_status" as *u8, "UNSTAMPED" as *u8); wc(1, 44)
1321 kv_s(1, "note" as *u8, "no evidence stamp exists for this domain yet: run nx_swcompare_evidence on it and this object fills itself on the next beat. Not one numeric field is emitted, deliberately -- a zero-filled profile reads as a board with no gaps, which is the one wrong answer nobody would question." as *u8)
1322 wc(1, 125)
1323 return 0
1324 }
1325 let f: *i64 = sys_mmap(8 * EVP_NF) as *i64
1326 evp_parse(buf, n, f)
1327 kv_s(1, "source" as *u8, pathout); wc(1, 44)
1328 kv_n(1, "stamp_version" as *u8, f[EVP_F_V]); wc(1, 44)
1329 kv_n(1, "stamp_read_capped" as *u8, flags[EVP_FL_BRIM]); wc(1, 44)
1330 // THE VERSION IS DERIVED FROM THE WIRE, NEVER DECLARED ON IT: a v1 stamp simply has no profile keys.
1331 if f[EVP_F_V] < 2 {
1332 kv_s(1, "evidence_status" as *u8, "UNKNOWN" as *u8); wc(1, 44)
1333 kv_s(1, "note" as *u8, "this stamp predates the gap profile and carries none of its keys, so the reader abstains rather than acquit. UNKNOWN IS NOT ZERO. Re-stamp with nx_swcompare_evidence on this domain and the counts below appear." as *u8)
1334 wc(1, 125)
1335 return 0
1336 }
1337 let now: i64 = sys_now_realtime_sec()
1338 let ttl: i64 = evp_ttl_sec()
1339 let stale: i64 = evp_stale(f, now, ttl)
1340 var age: i64 = now - f[EVP_F_EPOCH]
1341 if age < 0 { age = 0 }
1342 kv_s(1, "evidence_status" as *u8, "MEASURED" as *u8); wc(1, 44)
1343 kv_n(1, "ok" as *u8, f[EVP_F_OK]); wc(1, 44)
1344 kv_n(1, "epoch" as *u8, f[EVP_F_EPOCH]); wc(1, 44)
1345 kv_n(1, "age_sec" as *u8, age); wc(1, 44)
1346 kv_n(1, "ttl_sec" as *u8, ttl); wc(1, 44)
1347 kv_n(1, "stale" as *u8, stale); wc(1, 44)
1348 // EVERY COUNT CARRIES ITS DENOMINATOR: a bare grounded=14 is not a fact about a board.
1349 wq(1); w(1, "grounded" as *u8); wq(1); wc(1, 58); wc(1, 123)
1350 kv_n(1, "count" as *u8, f[EVP_F_GROUNDED]); wc(1, 44); kv_n(1, "of" as *u8, f[EVP_F_PRESENT])
1351 wc(1, 125); wc(1, 44)
1352 kv_n(1, "unsupported" as *u8, f[EVP_F_UNGROUND]); wc(1, 44)
1353 wq(1); w(1, "gates" as *u8); wq(1); wc(1, 58); wc(1, 123)
1354 kv_n(1, "green" as *u8, f[EVP_F_GREEN]); wc(1, 44)
1355 kv_n(1, "ran" as *u8, f[EVP_F_RAN]); wc(1, 44)
1356 kv_n(1, "declared" as *u8, f[EVP_F_DECLARED]); wc(1, 44)
1357 kv_n(1, "skipped" as *u8, f[EVP_F_SKIPPED]); wc(1, 44)
1358 kv_n(1, "hashed" as *u8, f[EVP_F_HASHED]); wc(1, 44)
1359 kv_n(1, "redseen" as *u8, f[EVP_F_REDSEEN]); wc(1, 44)
1360 kv_n(1, "vacuous" as *u8, f[EVP_F_VACUOUS])
1361 wc(1, 125); wc(1, 44)
1362 wq(1); w(1, "gaps" as *u8); wq(1); wc(1, 58); wc(1, 123)
1363 kv_n(1, "open" as *u8, f[EVP_F_ABSENT]); wc(1, 44)
1364 kv_n(1, "named" as *u8, f[EVP_F_ABSNAMED]); wc(1, 44)
1365 kv_n(1, "unnamed" as *u8, f[EVP_F_ABSBARE])
1366 wc(1, 125); wc(1, 44)
1367 kv_n(1, "flips_ready" as *u8, f[EVP_F_LANDED]); wc(1, 44)
1368 // A PARTITION IS A CLAIM: PUBLISH THE PARTS AND THE SUM SO A LEAK CANNOT HIDE BEHIND A TOTAL.
1369 // reconciles is THREE-STATE on purpose -- 1 sums, 0 LEAKS, -1 not measurable from this stamp --
1370 // because a partition we could not check and one that failed are different facts.
1371 wq(1); w(1, "partition" as *u8); wq(1); wc(1, 58); wc(1, 123)
1372 kv_n(1, "grounded_plus_unsupported" as *u8, f[EVP_F_GROUNDED] + f[EVP_F_UNGROUND]); wc(1, 44)
1373 kv_n(1, "present_axes" as *u8, f[EVP_F_PRESENT]); wc(1, 44)
1374 kv_n(1, "named_plus_unnamed" as *u8, f[EVP_F_ABSNAMED] + f[EVP_F_ABSBARE]); wc(1, 44)
1375 kv_n(1, "open" as *u8, f[EVP_F_ABSENT]); wc(1, 44)
1376 kv_n(1, "reconciles" as *u8, evp_reconciles(f))
1377 wc(1, 125); wc(1, 44)
1378 // THE FAILING CONJUNCT, NAMED. A bare verdict is a disjunction and the reader always guesses the
1379 // alarming third; GPqN and gPQN are the same word and opposite work. evp_conj_char is the WRITER's
1380 // own function, so these letters cannot drift from the letters the referee stamped.
1381 wq(1); w(1, "conj" as *u8); wq(1); wc(1, 58); wq(1)
1382 wc(1, evp_conj_char(f[EVP_F_CJ_G], 71, 103))
1383 wc(1, evp_conj_char(f[EVP_F_CJ_P], 80, 112))
1384 wc(1, evp_conj_char(f[EVP_F_CJ_Q], 81, 113))
1385 wc(1, evp_conj_char(f[EVP_F_CJ_N], 78, 110))
1386 wq(1); wc(1, 44)
1387 kv_s(1, "first_failing_conjunct" as *u8, evp_conj_name(evp_conj_fail(f))); wc(1, 44)
1388 // WHICH DOCUMENT WAS GRADED. There are two knowledge trees and their copies of a matrix differ, so a
1389 // verdict that cannot name its subject document is not a verdict about the published board.
1390 wq(1); w(1, "graded_document" as *u8); wq(1); wc(1, 58); wc(1, 123)
1391 kv_s(1, "tree" as *u8, evp_tree_name(f[EVP_F_MROOT])); wc(1, 44)
1392 kv_n(1, "bytes" as *u8, f[EVP_F_MBYTES]); wc(1, 44)
1393 kv_n(1, "read_capped" as *u8, f[EVP_F_MCAPPED])
1394 wc(1, 125); wc(1, 44)
1395 kv_s(1, "gates_map_tree" as *u8, evp_tree_name(f[EVP_F_GATESROOT])); wc(1, 44)
1396 // THE GAP CLASSES THAT FIRE -- the machine half of the worklist. SEPARATE, NEVER MERGED: CLAIM-ONLY
1397 // needs a gate WRITTEN and GATE-FAILING needs one FIXED, and a single blended number sends a seat at
1398 // the wrong work. The remedy prose lives on the board page and is deliberately NOT copied here: two
1399 // copies of one sentence is a duplicate ruler that drifts on the first edit.
1400 wq(1); w(1, "classes" as *u8); wq(1); wc(1, 58); wc(1, 91)
1401 let cn: *i64 = sys_mmap(16) as *i64
1402 cn[0] = 0
1403 evj_class(evp_claim_only(f), "CLAIM-ONLY" as *u8, cn)
1404 evj_class(evp_gate_failing(f), "GATE-FAILING" as *u8, cn)
1405 evj_class(evp_fabricated(f), "UNSUPPORTED-CLAIM" as *u8, cn)
1406 evj_class(evp_flip_ready(f), "FLIP-READY" as *u8, cn)
1407 evj_class(evp_unnamed_gap(f), "UNNAMED-GAP" as *u8, cn)
1408 evj_class(evp_vacuous_gate(f), "VACUOUS-GATE" as *u8, cn)
1409 evj_class(stale, "STALE" as *u8, cn)
1410 wc(1, 93); wc(1, 44)
1411 kv_n(1, "classes_fired" as *u8, cn[0])
1412 wc(1, 125)
1413 return cn[0]
1414}
1415
1416// ---- MEASURED HEAD-TO-HEAD RECEIPTS (2026-09-01, lang leg) ---------------------------------------------
1417// OPERATOR: "meet and exceed gcc and rust and all the other languages independently verified with evidence
1418// documented and our /compare properly storing and making the evidence reproducible and visible and have that
1419// be an ecosystem wide capability". A performance number typed into a note is a CLAIM; this section renders a
1420// RECEIPT. knowledge/compare/<dom>.bench is written by a measuring organ (nx_lang_h2h for lang) and carries
1421// the host, every toolchain version, every source and binary sha256, min and median microseconds per arm, the
1422// checksum every arm had to agree on, and the exact command that regenerates it. ONE reader
1423// (nx_bench_receipt_lib) is shared by the writer, this renderer and the gate, and the verdict on the page is
1424// RE-DERIVED from the rows here, never copied from the file's own @verdict line -- the two are printed side by
1425// side and an agreement flag says whether the writer and the reader concur.
1426// ONE renderer in the base, BOTH generators call it (the refs_pass / plan_pass / watch_pass precedent), so a
1427// matrix board and a sota board publish the same bench dialect. A domain with no .bench emits NOTHING in both
1428// modes: every board without a receipt is byte-identical by construction.
1429const BD_SECS_PER_DAY: i64 = 86400
1430const BD_DAYS_TO_CIVIL_SHIFT: i64 = 719468 // days from 0000-03-01 to 1970-01-01 (Hinnant, civil_from_days)
1431const BD_DAYS_PER_ERA: i64 = 146097
1432const BD_DAYS_PER_4Y: i64 = 1460
1433const BD_DAYS_PER_100Y: i64 = 36524
1434const BD_DAYS_PER_ERA_LESS1: i64 = 146096
1435const BD_DAYS_PER_YEAR: i64 = 365
1436const BD_YEARS_PER_ERA: i64 = 400
1437const BD_MONTH_NUM: i64 = 153
1438const BD_MONTH_SHIFT: i64 = 2
1439const BD_MONTH_SCALE: i64 = 5
1440const BD_MARCH: i64 = 3
1441const BD_JAN_FROM_MP: i64 = 9
1442const BD_MP_WRAP: i64 = 10
1443const BD_FEB: i64 = 2
1444const BD_TEN: i64 = 10
1445const BD_SHA_SHOWN: i64 = 12
1446// YYYY-MM-DD from unix seconds (proleptic Gregorian, UTC); a non-positive epoch prints a dash
1447func bd_ymd(epoch: i64, dst: *u8, off: i64) -> i64 {
1448 if epoch <= 0 { return br_cat(dst, off, "-" as *u8) }
1449 let z: i64 = epoch / BD_SECS_PER_DAY + BD_DAYS_TO_CIVIL_SHIFT
1450 let era: i64 = z / BD_DAYS_PER_ERA
1451 let doe: i64 = z - era * BD_DAYS_PER_ERA
1452 let yoe: i64 = (doe - doe / BD_DAYS_PER_4Y + doe / BD_DAYS_PER_100Y - doe / BD_DAYS_PER_ERA_LESS1) / BD_DAYS_PER_YEAR
1453 let doy: i64 = doe - (BD_DAYS_PER_YEAR * yoe + yoe / 4 - yoe / 100)
1454 let mp: i64 = (BD_MONTH_SCALE * doy + BD_MONTH_SHIFT) / BD_MONTH_NUM
1455 let d: i64 = doy - (BD_MONTH_NUM * mp + BD_MONTH_SHIFT) / BD_MONTH_SCALE + 1
1456 var m: i64 = mp + BD_MARCH
1457 if mp >= BD_MP_WRAP { m = mp - BD_JAN_FROM_MP }
1458 var y: i64 = yoe + era * BD_YEARS_PER_ERA
1459 if m <= BD_FEB { y = y + 1 }
1460 var o: i64 = br_catn(dst, off, y)
1461 o = br_put(dst, o, 45)
1462 if m < BD_TEN { o = br_put(dst, o, 48) }
1463 o = br_catn(dst, o, m)
1464 o = br_put(dst, o, 45)
1465 if d < BD_TEN { o = br_put(dst, o, 48) }
1466 o = br_catn(dst, o, d)
1467 return o
1468}
1469// the first BD_SHA_SHOWN hex digits of a digest, or the whole thing when shorter
1470func bd_sha_short(fd: i64, s: *u8) -> i64 {
1471 var i: i64 = 0
1472 while s[i] != (0 as u8) { if i < BD_SHA_SHOWN { wc(fd, s[i] as i64) } i = i + 1 }
1473 return 0
1474}
1475func bd_status_class(st: i64) -> *u8 {
1476 if st == BR_ST_VALID { return "ok" as *u8 }
1477 if st == BR_ST_VOID { return "void" as *u8 }
1478 if st == BR_ST_UNMEASURABLE { return "unm" as *u8 }
1479 return "fail" as *u8
1480}
1481// ---- IM3 (intelmine, 2026-09-05): MINED INTELLIGENCE ON THE BOARD -- knowledge/compare/<dom>.proposed, rendered by the base for both generators ----
1482// nx_intelmine_propose routes review and competitive signals (nx_reviewmine_lib over Steam reviews under the
1483// exceeds / meets / mixed / does-not-meet rubric, the installed-title census) through capability_map.conf and APPENDS
1484// prop|epoch|appid|name|signal|kind|term|domain|rung-title|evidence (PR_NF fields; the writer dedupes on appid+kind+term)
1485// The proposer writes DATA and never a page. This is the ONE renderer, so every domain inherits the band on its next
1486// beat and a one-off report can never be built beside it (the grow-the-emitter law). An ABSENT file emits NOTHING --
1487// no section, no JSON key: an empty band would read as "the field has nothing to say", the one wrong answer nobody
1488// questions. A malformed row is COUNTED beside the rendered ones, never dropped in silence. A proposal is a LEAD, never
1489// a rung: it closes only when a rung with a gate lands, and the page says so in its own words.
1490const PR_READ_CAP: i64 = 65536 // announces when it binds; a .proposed file is rows, not a corpus
1491const PR_PATH_CAP: i64 = 600 // knowledge/compare/<dom>.proposed -- the reserve its sibling passes use
1492const PR_I64_BYTES: i64 = 8
1493const PR_NF: i64 = 10 // fields per prop| row, from the writer's own emit order (ip_emit)
1494const PR_SPLIT: i64 = 16 // field table: PR_NF plus room, so an over-long row is read whole rather than clipped to fit
1495const PR_F_TAG: i64 = 0
1496const PR_F_EPOCH: i64 = 1
1497const PR_F_APPID: i64 = 2
1498const PR_F_NAME: i64 = 3
1499const PR_F_SIGNAL: i64 = 4
1500const PR_F_KIND: i64 = 5
1501const PR_F_TERM: i64 = 6
1502const PR_F_DOMAIN: i64 = 7
1503const PR_F_TITLE: i64 = 8
1504const PR_F_EVIDENCE: i64 = 9
1505const PR_CH_COMMENT: i64 = 35
1506const PR_CH_LF: i64 = 10
1507const PR_CH_COMMA: i64 = 44
1508const PR_CH_COLON: i64 = 58
1509const PR_CH_LBRACE: i64 = 123
1510const PR_CH_RBRACE: i64 = 125
1511const PR_CH_LBRACKET: i64 = 91
1512const PR_CH_RBRACKET: i64 = 93
1513// RENDER-TIME TITLE (intelmine IM23/IM27, 2026-09-05): a row whose name column is its appid was written before any
1514// census or platform-api name existed, and the writer dedupes rows so it never rewrites them. The banked name
1515// (nx_steam_reviews name <appid> -> <appid>.name, one line) is read HERE instead, from the estate root as the mgmt
1516// daemon sees it AND from one directory up as the regen sees it (CWD = buildroot) -- the two-root read, announced
1517// per row as name_src=banked, never a silent guess. Absent in both: the row prints its appid and says so.
1518const PR_NAME_CAP: i64 = 256
1519const PR_NAME_DIR: *u8 = "knowledge/reviews/steam/"
1520const PR_NAME_DIR_UP: *u8 = "../knowledge/reviews/steam/"
1521const PR_NAME_SUFFIX: *u8 = ".name"
1522func pr_name_read(dir: *u8, appid: *u8, out: *u8, cap: i64) -> i64 {
1523 let path: *u8 = sys_mmap(PR_PATH_CAP)
1524 var o: i64 = scopy(path, 0, dir)
1525 o = scopy(path, o, appid); o = scopy(path, o, PR_NAME_SUFFIX); path[o] = 0 as u8
1526 let n: i64 = c_read(path, out, cap - 1)
1527 if n <= 0 { return 0 - 1 }
1528 var e: i64 = 0
1529 while e < n { if out[e] == (PR_CH_LF as u8) { break } e = e + 1 }
1530 out[e] = 0 as u8
1531 if e <= 0 { return 0 - 1 }
1532 return e
1533}
1534func pr_name_lookup(appid: *u8, out: *u8, cap: i64) -> i64 {
1535 let n: i64 = pr_name_read(PR_NAME_DIR, appid, out, cap)
1536 if n > 0 { return n }
1537 return pr_name_read(PR_NAME_DIR_UP, appid, out, cap)
1538}
1539func prop_pass(dom: *u8, fd: i64, mode: i64) -> i64 { return prop_pass_heading(dom, fd, mode, 2) }
1540func prop_pass_heading(dom: *u8, fd: i64, mode: i64, heading_level: i64) -> i64 {
1541 let path: *u8 = sys_mmap(PR_PATH_CAP)
1542 var o: i64 = scopy(path, 0, "knowledge/compare/" as *u8)
1543 o = scopy(path, o, dom); o = scopy(path, o, ".proposed" as *u8); path[o] = 0 as u8
1544 let buf: *u8 = sys_mmap(PR_READ_CAP)
1545 let n: i64 = c_read(path, buf, PR_READ_CAP - 1)
1546 if n <= 0 { return 0 }
1547 var capped: i64 = 0
1548 if n >= PR_READ_CAP - 1 { capped = 1 }
1549 buf[n] = 0 as u8
1550 let fld: *i64 = sys_mmap(PR_SPLIT * PR_I64_BYTES) as *i64
1551 if mode == 2 {
1552 wc(fd, PR_CH_COMMA); wq(fd); w(fd, "proposed" as *u8); wq(fd); wc(fd, PR_CH_COLON); wc(fd, PR_CH_LBRACE)
1553 kv_s(fd, "file" as *u8, path); wc(fd, PR_CH_COMMA)
1554 kv_s(fd, "writer" as *u8, "nx_intelmine_propose" as *u8); wc(fd, PR_CH_COMMA)
1555 wq(fd); w(fd, "rows" as *u8); wq(fd); wc(fd, PR_CH_COLON); wc(fd, PR_CH_LBRACKET)
1556 }
1557 if mode == 1 {
1558 sc_heading_open(fd, heading_level, "" as *u8); w(fd, "Mined from the field — review and competitive intelligence proposed to this board" as *u8); sc_heading_close(fd, heading_level); w(fd, "\n" as *u8)
1559 if capped == 1 { w(fd, "<div class='meth'>proposed artefact READ-CAPPED at " as *u8); wn(fd, PR_READ_CAP); w(fd, " bytes — the rows below are a PREFIX of the file</div>\n" as *u8) }
1560 w(fd, "<p class='lead'>Rows written by <code>nx_intelmine_propose</code> from <code>nx_reviewmine_lib</code> signals (Steam reviews under the exceeds / meets / mixed / does-not-meet rubric, the installed-title census) and routed here by <code>capability_map.conf</code>. <b>DEFECT</b> names a rival failing that a rung here answers; <b>DEMANDED</b> a capability buyers ask for and do not get; <b>WE-DO-BETTER</b> an exceed the reviews corroborate; <b>THEY-DO-WELL</b> a bar this board must meet; <b>SHIPS</b> a rival capability to match. <b>A proposal is a lead, never a rung</b> — it closes only when a rung with a gate lands, and nothing in this band changes a measured cell.</p>\n" as *u8)
1561 sc_plan_table_open(fd, "Capability proposals" as *u8); w(fd, "<thead><tr><th>Signal</th><th>Kind</th><th>Term</th><th>Title</th><th>Proposed rung</th><th>Evidence</th></tr></thead><tbody>\n" as *u8)
1562 }
1563 var rows: i64 = 0
1564 var malformed: i64 = 0
1565 let nbuf: *u8 = sys_mmap(PR_NAME_CAP)
1566 var p: i64 = 0
1567 while p < n {
1568 var e: i64 = p
1569 while e < n { if buf[e] == (PR_CH_LF as u8) { break } e = e + 1 }
1570 buf[e] = 0 as u8
1571 let line: *u8 = (buf as i64 + p) as *u8
1572 p = e + 1
1573 if line[0] != (PR_CH_COMMENT as u8) { if line[0] != (0 as u8) {
1574 let nf: i64 = splitpipe(line, fld, PR_SPLIT)
1575 var ok: i64 = 0
1576 if nf >= PR_NF { if streq(fld[PR_F_TAG] as *u8, "prop" as *u8) == 1 { ok = 1 } }
1577 if ok == 0 { malformed = malformed + 1 } else {
1578 rows = rows + 1
1579 let name: *u8 = fld[PR_F_NAME] as *u8
1580 let appid: *u8 = fld[PR_F_APPID] as *u8
1581 // the proposer wrote the appid as the name when nothing named the title: try the banked name at render
1582 // time (name_src=banked), and only when that is absent too print the number AND say so (name_src=appid)
1583 var shown: *u8 = name
1584 var nsrc: *u8 = "row" as *u8
1585 if streq(name, appid) == 1 {
1586 nsrc = "appid" as *u8
1587 if pr_name_lookup(appid, nbuf, PR_NAME_CAP) > 0 { shown = nbuf; nsrc = "banked" as *u8 }
1588 }
1589 if mode == 1 {
1590 w(fd, "<tr><td><span class='ex'>" as *u8); wnote(fd, fld[PR_F_SIGNAL] as *u8); w(fd, "</span></td><td class='ct'>" as *u8); wnote(fd, fld[PR_F_KIND] as *u8)
1591 w(fd, "</td><td class='ct'>" as *u8); wnote(fd, fld[PR_F_TERM] as *u8); w(fd, "</td><td>" as *u8)
1592 if streq(nsrc, "appid" as *u8) == 1 { w(fd, "appid <span class='ct'>" as *u8); wnote(fd, appid); w(fd, "</span> (title unresolved: no census row and no banked name)" as *u8) } else { wnote(fd, shown); w(fd, " <span class='ct'>" as *u8); wnote(fd, appid); w(fd, "</span>" as *u8) }
1593 w(fd, "</td><td><b>" as *u8); wnote(fd, fld[PR_F_TITLE] as *u8); w(fd, "</b></td><td class='ct'>" as *u8); wnote(fd, fld[PR_F_EVIDENCE] as *u8); w(fd, "</td></tr>\n" as *u8)
1594 }
1595 if mode == 2 {
1596 if rows > 1 { wc(fd, PR_CH_COMMA) }
1597 wc(fd, PR_CH_LBRACE)
1598 kv_s(fd, "epoch" as *u8, fld[PR_F_EPOCH] as *u8); wc(fd, PR_CH_COMMA)
1599 kv_s(fd, "appid" as *u8, appid); wc(fd, PR_CH_COMMA)
1600 kv_s(fd, "name" as *u8, shown); wc(fd, PR_CH_COMMA)
1601 kv_s(fd, "name_src" as *u8, nsrc); wc(fd, PR_CH_COMMA)
1602 kv_s(fd, "signal" as *u8, fld[PR_F_SIGNAL] as *u8); wc(fd, PR_CH_COMMA)
1603 kv_s(fd, "kind" as *u8, fld[PR_F_KIND] as *u8); wc(fd, PR_CH_COMMA)
1604 kv_s(fd, "term" as *u8, fld[PR_F_TERM] as *u8); wc(fd, PR_CH_COMMA)
1605 kv_s(fd, "domain" as *u8, fld[PR_F_DOMAIN] as *u8); wc(fd, PR_CH_COMMA)
1606 kv_s(fd, "title" as *u8, fld[PR_F_TITLE] as *u8); wc(fd, PR_CH_COMMA)
1607 kv_s(fd, "evidence" as *u8, fld[PR_F_EVIDENCE] as *u8)
1608 wc(fd, PR_CH_RBRACE)
1609 }
1610 }
1611 } }
1612 }
1613 if mode == 1 {
1614 sc_plan_table_close(fd); w(fd, "\n<p class='stats'>proposals <b>" as *u8); wn(fd, rows); w(fd, "</b><span class='sep'>|</span>malformed rows <b>" as *u8); wn(fd, malformed)
1615 w(fd, "</b> (counted, never rendered: a row that is not <code>prop|</code> with " as *u8); wn(fd, PR_NF); w(fd, " fields)<span class='sep'>|</span>read-capped <b>" as *u8); wn(fd, capped); w(fd, "</b></p>\n" as *u8)
1616 }
1617 if mode == 2 {
1618 wc(fd, PR_CH_RBRACKET); wc(fd, PR_CH_COMMA)
1619 kv_n(fd, "count" as *u8, rows); wc(fd, PR_CH_COMMA)
1620 kv_n(fd, "malformed" as *u8, malformed); wc(fd, PR_CH_COMMA)
1621 kv_n(fd, "read_capped" as *u8, capped)
1622 wc(fd, PR_CH_RBRACE)
1623 }
1624 return rows
1625}
1626// THE DISCOVERED FIELD (fieldwatch FW1, 2026-09-05; operator: the six columns "arent a good sample of the industry").
1627// knowledge/compare/<dom>.field is WRITTEN by nx_field_discover from <dom>.seeds -- public lists (Wikipedia wikitext,
1628// GitHub topics, awesome lists) read mechanically -- and rendered here by the ONE reader for both generators. The page
1629// shows the field, then measures the matrix's own @cols as a SUBSET of it: columns_in_field of columns, and how many
1630// discovered rivals have no column at all. A seat's pick is thereby shown for what it is. Absent file = no section.
1631const FI_READ_CAP: i64 = 262144 // announces when it binds: a .field is rows, not a corpus
1632const FI_PATH_CAP: i64 = 600
1633const FI_I64_BYTES: i64 = 8
1634const FI_NF: i64 = 7 // rival|name|seeds_hit|mentions|first_seed|link|kind (nx_field_lib fl_emit)
1635const FI_SPLIT: i64 = 12
1636const FI_F_TAG: i64 = 0
1637const FI_F_NAME: i64 = 1
1638const FI_F_SEEDS: i64 = 2
1639const FI_F_MENTIONS: i64 = 3
1640const FI_F_FIRST: i64 = 4
1641const FI_F_LINK: i64 = 5
1642const FI_F_KIND: i64 = 6
1643const FI_SHOW: i64 = 60 // rows rendered; the rest are COUNTED and the stats line says shown of count
1644const FI_COLS_MAX: i64 = 16
1645const FI_CH_COMMENT: i64 = 35
1646const FI_CH_LF: i64 = 10
1647const FI_CH_PIPE: i64 = 124
1648const FI_CH_COMMA: i64 = 44
1649const FI_CH_COLON: i64 = 58
1650const FI_CH_LBRACE: i64 = 123
1651const FI_CH_RBRACE: i64 = 125
1652const FI_CH_LBRACKET: i64 = 91
1653const FI_CH_RBRACKET: i64 = 93
1654const FI_UPPER_A: i64 = 65
1655const FI_UPPER_Z: i64 = 90
1656const FI_CASE_DELTA: i64 = 32
1657func fi_lc(c: i64) -> i64 { if c >= FI_UPPER_A { if c <= FI_UPPER_Z { return c + FI_CASE_DELTA } } return c }
1658// case-insensitive: does hay contain needle (needle non-empty)?
1659func fi_ci_contains(hay: *u8, needle: *u8) -> i64 {
1660 var nl: i64 = 0
1661 while needle[nl] != (0 as u8) { nl = nl + 1 }
1662 if nl < 1 { return 0 }
1663 var hl: i64 = 0
1664 while hay[hl] != (0 as u8) { hl = hl + 1 }
1665 var i: i64 = 0
1666 while i + nl <= hl {
1667 var m: i64 = 0
1668 var j: i64 = 0
1669 while j < nl { if fi_lc(hay[i + j] as i64) == fi_lc(needle[j] as i64) { m = m + 1 } j = j + 1 }
1670 if m == nl { return 1 }
1671 i = i + 1
1672 }
1673 return 0
1674}
1675// the leading words of a column label (up to the first space) -- "Blender 4.5 plus addons" matches a rival named Blender
1676func fi_head_word(col: *u8, out: *u8, cap: i64) -> i64 {
1677 var i: i64 = 0
1678 while col[i] != (0 as u8) { if col[i] == (32 as u8) { break } if i < cap - 1 { out[i] = col[i] } i = i + 1 }
1679 if i > cap - 1 { i = cap - 1 }
1680 out[i] = 0 as u8
1681 return i
1682}
1683// colv/ncols: the matrix generator's ALREADY-SPLIT @cols vector (one owner of the split); the sota generator passes 0/0.
1684func field_pass(dom: *u8, fd: i64, mode: i64, colv: *i64, ncols_in: i64) -> i64 { return field_pass_heading(dom, fd, mode, colv, ncols_in, 2) }
1685func field_pass_heading(dom: *u8, fd: i64, mode: i64, colv: *i64, ncols_in: i64, heading_level: i64) -> i64 {
1686 let path: *u8 = sys_mmap(FI_PATH_CAP)
1687 var o: i64 = scopy(path, 0, "knowledge/compare/" as *u8)
1688 o = scopy(path, o, dom); o = scopy(path, o, ".field" as *u8); path[o] = 0 as u8
1689 let buf: *u8 = sys_mmap(FI_READ_CAP)
1690 let n: i64 = c_read(path, buf, FI_READ_CAP - 1)
1691 if n <= 0 { return 0 }
1692 var capped: i64 = 0
1693 if n >= FI_READ_CAP - 1 { capped = 1 }
1694 buf[n] = 0 as u8
1695 var ncols: i64 = ncols_in
1696 if ncols > FI_COLS_MAX { ncols = FI_COLS_MAX }
1697 if ncols < 0 { ncols = 0 }
1698 let colhit: *i64 = sys_mmap(FI_COLS_MAX * FI_I64_BYTES) as *i64
1699 let head: *u8 = sys_mmap(FI_PATH_CAP)
1700 let fld: *i64 = sys_mmap(FI_SPLIT * FI_I64_BYTES) as *i64
1701 var summary: *u8 = "" as *u8
1702 var rows: i64 = 0
1703 var shown: i64 = 0
1704 var malformed: i64 = 0
1705 var p: i64 = 0
1706 // pass 1: the summary row and the column coverage (every row, never a prefix)
1707 while p < n {
1708 var e: i64 = p
1709 while e < n { if buf[e] == (FI_CH_LF as u8) { break } e = e + 1 }
1710 buf[e] = 0 as u8
1711 let line: *u8 = (buf as i64 + p) as *u8
1712 p = e + 1
1713 if line[0] != (FI_CH_COMMENT as u8) { if line[0] != (0 as u8) {
1714 if starts(line, "field|" as *u8) == 1 { summary = line } else {
1715 let nf: i64 = splitpipe(line, fld, FI_SPLIT)
1716 var ok: i64 = 0
1717 if nf >= FI_NF { if streq(fld[FI_F_TAG] as *u8, "rival" as *u8) == 1 { ok = 1 } }
1718 if ok == 0 { malformed = malformed + 1 } else {
1719 rows = rows + 1
1720 var c: i64 = 0
1721 while c < ncols {
1722 if colhit[c] == 0 {
1723 fi_head_word(colv[c] as *u8, head, FI_PATH_CAP)
1724 if fi_ci_contains(fld[FI_F_NAME] as *u8, head) == 1 { colhit[c] = 1 }
1725 }
1726 c = c + 1
1727 }
1728 }
1729 }
1730 } }
1731 }
1732 var cols_in: i64 = 0
1733 var c2: i64 = 0
1734 while c2 < ncols { if colhit[c2] == 1 { cols_in = cols_in + 1 } c2 = c2 + 1 }
1735 // pass 2: render (re-read, because splitpipe NUL-terminates in place)
1736 let n2: i64 = c_read(path, buf, FI_READ_CAP - 1)
1737 buf[n2] = 0 as u8
1738 if mode == 2 {
1739 wc(fd, FI_CH_COMMA); wq(fd); w(fd, "field" as *u8); wq(fd); wc(fd, FI_CH_COLON); wc(fd, FI_CH_LBRACE)
1740 kv_s(fd, "file" as *u8, path); wc(fd, FI_CH_COMMA)
1741 kv_s(fd, "writer" as *u8, "nx_field_discover" as *u8); wc(fd, FI_CH_COMMA)
1742 kv_s(fd, "summary" as *u8, summary); wc(fd, FI_CH_COMMA)
1743 kv_n(fd, "columns" as *u8, ncols); wc(fd, FI_CH_COMMA)
1744 kv_n(fd, "columns_in_field" as *u8, cols_in); wc(fd, FI_CH_COMMA)
1745 wq(fd); w(fd, "rows" as *u8); wq(fd); wc(fd, FI_CH_COLON); wc(fd, FI_CH_LBRACKET)
1746 }
1747 if mode == 1 {
1748 sc_heading_open(fd, heading_level, " id='field'" as *u8); w(fd, "The field — discovered, not chosen" as *u8); sc_heading_close(fd, heading_level); w(fd, "\n" as *u8)
1749 if capped == 1 { w(fd, "<div class='meth'>field artefact READ-CAPPED at " as *u8); wn(fd, FI_READ_CAP); w(fd, " bytes — the rows below are a PREFIX of the file</div>\n" as *u8) }
1750 w(fd, "<p class='lead'>Rows written by <code>nx_field_discover</code> from <code>" as *u8); wnote(fd, dom); w(fd, ".seeds</code>: the industry's own lists (Wikipedia wikitext, GitHub topics, awesome lists) read mechanically, every candidate counted across seeds. The matrix columns above are a SEAT'S pick; this band is the population they were picked from, and the stats line measures one against the other. A rival here is a lead, never a verdict — it earns a column when its capabilities are read and pinned.</p>\n" as *u8)
1751 w(fd, "<div class='meth'><code>" as *u8); wnote(fd, summary); w(fd, "</code></div>\n" as *u8)
1752 sc_plan_table_open(fd, "Competitor field" as *u8); w(fd, "<thead><tr><th>Rank</th><th>Rival</th><th>Seeds</th><th>Mentions</th><th>First seed</th><th>Kind</th><th>Link</th></tr></thead><tbody>\n" as *u8)
1753 }
1754 var p2: i64 = 0
1755 var rank: i64 = 0
1756 while p2 < n2 {
1757 var e: i64 = p2
1758 while e < n2 { if buf[e] == (FI_CH_LF as u8) { break } e = e + 1 }
1759 buf[e] = 0 as u8
1760 let line: *u8 = (buf as i64 + p2) as *u8
1761 p2 = e + 1
1762 if line[0] != (FI_CH_COMMENT as u8) { if line[0] != (0 as u8) { if starts(line, "rival|" as *u8) == 1 {
1763 let nf: i64 = splitpipe(line, fld, FI_SPLIT)
1764 if nf >= FI_NF { if shown < FI_SHOW {
1765 rank = rank + 1
1766 shown = shown + 1
1767 if mode == 1 {
1768 w(fd, "<tr><td class='ct'>" as *u8); wn(fd, rank); w(fd, "</td><td><b>" as *u8); wnote(fd, fld[FI_F_NAME] as *u8)
1769 w(fd, "</b></td><td class='ct'>" as *u8); wnote(fd, fld[FI_F_SEEDS] as *u8); w(fd, "</td><td class='ct'>" as *u8); wnote(fd, fld[FI_F_MENTIONS] as *u8)
1770 w(fd, "</td><td class='ct'>" as *u8); wnote(fd, fld[FI_F_FIRST] as *u8); w(fd, "</td><td class='ct'>" as *u8); wnote(fd, fld[FI_F_KIND] as *u8)
1771 w(fd, "</td><td class='ct'>" as *u8); wnote(fd, fld[FI_F_LINK] as *u8); w(fd, "</td></tr>\n" as *u8)
1772 }
1773 if mode == 2 {
1774 if shown > 1 { wc(fd, FI_CH_COMMA) }
1775 wc(fd, FI_CH_LBRACE)
1776 kv_s(fd, "name" as *u8, fld[FI_F_NAME] as *u8); wc(fd, FI_CH_COMMA)
1777 kv_s(fd, "seeds" as *u8, fld[FI_F_SEEDS] as *u8); wc(fd, FI_CH_COMMA)
1778 kv_s(fd, "mentions" as *u8, fld[FI_F_MENTIONS] as *u8); wc(fd, FI_CH_COMMA)
1779 kv_s(fd, "first_seed" as *u8, fld[FI_F_FIRST] as *u8); wc(fd, FI_CH_COMMA)
1780 kv_s(fd, "link" as *u8, fld[FI_F_LINK] as *u8); wc(fd, FI_CH_COMMA)
1781 kv_s(fd, "kind" as *u8, fld[FI_F_KIND] as *u8)
1782 wc(fd, FI_CH_RBRACE)
1783 }
1784 } }
1785 } } }
1786 }
1787 if mode == 1 {
1788 sc_plan_table_close(fd); w(fd, "\n<p class='stats'>field candidates <b>" as *u8); wn(fd, rows); w(fd, "</b><span class='sep'>|</span>shown <b>" as *u8); wn(fd, shown)
1789 w(fd, "</b> of " as *u8); wn(fd, rows); w(fd, "<span class='sep'>|</span>matrix columns in the field <b>" as *u8); wn(fd, cols_in); w(fd, "</b> of " as *u8); wn(fd, ncols)
1790 w(fd, "<span class='sep'>|</span>discovered rivals with no column <b>" as *u8); wn(fd, rows - cols_in); w(fd, "</b><span class='sep'>|</span>malformed rows <b>" as *u8); wn(fd, malformed)
1791 w(fd, "</b> (counted, never rendered)<span class='sep'>|</span>read-capped <b>" as *u8); wn(fd, capped); w(fd, "</b></p>\n" as *u8)
1792 }
1793 if mode == 2 {
1794 wc(fd, FI_CH_RBRACKET); wc(fd, FI_CH_COMMA)
1795 kv_n(fd, "count" as *u8, rows); wc(fd, FI_CH_COMMA)
1796 kv_n(fd, "shown" as *u8, shown); wc(fd, FI_CH_COMMA)
1797 kv_n(fd, "no_column" as *u8, rows - cols_in); wc(fd, FI_CH_COMMA)
1798 kv_n(fd, "malformed" as *u8, malformed); wc(fd, FI_CH_COMMA)
1799 kv_n(fd, "read_capped" as *u8, capped)
1800 wc(fd, FI_CH_RBRACE)
1801 }
1802 return rows
1803}
1804// ---- GAUGE HEARTBEATS (codeeffectiveness CE9, 2026-09-06): A GAUGE CELL THAT READS STALE, NEVER ZERO ----
1805// <dom>.gauge rows: gauge|<label>|<stamp-path>|<cadence_s>|<note> (cadence_s 0 = take it from the stamp)
1806// WHY THIS IS IN THE BASE. The estate paid once for its effectiveness gauge going dark for 28 days and reading as
1807// "no movement": a number with no heartbeat is a claim with an expiry date nobody recorded. Every gauge row here is
1808// re-judged on every publish by THE ONE ruler the writing beat also uses (nx_gauge_lib.ga_judge), so the page and the
1809// beat cannot disagree: FRESH shows the value, STALE withholds it (age beyond two beats), BLIND withholds it (an axis
1810// abstained), ABSENT means nothing has measured. In api.json the "gauge" value key exists ONLY on a FRESH row -- a
1811// consumer that reads a missing key as zero is the defect this pass exists to make impossible on the page.
1812const GP_PATH_CAP: i64 = 600
1813const GP_READ_CAP: i64 = 65536
1814const GP_SPLIT: i64 = 8
1815const GP_NF: i64 = 5
1816const GP_F_LABEL: i64 = 1
1817const GP_F_PATH: i64 = 2
1818const GP_F_CAD: i64 = 3
1819const GP_F_NOTE: i64 = 4
1820const GP_ROW_CAP: i64 = 1024
1821const GP_CH_NL: i64 = 10
1822const GP_CH_HASH: i64 = 35
1823const GP_CH_COMMA: i64 = 44
1824const GP_CH_COLON: i64 = 58
1825const GP_CH_LBRACKET: i64 = 91
1826const GP_CH_RBRACKET: i64 = 93
1827const GP_CH_LBRACE: i64 = 123
1828const GP_CH_RBRACE: i64 = 125
1829func gauge_pass(dom: *u8, fd: i64, mode: i64) -> i64 { return gauge_pass_heading(dom, fd, mode, 2) }
1830func gauge_pass_heading(dom: *u8, fd: i64, mode: i64, heading_level: i64) -> i64 {
1831 let path: *u8 = sys_mmap(GP_PATH_CAP)
1832 var o: i64 = scopy(path, 0, "knowledge/compare/" as *u8)
1833 o = scopy(path, o, dom); o = scopy(path, o, ".gauge" as *u8); path[o] = 0 as u8
1834 let buf: *u8 = sys_mmap(GP_READ_CAP)
1835 let n: i64 = c_read(path, buf, GP_READ_CAP - 1)
1836 if n <= 0 { return 0 }
1837 var capped: i64 = 0
1838 if n >= GP_READ_CAP - 1 { capped = 1 }
1839 let now: i64 = sys_now_realtime_sec()
1840 let fld: *i64 = sys_mmap(GP_SPLIT * GA_WORD) as *i64
1841 let f: *i64 = sys_mmap(GA_F_SLOTS * GA_WORD) as *i64
1842 let rb: *u8 = sys_mmap(GP_ROW_CAP)
1843 var rows: i64 = 0
1844 var malformed: i64 = 0
1845 var c_fresh: i64 = 0
1846 var c_stale: i64 = 0
1847 var c_blind: i64 = 0
1848 var c_absent: i64 = 0
1849 if mode == 2 {
1850 wc(fd, GP_CH_COMMA); wq(fd); w(fd, "gauge" as *u8); wq(fd); wc(fd, GP_CH_COLON); wc(fd, GP_CH_LBRACE)
1851 kv_s(fd, "file" as *u8, path); wc(fd, GP_CH_COMMA)
1852 kv_s(fd, "reader" as *u8, "nx_gauge_lib" as *u8); wc(fd, GP_CH_COMMA)
1853 kv_n(fd, "now" as *u8, now); wc(fd, GP_CH_COMMA)
1854 wq(fd); w(fd, "rows" as *u8); wq(fd); wc(fd, GP_CH_COLON); wc(fd, GP_CH_LBRACKET)
1855 }
1856 if mode == 1 {
1857 sc_heading_open(fd, heading_level, " id='gauge'" as *u8); w(fd, "Gauges — a heartbeat, never a bare number" as *u8); sc_heading_close(fd, heading_level); w(fd, "\n" as *u8)
1858 if capped == 1 { w(fd, "<div class='meth'>gauge artefact READ-CAPPED at " as *u8); wn(fd, GP_READ_CAP); w(fd, " bytes — the rows below are a PREFIX of the file</div>\n" as *u8) }
1859 w(fd, "<p class='lead'>Each row names a gauge stamp written by its measuring beat. This page re-judges the stamp on every publish with the same ruler the beat uses (<code>nx_gauge_lib</code>): <b>FRESH</b> shows the value; <b>STALE</b> withholds it (older than two beats); <b>BLIND</b> withholds it (an axis abstained); <b>ABSENT</b> means nothing has measured. A stale gauge never reads as zero.</p>\n" as *u8)
1860 w(fd, "<table class='gauge-tab'><thead><tr><th>gauge</th><th>state</th><th>reading</th><th>note</th></tr></thead><tbody>\n" as *u8)
1861 }
1862 var p: i64 = 0
1863 while p < n {
1864 var e: i64 = p
1865 while e < n { if buf[e] == (GP_CH_NL as u8) { break } e = e + 1 }
1866 buf[e] = 0 as u8
1867 let line: *u8 = (buf as i64 + p) as *u8
1868 p = e + 1
1869 if line[0] != (GP_CH_HASH as u8) { if line[0] != (0 as u8) { if starts(line, "gauge|" as *u8) == 1 {
1870 let nf: i64 = splitpipe(line, fld, GP_SPLIT)
1871 if nf < GP_NF { malformed = malformed + 1 } else {
1872 let cs: *u8 = fld[GP_F_CAD] as *u8
1873 let cad: i64 = sj_atoi_span(cs, 0, sj_vlen(cs))
1874 // RESOLVE BEFORE JUDGING (2026-09-06): the regen runs with CWD=buildroot while every beat stamps from the serving root, so a
1875 // bare stamp path read ABSENT on the page for a stamp FRESH on disk (measured: knowledge/status/stepsolve.stamp 66 B at the
1876 // root, absent under buildroot). ep_artifact_path is the ONE probe order; an absent stamp still judges ABSENT through the same ruler.
1877 let gpath: *u8 = sys_mmap(GP_PATH_CAP)
1878 if ep_artifact_path(gpath, fld[GP_F_PATH] as *u8) == 0 { let go: i64 = scopy(gpath, 0, fld[GP_F_PATH] as *u8); gpath[go] = 0 as u8 }
1879 let st: i64 = ga_judge(gpath, now, cad, f)
1880 var age: i64 = 0 - 1
1881 if f[GA_F_TS] > 0 { age = now - f[GA_F_TS] }
1882 var mcad: i64 = cad
1883 if mcad <= 0 { mcad = f[GA_F_CADENCE] }
1884 let rl: i64 = ga_render(rb, 0, st, age, ga_max_age(mcad), f[GA_F_GAUGE], f[GA_F_KNOWN], f[GA_F_TOTAL])
1885 rb[rl] = 0 as u8
1886 if st == GA_FRESH { c_fresh = c_fresh + 1 }
1887 if st == GA_STALE { c_stale = c_stale + 1 }
1888 if st == GA_BLIND { c_blind = c_blind + 1 }
1889 if st == GA_ABSENT { c_absent = c_absent + 1 }
1890 if mode == 1 {
1891 w(fd, "<tr><td><b>" as *u8); wnote(fd, fld[GP_F_LABEL] as *u8); w(fd, "</b></td><td class='ct'>" as *u8); w(fd, ga_state_name(st))
1892 w(fd, "</td><td class='ct'>" as *u8); wnote(fd, rb); w(fd, "</td><td>" as *u8); wnote(fd, fld[GP_F_NOTE] as *u8); w(fd, "</td></tr>\n" as *u8)
1893 }
1894 if mode == 2 {
1895 if rows > 0 { wc(fd, GP_CH_COMMA) }
1896 wc(fd, GP_CH_LBRACE)
1897 kv_s(fd, "label" as *u8, fld[GP_F_LABEL] as *u8); wc(fd, GP_CH_COMMA)
1898 kv_s(fd, "stamp" as *u8, fld[GP_F_PATH] as *u8); wc(fd, GP_CH_COMMA)
1899 kv_s(fd, "state" as *u8, ga_state_name(st)); wc(fd, GP_CH_COMMA)
1900 kv_n(fd, "age_s" as *u8, age); wc(fd, GP_CH_COMMA)
1901 kv_n(fd, "max_age_s" as *u8, ga_max_age(mcad)); wc(fd, GP_CH_COMMA)
1902 kv_n(fd, "axes_known" as *u8, f[GA_F_KNOWN]); wc(fd, GP_CH_COMMA)
1903 kv_n(fd, "axes_total" as *u8, f[GA_F_TOTAL]); wc(fd, GP_CH_COMMA)
1904 if st == GA_FRESH { kv_n(fd, "gauge" as *u8, f[GA_F_GAUGE]); wc(fd, GP_CH_COMMA) }
1905 kv_s(fd, "reading" as *u8, rb); wc(fd, GP_CH_COMMA)
1906 kv_s(fd, "note" as *u8, fld[GP_F_NOTE] as *u8)
1907 wc(fd, GP_CH_RBRACE)
1908 }
1909 rows = rows + 1
1910 }
1911 } } }
1912 }
1913 if mode == 2 {
1914 wc(fd, GP_CH_RBRACKET); wc(fd, GP_CH_COMMA)
1915 kv_n(fd, "count" as *u8, rows); wc(fd, GP_CH_COMMA)
1916 kv_n(fd, "fresh" as *u8, c_fresh); wc(fd, GP_CH_COMMA)
1917 kv_n(fd, "stale" as *u8, c_stale); wc(fd, GP_CH_COMMA)
1918 kv_n(fd, "blind" as *u8, c_blind); wc(fd, GP_CH_COMMA)
1919 kv_n(fd, "absent" as *u8, c_absent); wc(fd, GP_CH_COMMA)
1920 kv_n(fd, "malformed" as *u8, malformed); wc(fd, GP_CH_COMMA)
1921 kv_n(fd, "read_capped" as *u8, capped)
1922 wc(fd, GP_CH_RBRACE)
1923 }
1924 if mode == 1 {
1925 w(fd, "</tbody></table>\n<p class='stats'>gauges <b>" as *u8); wn(fd, rows)
1926 w(fd, "</b><span class='sep'>|</span>fresh <b>" as *u8); wn(fd, c_fresh); w(fd, "</b><span class='sep'>|</span>stale <b>" as *u8); wn(fd, c_stale)
1927 w(fd, "</b><span class='sep'>|</span>blind <b>" as *u8); wn(fd, c_blind); w(fd, "</b><span class='sep'>|</span>absent <b>" as *u8); wn(fd, c_absent)
1928 w(fd, "</b> (partition sums)<span class='sep'>|</span>malformed rows <b>" as *u8); wn(fd, malformed); w(fd, "</b> (counted, never rendered)</p>\n" as *u8)
1929 }
1930 return rows
1931}
1932// ---- GAPS FROM THE RECORD (ecosystem EC38, 2026-09-06) ------------------------------------------------------
1933// Renders the record census (nx_goalmap record): organs the estate invokes and directives its own plan queue rows
1934// name that NO board row carries. The feed is the plane's own bytes written beside the conf by the same run
1935// (knowledge/recordgaps.conf.rows), resolved through ep_artifact_path like every status artifact, and its freshness
1936// is judged from the sibling stamp with the ONE gauge ruler: a stale census renders its rows under a STALE state
1937// and a BLIND one says how many declared sources are still unread; neither ever reads as "no gaps".
1938// Per board: this board's own directive rows (board == dom) always; the estate-wide UNASSIGNED organs in full on
1939// the ecosystem hub and as a COUNT everywhere else (hundreds of rows on every page would be the site saying one
1940// thing a hundred times). mode 1 = HTML section, mode 2 = api.json object. Absent feed = no section, returns 0.
1941const GX_FEED: *u8 = "knowledge/recordgaps.conf.rows"
1942const GX_STAMP: *u8 = "knowledge/recordgaps.conf.stamp"
1943const GX_READ_CAP: i64 = 4194304
1944const GX_NF: i64 = 5
1945const GX_F_KIND: i64 = 0
1946const GX_F_NAME: i64 = 1
1947const GX_F_BOARD: i64 = 2
1948const GX_F_SRC: i64 = 3
1949const GX_F_EV: i64 = 4
1950const GX_HUB: *u8 = "ecosystem"
1951const GX_UNASSIGNED: *u8 = "UNASSIGNED"
1952func gaps_pass(dom: *u8, fd: i64, mode: i64) -> i64 { return gaps_pass_heading(dom, fd, mode, 2) }
1953func gaps_pass_heading(dom: *u8, fd: i64, mode: i64, heading_level: i64) -> i64 {
1954 let path: *u8 = sys_mmap(GP_PATH_CAP)
1955 if ep_artifact_path(path, GX_FEED) == 0 { return 0 }
1956 let buf: *u8 = sys_mmap(GX_READ_CAP)
1957 let n: i64 = c_read(path, buf, GX_READ_CAP - 1)
1958 if n <= 0 { return 0 }
1959 var capped: i64 = 0
1960 if n >= GX_READ_CAP - 1 { capped = 1 }
1961 let now: i64 = sys_now_realtime_sec()
1962 let spath: *u8 = sys_mmap(GP_PATH_CAP)
1963 if ep_artifact_path(spath, GX_STAMP) == 0 { let so: i64 = scopy(spath, 0, GX_STAMP); spath[so] = 0 as u8 }
1964 let f: *i64 = sys_mmap(GA_F_SLOTS * GA_WORD) as *i64
1965 var st: i64 = ga_judge(spath, now, 0, f)
1966 if f[GA_F_CADENCE] > 0 { st = ga_judge(spath, now, f[GA_F_CADENCE], f) }
1967 var age: i64 = 0 - 1
1968 if f[GA_F_TS] > 0 { age = now - f[GA_F_TS] }
1969 let fld: *i64 = sys_mmap(GP_SPLIT * GA_WORD) as *i64
1970 var hub: i64 = 0
1971 if streq(dom, GX_HUB) == 1 { hub = 1 }
1972 var total: i64 = 0
1973 var own: i64 = 0
1974 var unassigned: i64 = 0
1975 var malformed: i64 = 0
1976 var shown: i64 = 0
1977 if mode == 2 {
1978 wc(fd, GP_CH_COMMA); wq(fd); w(fd, "gaps" as *u8); wq(fd); wc(fd, GP_CH_COLON); wc(fd, GP_CH_LBRACE)
1979 kv_s(fd, "feed" as *u8, path); wc(fd, GP_CH_COMMA)
1980 kv_s(fd, "stamp" as *u8, spath); wc(fd, GP_CH_COMMA)
1981 kv_s(fd, "state" as *u8, ga_state_name(st)); wc(fd, GP_CH_COMMA)
1982 kv_n(fd, "age_s" as *u8, age); wc(fd, GP_CH_COMMA)
1983 kv_n(fd, "sources_read" as *u8, f[GA_F_KNOWN]); wc(fd, GP_CH_COMMA)
1984 kv_n(fd, "sources_declared" as *u8, f[GA_F_TOTAL]); wc(fd, GP_CH_COMMA)
1985 kv_n(fd, "hub" as *u8, hub); wc(fd, GP_CH_COMMA)
1986 wq(fd); w(fd, "rows" as *u8); wq(fd); wc(fd, GP_CH_COLON); wc(fd, GP_CH_LBRACKET)
1987 }
1988 if mode == 1 {
1989 sc_heading_open(fd, heading_level, " id='gaps'" as *u8); w(fd, "Gaps from the record — what the estate does that no board carries" as *u8); sc_heading_close(fd, heading_level); w(fd, "\n" as *u8)
1990 w(fd, "<p class='lead'>The record census (<code>nx_goalmap record</code>) reads the invoked-tool population and every plan queue row and files each organ or directive that NO matrix, plan or gates row names. A row here is a callout the boards missed: adjudicate it onto a board or declare it infrastructure. Census state <b>" as *u8)
1991 w(fd, ga_state_name(st)); w(fd, "</b>" as *u8)
1992 if age >= 0 { w(fd, " (age " as *u8); wn(fd, age); w(fd, " s)" as *u8) }
1993 w(fd, ", sources read <b>" as *u8); wn(fd, f[GA_F_KNOWN]); w(fd, "</b> of <b>" as *u8); wn(fd, f[GA_F_TOTAL])
1994 w(fd, "</b> declared — a BLIND census is a FLOOR: unread sources can only add rows.</p>\n" as *u8)
1995 if capped == 1 { w(fd, "<div class='meth'>feed READ-CAPPED at " as *u8); wn(fd, GX_READ_CAP); w(fd, " bytes — the rows below are a PREFIX of the file</div>\n" as *u8) }
1996 w(fd, "<table class='gaps-tab'><thead><tr><th>kind</th><th>name</th><th>board</th><th>source</th><th>evidence</th></tr></thead><tbody>\n" as *u8)
1997 }
1998 var p: i64 = 0
1999 while p < n {
2000 var e: i64 = p
2001 while e < n { if buf[e] == (GP_CH_NL as u8) { break } e = e + 1 }
2002 buf[e] = 0 as u8
2003 let line: *u8 = (buf as i64 + p) as *u8
2004 p = e + 1
2005 if line[0] != (GP_CH_HASH as u8) { if line[0] != (0 as u8) {
2006 let nf: i64 = splitpipe(line, fld, GP_SPLIT)
2007 if nf < GX_NF { malformed = malformed + 1 } else {
2008 total = total + 1
2009 var render: i64 = 0
2010 if streq(fld[GX_F_BOARD] as *u8, dom) == 1 { own = own + 1; render = 1 }
2011 if streq(fld[GX_F_BOARD] as *u8, GX_UNASSIGNED) == 1 { unassigned = unassigned + 1; if hub == 1 { render = 1 } }
2012 if render == 1 {
2013 if mode == 1 {
2014 w(fd, "<tr><td class='ct'>" as *u8); wnote(fd, fld[GX_F_KIND] as *u8); w(fd, "</td><td><code>" as *u8); wnote(fd, fld[GX_F_NAME] as *u8)
2015 w(fd, "</code></td><td class='ct'>" as *u8); wnote(fd, fld[GX_F_BOARD] as *u8); w(fd, "</td><td class='ct'>" as *u8); wnote(fd, fld[GX_F_SRC] as *u8)
2016 w(fd, "</td><td>" as *u8); wnote(fd, fld[GX_F_EV] as *u8); w(fd, "</td></tr>\n" as *u8)
2017 }
2018 if mode == 2 {
2019 if shown > 0 { wc(fd, GP_CH_COMMA) }
2020 wc(fd, GP_CH_LBRACE)
2021 kv_s(fd, "kind" as *u8, fld[GX_F_KIND] as *u8); wc(fd, GP_CH_COMMA)
2022 kv_s(fd, "name" as *u8, fld[GX_F_NAME] as *u8); wc(fd, GP_CH_COMMA)
2023 kv_s(fd, "board" as *u8, fld[GX_F_BOARD] as *u8); wc(fd, GP_CH_COMMA)
2024 kv_s(fd, "source" as *u8, fld[GX_F_SRC] as *u8); wc(fd, GP_CH_COMMA)
2025 kv_s(fd, "evidence" as *u8, fld[GX_F_EV] as *u8)
2026 wc(fd, GP_CH_RBRACE)
2027 }
2028 shown = shown + 1
2029 }
2030 }
2031 } }
2032 }
2033 if mode == 2 {
2034 wc(fd, GP_CH_RBRACKET); wc(fd, GP_CH_COMMA)
2035 kv_n(fd, "shown" as *u8, shown); wc(fd, GP_CH_COMMA)
2036 kv_n(fd, "own" as *u8, own); wc(fd, GP_CH_COMMA)
2037 kv_n(fd, "estate_unassigned" as *u8, unassigned); wc(fd, GP_CH_COMMA)
2038 kv_n(fd, "total" as *u8, total); wc(fd, GP_CH_COMMA)
2039 kv_n(fd, "malformed" as *u8, malformed); wc(fd, GP_CH_COMMA)
2040 kv_n(fd, "read_capped" as *u8, capped)
2041 wc(fd, GP_CH_RBRACE)
2042 }
2043 if mode == 1 {
2044 w(fd, "</tbody></table>\n<p class='stats'>rows shown <b>" as *u8); wn(fd, shown)
2045 w(fd, "</b><span class='sep'>|</span>this board's directives <b>" as *u8); wn(fd, own)
2046 w(fd, "</b><span class='sep'>|</span>estate-wide un-boarded organs <b>" as *u8); wn(fd, unassigned)
2047 if hub == 0 { w(fd, "</b> (listed in full on <a href='/compare/ecosystem'>/compare/ecosystem</a>)<span class='sep'>|</span>census rows <b>" as *u8) } else { w(fd, "</b><span class='sep'>|</span>census rows <b>" as *u8) }
2048 wn(fd, total); w(fd, "</b><span class='sep'>|</span>malformed <b>" as *u8); wn(fd, malformed); w(fd, "</b> (counted, never rendered)</p>\n" as *u8)
2049 }
2050 return shown
2051}
2052func bench_pass(dom: *u8, fd: i64, mode: i64) -> i64 { return bench_pass_heading(dom, fd, mode, 2) }
2053func bench_pass_heading(dom: *u8, fd: i64, mode: i64, heading_level: i64) -> i64 {
2054 let path: *u8 = sys_mmap(600)
2055 var o: i64 = scopy(path, 0, "knowledge/compare/" as *u8)
2056 o = scopy(path, o, dom); o = scopy(path, o, ".bench" as *u8); path[o] = 0 as u8
2057 let hdr: *i64 = sys_mmap(BR_H_N * 8) as *i64
2058 let arms: *i64 = sys_mmap(BR_MAXARMS * BR_STRIDE * 8) as *i64
2059 let n: i64 = br_load(path, hdr, arms)
2060 if n < 0 { return 0 }
2061 let verdict: i64 = br_verdict(hdr, arms, n)
2062 let written: i64 = hdr[BR_H_WRITTEN_VERDICT]
2063 var agree: i64 = 0
2064 if written == verdict { agree = 1 }
2065 var c_valid: i64 = 0; var c_void: i64 = 0; var c_unm: i64 = 0; var c_bf: i64 = 0; var c_rf: i64 = 0; var c_unk: i64 = 0
2066 var i: i64 = 0
2067 while i < n {
2068 let st: i64 = arms[i * BR_STRIDE + BR_A_STATUS]
2069 if st == BR_ST_VALID { c_valid = c_valid + 1 } else { if st == BR_ST_VOID { c_void = c_void + 1 } else {
2070 if st == BR_ST_UNMEASURABLE { c_unm = c_unm + 1 } else { if st == BR_ST_BUILDFAIL { c_bf = c_bf + 1 } else {
2071 if st == BR_ST_RUNFAIL { c_rf = c_rf + 1 } else { c_unk = c_unk + 1 } } } } }
2072 i = i + 1
2073 }
2074 let ymd: *u8 = sys_mmap(32)
2075 bd_ymd(hdr[BR_H_ASOF], ymd, 0)
2076 let rt: *u8 = sys_mmap(32)
2077 if mode == 2 {
2078 wc(fd, 44); wq(fd); w(fd, "bench" as *u8); wq(fd); wc(fd, 58); wc(fd, 123)
2079 kv_s(fd, "file" as *u8, path); wc(fd, 44)
2080 kv_s(fd, "reader" as *u8, "nx_bench_receipt_lib" as *u8); wc(fd, 44)
2081 kv_s(fd, "writer" as *u8, hdr[BR_H_WRITER] as *u8); wc(fd, 44)
2082 kv_s(fd, "title" as *u8, hdr[BR_H_TITLE] as *u8); wc(fd, 44)
2083 kv_s(fd, "workload" as *u8, hdr[BR_H_WORKLOAD] as *u8); wc(fd, 44)
2084 kv_s(fd, "host" as *u8, hdr[BR_H_HOST] as *u8); wc(fd, 44)
2085 kv_n(fd, "runs" as *u8, hdr[BR_H_RUNS]); wc(fd, 44)
2086 kv_s(fd, "ref" as *u8, hdr[BR_H_REF] as *u8); wc(fd, 44)
2087 kv_n(fd, "asof" as *u8, hdr[BR_H_ASOF]); wc(fd, 44)
2088 kv_s(fd, "asof_ymd" as *u8, ymd); wc(fd, 44)
2089 kv_s(fd, "repro" as *u8, hdr[BR_H_REPRO] as *u8); wc(fd, 44)
2090 kv_s(fd, "verdict" as *u8, br_verdict_name(verdict)); wc(fd, 44)
2091 kv_s(fd, "written_verdict" as *u8, br_verdict_name(written)); wc(fd, 44)
2092 kv_n(fd, "writer_reader_agree" as *u8, agree); wc(fd, 44)
2093 kv_n(fd, "arms" as *u8, n); wc(fd, 44)
2094 kv_n(fd, "valid" as *u8, c_valid); wc(fd, 44); kv_n(fd, "void" as *u8, c_void); wc(fd, 44)
2095 kv_n(fd, "unmeasurable" as *u8, c_unm); wc(fd, 44); kv_n(fd, "build_fail" as *u8, c_bf); wc(fd, 44)
2096 kv_n(fd, "run_fail" as *u8, c_rf); wc(fd, 44); kv_n(fd, "unknown" as *u8, c_unk); wc(fd, 44)
2097 wq(fd); w(fd, "rows" as *u8); wq(fd); wc(fd, 58); wc(fd, 91)
2098 var j: i64 = 0
2099 while j < n {
2100 let b: i64 = j * BR_STRIDE
2101 if j > 0 { wc(fd, 44) }
2102 wc(fd, 123)
2103 kv_s(fd, "arm" as *u8, arms[b + BR_A_NAME] as *u8); wc(fd, 44)
2104 kv_s(fd, "toolchain" as *u8, arms[b + BR_A_TOOL] as *u8); wc(fd, 44)
2105 kv_s(fd, "version" as *u8, arms[b + BR_A_VER] as *u8); wc(fd, 44)
2106 kv_s(fd, "source" as *u8, arms[b + BR_A_SRC] as *u8); wc(fd, 44)
2107 kv_s(fd, "source_sha256" as *u8, arms[b + BR_A_SRCSHA] as *u8); wc(fd, 44)
2108 kv_n(fd, "bin_bytes" as *u8, arms[b + BR_A_BINBYTES]); wc(fd, 44)
2109 kv_s(fd, "bin_sha256" as *u8, arms[b + BR_A_BINSHA] as *u8); wc(fd, 44)
2110 kv_n(fd, "runs" as *u8, arms[b + BR_A_RUNS]); wc(fd, 44)
2111 kv_n(fd, "min_us" as *u8, arms[b + BR_A_MIN]); wc(fd, 44)
2112 kv_n(fd, "median_us" as *u8, arms[b + BR_A_MED]); wc(fd, 44)
2113 kv_n(fd, "checksum" as *u8, arms[b + BR_A_CHK]); wc(fd, 44)
2114 kv_s(fd, "status" as *u8, br_status_name(arms[b + BR_A_STATUS])); wc(fd, 44)
2115 kv_n(fd, "ratio_permil" as *u8, arms[b + BR_A_RATIO]); wc(fd, 44)
2116 kv_s(fd, "note" as *u8, arms[b + BR_A_NOTE] as *u8)
2117 wc(fd, 125)
2118 j = j + 1
2119 }
2120 wc(fd, 93)
2121 wc(fd, 125)
2122 return n
2123 }
2124 if mode == 1 {
2125 // scoped style so the section renders identically under both generators' sheets; theme vars with fallbacks
2126 w(fd, "<style>.bench-tab{width:100%;border-collapse:collapse;font-size:.84rem}.bench-tab th,.bench-tab td{text-align:left;padding:6px 8px;border-bottom:1px solid var(--line,rgb(60,64,72));vertical-align:top}.bench-tab th{font-size:.7rem;letter-spacing:.08em;text-transform:uppercase;color:var(--mut,rgb(150,162,186))}.bench-tab td.num{font-variant-numeric:tabular-nums;text-align:right;white-space:nowrap}.bench-tab code{font-family:ui-monospace,Consolas,monospace;font-size:.78rem}.bst{font-size:.66rem;letter-spacing:.08em;text-transform:uppercase;font-weight:650;padding:2px 8px;border-radius:8px;display:inline-block;white-space:nowrap;border:1px solid var(--line,rgb(60,64,72))}.bst.ok{color:var(--nx-color-ok,rgb(26,127,55))}.bst.void{color:var(--nx-color-absent,rgb(179,38,30))}.bst.unm{color:var(--mut,rgb(150,162,186))}.bst.fail{color:var(--nx-color-part,rgb(178,106,0))}.bench-repro{font-family:ui-monospace,Consolas,monospace;font-size:.78rem;background:var(--soft,rgb(40,46,64));padding:8px 10px;border-radius:8px;overflow-x:auto;white-space:pre}.bench-ref{font-weight:600}</style>\n" as *u8)
2127 sc_heading_open(fd, heading_level, " class='ghead' id='bench'" as *u8); w(fd, "Measured head-to-head — a receipt, not a claim" as *u8); sc_heading_close(fd, heading_level); w(fd, "\n<div class='meth'><b>" as *u8); wnote(fd, hdr[BR_H_TITLE] as *u8); w(fd, ".</b> " as *u8); wnote(fd, hdr[BR_H_WORKLOAD] as *u8)
2128 w(fd, " Measured on <code>" as *u8); wnote(fd, hdr[BR_H_HOST] as *u8); w(fd, "</code> on " as *u8); w(fd, ymd); w(fd, " (unix " as *u8); wn(fd, hdr[BR_H_ASOF]); w(fd, "), " as *u8); wn(fd, hdr[BR_H_RUNS]); w(fd, " runs per arm, reference arm <span class='bench-ref'>" as *u8); wnote(fd, hdr[BR_H_REF] as *u8)
2129 w(fd, "</span> = 1.00x. Every arm had to print the same checksum or its row is VOID and never ranked; an arm whose toolchain is not declared on the host is UNMEASURABLE, an absence rather than a loss. Written by <code>" as *u8); wnote(fd, hdr[BR_H_WRITER] as *u8); w(fd, "</code>, re-derived here by <code>nx_bench_receipt_lib</code>: reader verdict <span class='bst " as *u8)
2130 if verdict == BR_V_VALID { w(fd, "ok" as *u8) } else { if verdict == BR_V_VOID { w(fd, "void" as *u8) } else { w(fd, "unm" as *u8) } }
2131 w(fd, "'>" as *u8); w(fd, br_verdict_name(verdict)); w(fd, "</span>, writer wrote " as *u8); w(fd, br_verdict_name(written))
2132 if agree == 1 { w(fd, " (writer and reader agree)" as *u8) } else { w(fd, " (<b>WRITER AND READER DISAGREE</b> -- the rows were edited after the receipt was written)" as *u8) }
2133 w(fd, ".</div>\n<div style='overflow-x:auto'><table class='bench-tab'><thead><tr><th>Arm</th><th>Toolchain</th><th>Version</th><th>Median µs</th><th>Min µs</th><th>vs reference</th><th>Checksum</th><th>Status</th><th>Runs</th><th>Source sha256</th><th>Binary</th></tr></thead><tbody>\n" as *u8)
2134 var k: i64 = 0
2135 while k < n {
2136 let b: i64 = k * BR_STRIDE
2137 let st: i64 = arms[b + BR_A_STATUS]
2138 w(fd, "<tr><td><b>" as *u8); wnote(fd, arms[b + BR_A_NAME] as *u8); w(fd, "</b></td><td>" as *u8); wnote(fd, arms[b + BR_A_TOOL] as *u8)
2139 w(fd, "</td><td><code>" as *u8); wnote(fd, arms[b + BR_A_VER] as *u8); w(fd, "</code></td><td class='num'>" as *u8)
2140 if st == BR_ST_VALID { wn(fd, arms[b + BR_A_MED]) } else { w(fd, "-" as *u8) }
2141 w(fd, "</td><td class='num'>" as *u8)
2142 if st == BR_ST_VALID { wn(fd, arms[b + BR_A_MIN]) } else { w(fd, "-" as *u8) }
2143 w(fd, "</td><td class='num'>" as *u8)
2144 br_ratio_text(arms[b + BR_A_RATIO], rt, 0); w(fd, rt)
2145 w(fd, "</td><td class='num'>" as *u8)
2146 if st == BR_ST_VALID { wn(fd, arms[b + BR_A_CHK]) } else { if st == BR_ST_VOID { wn(fd, arms[b + BR_A_CHK]) } else { w(fd, "-" as *u8) } }
2147 w(fd, "</td><td><span class='bst " as *u8); w(fd, bd_status_class(st)); w(fd, "'>" as *u8); w(fd, br_status_name(st)); w(fd, "</span>" as *u8)
2148 if st != BR_ST_VALID { w(fd, "<br><span class='ct'>" as *u8); wnote(fd, arms[b + BR_A_NOTE] as *u8); w(fd, "</span>" as *u8) }
2149 w(fd, "</td><td class='num'>" as *u8); wn(fd, arms[b + BR_A_RUNS])
2150 w(fd, "</td><td><code title='" as *u8); wnote(fd, arms[b + BR_A_SRC] as *u8); w(fd, "'>" as *u8); bd_sha_short(fd, arms[b + BR_A_SRCSHA] as *u8); w(fd, "</code></td><td class='num'><code>" as *u8); bd_sha_short(fd, arms[b + BR_A_BINSHA] as *u8); w(fd, "</code> " as *u8); wn(fd, arms[b + BR_A_BINBYTES]); w(fd, " B</td></tr>\n" as *u8)
2151 k = k + 1
2152 }
2153 w(fd, "</tbody></table></div>\n<p class='foot'>bench arms=" as *u8); wn(fd, n); w(fd, " valid=" as *u8); wn(fd, c_valid); w(fd, " void=" as *u8); wn(fd, c_void); w(fd, " unmeasurable=" as *u8); wn(fd, c_unm); w(fd, " build_fail=" as *u8); wn(fd, c_bf); w(fd, " run_fail=" as *u8); wn(fd, c_rf); w(fd, " unknown=" as *u8); wn(fd, c_unk); w(fd, " (partition sums) verdict=" as *u8); w(fd, br_verdict_name(verdict)); w(fd, "</p>\n" as *u8)
2154 w(fd, "<p class='foot'>reproduce: </p><div class='bench-repro'>" as *u8); wnote(fd, hdr[BR_H_REPRO] as *u8); w(fd, "</div>\n<p class='foot'>receipt: knowledge/compare/" as *u8); w(fd, dom); w(fd, ".bench · a rerun on the same host that changes the ranking is a finding, not noise; a rerun on a different host is a different receipt and says so in its host line.</p>\n" as *u8)
2155 return n
2156 }
2157 return n
2158}
2159
2160// Additive shared dependency projection. Parsed declarations are not verified readiness.
2161// Owned by nx_swcompare_lib; no main, filesystem writes, publication or dispatch.
2162import "nx_sha256.nx"
2163const SGP_FIELDS: i64 = 8
2164const SGP_PATH_CAP: i64 = 600
2165const SGP_I64_MAX: i64 = 9223372036854775807
2166struct SgPlan {
2167 plan: *u8
2168 plan_bytes: i64
2169 plan_sha: *u8
2170 matrix_sha: *u8
2171 matrix_bytes: i64
2172 rank_sha: *u8
2173 rank_bytes: i64
2174 nodes: *i64
2175 count: i64
2176 declared: i64
2177 edges: *i64
2178 edge_count: i64
2179 malformed: i64
2180 duplicate_ids: i64
2181 duplicate_edges: i64
2182 missing_deps: i64
2183 cyclic_nodes: i64
2184 target_rows: i64
2185 role_rows: i64
2186 risk_rows: i64
2187 log_rows: i64
2188 rank_count: i64
2189 rank_mismatches: i64
2190 binding_rows: i64
2191 binding_ok: i64
2192 growth: *CgModel
2193}
2194func sg_len(s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { i = i + 1 } return i }
2195func sg_id(s: *u8, n: i64) -> i64 {
2196 if n <= 0 { return 0 }
2197 var i: i64 = 0
2198 while i < n {
2199 let c: i64 = s[i] as i64
2200 var ok: i64 = 0
2201 if c >= 48 { if c <= 57 { ok = 1 } }
2202 if c >= 65 { if c <= 90 { ok = 1 } }
2203 if c >= 97 { if c <= 122 { ok = 1 } }
2204 if c == 95 { ok = 1 }; if c == 45 { ok = 1 }
2205 if ok == 0 { return 0 }; i = i + 1
2206 }
2207 return 1
2208}
2209// Unlike splitpipe, count every field even when the caller's pointer reserve is full.
2210func sg_split(s: *u8, f: *i64, capacity: i64, delimiter: i64) -> i64 {
2211 var count: i64 = 1; var i: i64 = 0; f[0] = s as i64
2212 while s[i] != (0 as u8) {
2213 if s[i] == (delimiter as u8) { s[i] = 0 as u8; if count < capacity { f[count] = s as i64 + i + 1 }; count = count + 1 }
2214 i = i + 1
2215 }
2216 return count
2217}
2218func sg_decimal(s: *u8) -> i64 {
2219 if s[0] == (0 as u8) { return 0 - 1 }
2220 var v: i64 = 0; var i: i64 = 0
2221 while s[i] != (0 as u8) {
2222 let c: i64 = s[i] as i64; if c < 48 { return 0 - 1 }; if c > 57 { return 0 - 1 }
2223 let d: i64 = c - 48; if v > (SGP_I64_MAX - d) / 10 { return 0 - 1 }
2224 v = v * 10 + d; i = i + 1
2225 }
2226 return v
2227}
2228func sg_sha(b: *u8, n: i64) -> *u8 {
2229 let raw: *u8 = sys_mmap(32); let text: *u8 = sys_mmap(65)
2230 if (raw as i64) <= 0 { return "" as *u8 }; if (text as i64) <= 0 { return "" as *u8 }
2231 sha256_digest(b, n, raw)
2232 let digits: *u8 = "0123456789abcdef" as *u8
2233 var i: i64 = 0
2234 while i < 32 { let c: i64 = raw[i] as i64; text[i*2] = digits[c / 16]; text[i*2+1] = digits[c % 16]; i = i + 1 }
2235 text[64] = 0 as u8; return text
2236}
2237func sg_find(m: *SgPlan, name: *u8, length: i64) -> i64 {
2238 var i: i64 = 0
2239 while i < m.count {
2240 let id: *u8 = m.nodes[i*SGP_FIELDS + 1] as *u8
2241 if sg_len(id) == length {
2242 var j: i64 = 0; var equal: i64 = 1
2243 while j < length { if id[j] != name[j] { equal = 0 }; j = j + 1 }
2244 if equal == 1 { return i }
2245 }
2246 i = i + 1
2247 }
2248 return 0 - 1
2249}
2250func sg_prefix_decimal(s: *u8, key: *u8) -> i64 {
2251 if starts(s, key) == 0 { return 0 - 1 }
2252 return sg_decimal((s as i64 + sg_len(key)) as *u8)
2253}
2254func sg_rank(m: *SgPlan, raw: *u8, n: i64) -> i64 {
2255 m.rank_count = 0 - 1
2256 if n <= 0 { return 0 }
2257 if n == SGP_I64_MAX { m.rank_mismatches = m.rank_mismatches + 1; return 0 }
2258 m.rank_sha = sg_sha(raw, n); m.rank_bytes = n
2259 if sg_len(m.rank_sha) != 64 { m.rank_mismatches = m.rank_mismatches + 1; return 0 }
2260 let b: *u8 = sys_mmap(n + 1); var c: i64 = 0
2261 if (b as i64) <= 0 { m.rank_mismatches = m.rank_mismatches + 1; return 0 }
2262 while c < n { if raw[c] == (0 as u8) { m.rank_mismatches = m.rank_mismatches + 1; return 0 }; b[c] = raw[c]; c = c + 1 }; b[n] = 0 as u8
2263 let f: *i64 = sys_mmap(12 * 8) as *i64
2264 if (f as i64) <= 0 { m.rank_mismatches = m.rank_mismatches + 1; return 0 }
2265 var pos: i64 = 0; var stamps: i64 = 0
2266 while pos < n {
2267 var end: i64 = pos; while end < n { if b[end] == (10 as u8) { break }; end = end + 1 }
2268 b[end] = 0 as u8; if end > pos { if b[end-1] == (13 as u8) { b[end-1] = 0 as u8 } }
2269 let line: *u8 = (b as i64 + pos) as *u8; pos = end + 1
2270 if starts(line, "# inputs_v=" as *u8) == 1 {
2271 m.binding_rows = m.binding_rows + 1
2272 let nf: i64 = sg_split(line, f, 12, 32)
2273 if nf == 6 {
2274 if streq(f[1] as *u8, "inputs_v=1" as *u8) == 1 {
2275 let ps: *u8 = f[2] as *u8; let ms: *u8 = f[4] as *u8
2276 if starts(ps, "plan_sha256=" as *u8) == 1 { if starts(ms, "matrix_sha256=" as *u8) == 1 {
2277 if streq((ps as i64 + 12) as *u8, m.plan_sha) == 1 { if streq((ms as i64 + 14) as *u8, m.matrix_sha) == 1 {
2278 if sg_prefix_decimal(f[3] as *u8, "plan_bytes=" as *u8) == m.plan_bytes {
2279 if sg_prefix_decimal(f[5] as *u8, "matrix_bytes=" as *u8) == m.matrix_bytes { m.binding_ok = 1 }
2280 }
2281 } }
2282 } }
2283 }
2284 }
2285 } else {
2286 if starts(line, "# asof=" as *u8) == 1 {
2287 stamps = stamps + 1
2288 let nf: i64 = sg_split(line, f, 12, 32)
2289 if nf > 12 { m.rank_mismatches = m.rank_mismatches + 1 } else {
2290 var z: i64 = 0; var found: i64 = 0
2291 while z < nf { if starts(f[z] as *u8, "rungs=" as *u8) == 1 { found = found + 1; m.rank_count = sg_prefix_decimal(f[z] as *u8, "rungs=" as *u8) }; z = z + 1 }
2292 if found != 1 { m.rank_mismatches = m.rank_mismatches + 1 }
2293 }
2294 } else {
2295 if starts(line, "rank|" as *u8) == 1 {
2296 let nf: i64 = sg_split(line, f, 12, 124)
2297 if nf != 10 { m.rank_mismatches = m.rank_mismatches + 1 } else {
2298 let id: *u8 = f[3] as *u8; let idx: i64 = sg_find(m, id, sg_len(id))
2299 if idx < 0 { m.rank_mismatches = m.rank_mismatches + 1 } else {
2300 if streq(f[9] as *u8, m.nodes[idx*SGP_FIELDS+3] as *u8) == 0 { m.rank_mismatches = m.rank_mismatches + 1 }
2301 }
2302 }
2303 }
2304 }
2305 }
2306 }
2307 if stamps != 1 { m.rank_mismatches = m.rank_mismatches + 1 }
2308 if m.binding_rows != 1 { m.binding_ok = 0 }
2309 if m.matrix_bytes <= 0 { m.binding_ok = 0 }
2310 return 0
2311}
2312func sg_parse(raw: *u8, n: i64, rank: *u8, rn: i64, matrix: *u8, mn: i64) -> *SgPlan {
2313 // SgPlan stores 26 pointer/i64 fields, each one native 64-bit word.
2314 let m: *SgPlan = sys_mmap(26 * 8) as *SgPlan
2315 if (m as i64) <= 0 { return 0 as *SgPlan }
2316 m.rank_count = 0 - 1; m.matrix_bytes = mn
2317 m.plan_sha = "" as *u8; m.matrix_sha = "" as *u8; m.rank_sha = "" as *u8
2318 if n <= 0 { m.malformed = 1; return m }
2319 if (raw as i64) <= 0 { m.malformed = 1; return m }
2320 // Reserve arithmetic is bounded by the input byte count, not a policy cutoff.
2321 if n > SGP_I64_MAX / (SGP_FIELDS * 8) - 1 { m.malformed = 1; return m }
2322 if rn < 0 { m.malformed = 1; return m }; if mn < 0 { m.malformed = 1; return m }
2323 if rn > 0 { if (rank as i64) <= 0 { m.malformed = 1; return m } }
2324 if mn > 0 { if (matrix as i64) <= 0 { m.malformed = 1; return m } }
2325 m.growth = cg_parse(raw, n)
2326 m.plan_bytes = n; m.plan_sha = sg_sha(raw, n)
2327 if sg_len(m.plan_sha) != 64 { m.malformed = 1; return m }
2328 if mn > 0 { m.matrix_sha = sg_sha(matrix, mn); if sg_len(m.matrix_sha) != 64 { m.malformed = 1; return m } }
2329 let b: *u8 = sys_mmap(n + 1); m.plan = b
2330 if (b as i64) <= 0 { m.malformed = 1; return m }
2331 var maxrows: i64 = 1; var maxedges: i64 = 1; var c: i64 = 0
2332 while c < n {
2333 if raw[c] == (0 as u8) { m.malformed = m.malformed + 1 }
2334 if raw[c] == (10 as u8) { maxrows = maxrows + 1; maxedges = maxedges + 1 }
2335 if raw[c] == (44 as u8) { maxedges = maxedges + 1 }
2336 b[c] = raw[c]; c = c + 1
2337 }
2338 b[n] = 0 as u8
2339 m.nodes = sys_mmap(maxrows * SGP_FIELDS * 8) as *i64
2340 m.edges = sys_mmap(maxedges * 2 * 8) as *i64
2341 let f: *i64 = sys_mmap(SGP_FIELDS * 8) as *i64
2342 if (m.nodes as i64) <= 0 { m.malformed = 1; return m }
2343 if (m.edges as i64) <= 0 { m.malformed = 1; return m }
2344 if (f as i64) <= 0 { m.malformed = 1; return m }
2345 var pos: i64 = 0
2346 while pos < n {
2347 var end: i64 = pos; while end < n { if b[end] == (10 as u8) { break }; end = end + 1 }
2348 b[end] = 0 as u8; if end > pos { if b[end-1] == (13 as u8) { b[end-1] = 0 as u8 } }
2349 let line: *u8 = (b as i64 + pos) as *u8; pos = end + 1
2350 if starts(line, "sotatarget|" as *u8) == 1 { m.target_rows = m.target_rows + 1 }
2351 if starts(line, "rungrole|" as *u8) == 1 { m.role_rows = m.role_rows + 1 }
2352 if starts(line, "risk|" as *u8) == 1 { m.risk_rows = m.risk_rows + 1 }
2353 if starts(line, "log|" as *u8) == 1 { m.log_rows = m.log_rows + 1 }
2354 if starts(line, "rung|" as *u8) == 1 {
2355 m.declared = m.declared + 1
2356 let nf: i64 = sg_split(line, f, SGP_FIELDS, 124)
2357 if nf != SGP_FIELDS { m.malformed = m.malformed + 1 } else {
2358 let id: *u8 = f[1] as *u8
2359 if sg_id(id, sg_len(id)) == 0 { m.malformed = m.malformed + 1 } else {
2360 if sg_find(m, id, sg_len(id)) >= 0 { m.duplicate_ids = m.duplicate_ids + 1 } else {
2361 var j: i64 = 0; while j < SGP_FIELDS { m.nodes[m.count*SGP_FIELDS+j] = f[j]; j = j + 1 }
2362 m.count = m.count + 1
2363 }
2364 }
2365 }
2366 }
2367 }
2368 var node: i64 = 0
2369 while node < m.count {
2370 let deps: *u8 = m.nodes[node*SGP_FIELDS+7] as *u8
2371 if streq(deps, "-" as *u8) == 0 {
2372 var start: i64 = 0; var at: i64 = 0; var more: i64 = 1
2373 while more == 1 {
2374 var delimiter: i64 = 0
2375 if deps[at] == (0 as u8) { more = 0; delimiter = 1 }
2376 if deps[at] == (44 as u8) { delimiter = 1 }
2377 if delimiter == 1 {
2378 let length: i64 = at - start
2379 let name: *u8 = (deps as i64 + start) as *u8
2380 if sg_id(name, length) == 0 { m.malformed = m.malformed + 1 } else {
2381 let dep: i64 = sg_find(m, name, length)
2382 if dep < 0 { m.missing_deps = m.missing_deps + 1 } else {
2383 var duplicate: i64 = 0; var e: i64 = 0
2384 while e < m.edge_count { if m.edges[e*2] == dep { if m.edges[e*2+1] == node { duplicate = 1 } }; e = e + 1 }
2385 if duplicate == 1 { m.duplicate_edges = m.duplicate_edges + 1 } else {
2386 m.edges[m.edge_count*2] = dep; m.edges[m.edge_count*2+1] = node; m.edge_count = m.edge_count + 1
2387 }
2388 }
2389 }
2390 start = at + 1
2391 }
2392 at = at + 1
2393 }
2394 }
2395 node = node + 1
2396 }
2397 let degree: *i64 = sys_mmap((m.count+1)*8) as *i64
2398 let visited: *i64 = sys_mmap((m.count+1)*8) as *i64
2399 if (degree as i64) <= 0 { m.malformed = 1; return m }
2400 if (visited as i64) <= 0 { m.malformed = 1; return m }
2401 var e: i64 = 0; while e < m.edge_count { let to: i64 = m.edges[e*2+1]; degree[to] = degree[to] + 1; e = e + 1 }
2402 var removed: i64 = 0; var progress: i64 = 1
2403 while progress == 1 {
2404 progress = 0; var i: i64 = 0
2405 while i < m.count {
2406 if visited[i] == 0 { if degree[i] == 0 {
2407 visited[i] = 1; removed = removed + 1; progress = 1
2408 var j: i64 = 0; while j < m.edge_count { if m.edges[j*2] == i { let to: i64 = m.edges[j*2+1]; degree[to] = degree[to] - 1 }; j = j + 1 }
2409 } }
2410 i = i + 1
2411 }
2412 }
2413 m.cyclic_nodes = m.count - removed
2414 sg_rank(m, rank, rn)
2415 return m
2416}
2417func sg_valid(m: *SgPlan) -> i64 {
2418 if (m as i64) <= 0 { return 0 }
2419 if m.malformed + m.duplicate_ids + m.duplicate_edges + m.missing_deps + m.cyclic_nodes != 0 { return 0 }
2420 return 1
2421}
2422func sg_rank_state(m: *SgPlan) -> *u8 {
2423 if m.rank_bytes <= 0 { return "UNAVAILABLE" as *u8 }
2424 if m.rank_count != m.declared { return "STALE_INCONSISTENT" as *u8 }
2425 if m.rank_mismatches > 0 { return "STALE_INCONSISTENT" as *u8 }
2426 if m.binding_rows > 1 { return "INVALID_BINDING" as *u8 }
2427 if m.binding_rows == 1 { if m.binding_ok == 0 { return "STALE_OR_INVALID_BINDING" as *u8 } }
2428 if m.binding_ok == 1 { return "PLAN_MATRIX_BOUND_ONLY" as *u8 }
2429 return "UNBOUND" as *u8
2430}
2431func sg_load(domain: *u8) -> *SgPlan {
2432 let path: *u8 = sys_mmap(SGP_PATH_CAP)
2433 if (path as i64) <= 0 { return 0 as *SgPlan }
2434 let prefix: *u8 = "knowledge/compare/" as *u8
2435 let dn: i64 = sg_len(domain)
2436 if dn + sg_len(prefix) + sg_len(".matrix") + 1 > SGP_PATH_CAP { return 0 as *SgPlan }
2437 if sg_id(domain, dn) == 0 { return 0 as *SgPlan }
2438 let base: i64 = scopy(path, 0, prefix)
2439 let tail: i64 = scopy(path, base, domain)
2440 let plen: *i64 = sys_mmap(16) as *i64; let rlen: *i64 = sys_mmap(16) as *i64; let mlen: *i64 = sys_mmap(16) as *i64
2441 if (plen as i64) <= 0 { return 0 as *SgPlan }; if (rlen as i64) <= 0 { return 0 as *SgPlan }; if (mlen as i64) <= 0 { return 0 as *SgPlan }
2442 var end: i64 = scopy(path, tail, ".plan" as *u8); path[end] = 0 as u8
2443 let p: *u8 = sys_read_file(path, plen)
2444 if (p as i64) == 0 { return 0 as *SgPlan }
2445 end = scopy(path, tail, ".rank" as *u8); path[end] = 0 as u8
2446 let r: *u8 = sys_read_file(path, rlen)
2447 if (r as i64) == 0 { rlen[0] = 0 }
2448 end = scopy(path, tail, ".matrix" as *u8); path[end] = 0 as u8
2449 let x: *u8 = sys_read_file(path, mlen)
2450 if (x as i64) == 0 { mlen[0] = 0 }
2451 return sg_parse(p, plen[0], r, rlen[0], x, mlen[0])
2452}
2453
2454// Growth projects the same borrowed plan capture; eligibility remains a separate unverified axis.
2455func sg_growth_json(g: *CgModel,fd: i64) -> i64 {
2456 if (g as i64)<=0 { w(fd,"null" as *u8); return 0 }
2457 // Six bytes is JSON's maximum one-input-byte escape (\\u00xx).
2458 // Fixed overhead is derived from the projection's complete literal inventory, once per possible row.
2459 let inventory: *u8="\"nx_compare_growth_lib_20260910.nx\",:{}[]\"json_emit.nx\",:{}[]\"id\",:{}[]\"rung_id\",:{}[]\"entry_basis\",:{}[]\"target_id\",:{}[]\"research_refs_authored\",:{}[]\"learned_model_authored\",:{}[]\"questions_authored\",:{}[]\"path_id\",:{}[]\"prerequisite_exercises_authored\",:{}[]\"contract_symbol_authored\",:{}[]\"tool_or_api_ref_authored\",:{}[]\"workload_ref_authored\",:{}[]\"resource_ref_authored\",:{}[]\"acceptance_ref_authored\",:{}[]\"failure_next_authored\",:{}[]\"path_id\",:{}[]\"scope_authored\",:{}[]\"asserted_stage\",:{}[]\"evidence_refs_authored\",:{}[]\"assessed_unix_text\",:{}[]\"assessor_ref_authored\",:{}[]\"supersedes_assessment_id_authored\",:{}[]\"evidence_validated_stage\",:{}[]\"evidence_verified\",:{}[]\"evidence_age_seconds\",:{}[]\"investment_observed\",:{}[]\"investment_uncertainty\",:{}[]\"reference_resolution\",:{}[]\"local_graph_only_external_refs_unresolved\",:{}[]\"v\",:{}[]\"status\",:{}[]\"invalid_authored_growth\",:{}[]\"not_declared\",:{}[]\"authored_graph_valid\",:{}[]\"code\",:{}[]\"error_growth_row\",:{}[]\"scope\",:{}[]\"authored_growth_graph_not_behavior_or_mastery\",:{}[]\"paths\",:{}[]\"exercises\",:{}[]\"assessments\",:{}[]" as *u8
2460 let fixed: i64=bf_slen(inventory)
2461 if g.count>=SGP_I64_MAX/fixed-1 { w(fd,"{\"v\":1,\"status\":\"projection_unavailable\",\"code\":-2}" as *u8); return 0 }
2462 let structural: i64=(g.count+1)*fixed
2463 if g.n>(SGP_I64_MAX-structural-1)/6 { w(fd,"{\"v\":1,\"status\":\"projection_unavailable\",\"code\":-2}" as *u8); return 0 }
2464 let capacity: i64=g.n*6+structural
2465 let out: *u8=sys_mmap(capacity+1)
2466 if (out as i64)<=0 { w(fd,"{\"v\":1,\"status\":\"projection_unavailable\",\"code\":-2}" as *u8); return 0 }
2467 let n: i64=cg_json_into(g,out,capacity)
2468 if n<0 { w(fd,"{\"v\":1,\"status\":\"projection_unavailable\",\"code\":-2}" as *u8) } else { out[n]=0 as u8; w(fd,out) }
2469 sys_munmap(out,capacity+1); return n
2470}
2471func sg_growth_text(g: *CgModel,row: i64,col: i64,fd: i64) -> i64 {
2472 var offset: i64=0; let n: i64=cg_field(g,row,col,&offset)
2473 if n<0 { w(fd,"[field unavailable]" as *u8); return 0 }
2474 let text: *u8=sys_mmap(n+1)
2475 if (text as i64)<=0 { w(fd,"[field unavailable]" as *u8); return 0 }
2476 var i: i64=0; while i<n { text[i]=g.plan[offset+i]; i=i+1 }; text[n]=0 as u8
2477 sg_text(fd,text); sys_munmap(text,n+1); return n
2478}
2479func sg_growth_detail(g: *CgModel,row: i64,col: i64,label: *u8,fd: i64) -> i64 {
2480 w(fd,"<dt>" as *u8); w(fd,label); w(fd,"</dt><dd>" as *u8); sg_growth_text(g,row,col,fd); w(fd,"</dd>" as *u8); return 0
2481}
2482func sg_growth_html(g: *CgModel,fd: i64,heading: i64) -> i64 {
2483 w(fd,"<section class='capability-growth' aria-label='Learning and practice paths'>" as *u8)
2484 sc_heading_open(fd,heading,"" as *u8); w(fd,"Learning and practice paths" as *u8); sc_heading_close(fd,heading)
2485 if (g as i64)<=0 { w(fd,"<p>Growth capture unavailable.</p></section>" as *u8); return 0 }
2486 if g.error!=0 {
2487 w(fd,"<p>Invalid authored growth data. Error " as *u8); wn(fd,g.error); w(fd," at growth row " as *u8); wn(fd,g.error_row)
2488 w(fd,". Path details withheld; existing capability evidence retains its own scope.</p></section>" as *u8); return 0
2489 }
2490 if g.count==0 { w(fd,"<p>No structured learning path is declared for this plan. Existing research, roadmap and worklog remain available above.</p></section>" as *u8); return 0 }
2491 w(fd,"<p>Paths can begin with proactive research, an observed failure or an operator target. Prerequisites below are authored and structurally checked; execution readiness, evidence validity and investment remain unknown. An asserted stage does not establish mastery or innovation.</p>" as *u8)
2492 var p: i64=0
2493 while p<g.count {
2494 if g.rows[p*CG_ROW_WORDS]==CG_PATH {
2495 w(fd,"<details><summary>Path " as *u8); sg_growth_text(g,p,2,fd); w(fd," for rung " as *u8); sg_growth_text(g,p,3,fd); w(fd,"</summary><dl>" as *u8)
2496 sg_growth_detail(g,p,4,"Entry",fd); sg_growth_detail(g,p,5,"Target",fd); sg_growth_detail(g,p,6,"Research references (unresolved)",fd)
2497 sg_growth_detail(g,p,7,"Learned model (authored)",fd); sg_growth_detail(g,p,8,"Open questions",fd); w(fd,"</dl>" as *u8)
2498 w(fd,"<p><b>Practice exercises</b></p><ul>" as *u8)
2499 var e: i64=0; var exercises: i64=0
2500 while e<g.count {
2501 if g.rows[e*CG_ROW_WORDS]==CG_EXERCISE { if cg_same(g,e,3,p,2)==1 {
2502 exercises=exercises+1
2503 w(fd,"<li><details><summary>Exercise " as *u8); sg_growth_text(g,e,2,fd); w(fd," — readiness unverified</summary><dl>" as *u8)
2504 sg_growth_detail(g,e,4,"Declared prerequisites",fd); sg_growth_detail(g,e,5,"Capability contract",fd)
2505 sg_growth_detail(g,e,6,"Tool or API reference (unresolved)",fd); sg_growth_detail(g,e,7,"Workload reference",fd)
2506 sg_growth_detail(g,e,8,"Resource envelope reference",fd); sg_growth_detail(g,e,9,"Acceptance reference",fd)
2507 sg_growth_detail(g,e,10,"If practice fails",fd); w(fd,"</dl></details></li>" as *u8)
2508 } }
2509 e=e+1
2510 }
2511 w(fd,"</ul>" as *u8); if exercises==0 { w(fd,"<p>No practice exercise declared.</p>" as *u8) }
2512 w(fd,"<p><b>Assessment history</b></p><ul>" as *u8)
2513 var a: i64=0; var assessments: i64=0
2514 while a<g.count {
2515 if g.rows[a*CG_ROW_WORDS]==CG_ASSESSMENT { if cg_same(g,a,3,p,2)==1 {
2516 assessments=assessments+1
2517 w(fd,"<li><details><summary>Assessment " as *u8); sg_growth_text(g,a,2,fd); w(fd," — asserted " as *u8); sg_growth_text(g,a,5,fd)
2518 w(fd,"; evidence not validated</summary><dl>" as *u8)
2519 sg_growth_detail(g,a,4,"Scope",fd); sg_growth_detail(g,a,6,"Evidence references (unresolved)",fd)
2520 sg_growth_detail(g,a,7,"Authored assessment epoch",fd); sg_growth_detail(g,a,8,"Assessor reference",fd)
2521 sg_growth_detail(g,a,9,"Supersedes assessment",fd); w(fd,"</dl></details></li>" as *u8)
2522 } }
2523 a=a+1
2524 }
2525 w(fd,"</ul>" as *u8); if assessments==0 { w(fd,"<p>No assessment declared.</p>" as *u8) }
2526 w(fd,"<p>Verified stage: unknown. Observed investment and uncertainty: unknown. No dispatch recommendation is made.</p></details>" as *u8)
2527 }
2528 p=p+1
2529 }
2530 w(fd,"</section>" as *u8); return 0
2531}
2532
2533func sg_json(m: *SgPlan, fd: i64) -> i64 {
2534 w(fd, ",\"ladder\":{\"v\":1,\"availability\":" as *u8)
2535 if (m as i64) == 0 { w(fd, "\"UNAVAILABLE\"}" as *u8); return 0 }
2536 w(fd, "\"CAPTURED\"," as *u8); kv_s(fd, "plan_sha256" as *u8, m.plan_sha); wc(fd, 44); kv_n(fd, "plan_bytes" as *u8, m.plan_bytes)
2537 wc(fd, 44); kv_s(fd, "matrix_sha256" as *u8, m.matrix_sha); wc(fd, 44); kv_n(fd, "matrix_bytes" as *u8, m.matrix_bytes)
2538 wc(fd, 44); kv_s(fd, "rank_sha256" as *u8, m.rank_sha); wc(fd, 44); kv_n(fd, "rank_bytes" as *u8, m.rank_bytes)
2539 wc(fd, 44); kv_s(fd, "rank_binding" as *u8, sg_rank_state(m)); wc(fd, 44); kv_n(fd, "rank_declared_nodes" as *u8, m.rank_count)
2540 wc(fd, 44); kv_n(fd, "rank_symbol_or_shape_errors" as *u8, m.rank_mismatches)
2541 wc(fd, 44); kv_n(fd, "declared_nodes" as *u8, m.declared); wc(fd, 44); kv_n(fd, "parsed_nodes" as *u8, m.count)
2542 wc(fd, 44); kv_n(fd, "declared_graph_valid" as *u8, sg_valid(m))
2543 wc(fd, 44); kv_n(fd, "malformed" as *u8, m.malformed); wc(fd, 44); kv_n(fd, "duplicate_ids" as *u8, m.duplicate_ids)
2544 wc(fd, 44); kv_n(fd, "duplicate_dependencies" as *u8, m.duplicate_edges); wc(fd, 44); kv_n(fd, "missing_dependencies" as *u8, m.missing_deps)
2545 wc(fd, 44); kv_n(fd, "cyclic_or_cycle_dependent_nodes" as *u8, m.cyclic_nodes)
2546 wc(fd, 44); kv_n(fd, "target_rows" as *u8, m.target_rows); wc(fd, 44); kv_n(fd, "role_rows" as *u8, m.role_rows)
2547 wc(fd, 44); kv_n(fd, "unprojected_risk_rows" as *u8, m.risk_rows); wc(fd, 44); kv_n(fd, "worklog_rows" as *u8, m.log_rows)
2548 w(fd, ",\"defaults\":{\"implementation\":\"UNKNOWN\",\"verification\":\"UNVERIFIED\",\"eligibility\":\"UNVERIFIED\",\"target_binding\":\"UNVERIFIED\",\"responsible\":null,\"accountable\":null,\"verifier\":null},\"eligible_now\":[],\"eligible_set_complete\":false,\"recommended\":[],\"recommendation_state\":\"WITHHELD\",\"changed_since_supported\":false,\"next_cursor\":null,\"nodes\":[" as *u8)
2549 if sg_valid(m) == 1 {
2550 var i: i64 = 0
2551 while i < m.count {
2552 if i > 0 { wc(fd, 44) }; wc(fd, 123)
2553 kv_s(fd, "id" as *u8, m.nodes[i*SGP_FIELDS+1] as *u8); wc(fd, 44); kv_s(fd, "title" as *u8, m.nodes[i*SGP_FIELDS+2] as *u8)
2554 wc(fd, 44); kv_s(fd, "contract_symbol" as *u8, m.nodes[i*SGP_FIELDS+3] as *u8)
2555 wc(fd, 44); kv_s(fd, "acceptance_authored" as *u8, m.nodes[i*SGP_FIELDS+4] as *u8)
2556 wc(fd, 44); kv_s(fd, "executor_kind_authored" as *u8, m.nodes[i*SGP_FIELDS+5] as *u8)
2557 wc(fd, 44); kv_s(fd, "effort_authored" as *u8, m.nodes[i*SGP_FIELDS+6] as *u8)
2558 w(fd, ",\"forecast\":false,\"prerequisites\":[" as *u8)
2559 var e: i64 = 0; var shown: i64 = 0
2560 while e < m.edge_count {
2561 if m.edges[e*2+1] == i { if shown > 0 { wc(fd, 44) }; let from: i64 = m.edges[e*2]; wq(fd); wj(fd, m.nodes[from*SGP_FIELDS+1] as *u8); wq(fd); shown = shown + 1 }
2562 e = e + 1
2563 }
2564 w(fd, "]}" as *u8); i = i + 1
2565 }
2566 }
2567 w(fd, "],\"capability_growth\":" as *u8); sg_growth_json(m.growth, fd)
2568 w(fd, "}" as *u8); return 0
2569}
2570// Literal authored fields use the existing text escaper; citation expansion is not needed here.
2571func sg_text(fd: i64, s: *u8) -> i64 {
2572 let n: i64 = sg_len(s)
2573 if n > (SGP_I64_MAX - IA_SEP_AND_NUL) / IA_MAX_EXPANSION - 1 { w(fd, "[text unavailable]" as *u8); return 0 }
2574 let cap: i64 = (n + 1) * IA_MAX_EXPANSION + IA_SEP_AND_NUL
2575 let out: *u8 = sys_mmap(cap); let cut: *i64 = sys_mmap(8) as *i64
2576 if (out as i64) <= 0 { w(fd, "[text unavailable]" as *u8); return 0 }
2577 if (cut as i64) <= 0 { w(fd, "[text unavailable]" as *u8); return 0 }
2578 let written: i64 = ia_esc_text(out, 0, s, cap, cut)
2579 if cut[0] != 0 { w(fd, "[text unavailable]" as *u8); return 0 }
2580 w(fd, out); return written
2581}
2582func sg_html(m: *SgPlan, fd: i64) -> i64 { return sg_html_heading(m, fd, 2) }
2583func sg_html_heading(m: *SgPlan, fd: i64, heading_level: i64) -> i64 {
2584 w(fd, "<section class='ladder-model' aria-label='Declared prerequisite paths'>" as *u8); sc_heading_open(fd, heading_level, "" as *u8); w(fd, "Inspect a rung and its prerequisites" as *u8); sc_heading_close(fd, heading_level)
2585 if (m as i64) == 0 { w(fd, "<p>Plan unavailable; no path or eligibility can be established.</p></section>" as *u8); return 0 }
2586 w(fd, "<p>Declared nodes " as *u8); wn(fd, m.declared); w(fd, ". Rank input binding: <b>" as *u8); w(fd, sg_rank_state(m))
2587 w(fd, "</b>. Dependency order is authored. Implementation, acceptance evidence, authority and resource readiness are unverified. No action is recommended or dispatched here.</p><p>Plan SHA-256 <code>" as *u8); w(fd, m.plan_sha); w(fd, "</code>. Target rows " as *u8); wn(fd, m.target_rows)
2588 w(fd, "; role rows " as *u8); wn(fd, m.role_rows); w(fd, ". Existing risks and release worklog retain their own scope; no node completion is inferred.</p>" as *u8)
2589 if sg_valid(m) == 0 {
2590 w(fd, "<p><b>Invalid declared graph.</b> Malformed rows or IDs " as *u8); wn(fd, m.malformed); w(fd, "; duplicate IDs " as *u8); wn(fd, m.duplicate_ids)
2591 w(fd, "; duplicate prerequisites " as *u8); wn(fd, m.duplicate_edges); w(fd, "; missing prerequisites " as *u8); wn(fd, m.missing_deps)
2592 w(fd, "; cyclic or cycle-dependent nodes " as *u8); wn(fd, m.cyclic_nodes); w(fd, ". Node paths withheld.</p></section>" as *u8)
2593 sg_growth_html(m.growth, fd, heading_level)
2594 return 0
2595 }
2596 w(fd, "<p>Use Enter or Space on a rung to inspect its contract. Prerequisite links locate another rung in this list; open its summary to inspect it. Estimates are authored effort, not forecasts.</p><ol class='ladder-nodes'>" as *u8)
2597 var i: i64 = 0
2598 while i < m.count {
2599 let id: *u8 = m.nodes[i*SGP_FIELDS+1] as *u8
2600 w(fd, "<li><details id='ladder-node-" as *u8); w(fd, id); w(fd, "'><summary>" as *u8); w(fd, id); w(fd, " — " as *u8); sg_text(fd, m.nodes[i*SGP_FIELDS+2] as *u8)
2601 w(fd, "</summary><p><b>Prerequisites:</b> " as *u8)
2602 var e: i64 = 0; var shown: i64 = 0
2603 while e < m.edge_count {
2604 if m.edges[e*2+1] == i {
2605 let from: i64 = m.edges[e*2]; let dep: *u8 = m.nodes[from*SGP_FIELDS+1] as *u8
2606 if shown > 0 { w(fd, ", " as *u8) }; w(fd, "<a href='#ladder-node-" as *u8); w(fd, dep); w(fd, "'>" as *u8); w(fd, dep); w(fd, "</a> (acceptance unverified)" as *u8); shown = shown + 1
2607 }; e = e + 1
2608 }
2609 if shown == 0 { w(fd, "None declared; this does not establish execution eligibility." as *u8) }
2610 w(fd, "</p><p><b>Contract:</b> <code>" as *u8); sg_text(fd, m.nodes[i*SGP_FIELDS+3] as *u8); w(fd, "</code></p><p><b>Acceptance:</b> " as *u8); sg_text(fd, m.nodes[i*SGP_FIELDS+4] as *u8)
2611 w(fd, "</p><p><b>Authored effort:</b> " as *u8); sg_text(fd, m.nodes[i*SGP_FIELDS+6] as *u8); w(fd, ". <b>Executor kind:</b> " as *u8); sg_text(fd, m.nodes[i*SGP_FIELDS+5] as *u8)
2612 w(fd, ". Responsible, accountable and verifier not established. <a href='#worklog'>Inspect retained worklog</a>.</p></details></li>" as *u8); i = i + 1
2613 }
2614 w(fd, "</ol></section>" as *u8)
2615 sg_growth_html(m.growth, fd, heading_level)
2616 return 0
2617}
2618func sg_css(fd: i64) -> i64 {
2619 w(fd, ".capability-growth{min-width:0}.capability-growth details{display:block}.capability-growth summary{display:list-item;cursor:pointer;list-style:revert;font-size:1rem;line-height:1.5}.capability-growth details summary::after,.capability-growth details[open] summary::after{content:none}.capability-growth summary:focus-visible{outline:3px solid var(--ac);outline-offset:2px}.capability-growth p{max-width:var(--nx-layout-measure)}.capability-growth dd{margin-inline-start:0;overflow-wrap:anywhere}.capability-growth dt{font-weight:600}.capability-growth dl{display:grid;grid-template-columns:minmax(0,1fr);gap:var(--nx-layout-capgap)}.capability-growth ul{padding-inline-start:1.5em}" as *u8)
2620 w(fd, ".ladder-model{min-width:0}.ladder-model p{max-width:var(--nx-layout-measure)}.ladder-model code{overflow-wrap:anywhere}.ladder-nodes{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,var(--nx-layout-capmin)),1fr));gap:var(--nx-layout-capgap);padding-inline-start:1.5em}.ladder-nodes li{min-width:0}.ladder-nodes details{display:block}.ladder-nodes summary{display:list-item;cursor:pointer;list-style:revert;font-size:1rem;line-height:1.5}.ladder-nodes summary::after{content:none}.ladder-nodes summary:focus-visible,.ladder-nodes a:focus-visible{outline:3px solid var(--ac);outline-offset:2px}.ladder-nodes details:target{outline:2px solid var(--ac);outline-offset:4px}\n" as *u8)
2621 return 0
2622}