nx_browser_struct_col_gate.nx source
↩ module page · 218 lines · 12929 B
1// nx_browser_struct_col_gate.nx -- the BR2 structural-exactness column, proven IN PROCESS.
2//
3// Subject: nx_browser_struct_col_lib.nx, IMPORTED (not forked), so every tooth here sits inside the
4// mutation harness's build closure and a planted defect in the lib actually kills a mutant. A gate
5// that exec'd the promoted census binary would read NOT-REACHED for every mutant and its GREEN would
6// mean nothing.
7//
8// The three things this gate exists to stop, each measured on real data on 2026-08-26 BEFORE it was
9// written, so no tooth here is a hypothetical:
10// 1. A permil computed over TWO oracle bands published as "1000" (goog_raw.html), and a permil
11// computed over ZERO oracle bands published as "0" (so_aug.html, x_aug.html). Both are
12// arithmetic on an empty subject wearing a number -- a perfect score and a total failure,
13// neither of them evidence.
14// 2. A bar reported MET on partial coverage -- one bar site measured out of the four the
15// browser.plan done-rule names.
16// 3. A CSS-ON/CSS-OFF flip taken on a difference smaller than the census's own measured variance.
17// license_tier: ORIGINAL No hw writes (Rule 26).
18import "nx_gate_verdict.nx"
19import "nx_browser_struct_col_lib.nx"
20
21const BG_SITECAP: i64 = 512
22const BG_BAR_SHIPPING_PM: i64 = 900
23const BG_BAR_SHIPPING_DY: i64 = 4
24const BG_BAR_SHIPPING_SITES: i64 = 4
25const BG_FLOOR_AT_900: i64 = 10
26const BG_BAR_TIGHT: i64 = 950
27const BG_FLOOR_AT_950: i64 = 20
28// the live pair reading this rung must adjudicate: browser.plan debt css-off-default, "426 vs 311"
29const BG_LIVE_OFF: i64 = 426
30const BG_LIVE_ON: i64 = 311
31const BG_LEGN: i64 = 13
32// the 2026-08-26 saved-bytes deep-window readings, bench/selfpage through the incumbent ruler
33const BG_WIKI_PM: i64 = 845
34const BG_WIKI_DY: i64 = 7
35const BG_WIKI_DX: i64 = 80
36const BG_WIKI_BANDS: i64 = 84
37const BG_HN_PM: i64 = 769
38const BG_HN_DY: i64 = 12
39const BG_HN_DX: i64 = 91
40const BG_HN_BANDS: i64 = 26
41// the under-powered readings that motivated the denominator column
42const BG_GOOG_PM: i64 = 1000
43const BG_GOOG_BANDS: i64 = 2
44const BG_SO_BANDS: i64 = 0
45
46func bg_is_neg(v: i64) -> i64 { if v < 0 { return 1 } return 0 }
47func bg_is_zero(v: i64) -> i64 { if v == 0 { return 1 } return 0 }
48func bg_is_unobs(v: i64) -> i64 { if v == BSC_UNOBSERVABLE { return 1 } return 0 }
49func bg_is_tied(v: i64) -> i64 { if v == BSC_PAIR_TIED { return 1 } return 0 }
50func bg_is_pair_unobs(v: i64) -> i64 { if v == BSC_PAIR_UNOBSERVABLE { return 1 } return 0 }
51
52// 1 when a bar-site row with this (pm, dy) was REFUSED by the bar, 0 when it counted.
53func bg_bar_refused(csv: *u8, floor: i64, bar_pm: i64, bar_dy: i64, pm: i64, dy: i64) -> i64 {
54 let a: *i64 = bsc_acc()
55 bsc_row(a, csv, "wikipedia" as *u8, 9, pm, dy, 0, floor, floor, bar_pm, bar_dy)
56 if a[BSC_A_BARMET] == 0 { return 1 }
57 return 0
58}
59
60func main() -> i64 {
61 let ctr: *i64 = gv_ctr()
62 gv_head("nx_browser_struct_col_gate -- BR2: the census struct_diff column, its denominator floor, its bar and its pair verdict" as *u8)
63
64 // ---- the conf is a PRECONDITION, not a tooth: an unreadable bar proves nothing either way ----
65 let sites: *u8 = sys_mmap(BG_SITECAP)
66 let slen: i64 = bsc_bar_sites(sites, BG_SITECAP)
67 let bar_pm: i64 = bsc_bar_pm()
68 let bar_dy: i64 = bsc_bar_dy()
69 let band: i64 = bsc_pair_band()
70 var conf_ok: i64 = 0
71 if slen > 0 { if bar_pm >= 0 { if bar_dy >= 0 { if band >= 0 { conf_ok = 1 } } } }
72 gv_need("knowledge/browser_br2_bar.conf readable with bar, sites and variance band" as *u8, conf_ok, ctr)
73
74 // ---- the conf carries the browser.plan BR2 done-rule, not some other bar ----
75 var c1: i64 = 0
76 if bar_pm == BG_BAR_SHIPPING_PM { if bar_dy == BG_BAR_SHIPPING_DY { c1 = 1 } }
77 gv_check("conf-bar-equals-the-plan-done-rule-900-permil-dy-4" as *u8, c1, ctr)
78 let decl: i64 = bsc_bar_declared(sites)
79 var c2: i64 = 0
80 if decl == BG_BAR_SHIPPING_SITES { c2 = 1 }
81 gv_check("conf-declares-the-four-bar-sites-the-done-rule-names" as *u8, c2, ctr)
82
83 // ---- the denominator floor is DERIVED from the bar, and the derivation generalises ----
84 var c3: i64 = 0
85 if bsc_band_floor(BG_BAR_SHIPPING_PM) == BG_FLOOR_AT_900 { c3 = 1 }
86 gv_check("floor-derived-from-bar-headroom-900-needs-ten-oracle-bands" as *u8, c3, ctr)
87 var c4: i64 = 0
88 if bsc_band_floor(BG_BAR_TIGHT) == BG_FLOOR_AT_950 { c4 = 1 }
89 gv_check("floor-tracks-a-tighter-bar-950-needs-twenty" as *u8, c4, ctr)
90 var c5: i64 = 0
91 if bsc_band_floor(BG_BAR_TIGHT) > bsc_band_floor(BG_BAR_SHIPPING_PM) { c5 = 1 }
92 gv_check("floor-is-monotone-in-the-bar-not-a-fixed-number-wearing-a-derivation" as *u8, c5, ctr)
93 gv_bite("neg-control-unreadable-bar-yields-no-floor-never-a-permissive-one" as *u8,
94 bg_is_neg(bsc_band_floor(0 - 1)),
95 bg_is_neg(bsc_band_floor(BG_BAR_SHIPPING_PM)), ctr)
96
97 // ---- field parsing: UNMEASURED and a real zero are different claims ----
98 var c6: i64 = 0
99 if bsc_field_int("845" as *u8, 3) == BG_WIKI_PM { c6 = 1 }
100 gv_check("field-parses-a-measured-permil" as *u8, c6, ctr)
101 var c7: i64 = 0
102 if bsc_field_int("0" as *u8, 1) == 0 { c7 = 1 }
103 gv_check("field-keeps-a-real-zero-as-a-measurement" as *u8, c7, ctr)
104 gv_bite("neg-control-dash-is-unmeasured-not-zero" as *u8,
105 bg_is_neg(bsc_field_int("-" as *u8, 1)),
106 bg_is_neg(bsc_field_int("0" as *u8, 1)), ctr)
107
108 // ---- bar-site membership is whole-name, in both directions ----
109 var c8: i64 = 0
110 if bsc_is_bar_site(sites, "wikipedia" as *u8, 9) == 1 { c8 = 1 }
111 gv_check("bar-site-membership-hits-a-declared-name" as *u8, c8, ctr)
112 gv_bite("neg-control-a-longer-name-sharing-a-declared-prefix-is-not-a-bar-site" as *u8,
113 bg_is_zero(bsc_is_bar_site(sites, "xkcd" as *u8, 4)),
114 bg_is_zero(bsc_is_bar_site(sites, "x" as *u8, 1)), ctr)
115 gv_bite("neg-control-a-shorter-name-inside-a-declared-one-is-not-a-bar-site" as *u8,
116 bg_is_zero(bsc_is_bar_site(sites, "exam" as *u8, 4)),
117 bg_is_zero(bsc_is_bar_site(sites, "example" as *u8, 7)), ctr)
118
119 let floor: i64 = bsc_band_floor(bar_pm)
120
121 // ---- THE DENOMINATOR FLOOR IN ANGER: the two real readings that motivated this column ----
122 let a1: *i64 = bsc_acc()
123 let r_goog: i64 = bsc_row(a1, sites, "google" as *u8, 6, BG_GOOG_PM, 6, 193, BG_GOOG_BANDS, floor, bar_pm, bar_dy)
124 var c9: i64 = 0
125 if r_goog == 2 { if a1[BSC_A_MEASURED] == 0 { if a1[BSC_A_UNDERPOWERED] == 1 { c9 = 1 } } }
126 gv_check("a-perfect-score-over-two-oracle-bands-is-underpowered-not-a-1000" as *u8, c9, ctr)
127 let r_so: i64 = bsc_row(a1, sites, "stackoverflow" as *u8, 13, 0, 0, 0, BG_SO_BANDS, floor, bar_pm, bar_dy)
128 var c10: i64 = 0
129 if r_so == 2 { if a1[BSC_A_MEASURED] == 0 { if a1[BSC_A_UNDERPOWERED] == 2 { c10 = 1 } } }
130 gv_check("a-zero-over-zero-oracle-bands-is-underpowered-not-a-total-failure" as *u8, c10, ctr)
131 var c11: i64 = 0
132 if bsc_mean(a1[BSC_A_SUMPM], a1[BSC_A_MEASURED]) == BSC_UNMEASURED { c11 = 1 }
133 gv_check("a-mean-over-zero-measured-rows-is-absent-not-zero" as *u8, c11, ctr)
134
135 // ---- a well-powered row counts, and the bar is judged on it ----
136 let a2: *i64 = bsc_acc()
137 let r_w: i64 = bsc_row(a2, sites, "wikipedia" as *u8, 9, BG_WIKI_PM, BG_WIKI_DY, BG_WIKI_DX, BG_WIKI_BANDS, floor, bar_pm, bar_dy)
138 var c12: i64 = 0
139 if r_w == 1 { if a2[BSC_A_MEASURED] == 1 { if a2[BSC_A_BARN] == 1 { c12 = 1 } } }
140 gv_check("a-well-powered-row-counts-and-registers-against-the-bar" as *u8, c12, ctr)
141 var c13: i64 = 0
142 if a2[BSC_A_BARMET] == 0 { c13 = 1 }
143 gv_check("the-measured-wikipedia-deep-reading-does-not-clear-the-bar" as *u8, c13, ctr)
144 gv_bite("neg-control-a-reading-one-pixel-over-the-dy-limit-is-refused-at-the-limit-accepted" as *u8,
145 bg_bar_refused(sites, floor, bar_pm, bar_dy, bar_pm, bar_dy + 1),
146 bg_bar_refused(sites, floor, bar_pm, bar_dy, bar_pm, bar_dy), ctr)
147 gv_bite("neg-control-a-reading-one-permil-under-the-matched-bar-is-refused" as *u8,
148 bg_bar_refused(sites, floor, bar_pm, bar_dy, bar_pm - 1, bar_dy),
149 bg_bar_refused(sites, floor, bar_pm, bar_dy, bar_pm, bar_dy), ctr)
150
151 // ---- coverage: a bar met on part of its evidence is UNOBSERVABLE, never MET ----
152 let a3: *i64 = bsc_acc()
153 bsc_row(a3, sites, "wikipedia" as *u8, 9, bar_pm, bar_dy, 0, floor, floor, bar_pm, bar_dy)
154 var c14: i64 = 0
155 if bsc_bar_verdict(a3, decl, bar_pm, bar_dy) == BSC_UNOBSERVABLE { c14 = 1 }
156 gv_check("one-passing-bar-site-of-four-declared-is-unobservable-not-met" as *u8, c14, ctr)
157
158 // PRESENCE NEEDS ONE WITNESS; ABSENCE NEEDS EXHAUSTIVE COVERAGE. The first cut of the bar rule
159 // returned UNOBSERVABLE here, i.e. "we cannot say" about a ratchet a measured site had already
160 // refuted -- caught on the first real seed, where wikipedia and hackernews were both below the bar
161 // while example and x had no usable deep reading at all.
162 let a3b: *i64 = bsc_acc()
163 bsc_row(a3b, sites, "wikipedia" as *u8, 9, BG_WIKI_PM, BG_WIKI_DY, BG_WIKI_DX, BG_WIKI_BANDS, floor, bar_pm, bar_dy)
164 var c14b: i64 = 0
165 if bsc_bar_verdict(a3b, decl, bar_pm, bar_dy) == BSC_UNMET { c14b = 1 }
166 gv_check("one-measured-bar-site-below-the-bar-is-unmet-even-on-partial-coverage" as *u8, c14b, ctr)
167
168 let a4: *i64 = bsc_acc()
169 bsc_row(a4, sites, "wikipedia" as *u8, 9, bar_pm, bar_dy, 0, floor, floor, bar_pm, bar_dy)
170 bsc_row(a4, sites, "hackernews" as *u8, 10, bar_pm, bar_dy, 0, floor, floor, bar_pm, bar_dy)
171 bsc_row(a4, sites, "example" as *u8, 7, bar_pm, bar_dy, 0, floor, floor, bar_pm, bar_dy)
172 bsc_row(a4, sites, "x" as *u8, 1, bar_pm, bar_dy, 0, floor, floor, bar_pm, bar_dy)
173 var c15: i64 = 0
174 if bsc_bar_verdict(a4, decl, bar_pm, bar_dy) == BSC_MET { c15 = 1 }
175 gv_check("all-four-bar-sites-clearing-both-halves-is-met-so-the-rung-is-reachable" as *u8, c15, ctr)
176
177 let a5: *i64 = bsc_acc()
178 bsc_row(a5, sites, "wikipedia" as *u8, 9, bar_pm, bar_dy, 0, floor, floor, bar_pm, bar_dy)
179 bsc_row(a5, sites, "hackernews" as *u8, 10, BG_HN_PM, BG_HN_DY, BG_HN_DX, BG_HN_BANDS, floor, bar_pm, bar_dy)
180 bsc_row(a5, sites, "example" as *u8, 7, bar_pm, bar_dy, 0, floor, floor, bar_pm, bar_dy)
181 bsc_row(a5, sites, "x" as *u8, 1, bar_pm, bar_dy, 0, floor, floor, bar_pm, bar_dy)
182 var c16: i64 = 0
183 if bsc_bar_verdict(a5, decl, bar_pm, bar_dy) == BSC_UNMET { c16 = 1 }
184 gv_check("full-coverage-with-one-measured-site-short-is-unmet-not-unobservable" as *u8, c16, ctr)
185 gv_bite("neg-control-an-unreadable-bar-can-neither-pass-nor-fail-a-census" as *u8,
186 bg_is_unobs(bsc_bar_verdict(a4, decl, 0 - 1, bar_dy)),
187 bg_is_unobs(bsc_bar_verdict(a4, decl, bar_pm, bar_dy)), ctr)
188
189 // ---- the pair, on the numbers the rung actually has to adjudicate ----
190 var c17: i64 = 0
191 if bsc_pair_verdict(BG_LIVE_ON, BG_LEGN, BG_LIVE_OFF, BG_LEGN, band) == BSC_PAIR_OFF { c17 = 1 }
192 gv_check("the-live-311-vs-426-pair-still-favours-css-off-outside-the-variance-band" as *u8, c17, ctr)
193 gv_bite("neg-control-a-gap-inside-the-measured-variance-is-tied-not-a-win" as *u8,
194 bg_is_tied(bsc_pair_verdict(BG_LIVE_OFF - band, BG_LEGN, BG_LIVE_OFF, BG_LEGN, band)),
195 bg_is_tied(bsc_pair_verdict(BG_LIVE_ON, BG_LEGN, BG_LIVE_OFF, BG_LEGN, band)), ctr)
196 var c18: i64 = 0
197 if bsc_pair_verdict(BG_LIVE_OFF, BG_LEGN, BG_LIVE_ON, BG_LEGN, band) == BSC_PAIR_ON { c18 = 1 }
198 gv_check("the-pair-can-favour-css-on-so-the-flip-is-reachable-by-evidence" as *u8, c18, ctr)
199 gv_bite("neg-control-a-missing-leg-is-unobservable-never-a-default-winner" as *u8,
200 bg_is_pair_unobs(bsc_pair_verdict(BG_LIVE_ON, 0, BG_LIVE_OFF, BG_LEGN, band)),
201 bg_is_pair_unobs(bsc_pair_verdict(BG_LIVE_ON, BG_LEGN, BG_LIVE_OFF, BG_LEGN, band)), ctr)
202
203 // ---- the partition reconciles: every row landed in exactly one bucket ----
204 let a6: *i64 = bsc_acc()
205 bsc_row(a6, sites, "wikipedia" as *u8, 9, BG_WIKI_PM, BG_WIKI_DY, BG_WIKI_DX, BG_WIKI_BANDS, floor, bar_pm, bar_dy)
206 bsc_row(a6, sites, "google" as *u8, 6, BG_GOOG_PM, 6, 193, BG_GOOG_BANDS, floor, bar_pm, bar_dy)
207 bsc_row(a6, sites, "bbc" as *u8, 3, 0 - 1, 0 - 1, 0 - 1, 0 - 1, floor, bar_pm, bar_dy)
208 gv_subjects("census rows folded by this gate" as *u8, a6[BSC_A_ROWS], ctr)
209 var c19: i64 = 0
210 let part: i64 = a6[BSC_A_MEASURED] + a6[BSC_A_UNDERPOWERED] + a6[BSC_A_UNMEASURED]
211 if part == a6[BSC_A_ROWS] { c19 = 1 }
212 gv_check("measured-plus-underpowered-plus-unmeasured-sums-to-rows-seen" as *u8, c19, ctr)
213
214 let rc: i64 = gv_verdict("BROWSER-STRUCT-COL-GATE" as *u8, ctr,
215 "the BR2 column refuses a permil its oracle band count cannot resolve, refuses a bar met on partial coverage, and refuses a pair flip inside the census's own measured variance" as *u8)
216 sys_exit(rc)
217 return rc
218}