pandorga 2.3.16 → 2.3.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,15 +18,67 @@ def fail!(msg)
18
18
  true
19
19
  end
20
20
 
21
- # PLT-AC-88 — Projects island centered in desktop column
21
+ # PLT-AC-88 — Contents page from 1024px
22
+ unless HOME.include?("PLT-AC-88 contents")
23
+ failed = 1 if fail!("PLT-AC-88: home.css must document the contents page")
24
+ end
25
+ unless HOME.match?(/\.home-project-inventory-body\s*\{[^}]*display:\s*contents/)
26
+ failed = 1 if fail!("PLT-AC-88: the row body must participate in the line")
27
+ end
28
+ unless HOME.match?(/width:\s*11rem/)
29
+ failed = 1 if fail!("PLT-AC-88: the opened picture must be 11rem wide")
30
+ end
31
+ if HOME.match?(/--home-specimen-plate-height:\s*15\.3125rem/)
32
+ failed = 1 if fail!("PLT-AC-88: desktop must not keep the 15.3125rem specimen cap")
33
+ end
34
+ if HOME.match?(/\.home-project-inventory-title\s*\{[^}]*text-overflow:\s*ellipsis/)
35
+ failed = 1 if fail!("PLT-AC-88: inventory titles must not ellipsize")
36
+ end
37
+ unless HOME.match?(/\.home-project-inventory-title\s*\{[^}]*white-space:\s*normal/)
38
+ failed = 1 if fail!("PLT-AC-88: inventory titles must wrap")
39
+ end
40
+ unless HOME.match?(/\.home-project-inventory-title\s*\{[^}]*font-family:\s*var\(--font-body\)/)
41
+ failed = 1 if fail!("PLT-AC-88: inventory titles must use --font-body")
42
+ end
43
+ unless HOME.match?(/\.home-project-inventory-title\s*\{[^}]*font-weight:\s*var\(--weight-body\)/)
44
+ failed = 1 if fail!("PLT-AC-88: inventory titles must use --weight-body")
45
+ end
46
+ unless HOME.match?(/font-size:\s*clamp\(1\.45rem,\s*2\.2vw,\s*2\.05rem\)/)
47
+ failed = 1 if fail!("PLT-AC-88: names must use the contents size clamp")
48
+ end
49
+ if HOME.match?(/\.home-project-inventory-title\s*\{[^}]*font-family:\s*var\(--font-(?:title|label)\)/)
50
+ failed = 1 if fail!("PLT-AC-88: inventory titles must not use the serif title or label face")
51
+ end
52
+ unless HOME.match?(/\.home-project-specimen[^{]*\{[^}]*display:\s*none/)
53
+ failed = 1 if fail!("PLT-AC-88: the specimen card must be hidden")
54
+ end
22
55
  unless HOME.match?(/\.home-projects-bench[\s\S]{0,800}?margin-inline:\s*auto/)
23
- failed = 1 if fail!("PLT-AC-88: .home-projects-bench must use margin-inline: auto")
56
+ failed = 1 if fail!("PLT-AC-88: tablet island must keep margin-inline: auto")
57
+ end
58
+ unless SPEC.include?("Contents") && SPEC.include?("11rem")
59
+ failed = 1 if fail!("PLT-AC-88: spec must describe the contents page and the 11rem picture")
24
60
  end
25
- unless HOME.match?(/\.home-projects-bench[\s\S]{0,800}?width:\s*max-content/)
26
- failed = 1 if fail!("PLT-AC-88: .home-projects-bench must use width: max-content")
61
+ unless HOME.match?(/\.home-project-inventory-row\s*>\s*\.home-project-inventory-glyph[^{]*\{[^}]*grid-area:\s*icon/) ||
62
+ HOME.match?(/\.home-project-inventory-glyph[^{]*\{[^}]*grid-area:\s*icon/)
63
+ failed = 1 if fail!("PLT-AC-88: the project icon glyph must occupy the icon cell")
27
64
  end
28
- unless HOME.include?("PLT-AC-88") || SPEC.include?("PLT-AC-88")
29
- failed = 1 if fail!("PLT-AC-88: spec must name PLT-AC-88")
65
+ unless HOME.match?(/\.home-project-inventory-code[^{]*\{[^}]*display:\s*none/)
66
+ failed = 1 if fail!("PLT-AC-88: folio/meta code must be hidden on the contents page")
67
+ end
68
+ unless HOME.match?(/\.home-project-inventory-year[^{]*\{[^}]*display:\s*none/)
69
+ failed = 1 if fail!("PLT-AC-88: year must be hidden on collapsed contents rows")
70
+ end
71
+ unless HOME.match?(/\.home-project-inventory-tags[^{]*\{[^}]*display:\s*none/)
72
+ failed = 1 if fail!("PLT-AC-88: tags must be hidden on collapsed contents rows")
73
+ end
74
+ unless HOME.match?(/home-project-inventory-excerpt/)
75
+ failed = 1 if fail!("PLT-AC-88: home.css must style the presentation excerpt")
76
+ end
77
+ unless HOME.match?(/-webkit-line-clamp:\s*[2-6]/)
78
+ failed = 1 if fail!("PLT-AC-88: the excerpt must clamp to a few lines")
79
+ end
80
+ unless SPEC.include?("icon glyph") || SPEC.include?("project icon")
81
+ failed = 1 if fail!("PLT-AC-88: spec must describe the icon-plus-name collapsed row")
30
82
  end
31
83
 
32
84
  # PLT-AC-89 — soft edgeless overlay, no panel behind copy
@@ -107,6 +159,26 @@ unless HOME.match?(/\.home-hero-actions-contacts[\s\S]{0,120}?flex-wrap:\s*nowra
107
159
  failed = 1 if fail!("PLT-AC-94: .home-hero-actions-contacts must keep flex-wrap: nowrap")
108
160
  end
109
161
 
162
+ # PLT-AC-104 / PLT-AC-105 / PLT-AC-106 — icon/name center + gray wash + pad balance
163
+ unless HOME.include?("PLT-AC-104")
164
+ failed = 1 if fail!("PLT-AC-104: home.css must document icon/name vertical center")
165
+ end
166
+ if HOME.include?("data-contents-select")
167
+ failed = 1 if fail!("PLT-AC-105: home.css must not keep data-contents-select selection switch")
168
+ end
169
+ if HOME.match?(/--mk-h:\s*0\.42em/)
170
+ failed = 1 if fail!("PLT-AC-105: selected title must not keep the thin 0.42em mark bar")
171
+ end
172
+ unless HOME.include?("PLT-AC-105") && HOME.include?("color-surface-high")
173
+ failed = 1 if fail!("PLT-AC-105: home.css must document gray --color-surface-high selection wash")
174
+ end
175
+ unless HOME.include?("PLT-AC-106")
176
+ failed = 1 if fail!("PLT-AC-106: home.css must document selected-row padding balance")
177
+ end
178
+ unless SPEC.include?("PLT-AC-104") && SPEC.include?("PLT-AC-105") && SPEC.include?("PLT-AC-106")
179
+ failed = 1 if fail!("spec docs/features/home-hero-c4.md must cover PLT-AC-104/105/106")
180
+ end
181
+
110
182
  # Spec + validate wiring
111
183
  unless SPEC.include?("PLT-AC-94") && SPEC.include?("2.3.6")
112
184
  failed = 1 if fail!("spec docs/features/home-hero-c4.md must cover PLT-AC-88…94 and 2.3.6")
@@ -116,7 +188,7 @@ unless VALIDATE.include?("test-home-hero-c4.rb")
116
188
  end
117
189
 
118
190
  if failed.zero?
119
- puts "PASS test-home-hero-c4 (PLT-AC-88…94)"
191
+ puts "PASS test-home-hero-c4 (PLT-AC-88…94, 104/105/106)"
120
192
  else
121
193
  exit 1
122
194
  end
@@ -0,0 +1,444 @@
1
+ #!/usr/bin/env node
2
+ // PLT-AC-103 — rendered monotonicity of strength (upper/face) and pool (text band)
3
+ // at 390 and 1440. Fixture uses a bright mid-tone "photo" so strength darkening
4
+ // is measurable (dark-wall regions hid the 2.3.16 charcoal inversion).
5
+
6
+ import { spawn } from 'node:child_process';
7
+ import { existsSync } from 'node:fs';
8
+ import { mkdtemp, writeFile, readFile, rm, mkdir } from 'node:fs/promises';
9
+ import { createServer as createNetServer } from 'node:net';
10
+ import { createServer as createHttpServer } from 'node:http';
11
+ import { tmpdir } from 'node:os';
12
+ import { join, resolve } from 'node:path';
13
+ import { setTimeout as delay } from 'node:timers/promises';
14
+ import { fileURLToPath } from 'node:url';
15
+
16
+ const __dirname = fileURLToPath(new URL('.', import.meta.url));
17
+ const ROOT = resolve(__dirname, '../..');
18
+ const HOME_CSS = join(ROOT, 'assets/css/ledger/home.css');
19
+
20
+ const STRENGTH_STEPS = [0.2, 0.4, 0.6, 0.8];
21
+ const POOL_STEPS = [0.2, 0.4, 0.6, 0.8];
22
+ // Minimum mean-RGB drop per 0.2 step on the bright face region / text band.
23
+ const MIN_DELTA_STRENGTH = 4.0;
24
+ const MIN_DELTA_POOL = 4.0;
25
+ const VIEWPORTS = [
26
+ { name: '390', width: 390, height: 844, mobile: true },
27
+ { name: '1440', width: 1440, height: 900, mobile: false }
28
+ ];
29
+
30
+ function freePort() {
31
+ return new Promise((resolveP, reject) => {
32
+ const server = createNetServer();
33
+ server.once('error', reject);
34
+ server.listen(0, '127.0.0.1', () => {
35
+ const { port } = server.address();
36
+ server.close(() => resolveP(port));
37
+ });
38
+ });
39
+ }
40
+
41
+ function findChrome() {
42
+ const candidates = [
43
+ process.env.CHROME_PATH,
44
+ '/usr/bin/google-chrome-stable',
45
+ '/usr/bin/google-chrome',
46
+ '/usr/bin/chromium',
47
+ '/usr/bin/chromium-browser'
48
+ ].filter(Boolean);
49
+ for (const c of candidates) {
50
+ if (c && existsSync(c)) return c;
51
+ }
52
+ return 'google-chrome';
53
+ }
54
+
55
+ class Cdp {
56
+ constructor(ws) {
57
+ this.ws = ws;
58
+ this.next = 1;
59
+ this.pending = new Map();
60
+ ws.addEventListener('message', (event) => {
61
+ const message = JSON.parse(event.data);
62
+ if (message.id && this.pending.has(message.id)) {
63
+ const { resolve: res, reject: rej } = this.pending.get(message.id);
64
+ this.pending.delete(message.id);
65
+ if (message.error) rej(new Error(message.error.message || JSON.stringify(message.error)));
66
+ else res(message.result || {});
67
+ }
68
+ });
69
+ }
70
+ send(method, params = {}, sessionId) {
71
+ const id = this.next++;
72
+ const payload = { id, method, params };
73
+ if (sessionId) payload.sessionId = sessionId;
74
+ this.ws.send(JSON.stringify(payload));
75
+ return new Promise((res, rej) => this.pending.set(id, { resolve: res, reject: rej }));
76
+ }
77
+ }
78
+
79
+ async function openSocket(url) {
80
+ const ws = new WebSocket(url);
81
+ await new Promise((resolveP, reject) => {
82
+ ws.addEventListener('open', resolveP, { once: true });
83
+ ws.addEventListener('error', () => reject(new Error('DevTools socket failed')), { once: true });
84
+ });
85
+ return ws;
86
+ }
87
+
88
+ async function waitForDevtools(port, chrome) {
89
+ let stderr = '';
90
+ if (chrome.stderr) chrome.stderr.on('data', (c) => { stderr += c; });
91
+ for (let i = 0; i < 100; i++) {
92
+ if (chrome.exitCode !== null) throw new Error(`Chrome exited ${chrome.exitCode}: ${stderr.slice(-500)}`);
93
+ try {
94
+ const response = await fetch(`http://127.0.0.1:${port}/json/version`);
95
+ if (response.ok) return response.json();
96
+ } catch (_e) { /* starting */ }
97
+ await delay(100);
98
+ }
99
+ throw new Error(`Chrome DevTools did not answer on ${port}`);
100
+ }
101
+
102
+ function extractOverlayCss(fullCss) {
103
+ const rootIdx = fullCss.indexOf('--home-hero-vignette:');
104
+ if (rootIdx < 0) throw new Error('missing --home-hero-vignette');
105
+ const rootStart = fullCss.lastIndexOf(':root {', rootIdx);
106
+ const rootEnd = fullCss.indexOf('}', rootIdx) + 1;
107
+ const rootBlock = fullCss.slice(rootStart, rootEnd);
108
+
109
+ const soft = fullCss.indexOf('/* Soft edgeless photo overlay');
110
+ if (soft < 0) throw new Error('missing Soft edgeless overlay block');
111
+ // Desk shared + ::before + ::after end at the blank line before stacked media
112
+ const stacked = fullCss.indexOf('/* ── Stacked / full-bleed', soft);
113
+ if (stacked < 0) throw new Error('missing stacked media marker');
114
+ const deskBlock = fullCss.slice(soft, stacked);
115
+
116
+ const stackMarker = fullCss.indexOf('PLT-AC-100…103: stack');
117
+ if (stackMarker < 0) throw new Error('missing stack overlay marker');
118
+ // Take from the stack comment through the end of the nested ::after rule
119
+ const afterStack = fullCss.indexOf('.home-hero-portrait::after {', stackMarker);
120
+ let depth = 0;
121
+ let i = fullCss.indexOf('{', afterStack);
122
+ for (; i < fullCss.length; i++) {
123
+ if (fullCss[i] === '{') depth++;
124
+ else if (fullCss[i] === '}') {
125
+ depth--;
126
+ if (depth === 0) { i++; break; }
127
+ }
128
+ }
129
+ const stackRules = fullCss.slice(stackMarker, i);
130
+ const stackMedia = `@media (max-width: 1023px) {
131
+ ${stackRules}
132
+ }
133
+ `;
134
+
135
+ return `${rootBlock}
136
+ ${deskBlock}
137
+ ${stackMedia}
138
+ `;
139
+ }
140
+
141
+ function buildFixtureHtml(overlayCss) {
142
+ // Bright face/shirt-like mid-tone (#d4b896) so black overlays darken measurably.
143
+ // Vertical gradient: brighter upper (face), slightly darker lower (so pool still measurable).
144
+ return `<!doctype html>
145
+ <html lang="en">
146
+ <head>
147
+ <meta charset="utf-8"/>
148
+ <meta name="viewport" content="width=device-width, initial-scale=1"/>
149
+ <style>
150
+ html, body { margin: 0; padding: 0; background: #111; }
151
+ .home-hero-portrait {
152
+ position: relative;
153
+ width: 100vw;
154
+ height: 100vh;
155
+ overflow: hidden;
156
+ background:
157
+ radial-gradient(ellipse 55% 45% at 48% 32%, #e8c9a8 0%, #d4b896 40%, #b8956e 70%, #6a5a48 100%),
158
+ linear-gradient(180deg, #c4a882 0%, #a88860 55%, #5a4a3a 100%);
159
+ }
160
+ ${overlayCss}
161
+ </style>
162
+ </head>
163
+ <body>
164
+ <div class="home-hero-portrait" id="hero"></div>
165
+ </body>
166
+ </html>`;
167
+ }
168
+
169
+ async function readPngRgba(pngPath) {
170
+ // Minimal PNG decoder (8-bit RGB/RGBA, non-interlaced) using node:zlib.
171
+ const { inflateSync } = await import('node:zlib');
172
+ const buf = await readFile(pngPath);
173
+ if (buf.toString('ascii', 1, 4) !== 'PNG') throw new Error('not PNG');
174
+ let pos = 8;
175
+ let width = 0, height = 0, colorType = 2, bits = 8;
176
+ const idat = [];
177
+ while (pos < buf.length) {
178
+ const len = buf.readUInt32BE(pos); pos += 4;
179
+ const type = buf.toString('ascii', pos, pos + 4); pos += 4;
180
+ const data = buf.subarray(pos, pos + len); pos += len;
181
+ pos += 4; // crc
182
+ if (type === 'IHDR') {
183
+ width = data.readUInt32BE(0);
184
+ height = data.readUInt32BE(4);
185
+ bits = data[8];
186
+ colorType = data[9];
187
+ } else if (type === 'IDAT') {
188
+ idat.push(data);
189
+ } else if (type === 'IEND') break;
190
+ }
191
+ if (bits !== 8 || (colorType !== 2 && colorType !== 6)) {
192
+ throw new Error(`unsupported PNG ct=${colorType} bits=${bits}`);
193
+ }
194
+ const bpp = colorType === 6 ? 4 : 3;
195
+ const raw = inflateSync(Buffer.concat(idat));
196
+ const stride = width * bpp;
197
+ const rgba = Buffer.alloc(width * height * 4);
198
+ let src = 0;
199
+ for (let y = 0; y < height; y++) {
200
+ const filter = raw[src++];
201
+ const row = raw.subarray(src, src + stride);
202
+ src += stride;
203
+ const out = rgba.subarray(y * width * 4, (y + 1) * width * 4);
204
+ // Paeth/Sub/Up/Average/None — Chrome uses filter 0 or 1 typically; handle 0–4.
205
+ const prev = y > 0 ? rgba.subarray((y - 1) * width * 4, y * width * 4) : null;
206
+ for (let i = 0; i < width; i++) {
207
+ let r = row[i * bpp], g = row[i * bpp + 1], b = row[i * bpp + 2];
208
+ const a = bpp === 4 ? row[i * bpp + 3] : 255;
209
+ const left = i > 0 ? [out[(i - 1) * 4], out[(i - 1) * 4 + 1], out[(i - 1) * 4 + 2]] : [0, 0, 0];
210
+ const up = prev ? [prev[i * 4], prev[i * 4 + 1], prev[i * 4 + 2]] : [0, 0, 0];
211
+ const apply = (chan, li, ui) => {
212
+ if (filter === 0) return chan;
213
+ if (filter === 1) return (chan + li) & 255;
214
+ if (filter === 2) return (chan + ui) & 255;
215
+ if (filter === 3) return (chan + ((li + ui) >> 1)) & 255;
216
+ if (filter === 4) {
217
+ const p = li + ui - (prev && i > 0 ? prev[(i - 1) * 4 + (li === left[0] ? 0 : li === left[1] ? 1 : 2)] : 0);
218
+ // Proper Paeth for each channel below
219
+ return chan; // placeholder replaced
220
+ }
221
+ return chan;
222
+ };
223
+ if (filter === 0) {
224
+ // none
225
+ } else if (filter === 1) {
226
+ r = (r + left[0]) & 255; g = (g + left[1]) & 255; b = (b + left[2]) & 255;
227
+ } else if (filter === 2) {
228
+ r = (r + up[0]) & 255; g = (g + up[1]) & 255; b = (b + up[2]) & 255;
229
+ } else if (filter === 3) {
230
+ r = (r + ((left[0] + up[0]) >> 1)) & 255;
231
+ g = (g + ((left[1] + up[1]) >> 1)) & 255;
232
+ b = (b + ((left[2] + up[2]) >> 1)) & 255;
233
+ } else if (filter === 4) {
234
+ const paeth = (a, b, c) => {
235
+ const p = a + b - c;
236
+ const pa = Math.abs(p - a), pb = Math.abs(p - b), pc = Math.abs(p - c);
237
+ return pa <= pb && pa <= pc ? a : pb <= pc ? b : c;
238
+ };
239
+ const ul = prev && i > 0 ? [prev[(i - 1) * 4], prev[(i - 1) * 4 + 1], prev[(i - 1) * 4 + 2]] : [0, 0, 0];
240
+ r = (r + paeth(left[0], up[0], ul[0])) & 255;
241
+ g = (g + paeth(left[1], up[1], ul[1])) & 255;
242
+ b = (b + paeth(left[2], up[2], ul[2])) & 255;
243
+ } else {
244
+ throw new Error('unsupported PNG filter ' + filter);
245
+ }
246
+ out[i * 4] = r; out[i * 4 + 1] = g; out[i * 4 + 2] = b; out[i * 4 + 3] = a;
247
+ }
248
+ }
249
+ return { width, height, rgba };
250
+ }
251
+
252
+ function meanBandsFromRgba({ width, height, rgba }, faceY0, faceY1, faceX0, faceX1, textY0, textY1) {
253
+ const band = (y0, y1, x0 = 0, x1 = 1) => {
254
+ const ya = Math.floor(height * y0);
255
+ const yb = Math.max(ya + 1, Math.floor(height * y1));
256
+ const xa = Math.floor(width * x0);
257
+ const xb = Math.max(xa + 1, Math.floor(width * x1));
258
+ let s = 0, n = 0, pb = 0;
259
+ for (let y = ya; y < yb; y++) {
260
+ for (let x = xa; x < xb; x++) {
261
+ const i = (y * width + x) * 4;
262
+ const r = rgba[i], g = rgba[i + 1], b = rgba[i + 2];
263
+ s += (r + g + b) / 3;
264
+ n++;
265
+ if (r + g + b < 3) pb++;
266
+ }
267
+ }
268
+ return { mean: n ? s / n : 0, pb: n ? (100 * pb) / n : 0 };
269
+ };
270
+ const face = band(faceY0, faceY1, faceX0, faceX1);
271
+ const text = band(textY0, textY1);
272
+ return { face: face.mean, text: text.mean, pb: text.pb };
273
+ }
274
+
275
+ async function main() {
276
+ const fullCss = await readFile(HOME_CSS, 'utf8');
277
+ const overlayCss = extractOverlayCss(fullCss);
278
+ const html = buildFixtureHtml(overlayCss);
279
+
280
+ const work = await mkdtemp(join(tmpdir(), 'pandorga-mono-'));
281
+ const htmlPath = join(work, 'index.html');
282
+ await writeFile(htmlPath, html);
283
+
284
+ const httpPort = await freePort();
285
+ const httpServer = createHttpServer(async (req, res) => {
286
+ res.writeHead(200, { 'Content-Type': 'text/html' });
287
+ res.end(html);
288
+ });
289
+ await new Promise((r) => httpServer.listen(httpPort, '127.0.0.1', r));
290
+
291
+ const chromePath = findChrome();
292
+ const profile = await mkdtemp(join(tmpdir(), 'pandorga-mono-chrome-'));
293
+ const dbgPort = await freePort();
294
+ const chrome = spawn(chromePath, [
295
+ '--headless=new', '--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage',
296
+ '--no-first-run', '--remote-allow-origins=*',
297
+ '--remote-debugging-address=127.0.0.1',
298
+ `--remote-debugging-port=${dbgPort}`,
299
+ `--user-data-dir=${profile}`,
300
+ 'about:blank'
301
+ ], { stdio: ['ignore', 'ignore', 'pipe'] });
302
+
303
+ const errors = [];
304
+ try {
305
+ const version = await waitForDevtools(dbgPort, chrome);
306
+ const ws = await openSocket(version.webSocketDebuggerUrl);
307
+ const browser = new Cdp(ws);
308
+
309
+ const { targetId } = await browser.send('Target.createTarget', { url: 'about:blank' });
310
+ const { sessionId } = await browser.send('Target.attachToTarget', { targetId, flatten: true });
311
+ await browser.send('Page.enable', {}, sessionId);
312
+ await browser.send('Runtime.enable', {}, sessionId);
313
+
314
+ for (const vp of VIEWPORTS) {
315
+ await browser.send('Emulation.setDeviceMetricsOverride', {
316
+ width: vp.width, height: vp.height,
317
+ deviceScaleFactor: 1, mobile: vp.mobile
318
+ }, sessionId);
319
+
320
+ await browser.send('Page.navigate', { url: `http://127.0.0.1:${httpPort}/` }, sessionId);
321
+ await delay(400);
322
+
323
+ // --- Strength monotonicity (pool fixed mid) ---
324
+ const strengthFace = [];
325
+ for (const s of STRENGTH_STEPS) {
326
+ await browser.send('Runtime.evaluate', {
327
+ expression: `document.documentElement.style.setProperty('--home-hero-vignette','${s}');document.documentElement.style.setProperty('--home-hero-pool','0.50');`
328
+ }, sessionId);
329
+ await delay(120);
330
+ const shot = await browser.send('Page.captureScreenshot', { format: 'png' }, sessionId);
331
+ const pngPath = join(work, `s-${vp.name}-${s}.png`);
332
+ await writeFile(pngPath, Buffer.from(shot.data, 'base64'));
333
+ // Face/shirt: central-upper bright region (not dark edges)
334
+ const m = meanBandsFromRgba(await readPngRgba(pngPath), 0.12, 0.38, 0.30, 0.70, 0.62, 0.92);
335
+ strengthFace.push(m.face);
336
+ console.log(`strength ${s} @${vp.name}: face=${m.face.toFixed(1)} text=${m.text.toFixed(1)}`);
337
+ }
338
+ for (let i = 1; i < strengthFace.length; i++) {
339
+ const delta = strengthFace[i - 1] - strengthFace[i];
340
+ if (delta < MIN_DELTA_STRENGTH) {
341
+ errors.push(`${vp.name}: strength ${STRENGTH_STEPS[i - 1]}→${STRENGTH_STEPS[i]} face brightness drop ${delta.toFixed(2)} < ${MIN_DELTA_STRENGTH} (PLT-AC-103)`);
342
+ }
343
+ }
344
+
345
+ // --- Pool monotonicity (strength fixed mid) ---
346
+ const poolText = [];
347
+ let maxPb = 0;
348
+ for (const p of POOL_STEPS) {
349
+ await browser.send('Runtime.evaluate', {
350
+ expression: `document.documentElement.style.setProperty('--home-hero-vignette','0.50');document.documentElement.style.setProperty('--home-hero-pool','${p}');`
351
+ }, sessionId);
352
+ await delay(120);
353
+ const shot = await browser.send('Page.captureScreenshot', { format: 'png' }, sessionId);
354
+ const pngPath = join(work, `p-${vp.name}-${p}.png`);
355
+ await writeFile(pngPath, Buffer.from(shot.data, 'base64'));
356
+ const m = meanBandsFromRgba(await readPngRgba(pngPath), 0.12, 0.38, 0.30, 0.70, 0.62, 0.92);
357
+ poolText.push(m.text);
358
+ maxPb = Math.max(maxPb, m.pb);
359
+ console.log(`pool ${p} @${vp.name}: face=${m.face.toFixed(1)} text=${m.text.toFixed(1)} pb%=${m.pb.toFixed(2)}`);
360
+ }
361
+ for (let i = 1; i < poolText.length; i++) {
362
+ const delta = poolText[i - 1] - poolText[i];
363
+ if (delta < MIN_DELTA_POOL) {
364
+ errors.push(`${vp.name}: pool ${POOL_STEPS[i - 1]}→${POOL_STEPS[i]} text brightness drop ${delta.toFixed(2)} < ${MIN_DELTA_POOL} (PLT-AC-103)`);
365
+ }
366
+ }
367
+ if (maxPb > 0.01) {
368
+ errors.push(`${vp.name}: pure-black pixels in text band ${maxPb.toFixed(3)}% > 0 (PLT-AC-103)`);
369
+ }
370
+
371
+ // --- Independence: strength change must not move text band much; pool must not move face much ---
372
+ await browser.send('Runtime.evaluate', {
373
+ expression: `document.documentElement.style.setProperty('--home-hero-vignette','0.20');document.documentElement.style.setProperty('--home-hero-pool','0.80');`
374
+ }, sessionId);
375
+ await delay(120);
376
+ let shot = await browser.send('Page.captureScreenshot', { format: 'png' }, sessionId);
377
+ let pngPath = join(work, `ind-a-${vp.name}.png`);
378
+ await writeFile(pngPath, Buffer.from(shot.data, 'base64'));
379
+ const a = meanBandsFromRgba(await readPngRgba(pngPath), 0.12, 0.38, 0.30, 0.70, 0.62, 0.92);
380
+
381
+ await browser.send('Runtime.evaluate', {
382
+ expression: `document.documentElement.style.setProperty('--home-hero-vignette','0.80');document.documentElement.style.setProperty('--home-hero-pool','0.80');`
383
+ }, sessionId);
384
+ await delay(120);
385
+ shot = await browser.send('Page.captureScreenshot', { format: 'png' }, sessionId);
386
+ pngPath = join(work, `ind-b-${vp.name}.png`);
387
+ await writeFile(pngPath, Buffer.from(shot.data, 'base64'));
388
+ const b = meanBandsFromRgba(await readPngRgba(pngPath), 0.12, 0.38, 0.30, 0.70, 0.62, 0.92);
389
+
390
+ // Strength ↑ should darken face substantially; text band change should be small (mask)
391
+ if (a.face - b.face < MIN_DELTA_STRENGTH * 2) {
392
+ errors.push(`${vp.name}: independence strength 0.2→0.8 face drop ${(a.face - b.face).toFixed(2)} too small (PLT-AC-103)`);
393
+ }
394
+ if (Math.abs(a.text - b.text) > 6.0) {
395
+ errors.push(`${vp.name}: independence: strength change moved text band by ${Math.abs(a.text - b.text).toFixed(2)} (>6) (PLT-AC-103)`);
396
+ }
397
+
398
+ await browser.send('Runtime.evaluate', {
399
+ expression: `document.documentElement.style.setProperty('--home-hero-vignette','0.70');document.documentElement.style.setProperty('--home-hero-pool','0.20');`
400
+ }, sessionId);
401
+ await delay(120);
402
+ shot = await browser.send('Page.captureScreenshot', { format: 'png' }, sessionId);
403
+ pngPath = join(work, `ind-c-${vp.name}.png`);
404
+ await writeFile(pngPath, Buffer.from(shot.data, 'base64'));
405
+ const c = meanBandsFromRgba(await readPngRgba(pngPath), 0.12, 0.38, 0.30, 0.70, 0.62, 0.92);
406
+
407
+ await browser.send('Runtime.evaluate', {
408
+ expression: `document.documentElement.style.setProperty('--home-hero-vignette','0.70');document.documentElement.style.setProperty('--home-hero-pool','0.80');`
409
+ }, sessionId);
410
+ await delay(120);
411
+ shot = await browser.send('Page.captureScreenshot', { format: 'png' }, sessionId);
412
+ pngPath = join(work, `ind-d-${vp.name}.png`);
413
+ await writeFile(pngPath, Buffer.from(shot.data, 'base64'));
414
+ const d = meanBandsFromRgba(await readPngRgba(pngPath), 0.12, 0.38, 0.30, 0.70, 0.62, 0.92);
415
+
416
+ if (c.text - d.text < MIN_DELTA_POOL * 2) {
417
+ errors.push(`${vp.name}: independence pool 0.2→0.8 text drop ${(c.text - d.text).toFixed(2)} too small (PLT-AC-103)`);
418
+ }
419
+ if (Math.abs(c.face - d.face) > 6.0) {
420
+ errors.push(`${vp.name}: independence: pool change moved face by ${Math.abs(c.face - d.face).toFixed(2)} (>6) (PLT-AC-103)`);
421
+ }
422
+ }
423
+
424
+ ws.close();
425
+ } finally {
426
+ chrome.kill('SIGKILL');
427
+ httpServer.close();
428
+ await delay(100);
429
+ await rm(profile, { recursive: true, force: true });
430
+ await rm(work, { recursive: true, force: true });
431
+ }
432
+
433
+ if (errors.length) {
434
+ console.error('FAIL test-home-hero-overlay-monotonic (PLT-AC-103):');
435
+ for (const e of errors) console.error(' - ' + e);
436
+ process.exit(1);
437
+ }
438
+ console.log('PASS test-home-hero-overlay-monotonic (PLT-AC-103)');
439
+ }
440
+
441
+ main().catch((err) => {
442
+ console.error(`ERROR: ${err.stack || err}`);
443
+ process.exit(1);
444
+ });
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ # PLT-AC-103 — rendered monotonicity gate (strength upper/face, pool text band).
4
+ require "pathname"
5
+ require "open3"
6
+
7
+ ROOT = Pathname.new(__dir__).join("../..").expand_path
8
+ MJS = ROOT.join("scripts/test/test-home-hero-overlay-monotonic.mjs")
9
+
10
+ unless MJS.file?
11
+ warn "FAIL test-home-hero-overlay-monotonic: missing #{MJS}"
12
+ exit 1
13
+ end
14
+
15
+ stdout, stderr, status = Open3.capture3("node", MJS.to_s, chdir: ROOT.to_s)
16
+ if status.success?
17
+ puts stdout
18
+ else
19
+ warn "FAIL test-home-hero-overlay-monotonic:\n#{stdout}\n#{stderr}"
20
+ exit 1
21
+ end