code wiki / _hdl_build / nx_editor_board.nx
nx_editor_board.nx source
↩ module page · 310 lines · 16505 B
1// nx_editor_board.nx -- F795 THE EDITOR COVERAGE BOARD (ecosystem-as-editor law, operator 2026-07-20:
2// the ecosystem is the EDITOR that lifts any-model seats to award-winning -- Marcia Lucas pattern; known
3// model failure modes must be covered STRUCTURALLY and the coverage must be a VISIBLE, supervised surface).
4// PURE RENDERER (model-card discipline): every byte of content comes from the sovereign plane
5// knowledge/store/editcover- (rows: id | failure-mode | covering-capability | evidence | status | note).
6// Status vocabulary: COVERED (structural organ + evidence) / PARTIAL (organ live, sweep open) / GAP
7// (no structural tooth -- F795 LAW: every GAP row must carry a filed F-rung; the board renders GAPs
8// fail-visible so an uncovered failure mode can never hide).
9// nx_editor_board -> ATOMIC emit to sites/nishifamily/editor.html (beat mode)
10// nx_editor_board emit <outpath> -> ATOMIC emit (tmp + renameat) to <outpath>
11// nx_editor_board selftest -> in-memory emit + substring teeth, exit 0/3
12// ENVELOPE (declared in page): plane cap 256KB, out cap 128KB, 64 rows; plane content operator-trusted
13// (no HTML-escape pass; plane vocabulary carries no < > &).
14// license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0
15import "nx_store_seed_lib.nx"
16import "nx_syscalls.nx"
17
18const EB_PREFIX: *u8 = "knowledge/store/editcover-" as *u8
19const EB_DEFOUT: *u8 = "sites/nishifamily/editor.html" as *u8
20const EB_PLANECAP: i64 = 262144
21const EB_OUTCAP: i64 = 131072
22const EB_NL: i64 = 10
23const EB_TAB: i64 = 9
24const EB_MODE: i64 = 0x1a4
25const EB_NCOLMAX: i64 = 8
26const EB_PAIR: i64 = 2
27const EB_SPB: i64 = 128
28const EB_MINBYTES: i64 = 2000
29const EB_EXIT_SELF: i64 = 3
30const EB_EXIT_EMPTY: i64 = 1
31const EB_SLACK: i64 = 4096
32
33func eb_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
34func eb_werr(s: *u8) -> i64 { sys_write(2, s, eb_slen(s)); return 0 }
35func eb_puts(b: *u8, off: i64, s: *u8) -> i64 { var o: i64 = off; var j: i64 = 0; while s[j] != (0 as u8) { b[o] = s[j]; o = o + 1; j = j + 1 } return o }
36func eb_putsl(b: *u8, off: i64, q: *u8, a: i64, e: i64) -> i64 { var o: i64 = off; var i: i64 = a; while i < e { b[o] = q[i]; o = o + 1; i = i + 1 } return o }
37func eb_puti(b: *u8, off: i64, v: i64) -> i64 {
38 var o: i64 = off
39 var m: i64 = v
40 if m < 0 { b[o] = 45 as u8; o = o + 1; m = 0 - m }
41 let t: *u8 = sys_mmap(28)
42 var k: i64 = 0
43 if m == 0 { t[0] = 48 as u8; k = 1 }
44 while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 }
45 var i: i64 = 0
46 while i < k { b[o] = t[k - 1 - i]; o = o + 1; i = i + 1 }
47 return o
48}
49func eb_cols(q: *u8, ls: i64, le: i64, sp: *i64) -> i64 {
50 var c: i64 = 0
51 var p: i64 = ls
52 while c < EB_NCOLMAX {
53 var e: i64 = p
54 var s: i64 = 1
55 while s == 1 { if e >= le { s = 0 } else { if q[e] == (EB_TAB as u8) { s = 0 } else { e = e + 1 } } }
56 sp[c*EB_PAIR] = p
57 sp[c*EB_PAIR+1] = e
58 c = c + 1
59 if e >= le { return c }
60 p = e + 1
61 }
62 return c
63}
64func eb_span_is(q: *u8, a: i64, b: i64, s: *u8) -> i64 {
65 let sn: i64 = eb_slen(s)
66 if b - a != sn { return 0 }
67 var i: i64 = 0
68 while i < sn { if q[a+i] != s[i] { return 0 } i = i + 1 }
69 return 1
70}
71func eb_find(hay: *u8, n: i64, needle: *u8) -> i64 {
72 let m: i64 = eb_slen(needle)
73 if m == 0 { return 0 - 1 }
74 var i: i64 = 0
75 while i + m <= n {
76 var j: i64 = 0
77 var ok: i64 = 1
78 while j < m { if hay[i+j] != needle[j] { ok = 0; j = m } else { j = j + 1 } }
79 if ok == 1 { return i }
80 i = i + 1
81 }
82 return 0 - 1
83}
84// render the whole page from the plane buffer; returns bytes (0 = empty plane)
85func eb_render(q: *u8, qn: i64, out: *u8) -> i64 {
86 let sp: *i64 = sys_mmap(EB_SPB) as *i64
87 var o: i64 = 0
88 var covered: i64 = 0
89 var partial: i64 = 0
90 var gap: i64 = 0
91 var i: i64 = 0
92 while i < qn {
93 var le: i64 = i
94 var s: i64 = 1
95 while s == 1 { if le >= qn { s = 0 } else { if q[le] == (EB_NL as u8) { s = 0 } else { le = le + 1 } } }
96 if le > i {
97 let nc: i64 = eb_cols(q, i, le, sp)
98 if nc >= 6 {
99 if eb_span_is(q, sp[8], sp[9], "COVERED" as *u8) == 1 { covered = covered + 1 }
100 if eb_span_is(q, sp[8], sp[9], "PARTIAL" as *u8) == 1 { partial = partial + 1 }
101 if eb_span_is(q, sp[8], sp[9], "GAP" as *u8) == 1 { gap = gap + 1 }
102 }
103 }
104 i = le + 1
105 }
106 let total: i64 = covered + partial + gap
107 if total == 0 { return 0 }
108 o = eb_puts(out, o, "<html><head><title>Nishi Editor Coverage</title><style>body{background:black;color:gainsboro;font:15px sans-serif;margin:24px}h1{color:white}table{border-collapse:collapse;width:100%}td,th{border-bottom:1px solid dimgray;padding:5px 9px;text-align:left;vertical-align:top}th{color:gray}.c{color:springgreen}.p{color:orange}.g{color:tomato;font-weight:bold}.d{color:gray}</style></head><body><h1>Nishi Editor Coverage</h1><p class=d>THE ECOSYSTEM-AS-EDITOR LAW: the model is the author; the ecosystem's editorial passes (gates · evidence-derived phase · adversarial verify · best-of-N + judge · recombination) lift any seat's good draft to award-winning — and every known model failure mode below must be covered STRUCTURALLY, with evidence, never by trust.</p><p>coverage: <span class=c>COVERED " as *u8)
109 o = eb_puti(out, o, covered)
110 o = eb_puts(out, o, "</span> · <span class=p>PARTIAL " as *u8)
111 o = eb_puti(out, o, partial)
112 o = eb_puts(out, o, "</span> · <span class=g>GAP " as *u8)
113 o = eb_puti(out, o, gap)
114 o = eb_puts(out, o, "</span> of " as *u8)
115 o = eb_puti(out, o, total)
116 o = eb_puts(out, o, " tracked failure modes</p><table><tr><th>#</th><th>failure mode</th><th>covering capability (structural)</th><th>evidence</th><th>status</th><th>note</th></tr>" as *u8)
117 i = 0
118 while i < qn {
119 var le2: i64 = i
120 var s2: i64 = 1
121 while s2 == 1 { if le2 >= qn { s2 = 0 } else { if q[le2] == (EB_NL as u8) { s2 = 0 } else { le2 = le2 + 1 } } }
122 if le2 > i {
123 let nc2: i64 = eb_cols(q, i, le2, sp)
124 if nc2 >= 6 {
125 o = eb_puts(out, o, "<tr><td>" as *u8)
126 o = eb_putsl(out, o, q, sp[0], sp[1])
127 o = eb_puts(out, o, "</td><td><b>" as *u8)
128 o = eb_putsl(out, o, q, sp[2], sp[3])
129 o = eb_puts(out, o, "</b></td><td>" as *u8)
130 o = eb_putsl(out, o, q, sp[4], sp[5])
131 o = eb_puts(out, o, "</td><td class=d>" as *u8)
132 o = eb_putsl(out, o, q, sp[6], sp[7])
133 o = eb_puts(out, o, "</td><td class=" as *u8)
134 if eb_span_is(q, sp[8], sp[9], "COVERED" as *u8) == 1 { o = eb_puts(out, o, "c" as *u8) } else { if eb_span_is(q, sp[8], sp[9], "PARTIAL" as *u8) == 1 { o = eb_puts(out, o, "p" as *u8) } else { o = eb_puts(out, o, "g" as *u8) } }
135 o = eb_puts(out, o, ">" as *u8)
136 o = eb_putsl(out, o, q, sp[8], sp[9])
137 o = eb_puts(out, o, "</td><td class=d>" as *u8)
138 o = eb_putsl(out, o, q, sp[10], sp[11])
139 o = eb_puts(out, o, "</td></tr>" as *u8)
140 }
141 }
142 i = le2 + 1
143 }
144 o = eb_puts(out, o, "</table><p class=d>F795 LAW: a GAP row without a filed F-rung is a defect. Sources: plane knowledge/store/editcover- (hist- provenance) · envelope: 256KB plane / 64 rows / 128KB out · proof lineage: autofix 71 pct resolve at 0.5-1.5B makers WITH best-of-N + judge. See also <a href=\"/standup\" style=\"color:skyblue\">/standup</a> · <a href=\"/modelcard\" style=\"color:skyblue\">/modelcard</a> · <a href=\"/frontier\" style=\"color:skyblue\">/frontier</a></p></body></html>" as *u8)
145 return o
146}
147// FRAGMENT renderer (F864): emits ONLY the body content, in the nishi_ds vocabulary (h1 / p.lede / .grid
148// .card .k .v / .meter / .tbl / .badge .b-good .b-warn .b-bad / .muted). nx_ui_kit wraps this with the
149// design system + header/nav/footer -> the page is POLISHED BY CONSTRUCTION instead of hand-rolled
150// dev-grade CSS (seq247, the operator's number-one gap). No hash or bang bytes in any literal (nx_cc trap).
151func eb_frag(q: *u8, qn: i64, out: *u8) -> i64 {
152 let sp: *i64 = sys_mmap(EB_SPB) as *i64
153 var o: i64 = 0
154 var covered: i64 = 0
155 var partial: i64 = 0
156 var gap: i64 = 0
157 var i: i64 = 0
158 while i < qn {
159 var le: i64 = i
160 var s: i64 = 1
161 while s == 1 { if le >= qn { s = 0 } else { if q[le] == (EB_NL as u8) { s = 0 } else { le = le + 1 } } }
162 if le > i {
163 let nc: i64 = eb_cols(q, i, le, sp)
164 if nc >= 6 {
165 if eb_span_is(q, sp[8], sp[9], "COVERED" as *u8) == 1 { covered = covered + 1 }
166 if eb_span_is(q, sp[8], sp[9], "PARTIAL" as *u8) == 1 { partial = partial + 1 }
167 if eb_span_is(q, sp[8], sp[9], "GAP" as *u8) == 1 { gap = gap + 1 }
168 }
169 }
170 i = le + 1
171 }
172 let total: i64 = covered + partial + gap
173 if total == 0 { return 0 }
174 let pct: i64 = (covered * 100) / total
175 let permille: i64 = (covered * 1000) / total
176 o = eb_puts(out, o, "<h1>Editor Coverage</h1><p class=lede>THE ECOSYSTEM-AS-EDITOR LAW: the model is the author; the ecosystem editorial passes (gates · evidence-derived phase · adversarial verify · best-of-N plus judge · recombination) lift any seat good draft to award-winning — and every known model failure mode below must be covered STRUCTURALLY, with evidence, never by trust.</p><div class=grid><div class=card><div class=k>Covered</div><div class=v>" as *u8)
177 o = eb_puti(out, o, covered)
178 o = eb_puts(out, o, "</div></div><div class=card><div class=k>Partial</div><div class=v>" as *u8)
179 o = eb_puti(out, o, partial)
180 o = eb_puts(out, o, "</div></div><div class=card><div class=k>Gap</div><div class=v>" as *u8)
181 o = eb_puti(out, o, gap)
182 o = eb_puts(out, o, "</div></div><div class=card><div class=k>Structurally covered</div><div class=v>" as *u8)
183 o = eb_puti(out, o, permille)
184 o = eb_puts(out, o, "‰</div><div class=meter><i style=width:" as *u8)
185 o = eb_puti(out, o, pct)
186 o = eb_puts(out, o, "%></i></div></div></div><div class=tbl><table><thead><tr><th>row</th><th>failure mode</th><th>covering capability (structural)</th><th>evidence</th><th>status</th><th>note</th></tr></thead><tbody>" as *u8)
187 i = 0
188 while i < qn {
189 var le2: i64 = i
190 var s2: i64 = 1
191 while s2 == 1 { if le2 >= qn { s2 = 0 } else { if q[le2] == (EB_NL as u8) { s2 = 0 } else { le2 = le2 + 1 } } }
192 if le2 > i {
193 let nc2: i64 = eb_cols(q, i, le2, sp)
194 if nc2 >= 6 {
195 o = eb_puts(out, o, "<tr><td class=mono>" as *u8)
196 o = eb_putsl(out, o, q, sp[0], sp[1])
197 o = eb_puts(out, o, "</td><td><b>" as *u8)
198 o = eb_putsl(out, o, q, sp[2], sp[3])
199 o = eb_puts(out, o, "</b></td><td>" as *u8)
200 o = eb_putsl(out, o, q, sp[4], sp[5])
201 o = eb_puts(out, o, "</td><td class=muted>" as *u8)
202 o = eb_putsl(out, o, q, sp[6], sp[7])
203 o = eb_puts(out, o, "</td><td><span class=" as *u8)
204 if eb_span_is(q, sp[8], sp[9], "COVERED" as *u8) == 1 { o = eb_puts(out, o, "'badge b-good'" as *u8) } else { if eb_span_is(q, sp[8], sp[9], "PARTIAL" as *u8) == 1 { o = eb_puts(out, o, "'badge b-warn'" as *u8) } else { o = eb_puts(out, o, "'badge b-bad'" as *u8) } }
205 o = eb_puts(out, o, ">" as *u8)
206 o = eb_putsl(out, o, q, sp[8], sp[9])
207 o = eb_puts(out, o, "</span></td><td class=muted>" as *u8)
208 o = eb_putsl(out, o, q, sp[10], sp[11])
209 o = eb_puts(out, o, "</td></tr>" as *u8)
210 }
211 }
212 i = le2 + 1
213 }
214 o = eb_puts(out, o, "</tbody></table></div><p class=muted>F795 LAW: a GAP row without a filed F-rung is a defect. Source plane <span class=mono>knowledge/store/editcover-</span> (hist- provenance) · envelope 256KB plane / 64 rows / 128KB out · proof lineage: autofix 71 pct resolve at 0.5-1.5B makers WITH best-of-N plus judge. See also <a href=/standup>standup</a> · <a href=/modelcard>model card</a> · <a href=/frontier>frontier</a>.</p>" as *u8)
215 return o
216}
217func eb_body(path: *u8) -> i64 {
218 let q: *u8 = sys_mmap(EB_PLANECAP)
219 let qn: i64 = sts_load(EB_PREFIX, q, EB_PLANECAP - EB_SLACK)
220 if qn <= 0 { eb_werr("EB-BODY EMPTY: plane unreadable\n" as *u8); return EB_EXIT_EMPTY }
221 let out: *u8 = sys_mmap(EB_OUTCAP)
222 let n: i64 = eb_frag(q, qn, out)
223 if n <= 0 { eb_werr("EB-BODY EMPTY: no parseable 6-col rows\n" as *u8); return EB_EXIT_EMPTY }
224 let tmp: *u8 = sys_mmap(512)
225 var t: i64 = eb_puts(tmp, 0, path)
226 t = eb_puts(tmp, t, ".tmp" as *u8)
227 tmp[t] = 0 as u8
228 let fd: i64 = sys_openat_wr(tmp, EB_MODE)
229 if fd < 0 { eb_werr("EB-BODY WRITE-FAIL\n" as *u8); return EB_EXIT_EMPTY }
230 sys_write(fd, out, n)
231 sys_close(fd)
232 sys_renameat(tmp, path)
233 let msg: *u8 = sys_mmap(256)
234 var mo: i64 = eb_puts(msg, 0, "EB-BODY OK bytes=" as *u8)
235 mo = eb_puti(msg, mo, n)
236 mo = eb_puts(msg, mo, " -> " as *u8)
237 mo = eb_puts(msg, mo, path)
238 mo = eb_puts(msg, mo, " (fragment in nishi_ds vocabulary; wrap with nx_ui_kit)" as *u8)
239 msg[mo] = 10 as u8
240 mo = mo + 1
241 sys_write(2, msg, mo)
242 return 0
243}
244func eb_emit(path: *u8) -> i64 {
245 let q: *u8 = sys_mmap(EB_PLANECAP)
246 let qn: i64 = sts_load(EB_PREFIX, q, EB_PLANECAP - EB_SLACK)
247 if qn <= 0 { eb_werr("EB-EMIT EMPTY: plane knowledge/store/editcover- unreadable or empty\n" as *u8); return EB_EXIT_EMPTY }
248 let out: *u8 = sys_mmap(EB_OUTCAP)
249 let n: i64 = eb_render(q, qn, out)
250 if n <= 0 { eb_werr("EB-EMIT EMPTY: no parseable 6-col rows\n" as *u8); return EB_EXIT_EMPTY }
251 let tmp: *u8 = sys_mmap(512)
252 var t: i64 = eb_puts(tmp, 0, path)
253 t = eb_puts(tmp, t, ".tmp" as *u8)
254 tmp[t] = 0 as u8
255 let fd: i64 = sys_openat_wr(tmp, EB_MODE)
256 if fd < 0 { eb_werr("EB-EMIT WRITE-FAIL\n" as *u8); return EB_EXIT_EMPTY }
257 sys_write(fd, out, n)
258 sys_close(fd)
259 sys_renameat(tmp, path)
260 let msg: *u8 = sys_mmap(256)
261 var mo: i64 = eb_puts(msg, 0, "EB-EMIT OK bytes=" as *u8)
262 mo = eb_puti(msg, mo, n)
263 mo = eb_puts(msg, mo, " -> " as *u8)
264 mo = eb_puts(msg, mo, path)
265 msg[mo] = 10 as u8
266 mo = mo + 1
267 sys_write(2, msg, mo)
268 return 0
269}
270func main(argc: i64, argv: *i64) -> i64 {
271 if argc >= 2 {
272 let verb: *u8 = argv[1] as *u8
273 if verb[0] == (115 as u8) {
274 let q: *u8 = sys_mmap(EB_PLANECAP)
275 let qn: i64 = sts_load(EB_PREFIX, q, EB_PLANECAP - EB_SLACK)
276 if qn <= 0 { eb_werr("EB-SELFTEST FAIL: plane empty\n" as *u8); sys_exit(EB_EXIT_SELF); return EB_EXIT_SELF }
277 let out: *u8 = sys_mmap(EB_OUTCAP)
278 let n: i64 = eb_render(q, qn, out)
279 var bad: i64 = 0
280 if n < EB_MINBYTES { bad = 1 }
281 if eb_find(out, n, "Nishi Editor Coverage" as *u8) < 0 { bad = 1 }
282 if eb_find(out, n, "COVERED" as *u8) < 0 { bad = 1 }
283 if eb_find(out, n, "failure mode" as *u8) < 0 { bad = 1 }
284 if bad == 1 { eb_werr("EB-SELFTEST FAIL (size floor or needle missing)\n" as *u8); sys_exit(EB_EXIT_SELF); return EB_EXIT_SELF }
285 let msg: *u8 = sys_mmap(128)
286 var mo: i64 = eb_puts(msg, 0, "EB-SELFTEST OK bytes=" as *u8)
287 mo = eb_puti(msg, mo, n)
288 msg[mo] = 10 as u8
289 mo = mo + 1
290 sys_write(2, msg, mo)
291 sys_exit(0)
292 return 0
293 }
294 if verb[0] == (98 as u8) {
295 if argc >= 3 { let rcb: i64 = eb_body(argv[2] as *u8); sys_exit(rcb); return rcb }
296 eb_werr("usage: nx_editor_board body <fragment-out>\n" as *u8)
297 sys_exit(2)
298 return 2
299 }
300 if verb[0] == (101 as u8) {
301 if argc >= 3 { let rc: i64 = eb_emit(argv[2] as *u8); sys_exit(rc); return rc }
302 eb_werr("usage: nx_editor_board [emit <out>|selftest]\n" as *u8)
303 sys_exit(2)
304 return 2
305 }
306 }
307 let rc2: i64 = eb_emit(EB_DEFOUT)
308 sys_exit(rc2)
309 return rc2
310}