code wiki / _hdl_build / nx_acceptview.nx
nx_acceptview.nx source
↩ module page · 629 lines · 37123 B
1// nx_acceptview.nx -- THE OPERATOR'S REVIEW QUEUE, PUBLISHED.
2//
3// WHY IT EXISTS (operator, 2026-09-03): "for human acceptance you need to publish a queue and evidence to
4// review like how we have rigview but you arent anywhere". That was exactly right and it named the missing
5// half of the three-party doctrine. The ledger was already complete -- nx_accept list computes, for every
6// subject, which of the three parties is missing, and knowledge/store/accept- already holds the operator's
7// own verdicts and words. NONE OF IT WAS PUBLISHED ANYWHERE. Acceptance you cannot SEE is not acceptance,
8// and asking an operator to attest to a queue that only exists as a CLI verb is asking them to sign blind.
9//
10// ★★★★★★A DECISION THAT REQUIRES A HUMAN AND IS NOT PUT IN FRONT OF THEM IS NOT A PENDING DECISION, IT IS
11// A STALLED ONE -- and from the inside it looks identical to the human being slow.
12//
13// COMPOSES, NEVER RE-DERIVES. The verdict and the missing-party call come from nx_accept list (one
14// classifier, nx_accept_lib, shared by every consumer); the operator's words come from the accept- plane
15// through nx_store_put's own loader. This organ computes NO verdict of its own -- a second opinion rendered
16// beside the first is the duplicate-ruler defect wearing a stylesheet.
17//
18// SORTS BY WHO IS BLOCKED. Subjects awaiting the OPERATOR come first, because this page exists for them;
19// everything else is shown but marked as waiting on a seat or a referee. A queue that does not say whose
20// turn it is makes the reader compute that themselves, every time.
21//
22// ESCAPES BY CONSTRUCTION. Operator words are free text written by a human and are rendered through
23// av_esc -- an unescaped quote or angle bracket in a rejection note must never become markup.
24// nx_acceptview [droot] default sites/nishifamily/compare (page: <droot>/acceptance/index.html)
25// license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0
26import "nx_syscalls.nx"
27import "nx_tool_run.nx"
28
29const AV_DROOT: *u8 = "sites/nishifamily/compare"
30const AV_SUBDIR: *u8 = "/acceptance"
31const AV_PAGE: *u8 = "/acceptance/index.html"
32const AV_STATUS: *u8 = "knowledge/status/accept_queue.status"
33const AV_ACCEPT_ELF: *u8 = "nx_accept.elf"
34const AV_STORE_ELF: *u8 = "nx_store_put.elf"
35const AV_PLANE: *u8 = "knowledge/store/accept-"
36const AV_REFPLANE: *u8 = "knowledge/store/referee-"
37// The referee plane stores an ABSOLUTE capture path; the page needs a URL. Everything under the served
38// site root maps 1:1, so the URL is the path with this prefix removed. Declared as a constant rather than
39// counted by hand: a hand-counted length beside a literal is a second copy of that literal's shape.
40const AV_SITEROOT: *u8 = "/volume1/homes/elderwesto/nishihost/sites/nishifamily"
41const AV_CAP: i64 = 262144
42const AV_PAGECAP: i64 = 524288
43const AV_STATCAP: i64 = 8192
44const AV_PATHB: i64 = 512
45const AV_TMO_MS: i64 = 20000
46const AV_MODE_DIR: i64 = 493 // 0755
47const AV_MODE_FILE: i64 = 420 // 0644
48const AV_NL: i64 = 10
49const AV_SP: i64 = 32
50const AV_TAB: i64 = 9
51const AV_COMMA: i64 = 44
52const AV_KEYPFX: *u8 = "ga_accept_"
53
54// ---- THE SECOND QUESTION, AND IT IS NOT THE LEDGER'S (2026-09-03) -----------------------------------
55// The ledger asks "has everyone signed?". It cannot ask "are we IMPROVING?", because a referee row is a
56// single-arm point grade: one capture, one number, no control. percept=214 against floor=151 says the frame
57// cleared the bar; it says NOTHING about whether the frame is better than the one before it, and a
58// bar-clearing frame can be a regression from a much better predecessor.
59// THE TWO ARE NOT DERIVABLE FROM EACH OTHER and this page must never present one as the other.
60// THIS ORGAN STILL COMPUTES NO VERDICT. A contrast needs TWO referee rows and nx_abstat owns the contrast;
61// all that is published here is whether the question CAN be answered for this subject, read straight off
62// the arm count the ledger already prints. Today that is the finding: publishing it turns an unanswerable
63// question from an ABSENCE into a visible state.
64// * AN ABSTENTION NOBODY READS IS A LIE NOBODY TOLD -- a page that simply omits the improvement question
65// reads as though it were not being asked, rather than as though it could not be answered.
66const AV_ARMS_NEEDED: i64 = 2 // the floor to PAIR at all: a contrast needs a baseline and a candidate
67// ...but pairing is not power. The unit of replication is the RUN, and a two-sample test needs the sample
68// floor PER ARM before it can say anything -- nx_abstat's NX_MC_MIN_N, which is 30. A page that called two
69// captures CONTRASTABLE would be promising a verdict the statistics cannot deliver, so the states below
70// distinguish PAIRED-NOT-YET-POWERED from CONTRASTABLE.
71// * TWO MEASUREMENTS MAKE A COMPARISON; THEY DO NOT MAKE AN INFERENCE, AND A SURFACE THAT BLURS THE TWO
72// INVITES EXACTLY THE CLAIM THE WHOLE LANE EXISTS TO PREVENT.
73const AV_ARMS_POWERED: i64 = 30
74const AV_D0: i64 = 48
75const AV_D9: i64 = 57
76
77func av_int_at(b: *u8, s: i64, e: i64) -> i64 {
78 var v: i64 = 0
79 var i: i64 = s
80 var any: i64 = 0
81 while i < e {
82 let c: i64 = b[i] as i64
83 if c >= AV_D0 { if c <= AV_D9 { v = v * 10 + (c - AV_D0); any = 1 } }
84 i = i + 1
85 }
86 if any == 0 { return 0 - 1 }
87 return v
88}
89
90// FOUR states, because three would force a lie: an unreadable arm count is not the same as zero arms, and
91// zero arms is not the same as one. Each names what is missing rather than saying a bare "no".
92func av_arm_state(rows: i64) -> *u8 {
93 if rows < 0 { return "UNREADABLE-ARM-COUNT" as *u8 }
94 if rows == 0 { return "NO-ARMS-NEVER-GRADED" as *u8 }
95 if rows < AV_ARMS_NEEDED { return "ONE-ARM-NO-BASELINE" as *u8 }
96 if rows < AV_ARMS_POWERED { return "PAIRED-NOT-YET-POWERED" as *u8 }
97 return "CONTRASTABLE" as *u8
98}
99
100func av_w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
101func av_n(v: i64) -> i64 {
102 let b: *u8 = sys_mmap(32); var x: i64 = v; var i: i64 = 31
103 if x < 0 { x = 0 - x }
104 if x == 0 { b[i] = 48 as u8; i = i - 1 }
105 while x > 0 { b[i] = (48 + x % 10) as u8; x = x / 10; i = i - 1 }
106 if v < 0 { b[i] = 45 as u8; i = i - 1 }
107 sys_write(1, ((b as i64) + i + 1) as *u8, 31 - i); return 0
108}
109func av_cat(d: *u8, o: i64, s: *u8) -> i64 { var p: i64 = o; var i: i64 = 0; while s[i] != (0 as u8) { d[p] = s[i]; p = p + 1; i = i + 1 } return p }
110
111// ---- THE ACCEPT-PLANE JOIN KEY, IN ONE PLACE, BECAUSE IT WAS WRONG ON THE OPERATOR'S OWN PAGE.
112// A card renders a subject's operator words beside that subject's referee capture. The first cut joined
113// them by searching the plane row for the SUBJECT NAME as a bare substring, and FACE MATCHED THE SKIN ROW
114// -- skin's targets carry graphics:gpe_skin_microsurface, and "microsurface" contains "face". The page
115// then rendered one subject's rejection words underneath another subject's image, which is worse than
116// rendering no words at all: a confident wrong attribution on the surface an operator signs from.
117// ★★★★★★A SUBSTRING IS NOT A KEY, AND THE ESTATE ALREADY HAD A REAL ONE HERE. nx_accept's contract is that
118// a row governs a subject through ga_accept_<subject> in its targets field; the weaker join was INVENTED
119// beside a declared one and failed silently on exactly the row a reader would trust most.
120// DECLARED IMPRECISION: only the RIGHT boundary is enforced. A left boundary is deliberately NOT required,
121// because a target is legitimately written graphics:ga_accept_face and refusing that shape would trade a
122// measured false positive for an unmeasured false negative.
123
124func av_is_term(c: i64) -> i64 {
125 if c == AV_COMMA { return 1 }
126 if c == AV_TAB { return 1 }
127 if c == AV_NL { return 1 }
128 if c == AV_SP { return 1 }
129 return 0
130}
131
132// av_needle -- build ga_accept_<subject> into dst; returns its length, or -1 when it cannot.
133// An EMPTY subject is refused BY NAME rather than building the bare prefix, which would then match every
134// acceptance target in the plane and answer yes to a question nobody asked.
135func av_needle(dst: *u8, cap: i64, subj: *u8, s0: i64, s1: i64) -> i64 {
136 if s1 <= s0 { return -1 }
137 var n: i64 = 0
138 var i: i64 = 0
139 while AV_KEYPFX[i] != (0 as u8) {
140 if n + 1 >= cap { return -1 }
141 dst[n] = AV_KEYPFX[i]
142 n = n + 1
143 i = i + 1
144 }
145 var k: i64 = s0
146 while k < s1 {
147 if n + 1 >= cap { return -1 }
148 dst[n] = subj[k]
149 n = n + 1
150 k = k + 1
151 }
152 dst[n] = 0 as u8
153 return n
154}
155
156// av_key_hit -- does [from,to) of hay carry the WHOLE key, ended where the row ends it?
157func av_key_hit(hay: *u8, from: i64, to: i64, nd: *u8, nl: i64) -> i64 {
158 if nl <= 0 { return 0 }
159 if to <= from { return 0 }
160 var hit: i64 = 0
161 var q: i64 = from
162 var scan: i64 = 1
163 while scan == 1 {
164 if q >= to { scan = 0 } else {
165 var k: i64 = 0
166 var eq: i64 = 1
167 var cmp: i64 = 1
168 while cmp == 1 {
169 if k >= nl { cmp = 0 } else {
170 if q + k >= to { eq = 0; cmp = 0 } else {
171 if hay[q + k] != nd[k] { eq = 0; cmp = 0 } else { k = k + 1 }
172 }
173 }
174 }
175 if eq == 1 { if q + nl < to { if av_is_term(hay[q + nl] as i64) == 0 { eq = 0 } } }
176 if eq == 1 { hit = 1; scan = 0 } else { q = q + 1 }
177 }
178 }
179 return hit
180}
181func av_catn(d: *u8, o: i64, v: i64) -> i64 {
182 var p: i64 = o; var m: i64 = v
183 if m < 0 { d[p] = 45 as u8; p = p + 1; m = 0 - m }
184 if m == 0 { d[p] = 48 as u8; return p + 1 }
185 var pw: i64 = 1
186 while m / pw >= 10 { pw = pw * 10 }
187 while pw > 0 { d[p] = (48 + (m / pw) % 10) as u8; p = p + 1; pw = pw / 10 }
188 return p
189}
190// HTML-escape a byte range. The operator's rejection notes are free text a human typed; an unescaped
191// angle bracket there would become markup on a page the operator reads to make a decision.
192func av_esc(d: *u8, o: i64, src: *u8, s: i64, e: i64) -> i64 {
193 var p: i64 = o
194 var i: i64 = s
195 while i < e {
196 let c: i64 = src[i] as i64
197 if c == 38 { p = av_cat(d, p, "&" as *u8) } else {
198 if c == 60 { p = av_cat(d, p, "<" as *u8) } else {
199 if c == 62 { p = av_cat(d, p, ">" as *u8) } else {
200 if c == 34 { p = av_cat(d, p, """ as *u8) } else {
201 d[p] = src[i]; p = p + 1
202 } } } }
203 i = i + 1
204 }
205 return p
206}
207func av_lit_at(b: *u8, i: i64, e: i64, lit: *u8) -> i64 {
208 var k: i64 = 0
209 while lit[k] != (0 as u8) {
210 if i + k >= e { return 0 }
211 if b[i + k] != lit[k] { return 0 }
212 k = k + 1
213 }
214 return 1
215}
216// Find `key` within [s,e) and return the extent of its value (to the next space or end) via out[0]/out[1].
217// Returns 1 when found. Values in this format never contain a space -- the operator's WORDS come from the
218// plane, which is tab-separated, and are handled separately.
219func av_val(b: *u8, s: i64, e: i64, key: *u8, out: *i64) -> i64 {
220 var kl: i64 = 0
221 while key[kl] != (0 as u8) { kl = kl + 1 }
222 var i: i64 = s
223 while i + kl <= e {
224 if av_lit_at(b, i, e, key) == 1 {
225 let vs: i64 = i + kl
226 var ve: i64 = vs
227 while ve < e { if (b[ve] as i64) == AV_SP { ve = e + 1 } else { ve = ve + 1 } }
228 var realend: i64 = vs
229 while realend < e { if (b[realend] as i64) == AV_SP { realend = e } else { realend = realend + 1 } }
230 var fin: i64 = vs
231 var go: i64 = 1
232 while go == 1 {
233 if fin >= e { go = 0 } else {
234 if (b[fin] as i64) == AV_SP { go = 0 } else { fin = fin + 1 }
235 }
236 }
237 out[0] = vs
238 out[1] = fin
239 return 1
240 }
241 i = i + 1
242 }
243 out[0] = 0
244 out[1] = 0
245 return 0
246}
247
248func main(argc: i64, argv: *i64) -> i64 {
249 var droot: *u8 = AV_DROOT
250 if argc >= 2 { droot = argv[1] as *u8 }
251
252 av_w("=== NX-ACCEPTVIEW -- publish the three-party acceptance queue (composes nx_accept list; computes no verdict of its own) ===\n" as *u8)
253
254 // ---- 0. RESOLVE THE PREFIX ONCE, BEFORE ANYTHING FORKS. First version resolved the OUTPUT paths
255 // and forgot that the CHILD PATHS are CWD-relative too: nx_accept.elf from CWD=buildroot is not
256 // found, execve returned, and the capture came back holding NX-EXEC-FAILED rc=127. The page
257 // published anyway, saying "Nothing is waiting on you right now" over five open subjects.
258 // ★★★★★★FIXING A PATH CLASS IN THE PLACE YOU NOTICED IT IS NOT FIXING THE CLASS -- the same CWD
259 // question governs every path this organ touches, including the ones it hands to execve.
260 var pfx: *u8 = "" as *u8
261 let probe: *u8 = sys_mmap(AV_PATHB)
262 var pl0: i64 = av_cat(probe, 0, AV_ACCEPT_ELF)
263 probe[pl0] = 0 as u8
264 var tfd: i64 = sys_openat_rd(probe)
265 if tfd < 0 {
266 pfx = "../" as *u8
267 var pl1: i64 = av_cat(probe, 0, pfx)
268 pl1 = av_cat(probe, pl1, AV_ACCEPT_ELF)
269 probe[pl1] = 0 as u8
270 tfd = sys_openat_rd(probe)
271 }
272 if tfd < 0 {
273 av_w("REFUSED: nx_accept.elf not found from this CWD as either " as *u8); av_w(AV_ACCEPT_ELF)
274 av_w(" or ../" as *u8); av_w(AV_ACCEPT_ELF)
275 av_w("\n Naming both is deliberate -- this is a CWD question, not a missing binary.\nverdict=SKIP\n" as *u8)
276 return 3
277 }
278 sys_close(tfd)
279 av_w("PREFIX resolved=" as *u8)
280 if pfx[0] == (0 as u8) { av_w("(none, CWD is the estate root)" as *u8) } else { av_w(pfx) }
281 av_w("\n" as *u8)
282 let ap: *u8 = sys_mmap(AV_PATHB)
283 var apn: i64 = av_cat(ap, 0, pfx); apn = av_cat(ap, apn, AV_ACCEPT_ELF); ap[apn] = 0 as u8
284 let sp2: *u8 = sys_mmap(AV_PATHB)
285 var spn: i64 = av_cat(sp2, 0, pfx); spn = av_cat(sp2, spn, AV_STORE_ELF); sp2[spn] = 0 as u8
286 // AND THE PLANE PATH, which is an ARGUMENT rather than an executable and was missed twice for exactly
287 // that reason. THIRD INSTANCE OF ONE CLASS IN ONE ORGAN: the output paths, then the child elf paths,
288 // now the child's ARGUMENTS -- every one of them a bare relative path, every one silently meaning a
289 // different tree depending on who forked us. The first two REFUSED loudly; this one failed QUIETLY,
290 // publishing cards with the operator's own words missing and nothing saying they were missing.
291 // ★★★★★★THE THIRD OCCURRENCE IS WHERE YOU STOP FIXING INSTANCES AND FIX THE SHAPE: one prefix,
292 // resolved once at entry, applied to EVERY path -- output, executable, and argument alike.
293 let plp: *u8 = sys_mmap(AV_PATHB)
294 var pln: i64 = av_cat(plp, 0, pfx); pln = av_cat(plp, pln, AV_PLANE); plp[pln] = 0 as u8
295
296 // ---- 1. THE LEDGER, from the one classifier.
297 let lbuf: *u8 = sys_mmap(AV_CAP)
298 let llen: *i64 = sys_mmap(16) as *i64
299 let a1: *i64 = sys_mmap(64) as *i64
300 a1[0] = ap as i64
301 a1[1] = "list" as i64
302 a1[2] = 0
303 llen[0] = 0
304 let rc1: i64 = tr_run_capture_to(ap, a1, lbuf, AV_CAP, llen, AV_TMO_MS)
305 if llen[0] <= 0 {
306 av_w("REFUSED: nx_accept list produced no output (rc=" as *u8); av_n(rc1)
307 av_w(") -- publishing an EMPTY queue would read as nothing awaiting review, which is the most\n dangerous possible false statement for this page to make. No page written.\nverdict=SKIP\n" as *u8)
308 return 3
309 }
310
311 // ---- 2. THE OPERATOR'S WORDS, from the plane's own loader.
312 let pbuf: *u8 = sys_mmap(AV_CAP)
313 let plen: *i64 = sys_mmap(16) as *i64
314 let a2: *i64 = sys_mmap(64) as *i64
315 a2[0] = sp2 as i64
316 a2[1] = plp as i64
317 a2[2] = "load" as i64
318 a2[3] = 0
319 plen[0] = 0
320 tr_run_capture_to(sp2, a2, pbuf, AV_CAP, plen, AV_TMO_MS)
321 // THE GUARD THAT SHOULD HAVE EXISTED FIRST TIME. Checking that the capture returned BYTES is not
322 // checking that the tool RAN: a failed execve returns a full, articulate error message, and the
323 // first version of this organ published a page reading "Nothing is waiting on you right now" over
324 // five open subjects because NX-EXEC-FAILED rc=127 is bytes.
325 // ★★★★★★A NON-EMPTY CAPTURE IS NOT A SUCCESSFUL RUN -- AND THE FAILURE MESSAGE IS EXACTLY THE THING
326 // THAT MAKES IT LOOK LIKE ONE.
327 var i9: i64 = 0
328 var execfail: i64 = 0
329 while i9 + 14 <= llen[0] {
330 if av_lit_at(lbuf, i9, llen[0], "NX-EXEC-FAILED" as *u8) == 1 { execfail = 1; i9 = llen[0] } else { i9 = i9 + 1 }
331 }
332 if execfail == 1 {
333 av_w("REFUSED: the ledger capture holds NX-EXEC-FAILED -- nx_accept never ran, so this organ knows\n NOTHING about what is awaiting review. Publishing now would state that nothing is, which is the\n single most dangerous sentence this page can carry. No page written.\nverdict=SKIP\n" as *u8)
334 return 3
335 }
336
337 // ---- 2b. THE REFEREE PLANE, WHICH CARRIES THE ACTUAL CAPTURE. Operator 2026-09-03: "you didnt even
338 // put any media output evidence on it this is the bullshit i tell you about i hate" -- and they were
339 // right. face, hair, skin, garments and locomotion are VISUAL subjects; nobody can judge photorealism
340 // from the word REJECT and an integer. The referee row has held the png path all along --
341 // nx_accept referee <subject> <png> <tier> <seat> -- and the first version of this page rendered the
342 // GRADE and threw away the IMAGE.
343 // ★★★★★★A REVIEW SURFACE FOR A VISUAL SUBJECT THAT SHOWS A NUMBER INSTEAD OF THE PIXELS HAS
344 // PUBLISHED THE MEASUREMENT AND WITHHELD THE EVIDENCE -- the reader cannot check the grader, which is
345 // the entire reason a human is in this loop.
346 let rbuf: *u8 = sys_mmap(AV_CAP)
347 let rlen: *i64 = sys_mmap(16) as *i64
348 let rpl: *u8 = sys_mmap(AV_PATHB)
349 var rpn: i64 = av_cat(rpl, 0, pfx); rpn = av_cat(rpl, rpn, AV_REFPLANE); rpl[rpn] = 0 as u8
350 let a3: *i64 = sys_mmap(64) as *i64
351 a3[0] = sp2 as i64
352 a3[1] = rpl as i64
353 a3[2] = "load" as i64
354 a3[3] = 0
355 rlen[0] = 0
356 tr_run_capture_to(sp2, a3, rbuf, AV_CAP, rlen, AV_TMO_MS)
357
358 // ---- 3. RENDER. Two passes over the ledger: operator-blocked first, then everything else.
359 let pg: *u8 = sys_mmap(AV_PAGECAP)
360 var o: i64 = 0
361 o = av_cat(pg, o, "<!doctype html><meta charset=utf-8><title>Acceptance queue</title>" as *u8)
362 o = av_cat(pg, o, "<meta name=viewport content=\"width=device-width,initial-scale=1\">" as *u8)
363 o = av_cat(pg, o, "<style>:root{color-scheme:light dark}body{font-family:-apple-system,Segoe UI,sans-serif;max-width:900px;margin:3vh auto;padding:0 16px;line-height:1.5}" as *u8)
364 o = av_cat(pg, o, "h1{font-size:1.3rem;letter-spacing:-.02em}.sub{color:rgb(110,110,118);font-size:.9rem}" as *u8)
365 o = av_cat(pg, o, ".card{border:1px solid rgb(200,200,208);border-radius:12px;padding:14px 16px;margin:12px 0}" as *u8)
366 o = av_cat(pg, o, ".you{border-color:rgb(200,120,0);background:rgba(255,170,0,0.07)}" as *u8)
367 o = av_cat(pg, o, ".s{font-weight:700;font-size:1.05rem}.b{color:rgb(110,110,118);font-size:.85rem}" as *u8)
368 o = av_cat(pg, o, ".p{display:inline-block;border:1px solid rgb(200,200,208);border-radius:999px;padding:2px 10px;margin:4px 6px 0 0;font-size:.82rem}" as *u8)
369 o = av_cat(pg, o, ".ok{border-color:rgb(0,140,80);color:rgb(0,120,70)}.no{border-color:rgb(190,60,60);color:rgb(170,50,50)}" as *u8)
370 o = av_cat(pg, o, ".words{margin-top:10px;padding:10px 12px;border-left:3px solid rgb(200,120,0);background:rgba(128,128,128,0.08);white-space:pre-wrap;overflow-wrap:anywhere;font-size:.92rem}" as *u8)
371 o = av_cat(pg, o, "table{border-collapse:collapse;width:100%;font-size:.85rem;margin-top:8px}td,th{text-align:left;padding:4px 8px;border-top:1px solid rgb(200,200,208)}" as *u8)
372 o = av_cat(pg, o, ".wrap{overflow-x:auto}</style>" as *u8)
373 o = av_cat(pg, o, "<h1>Acceptance queue</h1>" as *u8)
374 o = av_cat(pg, o, "<p class=sub>COMPLETE means three signatures: the OPERATOR, the REFEREE panel, and the SEAT. A subject is not done until all three agree. This page composes <code>nx_accept list</code> and the <code>accept-</code> plane and computes no verdict of its own.</p>" as *u8)
375
376 // pass 0 = operator-blocked, pass 1 = the rest
377 var pass: i64 = 0
378 var n_you: i64 = 0
379 var n_rework: i64 = 0
380 var n_other: i64 = 0
381 while pass < 3 {
382 if pass == 0 { o = av_cat(pg, o, "<h2 style=\"font-size:1.05rem\">Your decision</h2>" as *u8) }
383 if pass == 1 { o = av_cat(pg, o, "<h2 style=\"font-size:1.05rem\">You rejected these — waiting on a seat to rework</h2>" as *u8) }
384 if pass == 2 { o = av_cat(pg, o, "<h2 style=\"font-size:1.05rem\">Waiting on a seat or the referee</h2>" as *u8) }
385 var i: i64 = 0
386 let n: i64 = llen[0]
387 while i < n {
388 var e: i64 = i
389 var f: i64 = 0
390 while f == 0 { if e >= n { f = 1 } else { if (lbuf[e] as i64) == AV_NL { f = 1 } else { e = e + 1 } } }
391 if av_lit_at(lbuf, i, e, "subject=" as *u8) == 1 {
392 let vx: *i64 = sys_mmap(16) as *i64
393 av_val(lbuf, i, e, "missing=" as *u8, vx)
394 let ms: i64 = vx[0]
395 let me: i64 = vx[1]
396 // OPERATOR-* means this row is the operator's move
397 // THREE buckets, not two. missing=OPERATOR-REJECT means the operator HAS acted and a
398 // SEAT must now rework; only OPERATOR-UNJUDGED is a decision still owed by the operator.
399 // Collapsing both into "waiting on you" hands the operator four items that are not theirs
400 // to move, and a queue that misstates whose turn it is has failed at the one job it has.
401 var bucket: i64 = 2
402 if av_lit_at(lbuf, ms, me, "OPERATOR-UNJUDGED" as *u8) == 1 { bucket = 0 }
403 if av_lit_at(lbuf, ms, me, "OPERATOR-REJECT" as *u8) == 1 { bucket = 1 }
404 var isyou: i64 = 0
405 if bucket == 0 { isyou = 1 }
406 var show: i64 = 0
407 if bucket == pass { show = 1 }
408 if show == 1 {
409 if pass == 0 { n_you = n_you + 1 }
410 if pass == 1 { n_rework = n_rework + 1 }
411 if pass == 2 { n_other = n_other + 1 }
412 o = av_cat(pg, o, "<div class=\"card" as *u8)
413 if isyou == 1 { o = av_cat(pg, o, " you" as *u8) }
414 o = av_cat(pg, o, "\"><div class=s>" as *u8)
415 av_val(lbuf, i, e, "subject=" as *u8, vx)
416 o = av_esc(pg, o, lbuf, vx[0], vx[1])
417 o = av_cat(pg, o, "</div><div class=b>board " as *u8)
418 av_val(lbuf, i, e, "board=" as *u8, vx)
419 o = av_esc(pg, o, lbuf, vx[0], vx[1])
420 o = av_cat(pg, o, " · missing " as *u8)
421 o = av_esc(pg, o, lbuf, ms, me)
422 o = av_cat(pg, o, "</div>" as *u8)
423 // the three parties, each as its own chip
424 o = av_cat(pg, o, "<span class=\"p\">operator " as *u8)
425 av_val(lbuf, i, e, "operator=" as *u8, vx); o = av_esc(pg, o, lbuf, vx[0], vx[1])
426 o = av_cat(pg, o, "</span><span class=\"p\">referee " as *u8)
427 av_val(lbuf, i, e, "referee=" as *u8, vx); o = av_esc(pg, o, lbuf, vx[0], vx[1])
428 o = av_cat(pg, o, "</span><span class=\"p\">seat " as *u8)
429 av_val(lbuf, i, e, "seat=" as *u8, vx); o = av_esc(pg, o, lbuf, vx[0], vx[1])
430 o = av_cat(pg, o, "</span>" as *u8)
431 // referee EVIDENCE, printed as numbers not as a word -- percept against its own floor
432 o = av_cat(pg, o, "<span class=\"p\">percept " as *u8)
433 av_val(lbuf, i, e, "percept=" as *u8, vx); o = av_esc(pg, o, lbuf, vx[0], vx[1])
434 o = av_cat(pg, o, " vs floor " as *u8)
435 av_val(lbuf, i, e, "floor=" as *u8, vx); o = av_esc(pg, o, lbuf, vx[0], vx[1])
436 o = av_cat(pg, o, "</span>" as *u8)
437 // THE SECOND QUESTION, published beside the first and never merged with it: the chip
438 // above says whether this frame cleared its BAR, this one says whether an IMPROVEMENT
439 // claim is even answerable. The arm count is read from the ledger, not recomputed.
440 o = av_cat(pg, o, "<span class=\"p\">improving? " as *u8)
441 av_val(lbuf, i, e, "ref_rows=" as *u8, vx)
442 let arms: i64 = av_int_at(lbuf, vx[0], vx[1])
443 o = av_cat(pg, o, av_arm_state(arms))
444 o = av_cat(pg, o, " (runs " as *u8)
445 o = av_catn(pg, o, arms)
446 o = av_cat(pg, o, "; " as *u8)
447 o = av_catn(pg, o, AV_ARMS_NEEDED)
448 o = av_cat(pg, o, " to pair, " as *u8)
449 o = av_catn(pg, o, AV_ARMS_POWERED)
450 o = av_cat(pg, o, " to infer)</span>" as *u8)
451 // ---- THE CAPTURE ITSELF. Find this subject's referee row and render the PIXELS the
452 // lens graded, not just its verdict on them. The png path is the row's LAST tab field
453 // and is absolute; everything under the served site root maps 1:1 to a URL.
454 av_val(lbuf, i, e, "subject=" as *u8, vx)
455 let msubs: i64 = vx[0]
456 let msube: i64 = vx[1]
457 var rfound: i64 = 0
458 var ri: i64 = 0
459 let rn: i64 = rlen[0]
460 while ri < rn {
461 var re2: i64 = ri
462 var rf: i64 = 0
463 while rf == 0 { if re2 >= rn { rf = 1 } else { if (rbuf[re2] as i64) == AV_NL { rf = 1 } else { re2 = re2 + 1 } } }
464 if rfound == 0 { if re2 > ri {
465 // subject is the SECOND tab field
466 var sfs: i64 = ri
467 var seen1: i64 = 0
468 var z: i64 = ri
469 while z < re2 { if (rbuf[z] as i64) == AV_TAB { if seen1 == 0 { sfs = z + 1; seen1 = 1 } } z = z + 1 }
470 var sfe: i64 = sfs
471 var g3: i64 = 1
472 while g3 == 1 { if sfe >= re2 { g3 = 0 } else { if (rbuf[sfe] as i64) == AV_TAB { g3 = 0 } else { sfe = sfe + 1 } } }
473 var same: i64 = 1
474 if sfe - sfs != msube - msubs { same = 0 } else {
475 var k2: i64 = 0
476 while k2 < msube - msubs { if rbuf[sfs + k2] != lbuf[msubs + k2] { same = 0; k2 = msube - msubs } else { k2 = k2 + 1 } }
477 }
478 if same == 1 { if seen1 == 1 {
479 var lastt: i64 = ri
480 var z2: i64 = ri
481 while z2 < re2 { if (rbuf[z2] as i64) == AV_TAB { lastt = z2 + 1 } z2 = z2 + 1 }
482 if lastt < re2 {
483 // strip the served root to get a URL; if it is not under the root, say so
484 // rather than emitting a broken src that renders as a silent blank.
485 var rootlen: i64 = 0
486 while AV_SITEROOT[rootlen] != (0 as u8) { rootlen = rootlen + 1 }
487 var under: i64 = 1
488 var k3: i64 = 0
489 while k3 < rootlen { if lastt + k3 >= re2 { under = 0; k3 = rootlen } else { if rbuf[lastt + k3] != AV_SITEROOT[k3] { under = 0; k3 = rootlen } else { k3 = k3 + 1 } } }
490 if under == 1 {
491 o = av_cat(pg, o, "<figure style=\"margin:12px 0\"><img loading=lazy style=\"max-width:100%;border-radius:8px;border:1px solid rgb(200,200,208)\" src=\"" as *u8)
492 o = av_esc(pg, o, rbuf, lastt + rootlen, re2)
493 o = av_cat(pg, o, "\" alt=\"referee capture\"><figcaption class=b>the capture the referee lens actually graded — judge the pixels, not the number</figcaption></figure>" as *u8)
494 } else {
495 o = av_cat(pg, o, "<div class=b>CAPTURE EXISTS BUT IS NOT UNDER THE SERVED ROOT, so it has no URL: " as *u8)
496 o = av_esc(pg, o, rbuf, lastt, re2)
497 o = av_cat(pg, o, " — named rather than emitted as a broken src, which would render as a silent blank.</div>" as *u8)
498 }
499 rfound = 1
500 }
501 } }
502 } }
503 ri = re2 + 1
504 }
505 if rfound == 0 {
506 o = av_cat(pg, o, "<div class=b style=\"margin-top:10px;padding:8px 10px;border:1px dashed rgb(190,60,60);border-radius:8px\">NO CAPTURE. The referee lens has never run on this subject, so there is no image here to judge and any verdict on it rests on an eye alone. <code>nx_accept referee <subject> <png> <tier> <seat></code> is what puts pixels on this page.</div>" as *u8)
507 }
508 // the OPERATOR'S OWN WORDS from the plane, joined on the DECLARED key -- see av_needle
509 // for why a bare subject substring was wrong and what it cost on the served page.
510 // A subject that cannot be keyed yields ndl = -1, and av_key_hit answers 0 for that, so
511 // the card renders WITHOUT words rather than with somebody else's.
512 av_val(lbuf, i, e, "subject=" as *u8, vx)
513 let subs: i64 = vx[0]
514 let sube: i64 = vx[1]
515 let nd: *u8 = sys_mmap(AV_PATHB)
516 let ndl: i64 = av_needle(nd, AV_PATHB, lbuf, subs, sube)
517 var pi: i64 = 0
518 let pn: i64 = plen[0]
519 var found: i64 = 0
520 while pi < pn {
521 var pe: i64 = pi
522 var pf: i64 = 0
523 while pf == 0 { if pe >= pn { pf = 1 } else { if (pbuf[pe] as i64) == AV_NL { pf = 1 } else { pe = pe + 1 } } }
524 if found == 0 {
525 // ONE join, shared with the gate that proves it (av_key_hit).
526 let hit: i64 = av_key_hit(pbuf, pi, pe, nd, ndl)
527 if hit == 1 {
528 // words are the 6th tab field; walk to it
529 var tabs: i64 = 0
530 var ws: i64 = pi
531 var t: i64 = pi
532 while t < pe {
533 if (pbuf[t] as i64) == AV_TAB { tabs = tabs + 1; if tabs == 5 { ws = t + 1 } if tabs == 6 { t = pe } }
534 if t < pe { t = t + 1 }
535 }
536 var we: i64 = ws
537 while we < pe { if (pbuf[we] as i64) == AV_TAB { we = pe } else { we = we + 1 } }
538 var wend: i64 = ws
539 var g2: i64 = 1
540 while g2 == 1 { if wend >= pe { g2 = 0 } else { if (pbuf[wend] as i64) == AV_TAB { g2 = 0 } else { wend = wend + 1 } } }
541 if wend > ws {
542 o = av_cat(pg, o, "<div class=words>" as *u8)
543 o = av_esc(pg, o, pbuf, ws, wend)
544 o = av_cat(pg, o, "</div>" as *u8)
545 found = 1
546 }
547 }
548 }
549 pi = pe + 1
550 }
551 o = av_cat(pg, o, "</div>" as *u8)
552 }
553 }
554 i = e + 1
555 }
556 if pass == 0 { if n_you == 0 { o = av_cat(pg, o, "<p class=sub>Nothing is waiting on you right now.</p>" as *u8) } }
557 pass = pass + 1
558 }
559
560 // ---- the raw ledger line, verbatim, so the page can never disagree with the organ it composes
561 o = av_cat(pg, o, "<h2 style=\"font-size:1.05rem\">Ledger, verbatim</h2><div class=wrap><pre style=\"font-size:.78rem;overflow-x:auto\">" as *u8)
562 o = av_esc(pg, o, lbuf, 0, llen[0])
563 o = av_cat(pg, o, "</pre></div>" as *u8)
564 o = av_cat(pg, o, "<p class=sub>To accept a subject, write one row to the <code>accept-</code> plane with a <code>targets</code> field naming its <code>ga_accept_<subject></code> symbol. A row whose targets field does not name that symbol governs nothing and is printed as UNMAPPED.</p>" as *u8)
565
566 // ---- 4. WRITE THE PAGE.
567 // ---- RESOLVE THE ROOT, AND SAY WHICH ONE WON. A bare relative path is a CWD-RELATIVE EXPRESSION,
568 // not a tree name: nx_sov_build_run chdirs into buildroot/ before forking, the mgmt daemon does not,
569 // and the SAME literal therefore names two different trees depending on the caller. This organ's
570 // first run refused for exactly that reason -- it wrote sites/... from buildroot/ and there is no
571 // buildroot/sites. nx_maturity_board carries a hardcoded ../ for the same reason; probing and
572 // ANNOUNCING is better, because a resolver that returns a path without saying where it came from
573 // reproduces the original defect one layer up. The prefix found here is used for the STATUS file
574 // too -- buildroot/knowledge/status EXISTS, so an unresolved status write would land silently in
575 // the wrong one of the estate's two knowledge trees.
576 // ONE prefix, resolved at entry, used by every path this organ touches -- child elfs, docroot and
577 // status alike. The earlier version probed here SEPARATELY from the child paths, which is how the
578 // two disagreed and the page published over a failed fork.
579 let pb: *u8 = sys_mmap(AV_PATHB)
580 let pp: *u8 = sys_mmap(AV_PATHB)
581 var q1: i64 = av_cat(pb, 0, pfx)
582 q1 = av_cat(pb, q1, droot)
583 q1 = av_cat(pb, q1, AV_SUBDIR)
584 pb[q1] = 0 as u8
585 sys_mkdir(pb, AV_MODE_DIR)
586 var q2: i64 = av_cat(pp, 0, pfx)
587 q2 = av_cat(pp, q2, droot)
588 q2 = av_cat(pp, q2, AV_PAGE)
589 pp[q2] = 0 as u8
590 let fd: i64 = sys_openat_wr(pp, AV_MODE_FILE)
591 if fd < 0 {
592 av_w("REFUSED: no writable docroot. Probed BOTH candidates from this CWD: " as *u8)
593 av_w(droot); av_w(AV_PAGE); av_w(" and ../" as *u8); av_w(droot); av_w(AV_PAGE)
594 av_w("\n Naming both is deliberate: the failure is a CWD question, not a permissions one, and the\n next reader needs to know which trees were tried.\nverdict=RED\n" as *u8)
595 return 5
596 }
597 av_w("DOCROOT resolved prefix=" as *u8)
598 if pfx[0] == (0 as u8) { av_w("(none, CWD is the estate root)" as *u8) } else { av_w(pfx) }
599 av_w("\n" as *u8)
600 sys_write(fd, pg, o)
601 sys_close(fd)
602 av_w("PAGE wrote " as *u8); av_n(o); av_w(" bytes -> " as *u8); av_w(pp); av_w("\n" as *u8)
603
604 // ---- 5. CANONICAL STATUS, verdict LAST so a positional reader is safe.
605 let sb: *u8 = sys_mmap(AV_STATCAP)
606 var so: i64 = 0
607 so = av_cat(sb, so, "awaiting_operator " as *u8); so = av_catn(sb, so, n_you)
608 so = av_cat(sb, so, "\nrejected_awaiting_seat_rework " as *u8); so = av_catn(sb, so, n_rework)
609 so = av_cat(sb, so, "\nawaiting_seat_or_referee " as *u8); so = av_catn(sb, so, n_other)
610 so = av_cat(sb, so, "\nledger_bytes " as *u8); so = av_catn(sb, so, llen[0])
611 so = av_cat(sb, so, "\nplane_bytes " as *u8); so = av_catn(sb, so, plen[0])
612 so = av_cat(sb, so, "\npage_bytes " as *u8); so = av_catn(sb, so, o)
613 so = av_cat(sb, so, "\nverdict=GREEN\n" as *u8)
614 // SAME PREFIX as the docroot, deliberately. buildroot/knowledge/status EXISTS, so a bare relative
615 // status path would resolve from buildroot into the WRONG one of the estate's two knowledge trees
616 // and succeed while doing it -- the silent half of the CWD defect, worse than the refusal above.
617 let sp: *u8 = sys_mmap(AV_PATHB)
618 var sq: i64 = av_cat(sp, 0, pfx)
619 sq = av_cat(sp, sq, AV_STATUS)
620 sp[sq] = 0 as u8
621 let sfd: i64 = sys_openat_wr(sp, AV_MODE_FILE)
622 if sfd >= 0 { sys_write(sfd, sb, so); sys_close(sfd) }
623
624 av_w("ACCEPTVIEW awaiting_operator=" as *u8); av_n(n_you)
625 av_w(" rejected_awaiting_seat_rework=" as *u8); av_n(n_rework)
626 av_w(" awaiting_seat_or_referee=" as *u8); av_n(n_other)
627 av_w("\nverdict=GREEN\n" as *u8)
628 return 0
629}