feat(app): finish the visit session export facts

Split the export model/classification from the session wording, add the
no-session, selected-repair and missing-evidence coverage, and update the
parity matrix and R4 note.

The visit probe now passes the scheme name its fixture reads, asserts the
painted theme before capture and re-captures the export states.
This commit is contained in:
2026-10-22 04:43:25 +01:00
parent ddd8eacb1f
commit 3ee5d0e407
9 changed files with 794 additions and 335 deletions
+63 -1
View File
@@ -30,7 +30,9 @@ class _FakeGateway implements ApiGateway {
}
}
/// plan -> build, with a rich first visit and a sparse second visit.
/// plan -> build, with a rich first visit, a sparse second visit, a third visit
/// whose complete export carries a recorded failed repair, and a fourth whose
/// export is partial with a diagnostic.
JsonMap _graph() => <String, dynamic>{
'name': 'Release verification',
'stages': <dynamic>[
@@ -109,6 +111,66 @@ JsonMap _run() => <String, dynamic>{
'target': '#success',
'diagnostic': 'Built.',
},
<String, dynamic>{
'stage': 'audit',
'sequence': 3,
'status': 'completed',
'outcome': 'success',
'target': '#success',
'diagnostic': 'Audited.',
'session_id': 'sess-2',
'session_export': <String, dynamic>{
'html': 'session.html',
'status': 'complete',
'messages': 3,
'html_bytes': 500,
},
'session_export_repairs': <dynamic>[
<String, dynamic>{
'html': 'session-repair-1.html',
'status': 'failed',
'messages': 0,
'diagnostic': 'The repair read failed.',
},
],
'artifacts': <dynamic>[
<String, dynamic>{
'name': 'session.html',
'url': 'https://example.test/artifacts/session.html',
'content_type': 'text/html',
'size_bytes': 100,
},
<String, dynamic>{
'name': 'session-repair-1.html',
'url': 'https://example.test/artifacts/session-repair-1.html',
'content_type': 'text/html',
'size_bytes': 100,
},
],
},
<String, dynamic>{
'stage': 'partial',
'sequence': 4,
'status': 'completed',
'outcome': 'success',
'target': '#success',
'diagnostic': 'Partial export recorded.',
'session_id': 'sess-3',
'session_export': <String, dynamic>{
'html': 'session.html',
'status': 'failed',
'messages': 2,
'diagnostic': 'The native read was refused.',
},
'artifacts': <dynamic>[
<String, dynamic>{
'name': 'session.html',
'url': 'https://example.test/artifacts/session.html',
'content_type': 'text/html',
'size_bytes': 100,
},
],
},
],
};
+107 -3
View File
@@ -7,8 +7,12 @@
// recorded Input, Artifacts, Session and Definition, that the visit's artifact
// row opens a gallery listing exactly that visit's attributed files, that Back
// returns to the rows, that a sparse visit does not invent Duration or
// provider/model, and that a visit with no artifact field says the capture is
// unavailable rather than empty.
// provider/model, that a visit with no artifact field says the capture is
// unavailable rather than empty, and that the Session section renders the
// recorded export state: a complete export with a read-only failed repair and
// its open option, and a partial export with its state word and recorded
// reason. It also samples the rendered page so PROBE_SCHEME=dark cannot pass
// while the fixture silently renders light.
//
// PROBE_VARIANT=material|cupertino PROBE_SCHEME=dark|light PROBE_SCALE=1|2 \
// PROBE_WIDTH=1280 PROBE_HEIGHT=900 PROBE_WEB_ROOT=<probe build> \
@@ -175,6 +179,23 @@ try {
};
const clickLabel = (label, options) => clickSemantics(label, options);
const clickPrefix = (prefixText) => clickSemantics(prefixText, { prefix: true });
const scrollPage = async (deltaY) => {
await send('Input.dispatchMouseEvent', {
type: 'mouseWheel', x: width / 2, y: height - 24, deltaX: 0, deltaY,
}, session);
await delay(700);
};
// A short tab body at 320/2x builds its rows lazily: scroll toward the row
// before requiring it, and leave the page there so the capture follows the
// facts. Semantics can include clipped rows, so the 320 capture proves the
// rows are in the tree; legibility at rest is checked by the UI review.
const ensureText = async (needle, context) => {
for (let attempt = 0; attempt < 8; attempt++) {
if ((await bodyText()).includes(needle)) return;
await scrollPage(240);
}
throw new Error(`${context}: missing ${JSON.stringify(needle)}\n${await bodyText()}`);
};
const capture = async (name) => {
const data = (await send('Page.captureScreenshot', {
format: 'png', captureBeyondViewport: false,
@@ -183,11 +204,41 @@ try {
await writeFile(join(artifactDir, file), Buffer.from(data, 'base64'));
return file;
};
// Mean luminance of the actual render. The fixture receives the scheme through
// its own query parameter, so a mismatch between PROBE_SCHEME and the painted
// theme (as happened when the driver sent theme=1 and the fixture read
// 'dark') must fail rather than label a light capture as dark.
const pageLuminance = async () => {
const shot = (await send('Page.captureScreenshot', {
format: 'png', captureBeyondViewport: false,
}, session)).result.data;
return evaluate(`(async () => {
const img = new Image();
img.src = 'data:image/png;base64,${shot}';
await img.decode();
const canvas = document.createElement('canvas');
canvas.width = img.width;
canvas.height = img.height;
const ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0);
const data = ctx.getImageData(0, 0, img.width, img.height).data;
let sum = 0;
let samples = 0;
for (let y = 0; y < img.height; y += 8) {
for (let x = 0; x < img.width; x += 8) {
const i = (y * img.width + x) * 4;
sum += (0.2126 * data[i] + 0.7152 * data[i + 1] + 0.0722 * data[i + 2]) / 255;
samples += 1;
}
}
return { mean: sum / samples, samples };
})()`);
};
const evidence = { variant, scheme, scale, width, height, checks: [], captures: [] };
const check = (text, value) => evidence.checks.push({ check: text, value });
const navigation = await send('Page.navigate', {
url: `http://127.0.0.1:${port}/?platform=${variant}&theme=${scheme === 'dark' ? 1 : 0}&scale=${scale}`,
url: `http://127.0.0.1:${port}/?platform=${variant}&theme=${scheme}&scale=${scale}`,
}, session);
if (navigation.error || navigation.result?.errorText) throw new Error(JSON.stringify(navigation));
await delay(3200);
@@ -196,6 +247,17 @@ try {
await waitForText('Release verification', 'fixture load');
check('the real run detail opened over the recorded fixture', true);
const render = await pageLuminance();
evidence.pageLuminance = render.mean;
evidence.pageLuminanceSamples = render.samples;
const renderedDark = render.mean < 0.5;
if (renderedDark !== (scheme === 'dark')) {
throw new Error(
`PROBE_SCHEME=${scheme} painted the other theme (mean luminance ${render.mean.toFixed(3)})`,
);
}
check(`the ${scheme} scheme actually renders ${scheme === 'dark' ? 'dark' : 'light'}`, true);
await clickLabel('Graph');
await waitForText('Executed', 'graph legend');
await clickPrefix('plan');
@@ -256,6 +318,48 @@ try {
check('a visit without an artifact field says capture unavailable', true);
evidence.captures.push(await capture('sparse-artifacts'));
await clickLabel('Back to timeline');
await waitForText('plan · visit 1', 'rows before the export-state checks');
await clickPrefix('audit · visit 3');
await waitForText('audit · visit 3', 'recorded export visit');
await clickLabel('Session', { lowest: true });
await ensureText('Open repaired export', 'recorded repair option');
await ensureText(
'failed · 0 messages. The repair read failed.',
'recorded repair label',
);
await ensureText('Open session.html', 'recorded export open');
const auditText = await bodyText();
if (!auditText.includes('Export complete')) {
throw new Error(`The complete export state is missing\n${auditText}`);
}
if (auditText.includes('Reason')) {
throw new Error(`A complete export showed a Reason row\n${auditText}`);
}
check('a complete export shows its read-only repair attempt and option', true);
evidence.captures.push(await capture('export-complete-repair'));
await clickLabel('Back to timeline');
await waitForText('plan · visit 1', 'rows before the partial export check');
await ensureText('partial · visit 4', 'partial export row');
await clickPrefix('partial · visit 4');
await waitForText('partial · visit 4', 'partial export visit');
await clickLabel('Session', { lowest: true });
await ensureText(
'This export is failed; full session evidence is not available.',
'partial export sentence',
);
await ensureText('The native read was refused.', 'partial export reason');
const partialText = await bodyText();
if (!partialText.includes('Export partial')) {
throw new Error(`The partial export state is missing\n${partialText}`);
}
if (!partialText.includes('Reason The native read was refused.')) {
throw new Error(`The partial export reason is missing\n${partialText}`);
}
check('a partial export shows its state word and recorded reason', true);
evidence.captures.push(await capture('export-partial-reason'));
await clickLabel('Back to timeline');
await waitForText('plan · visit 1', 'rows before the gallery check');
await clickPrefix('plan · visit 1');