nx_swcompare_watch_gate.nx source
↩ module page · 575 lines · 49679 B
1// nx_swcompare_watch_gate.nx -- GATE for the ONE symbol ruler (nx_symdecl_lib) and the measured watch
2// section every page kind now renders (nx_swcompare_lib watch_pass). 2026-08-23, lane L.
3//
4// What it proves: (a) the ruler counts a top-level DECLARATION and nothing else -- a comment, a call
5// site, an indented line or a longer identifier sharing the prefix must NOT flip a cell (each such
6// neg-control is paired with the OLD substring rule fired on the same fixture, so the fixture is
7// proven to discriminate the two rulers); (b) watch_pass renders exactly the matrix's symbol rows with
8// a partition that sums, and renders NOTHING for a domain without a .matrix; (c) over the REAL
9// population (every regen.list domain that has a .matrix, from the nishihost cwd) it prints the rows
10// whose verdict CHANGES under the declaration ruler -- the false-LANDED population the pages and the
11// comparewatch plane had been publishing -- and asserts the census partition sums.
12// Fixtures under /tmp/nx_swcompare_watch_gate_<pid>/ (data only; the NAS mounts /tmp noexec and
13// nothing here is executed). In-process composition: no generator is forked.
14// license_tier: ORIGINAL No hw writes (Rule 26).
15import "nx_syscalls.nx"
16import "nx_gate_verdict.nx"
17import "nx_swcompare_lib.nx"
18
19const WG_PATH_MAX: i64 = 4096
20const WG_DIR_MODE: i64 = 0x1ed
21const WG_FILE_MODE: i64 = 0x1a4
22const WG_FIX_ROWS: i64 = 6 // symbol rows in the fixture matrix (the expected render count)
23
24func wg_both(a: i64, b: i64) -> i64 { if a == 1 { if b == 1 { return 1 } } return 0 }
25func wg_pid() -> i64 { return __syscall(172, 0, 0, 0, 0, 0, 0) }
26func wg_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
27func wg_cat(d: *u8, o: i64, s: *u8) -> i64 { var i: i64 = 0; var p: i64 = o; while s[i] != (0 as u8) { d[p] = s[i]; p = p + 1; i = i + 1 } d[p] = 0 as u8; return p }
28func wg_catn(d: *u8, o: i64, v: i64) -> i64 {
29 let t: *u8 = sys_mmap(24)
30 var x: i64 = v
31 var k: i64 = 0
32 if x == 0 { t[0] = 48 as u8; k = 1 }
33 while x > 0 { t[k] = (48 + (x % 10)) as u8; x = x / 10; k = k + 1 }
34 var p: i64 = o
35 var i: i64 = 0
36 while i < k { d[p] = t[k - 1 - i]; p = p + 1; i = i + 1 }
37 d[p] = 0 as u8
38 return p
39}
40func wg_path(base: *u8, leaf: *u8) -> *u8 {
41 let p: *u8 = sys_mmap(WG_PATH_MAX)
42 var o: i64 = wg_cat(p, 0, base)
43 o = wg_cat(p, o, "/" as *u8)
44 o = wg_cat(p, o, leaf)
45 return p
46}
47func wg_write(path: *u8, s: *u8) -> i64 {
48 let fd: i64 = sys_openat_wr(path, WG_FILE_MODE)
49 if fd < 0 { return 0 - 1 }
50 let n: i64 = wg_slen(s)
51 var off: i64 = 0
52 while off < n { let r: i64 = sys_write(fd, (s as i64 + off) as *u8, n - off); if r <= 0 { sys_close(fd); return 0 - 2 } off = off + r }
53 sys_close(fd)
54 return 0
55}
56// count non-overlapping occurrences of needle in a file (whole read); -1 unreadable
57func wg_count_in_file(path: *u8, needle: *u8) -> i64 {
58 let ln: *i64 = sys_mmap(16) as *i64
59 let b: *u8 = sys_read_file(path, ln)
60 if (b as i64) == 0 { return 0 - 1 }
61 let n: i64 = ln[0]
62 let nl: i64 = wg_slen(needle)
63 var c: i64 = 0
64 var i: i64 = 0
65 while i + nl <= n {
66 var same: i64 = 1
67 var j: i64 = 0
68 while j < nl { if b[i + j] != needle[j] { same = 0; j = nl } j = j + 1 }
69 if same == 1 { c = c + 1; i = i + nl } else { i = i + 1 }
70 }
71 sys_free_file(b, n)
72 return c
73}
74func wg_size(path: *u8) -> i64 {
75 let ln: *i64 = sys_mmap(16) as *i64
76 let b: *u8 = sys_read_file(path, ln)
77 if (b as i64) == 0 { return 0 - 1 }
78 let n: i64 = ln[0]
79 sys_free_file(b, n)
80 return n
81}
82// the old substring rule, applied to a FILE, as the control that proves a fixture discriminates
83func wg_substring_file(path: *u8, sym: *u8) -> i64 {
84 let ln: *i64 = sys_mmap(16) as *i64
85 let b: *u8 = sys_read_file(path, ln)
86 if (b as i64) == 0 { return 0 - 1 }
87 let n: i64 = ln[0]
88 let r: i64 = sd_substring_control(b, n, sym)
89 sys_free_file(b, n)
90 return r
91}
92// write a fixture matrix whose organ paths are absolute under base; returns 0 ok
93func wg_make_matrix(base: *u8, path: *u8) -> i64 {
94 let b: *u8 = sys_mmap(WG_PATH_MAX * 4)
95 var o: i64 = wg_cat(b, 0, "# fixture matrix for nx_swcompare_watch_gate\n@title Fixture\n@cols Rust|Zig\n" as *u8)
96 o = wg_cat(b, o, "Comment-only|" as *u8); o = wg_cat(b, o, base); o = wg_cat(b, o, "/organ_comment.nx|_ABSENT_:zzsym|0|0|0|the symbol is only named in a comment\n" as *u8)
97 o = wg_cat(b, o, "Call-only|" as *u8); o = wg_cat(b, o, base); o = wg_cat(b, o, "/organ_call.nx|_ABSENT_:zzsym|0|0|0|the symbol is only CALLED here\n" as *u8)
98 o = wg_cat(b, o, "Declared|" as *u8); o = wg_cat(b, o, base); o = wg_cat(b, o, "/organ_decl.nx|_ABSENT_:zzsym|0|0|0|a real top-level declaration\n" as *u8)
99 o = wg_cat(b, o, "Present-plain|" as *u8); o = wg_cat(b, o, base); o = wg_cat(b, o, "/organ_decl.nx|zzsym|0|0|0|a present row whose symbol is declared\n" as *u8)
100 o = wg_cat(b, o, "Missing-plain|" as *u8); o = wg_cat(b, o, base); o = wg_cat(b, o, "/organ_comment.nx|zzsym|0|0|0|a present row whose symbol is NOT declared\n" as *u8)
101 o = wg_cat(b, o, "No-contract|-|_ABSENT_|0|0|0|no contract named\n" as *u8)
102 o = wg_cat(b, o, "Not-a-row\n" as *u8)
103 return wg_write(path, b)
104}
105
106// ---- ONE DOOR FOR EVERY PER-ROW WORKLIST LINE (2026-08-31) --------------------------------------
107// The PERMISSION and the TALLY live in the same call, so a row that is printed without being counted
108// is not expressible: every worklist emission below is written as `if wg_wl_row(..) == 1 { gv_puts.. }`.
109// That is what lets T14e measure the lines actually WRITTEN rather than a bookkeeping variable kept
110// beside them -- a counter maintained next to a print drifts from it, and this defect exists because
111// an output nobody was measuring outgrew the reader that consumes it.
112func wg_wl_row(verbose: i64, tally: *i64) -> i64 {
113 if verbose == 1 { tally[0] = tally[0] + 1; return 1 }
114 return 0
115}
116
117// Dump the ONE graph emitter to a file, so a tooth can assert on the NAMES it prints and not merely
118// on the counters behind them: the refusal a seat actually reads is the TEXT, so the text is tested.
119func wg_graph_dump(base: *u8, leaf: *u8, p: *SgPlan) -> *u8 {
120 let path: *u8 = wg_path(base, leaf)
121 let fd: i64 = sys_openat_wr(path, WG_FILE_MODE)
122 if fd >= 0 { sg_graph_text(p, fd); sys_close(fd) }
123 return path
124}
125func main(argc: i64, argv: *i64) -> i64 {
126 gv_head("=== nx_swcompare_watch_gate -- one symbol ruler (declaration, never substring) + the measured watch section ===" as *u8)
127 let ctr: *i64 = gv_ctr()
128 // ---- OUTPUT BUDGET: THE DEFAULT RUN MUST FIT THE CAPTURE CAP OF EVERY AUTOMATED READER --------
129 // MEASURED 2026-08-31 on this gate. A direct fork emits 39,616 B, of which 33,909 B (856 permil)
130 // are the two PER-ROW worklists this census prints: 88 FALSE-LANDED rows (12,785 B) and the
131 // distinct UNREADABLE-ORGAN table (21,124 B). The partition sums -- head 2,967 + 12,785 + 21,124
132 // + tail 2,740 = 39,616. The mgmt lane captures 16,384 B and then CLOSES THE PIPE, so this gate was
133 // killed by SIGPIPE mid-worklist and /api/gate_run reported exit_code=141, verdict=RED,
134 // capture_truncated=1 to EVERY automated consumer while a direct fork read 65/65 GREEN. The layout
135 // teeth added on 2026-08-31 sit after the census, so on that surface they never ran at all.
136 // *** REORDERING THE TEETH COULD NOT HAVE FIXED THIS. *** gv_verdict anchors BY POSITION on the
137 // LAST line, so truncation destroys precisely the line the verdict is read from, whatever order
138 // the teeth are in. A gate that overruns the cap is RED to every automated reader regardless of
139 // its real verdict -- and a detector that is permanently RED is one everyone learns to ignore.
140 // THE FIX IS TO BOUND THE OUTPUT, NOT TO SHRINK THE TEETH OR RAISE A CAP WE DO NOT OWN: the two
141 // per-row worklists move behind a verb and the default run ANNOUNCES that it withheld them and
142 // names the verb that prints them. NOTHING IS DELETED -- a count without a worklist is not
143 // actionable, so the worklist stays exactly one call away -- and the default output is now
144 // O(teeth), a small constant, instead of O(population).
145 var wl_verbose: i64 = 0
146 if argc >= 2 { if streq(argv[1] as *u8, "worklist" as *u8) == 1 { wl_verbose = 1 } }
147 let wl_tally: *i64 = sys_mmap(16) as *i64
148 wl_tally[0] = 0
149 let base: *u8 = sys_mmap(WG_PATH_MAX)
150 var bo: i64 = wg_cat(base, 0, "/tmp/nx_swcompare_watch_gate_" as *u8)
151 bo = wg_catn(base, bo, wg_pid())
152 sys_mkdir(base, WG_DIR_MODE)
153 let f_comment: *u8 = wg_path(base, "organ_comment.nx" as *u8)
154 let f_call: *u8 = wg_path(base, "organ_call.nx" as *u8)
155 let f_decl: *u8 = wg_path(base, "organ_decl.nx" as *u8)
156 let f_const: *u8 = wg_path(base, "organ_const.nx" as *u8)
157 let f_indent: *u8 = wg_path(base, "organ_indent.nx" as *u8)
158 let f_prefix: *u8 = wg_path(base, "organ_prefix.nx" as *u8)
159 let f_static: *u8 = wg_path(base, "organ_static.nx" as *u8)
160 var wr: i64 = 0
161 wr = wr + wg_write(f_comment, "// zzsym is mentioned in this comment only, and nx_zzsym_gate names it too\nfunc other(a: i64) -> i64 { return a }\n" as *u8)
162 wr = wr + wg_write(f_call, "import \x22nx_syscalls.nx\x22\nfunc other(a: i64) -> i64 { return zzsym(a) + 1 }\n" as *u8)
163 wr = wr + wg_write(f_decl, "// the real thing\nfunc zzsym(a: i64) -> i64 { return a }\n" as *u8)
164 wr = wr + wg_write(f_const, "const ZZC: i64 = 1\nfunc other() -> i64 { return ZZC }\n" as *u8)
165 wr = wr + wg_write(f_indent, "// prose:\n func zzsym(a: i64) -> i64 { return a }\n" as *u8)
166 wr = wr + wg_write(f_prefix, "func zzsymx(a: i64) -> i64 { return a }\n" as *u8)
167 wr = wr + wg_write(f_static, "static zzstat: i64\nfunc other() -> i64 { return zzstat }\n" as *u8)
168 let f_matrix: *u8 = wg_path(base, "fixture.matrix" as *u8)
169 wr = wr + wg_make_matrix(base, f_matrix)
170 gv_check("T0 fixtures-written (eight files, all writes returned 0)" as *u8, wr == 0, ctr)
171
172 // ---- (a) the ruler ----
173 let sym: *u8 = "zzsym" as *u8
174 gv_check("T1 neg-control-comment-only-symbol-does-NOT-flip" as *u8, sd_declared(f_comment, sym) == 0, ctr)
175 gv_check("T1b substring-control-FIRES-on-the-comment-fixture (the fixture discriminates the rulers)" as *u8, wg_substring_file(f_comment, sym) == 1, ctr)
176 gv_check("T2 neg-control-call-site-only-symbol-does-NOT-flip" as *u8, sd_declared(f_call, sym) == 0, ctr)
177 gv_check("T2b substring-control-FIRES-on-the-call-fixture" as *u8, wg_substring_file(f_call, sym) == 1, ctr)
178 gv_check("T3 top-level-func-declaration-FLIPS" as *u8, sd_declared(f_decl, sym) == 1, ctr)
179 gv_check("T4 top-level-const-declaration-counts" as *u8, sd_declared(f_const, "ZZC" as *u8) == 1, ctr)
180 gv_check("T4b top-level-static-declaration-counts" as *u8, sd_declared(f_static, "zzstat" as *u8) == 1, ctr)
181 gv_check("T5 neg-control-indented-func-is-not-top-level" as *u8, sd_declared(f_indent, sym) == 0, ctr)
182 gv_check("T6 neg-control-longer-identifier-sharing-the-prefix-does-NOT-match (zzsymx is not zzsym)" as *u8, sd_declared(f_prefix, sym) == 0, ctr)
183 gv_check("T6b the-longer-identifier-itself-is-declared" as *u8, sd_declared(f_prefix, "zzsymx" as *u8) == 1, ctr)
184 gv_check("T7 unreadable-organ-reports-minus-1 (not the indistinguishable absent)" as *u8, sd_declared(wg_path(base, "nope.nx" as *u8), sym) == 0 - 1, ctr)
185 gv_check("T7b neg-control-empty-symbol-is-never-declared" as *u8, sd_declared(f_decl, "" as *u8) == 0, ctr)
186
187 // ---- (b) the rendered section, captured through a file descriptor ----
188 let f_html: *u8 = wg_path(base, "watch.html" as *u8)
189 let hfd: i64 = sys_openat_wr(f_html, WG_FILE_MODE)
190 let rows: i64 = watch_pass(f_matrix, hfd, 1)
191 sys_close(hfd)
192 gv_puts(" watch_rows_rendered=" as *u8); gv_num(rows); gv_puts(" expected=" as *u8); gv_num(WG_FIX_ROWS); gv_puts("\n" as *u8)
193 gv_check("T8 watch_pass-renders-every-symbol-row (count == fixture symbol rows)" as *u8, rows == WG_FIX_ROWS, ctr)
194 let c_landed: i64 = wg_count_in_file(f_html, ">LANDED<" as *u8)
195 let c_watching: i64 = wg_count_in_file(f_html, ">WATCHING<" as *u8)
196 let c_present: i64 = wg_count_in_file(f_html, ">PRESENT<" as *u8)
197 let c_missing: i64 = wg_count_in_file(f_html, ">MISSING<" as *u8)
198 let c_absent: i64 = wg_count_in_file(f_html, ">ABSENT<" as *u8)
199 gv_puts(" html landed=" as *u8); gv_num(c_landed); gv_puts(" watching=" as *u8); gv_num(c_watching); gv_puts(" present=" as *u8); gv_num(c_present)
200 gv_puts(" missing=" as *u8); gv_num(c_missing); gv_puts(" absent=" as *u8); gv_num(c_absent); gv_puts("\n" as *u8)
201 var cells_ok: i64 = 0
202 if c_landed == 1 { if c_watching == 2 { if c_present == 1 { if c_missing == 1 { if c_absent == 1 { cells_ok = 1 } } } } }
203 gv_check("T8b rendered-statuses-match-the-ruler (landed 1, watching 2, present 1, missing 1, absent 1)" as *u8, cells_ok, ctr)
204 gv_check("T8c partition-line-printed-and-sums (watch rows=6 landed=1 watching=2 present=1 missing=1 absent=1)" as *u8, wg_count_in_file(f_html, "watch rows=6 landed=1 watching=2 present=1 missing=1 absent=1" as *u8) == 1, ctr)
205 gv_check("T8d section-heading-present-once" as *u8, wg_count_in_file(f_html, "Watch contracts (measured)" as *u8) == 1, ctr)
206 let f_none: *u8 = wg_path(base, "none.html" as *u8)
207 let nfd: i64 = sys_openat_wr(f_none, WG_FILE_MODE)
208 let rows0: i64 = watch_pass(wg_path(base, "absent.matrix" as *u8), nfd, 1)
209 sys_close(nfd)
210 var none_ok: i64 = 0
211 if rows0 == 0 { if wg_size(f_none) == 0 { none_ok = 1 } }
212 gv_check("T9 neg-control-no-matrix-renders-nothing (returns 0, zero bytes written)" as *u8, none_ok, ctr)
213 let f_json: *u8 = wg_path(base, "watch.json" as *u8)
214 let jfd: i64 = sys_openat_wr(f_json, WG_FILE_MODE)
215 let rowsj: i64 = watch_pass(f_matrix, jfd, 2)
216 sys_close(jfd)
217 var json_ok: i64 = 0
218 if rowsj == WG_FIX_ROWS { if wg_count_in_file(f_json, "\x22status\x22:\x22LANDED\x22" as *u8) == 1 { if wg_count_in_file(f_json, "\x22status\x22:\x22WATCHING\x22" as *u8) == 2 { json_ok = 1 } } }
219 gv_check("T10 json-mode-carries-the-same-measured-statuses" as *u8, json_ok, ctr)
220
221 // ---- (b2) the rule is derived from the claim's shape, and each rule is proven both ways ----
222 let f_js: *u8 = wg_path(base, "app.js" as *u8)
223 let f_refs: *u8 = wg_path(base, "data.refs" as *u8)
224 var wr2: i64 = 0
225 wr2 = wr2 + wg_write(f_js, "// driftCheck is only mentioned here\nfunction kreq(a) { return a }\nclass Peer {\n rxChat(m) { return m }\n}\nconst t8Flag = 1;\nnavigator.mediaDevices.getDisplayMedia(x);\n" as *u8)
226 wr2 = wr2 + wg_write(f_refs, "ref|k1|cite|https://x/|knowledge/fetched/cmp_fx_k1.pdf|h00|2026-08-23|published-paper|row\n" as *u8)
227 wr2 = wr2 + wg_write(wg_path(base, "organ_marker.nx" as *u8), "func other() -> i64 { gv_puts(\x22PROJECT-TIME\x22 as *u8); return 0 }\n" as *u8)
228 let f_marker: *u8 = wg_path(base, "organ_marker.nx" as *u8)
229 gv_check("T11 rule-fixtures-written" as *u8, wr2 == 0, ctr)
230 let rl: *i64 = sys_mmap(16) as *i64
231 let ident: *u8 = sys_mmap(128)
232 gv_check("T12 rule: identifier on .nx -> decl" as *u8, sd_rule_for(f_decl, "zzsym" as *u8, ident) == SD_RULE_DECL, ctr)
233 let rule_fz: i64 = sd_rule_for(f_decl, "func zzsym(a" as *u8, ident)
234 gv_check("T12b rule: author-spelled 'func zzsym(a' on .nx -> decl with the identifier stripped" as *u8, wg_both(rule_fz == SD_RULE_DECL, sd_slen(ident) == 5), ctr)
235 gv_check("T12c rule: the organ's own name -> exists" as *u8, sd_rule_for(f_decl, "organ_decl" as *u8, ident) == SD_RULE_EXISTS, ctr)
236 gv_check("T12d rule: non-identifier text on .nx -> marker" as *u8, sd_rule_for(f_marker, "PROJECT-TIME" as *u8, ident) == SD_RULE_MARKER, ctr)
237 gv_check("T12e rule: identifier on .js -> jsdecl" as *u8, sd_rule_for(f_js, "kreq" as *u8, ident) == SD_RULE_JSDECL, ctr)
238 gv_check("T12f rule: anything on a data file -> data" as *u8, sd_rule_for(f_refs, "knowledge/fetched/cmp_fx_k1" as *u8, ident) == SD_RULE_DATA, ctr)
239 gv_check("T13 present: decl rule still refuses the comment-only fixture" as *u8, sd_present(f_comment, "zzsym" as *u8, rl) == 0, ctr)
240 gv_check("T13b present: 'func zzsym(a' finds the declaration" as *u8, sd_present(f_decl, "func zzsym(a" as *u8, rl) == 1, ctr)
241 gv_check("T13c present: exists rule is 1 for a readable organ named by the row" as *u8, sd_present(f_decl, "organ_decl" as *u8, rl) == 1, ctr)
242 gv_check("T13d present: marker literal carried in the source -> 1" as *u8, sd_present(f_marker, "PROJECT-TIME" as *u8, rl) == 1, ctr)
243 gv_check("T13e neg-control: marker not carried -> 0" as *u8, sd_present(f_marker, "PROJECT-NOPE" as *u8, rl) == 0, ctr)
244 gv_check("T13f present: js 'function kreq' -> 1" as *u8, sd_present(f_js, "kreq" as *u8, rl) == 1, ctr)
245 gv_check("T13g present: js method definition 'rxChat(m) {' -> 1" as *u8, sd_present(f_js, "rxChat" as *u8, rl) == 1, ctr)
246 gv_check("T13h present: js 'const t8Flag' -> 1" as *u8, sd_present(f_js, "t8Flag" as *u8, rl) == 1, ctr)
247 gv_check("T13i neg-control: js comment-only driftCheck -> 0" as *u8, sd_present(f_js, "driftCheck" as *u8, rl) == 0, ctr)
248 gv_check("T13j neg-control: js call-site-only getDisplayMedia -> 0" as *u8, sd_present(f_js, "getDisplayMedia" as *u8, rl) == 0, ctr)
249 gv_check("T13k present: data token in a .refs register -> 1" as *u8, sd_present(f_refs, "knowledge/fetched/cmp_fx_k1" as *u8, rl) == 1, ctr)
250 gv_check("T13l neg-control: absent data token -> 0" as *u8, sd_present(f_refs, "knowledge/fetched/cmp_nope" as *u8, rl) == 0, ctr)
251 // ---- DARK CONTRACT (2026-09-06, operator: a permanent fix, we do not build and lose capability to darkness) ----
252 // The generator's cell state and the regen's comparewatch plane classify a watch row DARK when the organ file was
253 // READ and the ruler said the symbol is not declared under a rule that can judge. Twice this week (DC16 amesh_run,
254 // motion mr_rig and mo_body_index) an organ shipped under another name and its board read 0 of N done for days.
255 // These teeth pin the exact predicate both consumers use, on the ruler they share.
256 let f_dark: *u8 = wg_path(base, "dark_organ.nx" as *u8)
257 let dkw: i64 = wg_write(f_dark, "func shipped_under_another_name() -> i64 { return 0 }\n" as *u8)
258 let rdk: *i64 = sys_mmap(16) as *i64
259 let dk_state: i64 = sd_present(f_dark, "contracted_name" as *u8, rdk)
260 gv_check("T30 dark-contract: an organ that EXISTS without the contracted symbol reads 0 (read-and-absent), never -1" as *u8, wg_both((dkw == 0), (dk_state == 0)), ctr)
261 gv_check("T30a dark-contract-rule-can-judge: the rule applied was not the JS abstention, so DARK is a verdict and not a shrug" as *u8, (rdk[0] != SD_RULE_JSDECL), ctr)
262 let f_gone: *u8 = wg_path(base, "no_such_organ.nx" as *u8)
263 gv_check("T30b neg-control: a MISSING organ reads -1 (unreadable), which is OPEN and never DARK" as *u8, sd_present(f_gone, "contracted_name" as *u8, rdk) == 0 - 1, ctr)
264 gv_check("T30c neg-control: a JS organ the ruler cannot judge reports the JS rule, so it is OPEN and never DARK (an abstention is not a verdict)" as *u8, wg_both((sd_present(f_js, "getDisplayMedia" as *u8, rdk) == 0), (rdk[0] == SD_RULE_JSDECL)), ctr)
265 let unread_rc: i64 = sd_present(wg_path(base, "nope.nx" as *u8), "zzsym" as *u8, rl)
266 gv_check("T13m unreadable organ -> -1 with the rule still named" as *u8, wg_both(unread_rc == 0 - 1, rl[0] == SD_RULE_DECL), ctr)
267 wg_write(wg_path(base, "organ_caps.nx" as *u8), "const ZZ_REAL: i64 = 1\nfunc other() -> i64 { gv_puts(\x22ZZGATE\x22 as *u8); return ZZ_REAL }\n" as *u8)
268 let f_caps: *u8 = wg_path(base, "organ_caps.nx" as *u8)
269 let caps_decl: i64 = sd_present(f_caps, "ZZ_REAL" as *u8, rl)
270 gv_check("T13n all-caps token that IS declared -> 1 under decl (the declaration wins)" as *u8, wg_both(caps_decl == 1, rl[0] == SD_RULE_DECL), ctr)
271 let caps_mark: i64 = sd_present(f_caps, "ZZGATE" as *u8, rl)
272 gv_check("T13o all-caps token only emitted -> 1 under marker (the fallback is NAMED, not hidden)" as *u8, wg_both(caps_mark == 1, rl[0] == SD_RULE_MARKER), ctr)
273 let caps_none: i64 = sd_present(f_caps, "ZZNOPE" as *u8, rl)
274 gv_check("T13p neg-control: all-caps token absent from the organ -> 0" as *u8, caps_none == 0, ctr)
275 gv_check("T13q neg-control: a lowercase identifier never falls back to marker (comment-only stays 0)" as *u8, sd_present(f_comment, "zzsym" as *u8, rl) == 0, ctr)
276
277 // ---- (c) the real population: every regen.list domain with a .matrix ----
278 var pfx: *u8 = "buildroot/" as *u8
279 let llen: *i64 = sys_mmap(16) as *i64
280 var lst: *u8 = sys_read_file("buildroot/knowledge/compare/regen.list" as *u8, llen)
281 if (lst as i64) == 0 { pfx = "" as *u8; lst = sys_read_file("knowledge/compare/regen.list" as *u8, llen) }
282 var have_list: i64 = 0
283 if (lst as i64) != 0 { if llen[0] > 0 { have_list = 1 } }
284 gv_need("regen.list readable (nishihost or buildroot cwd)" as *u8, have_list, ctr)
285 if have_list == 1 {
286 let ln: i64 = llen[0]
287 var t_rows: i64 = 0
288 var t_agree: i64 = 0
289 var t_false: i64 = 0
290 var t_gained: i64 = 0
291 var t_unread: i64 = 0
292 var t_domains: i64 = 0
293 let by_rule: *i64 = sys_mmap(8 * 8) as *i64 // rows per rule 1..5
294 let fl_rule: *i64 = sys_mmap(8 * 8) as *i64 // false-landed per rule
295 let mp: *u8 = sys_mmap(WG_PATH_MAX)
296 let op: *u8 = sys_mmap(WG_PATH_MAX)
297 let mlen: *i64 = sys_mmap(16) as *i64
298 // UNREADABLE ORGANS GET A WORKLIST, NOT JUST A COUNT: distinct organ paths with their row counts.
299 // Capacity DERIVED from the population: every row costs one newline in some matrix, so the total
300 // newline count over every matrix in regen.list bounds the distinct organs (pass 0, cheap), and
301 // the table announces if it ever fills (it cannot, by that derivation).
302 var un_cap: i64 = 1
303 var p0: i64 = 0
304 while p0 < ln {
305 var e0: i64 = p0
306 while e0 < ln { if lst[e0] == (10 as u8) { break } e0 = e0 + 1 }
307 // copy the domain name out: the list is NOT split in place here, the main walk needs its newlines
308 let dom0: *u8 = sys_mmap(e0 - p0 + 1)
309 var cz: i64 = 0
310 while p0 + cz < e0 { dom0[cz] = lst[p0 + cz]; cz = cz + 1 }
311 dom0[cz] = 0 as u8
312 p0 = e0 + 1
313 if dom0[0] == (0 as u8) { } else { if dom0[0] == (35 as u8) { } else {
314 var mo0: i64 = wg_cat(mp, 0, pfx); mo0 = wg_cat(mp, mo0, "knowledge/compare/" as *u8); mo0 = wg_cat(mp, mo0, dom0); mo0 = wg_cat(mp, mo0, ".matrix" as *u8)
315 let mb0: *u8 = sys_read_file(mp, mlen)
316 if (mb0 as i64) != 0 { var z: i64 = 0; while z < mlen[0] { if mb0[z] == (10 as u8) { un_cap = un_cap + 1 } z = z + 1 } sys_free_file(mb0, mlen[0]) }
317 } }
318 }
319 let un_path: *i64 = sys_mmap(un_cap * 8) as *i64
320 let un_cnt: *i64 = sys_mmap(un_cap * 8) as *i64
321 var un_n: i64 = 0
322 var un_overflow: i64 = 0
323 var p: i64 = 0
324 while p < ln {
325 var e: i64 = p
326 while e < ln { if lst[e] == (10 as u8) { break } e = e + 1 }
327 lst[e] = 0 as u8
328 let dom: *u8 = (lst as i64 + p) as *u8
329 p = e + 1
330 if dom[0] == (0 as u8) { } else { if dom[0] == (35 as u8) { } else {
331 var mo: i64 = wg_cat(mp, 0, pfx); mo = wg_cat(mp, mo, "knowledge/compare/" as *u8); mo = wg_cat(mp, mo, dom); mo = wg_cat(mp, mo, ".matrix" as *u8)
332 let mb: *u8 = sys_read_file(mp, mlen)
333 if (mb as i64) != 0 { if mlen[0] > 0 {
334 t_domains = t_domains + 1
335 let mn: i64 = mlen[0]
336 var maxf: i64 = 2
337 var pc: i64 = 0
338 var i: i64 = 0
339 while i < mn { if mb[i] == (124 as u8) { pc = pc + 1 } if mb[i] == (10 as u8) { if pc + 1 > maxf { maxf = pc + 1 } pc = 0 } i = i + 1 }
340 let fld: *i64 = sys_mmap((maxf + 1) * 8) as *i64
341 var q: i64 = 0
342 while q < mn {
343 var f: i64 = q
344 while f < mn { if mb[f] == (10 as u8) { break } f = f + 1 }
345 mb[f] = 0 as u8
346 let line: *u8 = (mb as i64 + q) as *u8
347 q = f + 1
348 var skip: i64 = 0
349 if line[0] == (0 as u8) { skip = 1 }
350 if line[0] == (35 as u8) { skip = 1 }
351 if line[0] == (64 as u8) { skip = 1 }
352 if skip == 0 {
353 let nf: i64 = splitpipe(line, fld, maxf)
354 if nf >= 4 {
355 let rsym: *u8 = fld[2] as *u8
356 var s2: *u8 = rsym
357 var is_row: i64 = 1
358 if rsym[0] == (0 as u8) { is_row = 0 }
359 if streq(rsym, "_ABSENT_" as *u8) == 1 { is_row = 0 }
360 if starts(rsym, "_ABSENT_:" as *u8) == 1 { s2 = (rsym as i64 + 9) as *u8 }
361 if is_row == 1 {
362 t_rows = t_rows + 1
363 var oo: i64 = wg_cat(op, 0, pfx); oo = wg_cat(op, oo, fld[1] as *u8)
364 let sub: i64 = wg_substring_file(op, s2)
365 let pres: i64 = sd_present(op, s2, rl)
366 let rr: i64 = rl[0]
367 if rr >= 1 { if rr <= 5 { by_rule[rr] = by_rule[rr] + 1 } }
368 if sub < 0 {
369 t_unread = t_unread + 1
370 var ui: i64 = 0
371 var hit: i64 = 0 - 1
372 while ui < un_n { if streq(un_path[ui] as *u8, op) == 1 { hit = ui; ui = un_n } ui = ui + 1 }
373 if hit >= 0 { un_cnt[hit] = un_cnt[hit] + 1 } else {
374 if un_n < un_cap {
375 let keep: *u8 = sys_mmap(wg_slen(op) + 1)
376 wg_cat(keep, 0, op)
377 un_path[un_n] = keep as i64; un_cnt[un_n] = 1; un_n = un_n + 1
378 } else { un_overflow = un_overflow + 1 }
379 }
380 } else {
381 if sub == pres { t_agree = t_agree + 1 } else {
382 if pres == 1 { t_gained = t_gained + 1 } else {
383 t_false = t_false + 1
384 if rr >= 1 { if rr <= 5 { fl_rule[rr] = fl_rule[rr] + 1 } }
385 if wg_wl_row(wl_verbose, wl_tally) == 1 { gv_puts(" FALSE-LANDED rule=" as *u8); gv_puts(sd_rule_name(rr)); gv_puts(" domain=" as *u8); gv_puts(dom); gv_puts(" label=" as *u8); gv_puts(fld[0] as *u8)
386 gv_puts(" organ=" as *u8); gv_puts(fld[1] as *u8); gv_puts(" symbol=" as *u8); gv_puts(s2); gv_puts("\n" as *u8) }
387 }
388 }
389 }
390 }
391 }
392 }
393 }
394 sys_free_file(mb, mn)
395 } }
396 } }
397 }
398 var uj: i64 = 0
399 while uj < un_n { if wg_wl_row(wl_verbose, wl_tally) == 1 { gv_puts(" UNREADABLE-ORGAN rows=" as *u8); gv_num(un_cnt[uj]); gv_puts(" organ=" as *u8); gv_puts(un_path[uj] as *u8); gv_puts("
400" as *u8) } uj = uj + 1 }
401 if un_overflow > 0 { gv_puts(" UNREADABLE-ORGAN TABLE FULL: " as *u8); gv_num(un_overflow); gv_puts(" rows not listed (the list above is a PREFIX)
402" as *u8) }
403 gv_puts(" CENSUS domains_with_matrix=" as *u8); gv_num(t_domains); gv_puts(" symbol_rows=" as *u8); gv_num(t_rows)
404 gv_puts(" agree=" as *u8); gv_num(t_agree); gv_puts(" false_landed=" as *u8); gv_num(t_false); gv_puts(" gained=" as *u8); gv_num(t_gained)
405 gv_puts(" organ_unreadable=" as *u8); gv_num(t_unread); gv_puts("\n" as *u8)
406 gv_puts(" CENSUS by rule: decl=" as *u8); gv_num(by_rule[1]); gv_puts(" (false_landed " as *u8); gv_num(fl_rule[1]); gv_puts(") jsdecl=" as *u8); gv_num(by_rule[2]); gv_puts(" (false_landed " as *u8); gv_num(fl_rule[2])
407 gv_puts(") exists=" as *u8); gv_num(by_rule[3]); gv_puts(" marker=" as *u8); gv_num(by_rule[4]); gv_puts(" data=" as *u8); gv_num(by_rule[5]); gv_puts("\n" as *u8)
408 gv_check("T14 census-partition-sums (rows == agree + false_landed + gained + unreadable)" as *u8, t_rows == t_agree + t_false + t_gained + t_unread, ctr)
409 gv_check("T14b census-rule-partition-sums (rows == decl + jsdecl + exists + marker + data)" as *u8, t_rows == by_rule[1] + by_rule[2] + by_rule[3] + by_rule[4] + by_rule[5], ctr)
410 gv_check("T14c census-examined-a-non-empty-population (a zero-subject census proves nothing)" as *u8, t_rows > 0, ctr)
411 gv_check("T14d false-landed-only-arises-under-a-declaration-rule (marker/exists/data cannot lose a cell)" as *u8, fl_rule[3] + fl_rule[4] + fl_rule[5] == 0, ctr)
412 // *** A SUPPRESSION THAT DOES NOT ANNOUNCE IS A SILENT TRUNCATION *** -- the same defect this
413 // gate was suffering from the other end. The default run states how many rows it withheld and
414 // the one verb that prints them, so a bounded run can never be mistaken for an empty finding.
415 // THE COUNTS ARE NEVER SUPPRESSED, only the per-row lines: the census above is unchanged.
416 gv_puts(" WORKLIST mode=" as *u8)
417 if wl_verbose == 1 { gv_puts("worklist-EVERY-ROW-PRINTED-ABOVE" as *u8) } else { gv_puts("default-SUPPRESSED" as *u8) }
418 gv_puts(" false_landed_rows=" as *u8); gv_num(t_false); gv_puts(" distinct_unreadable_organs=" as *u8); gv_num(un_n)
419 gv_puts(" rows_emitted=" as *u8); gv_num(wl_tally[0])
420 gv_puts(" -- for the per-row worklist, run this gate with the argument: worklist (it is withheld by default because it overruns the mgmt capture cap, and a truncated run takes the verdict line with it)\n" as *u8)
421 // NON-VACUITY AS AN ABSTENTION, NEVER AS A FAILURE: T14e can only discriminate the two modes
422 // while there is at least one row to withhold. A hard tooth here would go RED on GOOD news --
423 // the day the estate drains both worklists -- so this is a PRECONDITION (SKIP), not a check.
424 gv_subjects("worklist rows available to withhold (false-landed + distinct unreadable organs)" as *u8, t_false + un_n, ctr)
425 var wl_expect: i64 = 0
426 if wl_verbose == 1 { wl_expect = t_false + un_n }
427 // DECLARED IMPRECISION: T14e counts the lines that passed through wg_wl_row. A worklist line
428 // written later with a bare gv_puts would be invisible to it -- which is precisely why there is
429 // ONE door, and why that door permits and tallies in the same call instead of in two places.
430 gv_check("T14e worklist-emission-matches-the-mode (default emits ZERO per-row lines, the worklist verb emits every one -- so the default output is O(teeth) and the suppression cannot move a counter)" as *u8, wl_tally[0] == wl_expect, ctr)
431 }
432 // ================ (c) LAYOUT -- ASSERTED ON THE EMITTED BYTES, NOT ON THE SOURCE ================
433 // WHY HERE. This gate already imports nx_swcompare_lib and already owns /tmp/<gate>_<pid> fixture
434 // hygiene, so the layout emitter is checked by CALLING IT and reading back what it actually wrote --
435 // no fork, no second ruler, no new gate. The defect these teeth exist to catch is specific and was
436 // live until 2026-08-31: --nx-layout-wrap and --nx-layout-gutter were DEFINED in :root on every
437 // compare page and REFERENCED BY NONE of the sota-class ones, which hardcoded max-width:980px over
438 // the top. ***A TOOTH THAT ONLY CHECKS THE TOKEN IS DEFINED WOULD HAVE PASSED THROUGHOUT*** -- so
439 // every tooth below asserts the token is READ, and the neg-controls assert the literal is GONE.
440 let f_css: *u8 = wg_path(base, "layout.css" as *u8)
441 let cfd: i64 = sys_openat_wr(f_css, WG_FILE_MODE)
442 var cok: i64 = 0
443 if cfd >= 0 { sc_theme_pass(cfd); sc_layout_pass(cfd); sys_close(cfd); cok = 1 }
444 // ASSERT THE FIXTURE REACHED THE CONDITION BEFORE ASSERTING THE OUTCOME: a zero-byte capture would
445 // make every substring tooth below pass-or-fail on an empty file rather than on a stylesheet.
446 gv_check("T15 layout-fixture-captured (the emitters ran and wrote a non-empty stylesheet)" as *u8, wg_both(cok, (wg_size(f_css) > 0)), ctr)
447 gv_check("T16 body-READS-the-wrap-token (the whole defect was a token defined on every page and read by none)" as *u8, wg_substring_file(f_css, "max-width:var(--nx-layout-wrap)" as *u8) == 1, ctr)
448 gv_check("T17 body-READS-the-gutter-token (it was bypassed by a second hardcoded clamp)" as *u8, wg_substring_file(f_css, "padding:0 var(--nx-layout-gutter) 6vh" as *u8) == 1, ctr)
449 // The two neg-controls name the LITERALS, not a pattern: the emitted sheet legitimately contains
450 // max-width:860px and max-width:640px as the estate's breakpoint ladder, so a naive
451 // no-digits-after-max-width rule would fire on correct CSS and teach everyone to ignore this gate.
452 gv_check("T18 neg-control-the-980px-page-width-literal-is-GONE" as *u8, wg_substring_file(f_css, "max-width:980px" as *u8) == 0, ctr)
453 gv_check("T18b neg-control-the-old-1100px-fixed-wrap-value-is-GONE (the token is fluid now, not a bigger fixed number)" as *u8, wg_substring_file(f_css, "1100px" as *u8) == 0, ctr)
454 // ***A GREEN THAT NEVER HAD A CORRESPONDING RED IS UNVERIFIED.*** T18/T18b are absence claims, and an
455 // absence claim passes just as happily when the predicate is structurally incapable of matching
456 // anything. Plant the exact forbidden literal and require the SAME predicate to return 1 on it.
457 let f_plant: *u8 = wg_path(base, "planted.css" as *u8)
458 let pw: i64 = wg_write(f_plant, "body{background:var(--bg);max-width:980px;margin:0 auto}" as *u8)
459 gv_check("T18c neg-control-the-hardcoded-width-detector-FIRES-on-a-planted-980px (T18 is not vacuous)" as *u8, wg_both((pw == 0), (wg_substring_file(f_plant, "max-width:980px" as *u8) == 1)), ctr)
460 gv_check("T19 the-wrap-token-is-FLUID (a clamp, so the layout uses the display instead of a fixed column)" as *u8, wg_substring_file(f_css, "--nx-layout-wrap: clamp(" as *u8) == 1, ctr)
461 gv_check("T20 capability-board-is-a-responsive-multi-column-grid" as *u8, wg_substring_file(f_css, "repeat(auto-fill,minmax(min(100%,var(--nx-layout-capmin)),1fr))" as *u8) == 1, ctr)
462 // auto-fit COLLAPSES the empty tracks and stretches a lone card across the entire canvas, which is
463 // the one-wide-column complaint re-created at component scale. It is the plausible wrong edit here.
464 gv_check("T21 neg-control-auto-fit-is-NOT-used (it would stretch a lone card across the whole canvas)" as *u8, wg_substring_file(f_css, "auto-fit" as *u8) == 0, ctr)
465 // min(100%,...) inside minmax is load-bearing: the auto-repeat count is computed from the track
466 // MINIMUM, so a bare minmax(27rem,1fr) OVERFLOWS any container narrower than 27rem instead of
467 // dropping to one column -- i.e. the responsive grid would itself cause sideways page scroll.
468 gv_check("T20b the-grid-minimum-is-clamped-by-min(100%) (without it the grid overflows a narrow container)" as *u8, wg_substring_file(f_css, "minmax(min(100%," as *u8) == 1, ctr)
469 gv_check("T22 the-card-reflows-on-ITS-OWN-width (container query, so it is right inside a narrow pane on a wide monitor)" as *u8, wg_substring_file(f_css, "@container nxcap (min-width:" as *u8) == 1, ctr)
470 // FULL CANVAS IS A LAYOUT CLAIM, NOT A PROSE CLAIM. Without this tooth the honest way to pass every
471 // other tooth here is to let a paragraph run the full 1760px, which is ~230 characters a line.
472 gv_check("T23 prose-keeps-its-measure-cap (full canvas must not mean a 200-character line)" as *u8, wg_substring_file(f_css, "max-width:var(--nx-layout-measure)" as *u8) == 1, ctr)
473 // T23 IS SATISFIED BY .cap-note ALONE -- AND THAT IS EXACTLY HOW IT STAYED GREEN THROUGH A REGRESSION
474 // IT READS AS IF IT COVERS. When body moved from a fixed 980px to a fluid clamp capped at 110rem on
475 // 2026-08-31, .meth and .verdict -- the two prose blocks BOTH archetypes emit -- carried no cap at
476 // all on the sota class. MEASURED on the emitted bytes of the then-live binaries, before the fix:
477 // matrix's .meth ended ...color:var(--mut);max-width:72ch;text-wrap:pretty} and sota's ended
478 // ...color:var(--mut)} -- so sota's "How this is scored" block, the FIRST prose a reader meets, went
479 // from about 130 characters a line to about 240 while THIS TOOTH STAYED GREEN.
480 // ***A TOOTH THAT PROVES A TOKEN IS READ SOMEWHERE DOES NOT PROVE IT IS READ WHERE IT MATTERS.***
481 // T23b therefore names the SELECTOR, so no other rule's cap can satisfy it on its behalf.
482 gv_check("T23b the-prose-blocks-BOTH-archetypes-emit-carry-the-cap (.meth/.verdict BY NAME; T23 passes on .cap-note alone)" as *u8, wg_substring_file(f_css, ".meth,.verdict{max-width:var(--nx-layout-measure)" as *u8) == 1, ctr)
483 // ***A GREEN THAT NEVER HAD A CORRESPONDING RED IS UNVERIFIED.*** T23b is a presence claim, and a
484 // presence claim passes just as happily when its predicate is incapable of distinguishing anything.
485 // Plant BOTH shapes and require the SAME predicate to separate them: the real pre-fix sota rule
486 // (ending at color, no cap) must return 0, and the fixed rule must return 1. A predicate that could
487 // not tell those two apart IS the defect, wearing a passing test.
488 let f_mneg: *u8 = wg_path(base, "meth_prefix.css" as *u8)
489 let mnw: i64 = wg_write(f_mneg, ".meth{background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:14px 18px;margin:16px 0;font-size:.88rem;color:var(--mut)}.meth b{color:var(--fg)}" as *u8)
490 gv_check("T23c neg-control-the-measure-detector-is-SILENT-on-the-real-pre-fix-uncapped-rule (T23b is not vacuous)" as *u8, wg_both((mnw == 0), (wg_substring_file(f_mneg, ".meth,.verdict{max-width:var(--nx-layout-measure)" as *u8) == 0)), ctr)
491 let f_mpos: *u8 = wg_path(base, "meth_fixed.css" as *u8)
492 let mpw: i64 = wg_write(f_mpos, ".meth,.verdict{max-width:var(--nx-layout-measure);text-wrap:pretty}" as *u8)
493 gv_check("T23d pos-control-the-SAME-detector-FIRES-on-the-fixed-rule (so T23c is discrimination, not an always-zero predicate)" as *u8, wg_both((mpw == 0), (wg_substring_file(f_mpos, ".meth,.verdict{max-width:var(--nx-layout-measure)" as *u8) == 1)), ctr)
494 // THE CARD PRIMITIVE IS SCOPED, NOT GLOBAL. "cap" is an overloaded class name in this estate: a
495 // whole-corpus census (coverage_complete=1 corpus_complete=1, 23,407 files) found <td class='cap'>
496 // in nx_swcompare_crm and nx_swcompare_sending and <span class='cap'> in nx_rewards, none of them a
497 // child of .caps. A bare .cap{display:grid} emitted from this SHARED lib would claim all of them and
498 // override display:table-cell on the two <td> holders, destroying those tables the moment either
499 // generator is converted onto this emitter. The child combinator excludes them BY CONSTRUCTION.
500 gv_check("T22b the-card-primitive-is-SCOPED-to-.caps>.cap (a bare .cap in a shared lib claims an overloaded global name)" as *u8, wg_substring_file(f_css, ".caps>.cap{container-type:inline-size" as *u8) == 1, ctr)
501 let f_cneg: *u8 = wg_path(base, "cap_unscoped.css" as *u8)
502 let cnw: i64 = wg_write(f_cneg, ".cap{container-type:inline-size;container-name:nxcap;display:grid}" as *u8)
503 gv_check("T22c neg-control-the-scope-detector-is-SILENT-on-a-planted-BARE-.cap-rule (T22b is not vacuous)" as *u8, wg_both((cnw == 0), (wg_substring_file(f_cneg, ".caps>.cap{container-type:inline-size" as *u8) == 0)), ctr)
504 gv_check("T24 the-page-itself-cannot-scroll-sideways (min-content floor defeated on the layout children)" as *u8, wg_substring_file(f_css, "main{min-width:0}" as *u8) == 1, ctr)
505 // ---- what must SURVIVE the rewrite: these already worked and a layout change must not cost them ----
506 gv_check("T25 dark-theme-survives-on-BOTH-selectors (the chip and the OS preference cannot drift apart)" as *u8, wg_both((wg_substring_file(f_css, "html[data-theme='dark']" as *u8) == 1), (wg_substring_file(f_css, "@media(prefers-color-scheme:dark){:root:not([data-theme]){" as *u8) == 1)), ctr)
507 gv_check("T26 semantic-status-colours-survive (ok/part/absent/exceed are the page's meaning, not decoration)" as *u8, wg_both(wg_both((wg_substring_file(f_css, "--nx-color-ok:" as *u8) == 1), (wg_substring_file(f_css, "--nx-color-part:" as *u8) == 1)), wg_both((wg_substring_file(f_css, "--nx-color-absent:" as *u8) == 1), (wg_substring_file(f_css, "--nx-color-exceed:" as *u8) == 1))), ctr)
508 gv_check("T27 fluid-type-survives" as *u8, wg_substring_file(f_css, "font-size:clamp(15px,0.5vw + 13px,16.5px)" as *u8) == 1, ctr)
509 gv_check("T28 box-sizing-survives" as *u8, wg_substring_file(f_css, "*{box-sizing:border-box}" as *u8) == 1, ctr)
510 gv_check("T29 the-estate-breakpoint-ladder-survives (860/640, still the only one)" as *u8, wg_both((wg_substring_file(f_css, "max-width:860px" as *u8) == 1), (wg_substring_file(f_css, "max-width:640px" as *u8) == 1)), ctr)
511 // ---- THE AUTHORED GRAPH REFUSAL MUST NAME WHAT IS WRONG (2026-09-11, lane w1) ---------------
512 // THE DEFECT: sg_parse computed every counter and sg_valid threw them away, so nx_compare_rank
513 // refused a whole board with ONE sentence -- malformed, missing, duplicate or cyclic -- and every
514 // reader re-derived WHICH row by hand. companionchat (CC9 depends on G16, a rung on the GEN board)
515 // and charsim (R1 -> R25 -> R2 -> R1) were both refused exactly that way. These teeth drive
516 // sg_parse in-process and assert the NAMES the shared emitter prints, not merely the counters.
517 let gq_bad: *u8 = "rung|A1|t|s|d|Organ|1|-\nrung|A2$|t|s|d|Organ|1|-\n" as *u8
518 let gq_pbad: *SgPlan = sg_parse(gq_bad, sg_len(gq_bad), 0 as *u8, 0, 0 as *u8, 0)
519 let gq_fbad: *u8 = wg_graph_dump(base, "graph_badid.txt" as *u8, gq_pbad)
520 gv_check("T30 fixture-reached-the-condition: the bad-id plan declared 2 rung rows and admitted 1" as *u8, wg_both((gq_pbad.declared == 2), (gq_pbad.count == 1)), ctr)
521 gv_check("T30a a-bad-rung-id-still-REFUSES-the-board" as *u8, sg_valid(gq_pbad) == 0, ctr)
522 gv_check("T30b the-refusal-NAMES-the-row-and-the-rule" as *u8, wg_count_in_file(gq_fbad, "GRAPH OFFENDER rung=A2$ rule=bad-id" as *u8) == 1, ctr)
523 gv_check("T30c the-counters-travel-WITH-the-worklist" as *u8, wg_count_in_file(gq_fbad, "malformed=1" as *u8) == 1, ctr)
524 let gq_miss: *u8 = "rung|B1|t|s|d|Organ|1|B9\n" as *u8
525 let gq_pmiss: *SgPlan = sg_parse(gq_miss, sg_len(gq_miss), 0 as *u8, 0, 0 as *u8, 0)
526 let gq_fmiss: *u8 = wg_graph_dump(base, "graph_missdep.txt" as *u8, gq_pmiss)
527 gv_check("T31 fixture-reached-the-condition: one rung, one unresolved dependency" as *u8, wg_both((gq_pmiss.count == 1), (gq_pmiss.missing_deps == 1)), ctr)
528 gv_check("T31a a-BARE-unknown-dependency-still-REFUSES (this is companionchat CC9 to G16)" as *u8, sg_valid(gq_pmiss) == 0, ctr)
529 gv_check("T31b the-refusal-NAMES-the-rung-AND-the-dependency" as *u8, wg_count_in_file(gq_fmiss, "GRAPH OFFENDER rung=B1 rule=missing-dep dep=B9" as *u8) == 1, ctr)
530 let gq_ext: *u8 = "rung|C1|t|s|d|Organ|1|gen:G16\n" as *u8
531 let gq_pext: *SgPlan = sg_parse(gq_ext, sg_len(gq_ext), 0 as *u8, 0, 0 as *u8, 0)
532 let gq_fext: *u8 = wg_graph_dump(base, "graph_ext.txt" as *u8, gq_pext)
533 gv_check("T32 fixture-reached-the-condition: the cross-board ref was parsed, not skipped" as *u8, wg_both((gq_pext.count == 1), (gq_pext.external_deps == 1)), ctr)
534 gv_check("T32a a-DECLARED-cross-board-dependency-does-NOT-refuse-the-board" as *u8, sg_valid(gq_pext) == 1, ctr)
535 gv_check("T32b it-is-NOT-missing, NOT-malformed, and-adds-NO-edge-to-this-graph" as *u8, wg_both(wg_both((gq_pext.missing_deps == 0), (gq_pext.malformed == 0)), (gq_pext.edge_count == 0)), ctr)
536 gv_check("T32c the-run-NAMES-the-cross-board-reference" as *u8, wg_count_in_file(gq_fext, "GRAPH EXTERNAL rung=C1 ref=gen:G16" as *u8) == 1, ctr)
537 let gq_near: *u8 = "rung|D1|t|s|d|Organ|1|gen:\nrung|D2|t|s|d|Organ|1|:G16\nrung|D3|t|s|d|Organ|1|a:b:c\n" as *u8
538 let gq_pnear: *SgPlan = sg_parse(gq_near, sg_len(gq_near), 0 as *u8, 0, 0 as *u8, 0)
539 let gq_fnear: *u8 = wg_graph_dump(base, "graph_near.txt" as *u8, gq_pnear)
540 gv_check("T33 neg-control-a-colon-token-that-is-NOT-the-syntax-stays-malformed (narrow acceptance, not a blanket)" as *u8, wg_both((gq_pnear.external_deps == 0), (gq_pnear.malformed == 3)), ctr)
541 gv_check("T33a neg-control-all-three-REFUSE-and-each-is-NAMED" as *u8, wg_both((sg_valid(gq_pnear) == 0), (wg_count_in_file(gq_fnear, "rule=bad-dep-id" as *u8) == 3)), ctr)
542 let gq_cyc: *u8 = "rung|E1|t|s|d|Organ|1|E2\nrung|E2|t|s|d|Organ|1|E1\nrung|E3|t|s|d|Organ|1|E1\n" as *u8
543 let gq_pcyc: *SgPlan = sg_parse(gq_cyc, sg_len(gq_cyc), 0 as *u8, 0, 0 as *u8, 0)
544 let gq_fcyc: *u8 = wg_graph_dump(base, "graph_cycle.txt" as *u8, gq_pcyc)
545 gv_check("T34 fixture-reached-the-condition: 3 rungs, 3 residual nodes (this is the charsim shape)" as *u8, wg_both((gq_pcyc.count == 3), (gq_pcyc.cyclic_nodes == 3)), ctr)
546 gv_check("T34a a-cycle-REFUSES-and-BOTH-its-members-are-named" as *u8, wg_both((sg_valid(gq_pcyc) == 0), (wg_count_in_file(gq_fcyc, " rule=cycle\n" as *u8) == 2)), ctr)
547 gv_check("T34b the-node-merely-BLOCKED-by-the-cycle-is-named-DIFFERENTLY (opposite edits: break the cycle, leave E3 alone)" as *u8, wg_count_in_file(gq_fcyc, "GRAPH OFFENDER rung=E3 rule=cycle-downstream" as *u8) == 1, ctr)
548 let gq_shape: *u8 = "rung|F1|t|s|d|Organ|1\nrung|F2|t|s|d|Organ|1|-\nrung|F2|t|s|d|Organ|1|-\nrung|F3|t|s|d|Organ|1|F2,F2\n" as *u8
549 let gq_pshape: *SgPlan = sg_parse(gq_shape, sg_len(gq_shape), 0 as *u8, 0, 0 as *u8, 0)
550 let gq_fshape: *u8 = wg_graph_dump(base, "graph_shape.txt" as *u8, gq_pshape)
551 gv_check("T35 fixture-reached-the-condition: 4 declared rows, 2 admitted (F1 short, F2 declared twice)" as *u8, wg_both((gq_pshape.declared == 4), (gq_pshape.count == 2)), ctr)
552 gv_check("T35a a-short-row-is-named-WITH-the-count-it-carried-and-the-count-expected" as *u8, wg_count_in_file(gq_fshape, "GRAPH OFFENDER rung=F1 rule=field-count fields=7 expected=8" as *u8) == 1, ctr)
553 gv_check("T35b the-duplicate-id-is-named" as *u8, wg_count_in_file(gq_fshape, "GRAPH OFFENDER rung=F2 rule=duplicate-id" as *u8) == 1, ctr)
554 gv_check("T35c the-duplicate-EDGE-is-named-with-the-dependency-that-repeated" as *u8, wg_count_in_file(gq_fshape, "GRAPH OFFENDER rung=F3 rule=duplicate-edge dep=F2" as *u8) == 1, ctr)
555 let gq_ok: *u8 = "rung|H1|t|s|d|Organ|1|-\nrung|H2|t|s|d|Organ|1|H1\n" as *u8
556 let gq_pok: *SgPlan = sg_parse(gq_ok, sg_len(gq_ok), 0 as *u8, 0, 0 as *u8, 0)
557 let gq_fok: *u8 = wg_graph_dump(base, "graph_clean.txt" as *u8, gq_pok)
558 gv_check("T36 a-VALID-plan-is-unchanged-by-all-of-this: still valid, two nodes, one edge" as *u8, wg_both(wg_both((sg_valid(gq_pok) == 1), (gq_pok.count == 2)), (gq_pok.edge_count == 1)), ctr)
559 gv_check("T36a neg-control-the-emitter-INVENTS-NOTHING-on-a-clean-plan (a lister that always lists is worthless)" as *u8, wg_both((wg_count_in_file(gq_fok, "GRAPH OFFENDER" as *u8) == 0), (wg_count_in_file(gq_fok, "GRAPH EXTERNAL" as *u8) == 0)), ctr)
560 gv_check("T36b the-clean-plan-PRINTS-its-zero-counters-rather-than-going-silent" as *u8, wg_count_in_file(gq_fok, "offenders_listed=0 offenders_unlisted=0" as *u8) == 1, ctr)
561 // The list is CAPPED, and a cap reached in silence becomes a measurement nobody knows is partial.
562 // Built in a LOOP from the constant itself, so the fixture cannot drift away from the bound.
563 let gq_many: *u8 = sys_mmap((SGP_OFFENDER_MAX + 8) * 40)
564 var gq_mo: i64 = 0
565 var gq_mi: i64 = 0
566 while gq_mi < SGP_OFFENDER_MAX + 6 {
567 gq_mo = wg_cat(gq_many, gq_mo, "rung|Z" as *u8); gq_mo = wg_catn(gq_many, gq_mo, gq_mi); gq_mo = wg_cat(gq_many, gq_mo, "$|t|s|d|Organ|1|-\n" as *u8)
568 gq_mi = gq_mi + 1
569 }
570 let gq_pmany: *SgPlan = sg_parse(gq_many, sg_len(gq_many), 0 as *u8, 0, 0 as *u8, 0)
571 let gq_fmany: *u8 = wg_graph_dump(base, "graph_overflow.txt" as *u8, gq_pmany)
572 gv_check("T37 fixture-reached-the-condition: more bad rows than the ledger can hold" as *u8, wg_both((gq_pmany.declared == SGP_OFFENDER_MAX + 6), (gq_pmany.malformed == SGP_OFFENDER_MAX + 6)), ctr)
573 gv_check("T37a the-cap-ANNOUNCES-what-it-did-not-list" as *u8, wg_count_in_file(gq_fmany, "GRAPH OFFENDER-OVERFLOW unlisted=6" as *u8) == 1, ctr)
574 return gv_verdict("SWCOMPARE-WATCH" as *u8, ctr, "one ruler, rule derived from the claim's shape and named; shared by page, plane and ranker" as *u8)
575}