In this section
- PipelineNews Mobile UI Comparator Workflow automation · pipelinenews / .github/workflows/202608271656-mobile-ui-comparator.yml lines 1–700
PipelineNews Mobile UI Comparator Workflow
A GitHub Actions workflow that builds and publishes the site. Runs on push and by hand.
automationpipelinenews / .github/workflows/202608271656-mobile-ui-comparator.yml · lines 1–700 of 1006 · version 2026-08-27 16:56 · Entry point
- What it does
- It builds and publishes its content. Side effects: reads or writes files; makes network requests; starts processes.
- Why it exists in the grid workflow
- Domain stage upstream_foresight (repository name word 'pipelinenews'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight.
- Inputs & outputs
- In: JSON file 202608271656-mobile-ui-comparator.json; JSON file source-envelope.json; JSON file run.json; JSON file 202608271656-mobile-ui-comparator-stdout.json; JSON file artifact-manifest.json; JSON file metrics.json. Out: JSON file source-envelope.json; JSON file run.json; GitHub Pages deployment; commits pushed to the repository.
- Downstream impact
- It is itself an entry point (workflow); no other file was found loading it.
- What it achieves
- Publishes to GitHub Pages.
- Why it matters
- No other file in the estate was found to import it; it is an entry point.
- Application
- pipelinenews · .github/workflows · workflow
- Uses
- Dashboard (estate URL)
- Used by
- none found
- Produces
- none declared
- Defines here
- Audit PipelineNews Mobile UI Comparator 202608271656
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 .github/workflows/202608271656-mobile-ui-comparator.yml:1-700 · blob d94a0d96e3dfb87b06ea0af3ae6eb8c5cb510be8 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: filesystem, network, process · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
name: Audit PipelineNews Mobile UI Comparator 202608271656
on:
workflow_dispatch:
push:
branches: [main]
paths:
- ".github/workflows/202608271656-mobile-ui-comparator.yml"
- "atman/202608271656-verify-mobile-ui-browser.mjs"
- "atman/202608271656-compare-mobile-ui.mjs"
- "atman/202608271656-mobile-ui-invariants.mjs"
- "manifests/202608271656-mobile-ui-comparator.json"
permissions:
contents: read
concurrency:
group: pipelinenews-mobile-ui-comparator-202608271656
cancel-in-progress: false
env:
MOBILE_UI_GENERATION: "202608271656"
MOBILE_UI_SOURCE_PARENT: "da559edfc6e91b60352f8fb62dfd6e9c5b52824f"
MOBILE_UI_WORK_ROOT: "work/202608271656-mobile-ui-comparator"
MOBILE_UI_RAW_DIR: "work/202608271656-mobile-ui-comparator/audit/raw"
REPORT_DIR: "work/202608271656-mobile-ui-comparator/compact"
MOBILE_UI_SERVER_URL: "http://127.0.0.1:4173"
PLAYWRIGHT_VERSION: "1.55.0"
SHARP_VERSION: "0.34.3"
jobs:
audit-shards:
name: Measure ${{ matrix.id }}
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
timeout-minutes: 55
strategy:
fail-fast: false
max-parallel: 6
matrix:
include:
- id: candidate-static
target_ids: candidate
cell_ids: P1,P2,L1,L2,L3,L4,T1
include_rotate: "false"
- id: original-static
target_ids: original
cell_ids: P1,P2,L1,L2,L3,L4,T1
include_rotate: "false"
- id: baseline-a
target_ids: baseline
cell_ids: P1,P2,L1
include_rotate: "false"
- id: baseline-b
target_ids: baseline
cell_ids: L2,L3
include_rotate: "false"
- id: baseline-c
target_ids: baseline
cell_ids: L4,T1
include_rotate: "false"
- id: rotations
target_ids: candidate,baseline
cell_ids: none
include_rotate: "true"
env:
SHARD_RAW_DIR: work/202608271656-mobile-ui-comparator/shards/${{ matrix.id }}/raw
MOBILE_UI_TARGET_IDS: ${{ matrix.target_ids }}
MOBILE_UI_CELL_IDS: ${{ matrix.cell_ids }}
MOBILE_UI_INCLUDE_ROTATE: ${{ matrix.include_rotate }}
MOBILE_UI_SHARD_ID: ${{ matrix.id }}
MOBILE_UI_SOURCE_COMMIT: ${{ github.sha }}
MOBILE_UI_CANDIDATE_GENERATION: "202608271524"
steps:
- name: Checkout the exact audit source
uses: actions/checkout@v5
with:
ref: ${{ github.sha }}
fetch-depth: 0
persist-credentials: false
- name: Configure Node
uses: actions/setup-node@v5
with:
node-version: "22"
- name: Prove the five-file audit-only source envelope
shell: bash
run: |
set -euo pipefail
test "$(git rev-parse HEAD)" = "$GITHUB_SHA"
mkdir -p "$SHARD_RAW_DIR"
node --input-type=module <<'NODE'
import assert from "node:assert/strict";
import { createHash } from "node:crypto";
import { readFile, stat, writeFile } from "node:fs/promises";
import { spawnSync } from "node:child_process";
const generation = process.env.MOBILE_UI_GENERATION;
const manifestPath = `manifests/${generation}-mobile-ui-comparator.json`;
const expected = [
`.github/workflows/${generation}-mobile-ui-comparator.yml`,
`atman/${generation}-compare-mobile-ui.mjs`,
`atman/${generation}-mobile-ui-invariants.mjs`,
`atman/${generation}-verify-mobile-ui-browser.mjs`,
manifestPath,
].sort();
const tracked = spawnSync("git", ["ls-files", "--", ...expected], { encoding: "utf8" });
assert.equal(tracked.status, 0, tracked.stderr);
assert.deepEqual(tracked.stdout.trim().split("\n").filter(Boolean).sort(), expected,
"the five-file comparator source closure is incomplete");
if (process.env.GITHUB_EVENT_NAME === "push") {
const parents = spawnSync("git", ["show", "-s", "--format=%P", "HEAD"], { encoding: "utf8" });
assert.equal(parents.status, 0, parents.stderr);
assert.deepEqual(parents.stdout.trim().split(/\s+/u), [process.env.MOBILE_UI_SOURCE_PARENT],
"audit source is not the single successor of protected main");
const changed = spawnSync(
"git",
["diff", "--name-only", process.env.MOBILE_UI_SOURCE_PARENT, process.env.GITHUB_SHA],
{ encoding: "utf8" },
);
assert.equal(changed.status, 0, changed.stderr);
assert.deepEqual(changed.stdout.trim().split("\n").filter(Boolean).sort(), expected,
"push commit differs from the exact five-file boundary");
}
assert.ok(expected.every((relative) => relative.includes(generation)), "unstamped source path");
assert.ok(expected.every((relative) =>
!relative.startsWith("releases/")
&& !relative.startsWith("data/")
&& !relative.startsWith("archive/")
&& !relative.startsWith("build/authorisations/")
), "release or deployment state entered the source closure");
const workflow = await readFile(expected[0], "utf8");
for (const capability of [
["actions", "deploy-pages@"].join("/"),
["actions", "upload-pages-artifact@"].join("/"),
["pages", "write"].join(": "),
["id-token", "write"].join(": "),
]) assert.ok(!workflow.includes(capability), `deployment capability entered workflow: ${capability}`);
const manifest = JSON.parse(await readFile(manifestPath, "utf8"));
assert.equal(manifest.schema, "pipelinenews.mobile-ui-comparator-manifest.v1");
assert.equal(manifest.generation, generation);
assert.equal(manifest.source_parent_commit, process.env.MOBILE_UI_SOURCE_PARENT);
assert.equal(manifest.deployment, "not-authorised");
assert.equal(manifest.scope, "audit-only-browser-evidence");
assert.deepEqual(manifest.project_posture, {
owner: "Ventus Ltd",
application: "non-commercial-open-source",
publisher_redistribution_rights: "source-specific-not-inferred",
});
assert.equal(manifest.candidate_generation, "202608271524");
assert.equal(manifest.trusted_baseline_generation, "202608261927");
assert.equal(manifest.original_context_url,
"https://globalgrid2050.com/uk_renewables_pipeline/dashboard.html");
assert.deepEqual(manifest.browser, {
playwright_version: process.env.PLAYWRIGHT_VERSION,
engine: "chromium",
screenshot_encoder: `sharp@${process.env.SHARP_VERSION}`,
});
assert.deepEqual([...manifest.source_boundary].sort(), expected);
const expectedHashed = expected.filter((relative) => relative !== manifestPath);
assert.deepEqual(manifest.hashed_source_files.map(({ path }) => path).sort(), expectedHashed);
for (const record of manifest.hashed_source_files) {
assert.match(record.sha256, /^[0-9a-f]{64}$/u);
const bytes = await readFile(record.path);
assert.ok((await stat(record.path)).isFile());
assert.equal(bytes.length, record.bytes, `source byte count changed: ${record.path}`);
assert.equal(createHash("sha256").update(bytes).digest("hex"), record.sha256,
`source SHA-256 changed: ${record.path}`);
}
assert.deepEqual(manifest.execution.baseline_static_shards,
[["P1", "P2", "L1"], ["L2", "L3"], ["L4", "T1"]]);
assert.equal(manifest.execution.job_timeout_minutes, 55);
assert.equal(manifest.execution.cell_record_max_bytes, 262144);
assert.equal(manifest.execution.browser_rasterizations_per_screenshot, 1);
assert.deepEqual(manifest.execution.full_page_capture_limits, {
max_dimension_css_px: 16384,
max_area_css_pixels: 4194304,
max_project_rows: 1000,
});
assert.equal(manifest.execution.rotation_initial_sequence,
"navigate-target-meta-before-viewport-readiness");
assert.equal(manifest.execution.rotation_phase_diagnostics,
"phase-operation-expected-observed-bounded-trace");
assert.equal(manifest.execution.rotation_phase_geometry_gate,
"playwright-viewport-inner-orientation-dpr");
assert.equal(manifest.execution.rotation_readiness_gate,
"inner-viewport-and-match-media-orientation");
assert.equal(manifest.execution.rotation_screen_fields, "observed-not-gated");
assert.equal(manifest.execution.rotation_screenshot_state,
"reasserted-before-node-snapshot");
assert.equal(manifest.execution.rotation_snapshot_viewport_gate,
"inner-viewport-and-match-media-orientation");
assert.equal(manifest.execution.rotation_viewport_driver,
"playwright-page-set-viewport-size");
assert.equal(manifest.execution.screenshot_geometry_assertion,
"png-ihdr-css-pixels-equal-expected-viewport");
const verifierPath = `atman/${generation}-verify-mobile-ui-browser.mjs`;
const verifierSource = await readFile(verifierPath, "utf8");
const rotateStart = verifierSource.indexOf("async function runRotateCell(browser, target) {");
const rotateEnd = verifierSource.indexOf("\nfunction unavailableRecord", rotateStart);
assert.ok(rotateStart >= 0 && rotateEnd > rotateStart, "runRotateCell source is absent");
const rotateSource = verifierSource.slice(rotateStart, rotateEnd);
const navigationPosition = rotateSource.indexOf('"initial-P1-navigation"');
const readinessPosition = rotateSource.indexOf('"initial-P1-viewport"');
assert.ok(navigationPosition >= 0 && readinessPosition > navigationPosition,
"initial rotation readiness must run after target navigation loads viewport metadata");
const applyStart = verifierSource.indexOf("async function applyRotationViewport(");
const applyEnd = verifierSource.indexOf("\nfunction isStrictlyMonotonicGrowth", applyStart);
assert.ok(applyStart >= 0 && applyEnd > applyStart, "rotation viewport driver is absent");
const applySource = verifierSource.slice(applyStart, applyEnd);
assert.match(applySource, /page\.setViewportSize\(\{ width: viewport\.width, height: viewport\.height \}\)/u);
assert.doesNotMatch(applySource, /Emulation\.setDeviceMetricsOverride/u,
"out-of-band CDP metrics re-entered the Playwright-owned viewport driver");
assert.doesNotMatch(verifierSource, /Emulation\.setDeviceMetricsOverride/u,
"the verifier has more than one rotation geometry owner");
assert.match(verifierSource, /playwright_viewport: playwrightViewport/u);
const predicateMatch = verifierSource.match(
/function rotationViewportReady\(\{ width, height, orientation \}\) \{[\s\S]*?\n\}/u,
);
assert.ok(predicateMatch, "rotation viewport readiness predicate is absent");
assert.doesNotMatch(predicateMatch[0], /\bscreen(?:\.|\[)/u,
"screen fields entered the rotation readiness hard gate");
const viewportReady = Function(`"use strict"; return (${predicateMatch[0]});`)();
globalThis.innerWidth = 390;
globalThis.innerHeight = 844;
globalThis.screen = {
width: 9_999,
height: 8_888,
orientation: { type: "landscape-primary", angle: 90 },
};
globalThis.matchMedia = (query) => ({ matches: query === "(orientation: portrait)" });
assert.equal(viewportReady({ width: 390, height: 844, orientation: "portrait" }), true,
"mismatched screen fields must remain evidence-only when the layout viewport is ready");
globalThis.innerWidth = 980;
assert.equal(viewportReady({ width: 390, height: 844, orientation: "portrait" }), false,
"the layout viewport dimensions remain a hard readiness gate");
assert.match(verifierSource, /screen_width: screen\.width/u);
assert.match(verifierSource, /screen_height: screen\.height/u);
assert.match(verifierSource, /screen_orientation_type: screen\.orientation/u);
const fullPolicyStart = verifierSource.indexOf("function selectFullPageCapture(");
const fullPolicyEnd = verifierSource.indexOf("\nfunction pngDimensions", fullPolicyStart);
assert.ok(fullPolicyStart >= 0 && fullPolicyEnd > fullPolicyStart,
"bounded full-page capture policy is absent");
const fullPolicySource = verifierSource.slice(fullPolicyStart, fullPolicyEnd).trim();
const selectFullPageCapture = Function(`"use strict"; return (${fullPolicySource});`)();
const limits = manifest.execution.full_page_capture_limits;
const baselineFallback = selectFullPageCapture({
document_width: 844,
document_height: 390,
project_row_count: 7680,
}, limits);
assert.equal(baselineFallback.complete_document, false);
assert.match(baselineFallback.reason, /project row count 7680 exceeds 1000/u);
const areaFallback = selectFullPageCapture({
document_width: 5000,
document_height: 4000,
project_row_count: 50,
}, limits);
assert.equal(areaFallback.complete_document, false);
assert.match(areaFallback.reason,
/document 5000x4000 area 20000000 exceeds 4194304 CSS pixels/u);
const invalidFallback = selectFullPageCapture({
document_width: Number.POSITIVE_INFINITY,
document_height: 390,
project_row_count: 50,
}, limits);
assert.equal(invalidFallback.complete_document, false);
assert.match(invalidFallback.reason, /invalid document dimensions/u);
assert.match(invalidFallback.reason, /invalid or unsafe document area/u);
assert.equal(selectFullPageCapture({
document_width: 844,
document_height: 390,
project_row_count: 50,
}, limits).complete_document, true);
const pngStart = verifierSource.indexOf("function pngDimensions(");
const pngEnd = verifierSource.indexOf("\nfunction assertViewportScreenshotPixels", pngStart);
assert.ok(pngStart >= 0 && pngEnd > pngStart, "PNG geometry reader is absent");
const pngDimensions = Function(
`"use strict"; return (${verifierSource.slice(pngStart, pngEnd).trim()});`,
)();
const syntheticPng = Buffer.alloc(24);
Buffer.from("89504e470d0a1a0a", "hex").copy(syntheticPng, 0);
syntheticPng.write("IHDR", 12, "ascii");
syntheticPng.writeUInt32BE(844, 16);
syntheticPng.writeUInt32BE(390, 20);
assert.deepEqual(pngDimensions(syntheticPng), { width: 844, height: 390 });
const pixelAssertStart = verifierSource.indexOf("function assertViewportScreenshotPixels(");
const pixelAssertEnd = verifierSource.indexOf("\nasync function captureScreenshots", pixelAssertStart);
assert.ok(pixelAssertStart >= 0 && pixelAssertEnd > pixelAssertStart,
"viewport screenshot pixel assertion is absent");
const assertViewportScreenshotPixels = Function(
`"use strict"; return (${verifierSource.slice(pixelAssertStart, pixelAssertEnd).trim()});`,
)();
assert.equal(assertViewportScreenshotPixels(
"L1.jpeg",
{ width: 844, height: 390 },
{ width: 844, height: 390 },
), true);
assert.throws(
() => assertViewportScreenshotPixels(
"L1.jpeg",
{ width: 390, height: 844 },
{ width: 844, height: 390 },
),
(error) => (
error.name === "ScreenshotGeometryError"
&& error.expected_geometry.width === 844
&& error.observed_geometry.width === 390
),
);
const captureStart = verifierSource.indexOf("async function captureScreenshots(");
const captureEnd = verifierSource.indexOf("\nasync function exerciseReleaseMenu", captureStart);
assert.ok(captureStart >= 0 && captureEnd > captureStart, "screenshot capture source is absent");
const captureSource = verifierSource.slice(captureStart, captureEnd);
const policyPosition = captureSource.indexOf(
"const fullPagePolicy = selectFullPageCapture(dimensions, FULL_PAGE_CAPTURE_LIMITS);",
);
const viewportRasterPosition = captureSource.indexOf(
"const viewport = await boundedJpeg(viewportPath, false);",
);
const fullRasterPosition = captureSource.indexOf("full = await boundedJpeg(fullPath, true);");
assert.ok(
viewportRasterPosition >= 0
&& policyPosition > viewportRasterPosition
&& fullRasterPosition > policyPosition,
"viewport evidence must precede the bounded decision and any full-page browser raster",
);
assert.match(captureSource, /if \(fullPagePolicy\.complete_document\)/u);
assert.match(captureSource,
/assertViewportScreenshotPixels\(path\.basename\(filePath\), rasterPixels, expectedViewportPixels\)/u);
const restoreStart = verifierSource.indexOf(
"async function captureAndRestoreRotationScreenshot(steps) {",
);
const restoreEnd = verifierSource.indexOf("\nasync function runRotateCell", restoreStart);
assert.ok(restoreStart >= 0 && restoreEnd > restoreStart,
"rotation screenshot restoration helper is absent");
const restoreSource = verifierSource.slice(restoreStart, restoreEnd).trim();
const captureAndRestore = Function(`"use strict"; return (${restoreSource});`)();
const trace = [];
const restoredScreenshot = await captureAndRestore({
capture: async () => { trace.push("capture"); return { captured: true }; },
restoreViewport: async () => { trace.push("restore-viewport-844x390"); },
restoreSafeArea: async () => { trace.push("restore-safe-area-L1"); },
settle: async () => { trace.push("settle"); },
});
trace.push("node-snapshot");
assert.deepEqual(trace, [
"capture",
"restore-viewport-844x390",
"restore-safe-area-L1",
"settle",
"node-snapshot",
]);
assert.deepEqual(restoredScreenshot, { captured: true });
const landscapeCapturePosition = rotateSource.indexOf(
"screenshots.landscape = await captureAndRestoreRotationScreenshot({",
);
const landscapeRestorePosition = rotateSource.indexOf(
"`cycle-${cycle}-L1-post-screenshot-restore`",
landscapeCapturePosition,
);
const landscapeSnapshotPosition = rotateSource.indexOf(
"`cycle-${cycle}-L1-node-snapshot`",
landscapeRestorePosition,
);
assert.ok(
landscapeCapturePosition >= 0
&& landscapeRestorePosition > landscapeCapturePosition
&& landscapeSnapshotPosition > landscapeRestorePosition,
"cycle L1 node snapshot must follow screenshot state restoration");
assert.match(rotateSource, /restoreViewport: \(\) => applyRotationViewport\(/u);
assert.match(rotateSource, /\(\) => applySafeArea\(cdp, "L1", landscape\.orientation\)/u);
const nodeSnapshotStart = verifierSource.indexOf("async function nodeSnapshot(");
const nodeSnapshotEnd = verifierSource.indexOf("\nasync function observeRotationGeometry", nodeSnapshotStart);
assert.ok(nodeSnapshotStart >= 0 && nodeSnapshotEnd > nodeSnapshotStart,
"rotation node snapshot viewport gate is absent");
const nodeSnapshotSource = verifierSource.slice(nodeSnapshotStart, nodeSnapshotEnd);
assert.match(nodeSnapshotSource, /pageState\.inner_width !== expectedViewport\.width/u);
assert.match(nodeSnapshotSource, /pageState\.inner_height !== expectedViewport\.height/u);
assert.match(nodeSnapshotSource, /expectedViewport\.orientation === "landscape"/u);
const snapshotGateStart = nodeSnapshotSource.indexOf("const expectedOrientationMatches");
const snapshotGateEnd = nodeSnapshotSource.indexOf("return {", snapshotGateStart);
const snapshotGateSource = nodeSnapshotSource.slice(snapshotGateStart, snapshotGateEnd);
assert.doesNotMatch(snapshotGateSource, /screen_(?:width|height|orientation)/u,
"screen fields entered the rotation snapshot layout viewport gate");
const phaseStart = verifierSource.indexOf("async function runRotationPhase(");
const phaseEnd = verifierSource.indexOf("\nfunction rotationViewportReady", phaseStart);
assert.ok(phaseStart >= 0 && phaseEnd > phaseStart, "phase-aware rotation diagnostics are absent");
const phaseSource = verifierSource.slice(phaseStart, phaseEnd);
for (const field of [
"rotation_phase",
"rotation_operation",
"expected_geometry",
"observed_geometry",
"rotation_trace",
]) assert.match(phaseSource, new RegExp(field, "u"));
assert.match(phaseSource,
/rotationGeometryMatchesExpected\(after, descriptor\.expected_geometry\)/u);
const geometryGateStart = verifierSource.indexOf("function rotationGeometryMatchesExpected(");
const geometryGateEnd = verifierSource.indexOf("\nasync function runRotationPhase", geometryGateStart);
assert.ok(geometryGateStart >= 0 && geometryGateEnd > geometryGateStart,
"post-operation rotation geometry gate is absent");
const rotationGeometryMatchesExpected = Function(
`"use strict"; return (${verifierSource.slice(geometryGateStart, geometryGateEnd).trim()});`,
)();
const expectedLandscape = {
width: 844,
height: 390,
orientation: "landscape",
device_pixel_ratio: 3,
};
const observedLandscape = {
playwright_viewport: { width: 844, height: 390 },
browser: {
inner_width: 844,
inner_height: 390,
device_pixel_ratio: 3,
portrait: false,
landscape: true,
screen_width: 9_999,
screen_height: 8_888,
},
observation_error: null,
};
assert.equal(rotationGeometryMatchesExpected(observedLandscape, expectedLandscape), true);
assert.equal(rotationGeometryMatchesExpected({
...observedLandscape,
playwright_viewport: { width: 390, height: 844 },
}, expectedLandscape), false);
assert.equal(rotationGeometryMatchesExpected({
...observedLandscape,
browser: { ...observedLandscape.browser, device_pixel_ratio: 2 },
}, expectedLandscape), false);
assert.match(verifierSource, /rotation_failure: rotate \? failure : null/u);
await writeFile(
`${process.env.SHARD_RAW_DIR}/source-envelope.json`,
`${JSON.stringify({
schema: "pipelinenews.mobile-ui-comparator-source-envelope.v1",
generation,
source_commit: process.env.GITHUB_SHA,
required_parent_on_push: process.env.MOBILE_UI_SOURCE_PARENT,
source_boundary: expected,
project_posture: manifest.project_posture,
deployment_capability: false,
pages_state_changed: false,
}, null, 2)}\n`,
);
NODE
- name: Syntax-check the instrument
shell: bash
run: |
set -euo pipefail
node --check "atman/$MOBILE_UI_GENERATION-mobile-ui-invariants.mjs"
node --check "atman/$MOBILE_UI_GENERATION-verify-mobile-ui-browser.mjs"
node --check "atman/$MOBILE_UI_GENERATION-compare-mobile-ui.mjs"
! grep -R "SHA256_PENDING" \
"atman/$MOBILE_UI_GENERATION-mobile-ui-invariants.mjs" \
"atman/$MOBILE_UI_GENERATION-verify-mobile-ui-browser.mjs" \
"atman/$MOBILE_UI_GENERATION-compare-mobile-ui.mjs" \
"manifests/$MOBILE_UI_GENERATION-mobile-ui-comparator.json"
- name: Install the pinned browser and screenshot encoder
shell: bash
run: |
set -euo pipefail
npm install --no-save --no-package-lock \
"playwright@$PLAYWRIGHT_VERSION" "sharp@$SHARP_VERSION"
test "$(node -p "require('playwright/package.json').version")" = "$PLAYWRIGHT_VERSION"
test "$(node -p "require('sharp/package.json').version")" = "$SHARP_VERSION"
npx playwright install --with-deps chromium
- name: Run the bounded browser shard
shell: bash
run: |
set -euo pipefail
python3 -m http.server 4173 --bind 127.0.0.1 --directory . \
> "$RUNNER_TEMP/202608271656-${MOBILE_UI_SHARD_ID}-http.log" 2>&1 &
server_pid="$!"
trap 'kill "$server_pid" 2>/dev/null || true' EXIT
for attempt in {1..30}; do
if curl --fail --silent --show-error \
"$MOBILE_UI_SERVER_URL/releases/202608271524-v8-fast-candidate.html" >/dev/null; then
break
fi
sleep 1
done
curl --fail --silent --show-error \
"$MOBILE_UI_SERVER_URL/releases/202608271524-v8-fast-candidate.html" >/dev/null
curl --fail --silent --show-error \
"$MOBILE_UI_SERVER_URL/releases/202608261927-index.html" >/dev/null
MOBILE_UI_RAW_DIR="$SHARD_RAW_DIR" \
node "atman/$MOBILE_UI_GENERATION-verify-mobile-ui-browser.mjs" \
| tee "$RUNNER_TEMP/202608271656-${MOBILE_UI_SHARD_ID}-stdout.json"
test -s "$SHARD_RAW_DIR/run.json"
- name: Upload the raw shard
if: always()
uses: actions/upload-artifact@v4
with:
name: pipelinenews-mobile-ui-shard-202608271656-${{ matrix.id }}-${{ github.run_id }}-${{ github.run_attempt }}
path: ${{ env.SHARD_RAW_DIR }}
if-no-files-found: error
retention-days: 30
aggregate:
name: Reconstruct and compare exactly 23 records
needs: audit-shards
if: needs.audit-shards.result == 'success'
runs-on: ubuntu-latest
timeout-minutes: 20
env:
MOBILE_UI_SOURCE_COMMIT: ${{ github.sha }}
steps:
- name: Checkout the exact audit source
uses: actions/checkout@v5
with:
ref: ${{ github.sha }}
fetch-depth: 0
persist-credentials: false
- name: Configure Node
uses: actions/setup-node@v5
with:
node-version: "22"
- name: Download every browser shard
uses: actions/download-artifact@v5
with:
pattern: pipelinenews-mobile-ui-shard-202608271656-*-${{ github.run_id }}-${{ github.run_attempt }}
path: ${{ env.MOBILE_UI_WORK_ROOT }}/incoming/shards
- name: Reconstruct the single immutable raw closure
shell: bash
run: |
set -euo pipefail
test ! -e "$MOBILE_UI_RAW_DIR"
test ! -e "$REPORT_DIR"
mkdir -p "$MOBILE_UI_RAW_DIR/screenshots" "$REPORT_DIR"
node --input-type=module <<'NODE'
import assert from "node:assert/strict";
import { createHash } from "node:crypto";
import { copyFile, mkdir, readFile, readdir, writeFile } from "node:fs/promises";
import path from "node:path";
const incomingRoot = path.resolve(process.env.MOBILE_UI_WORK_ROOT, "incoming", "shards");
const finalRoot = path.resolve(process.env.MOBILE_UI_RAW_DIR);
const generation = process.env.MOBILE_UI_GENERATION;
const sourceCommit = process.env.GITHUB_SHA;
const planned = new Map([
["candidate-static", { targets: ["candidate"], cells: ["P1", "P2", "L1", "L2", "L3", "L4", "T1"], rotate: false }],
["original-static", { targets: ["original"], cells: ["P1", "P2", "L1", "L2", "L3", "L4", "T1"], rotate: false }],
["baseline-a", { targets: ["baseline"], cells: ["P1", "P2", "L1"], rotate: false }],
["baseline-b", { targets: ["baseline"], cells: ["L2", "L3"], rotate: false }],
["baseline-c", { targets: ["baseline"], cells: ["L4", "T1"], rotate: false }],
["rotations", { targets: ["candidate", "baseline"], cells: [], rotate: true }],
]);
async function walk(directory) {
const files = [];
for (const entry of await readdir(directory, { withFileTypes: true })) {
const filename = path.join(directory, entry.name);
if (entry.isDirectory()) files.push(...await walk(filename));
else if (entry.isFile()) files.push(filename);
else throw new Error(`non-file artifact entry: ${filename}`);
}
return files;
}
const sha256 = (bytes) => createHash("sha256").update(bytes).digest("hex");
const inside = (root, candidate) => {
const relative = path.relative(root, candidate);
return relative !== "" && relative !== ".." && !relative.startsWith(`..${path.sep}`)
&& !path.isAbsolute(relative);
};
const screenshotReferences = (record) => {
const references = [];
const visit = (value) => {
if (!value || typeof value !== "object") return;
if (typeof value.path === "string") {
references.push(value);
return;
}
for (const child of Object.values(value)) visit(child);
};
visit(record.screenshots);
return references;
};
const allFiles = await walk(incomingRoot);
const runPaths = allFiles.filter((filename) => path.basename(filename) === "run.json");
assert.equal(runPaths.length, planned.size, "exactly six shard run records are required");
const records = new Map();
const copiedScreenshots = new Map();
const sourceEnvelopes = [];
const shardSummaries = [];
let commonBrowser = null;
for (const runPath of runPaths) {
const shardRoot = path.dirname(runPath);
const run = JSON.parse(await readFile(runPath, "utf8"));
assert.equal(run.schema, "pipelinenews.mobile-ui-browser-run.v1");
assert.equal(run.generation, generation);
assert.equal(run.source_commit, sourceCommit);
assert.equal(run.candidate_generation, "202608271524");
assert.deepEqual(run.project_posture, {
owner: "Ventus Ltd",
application: "non-commercial-open-source",
publisher_redistribution_rights: "source-specific-not-inferred",
});
assert.equal(run.contract_schema, "pipelinenews.mobile-ui-invariants.v1");
assert.equal(run.mode, "audit");
assert.equal(run.deployment, "not-authorised");
assert.equal(run.status, "CAPTURED");
assert.deepEqual(run.required_failures, []);
assert.ok(run.shard && planned.has(run.shard.id), `unexpected shard ${run.shard?.id}`);
const plan = planned.get(run.shard.id);
assert.deepEqual(run.shard.target_ids, plan.targets);
assert.deepEqual(run.shard.static_cell_ids, plan.cells);
assert.equal(run.shard.include_rotate, plan.rotate);
const expectedCount = plan.targets.length * plan.cells.length + (plan.rotate ? 2 : 0);
assert.equal(run.expected_record_count, expectedCount);
assert.equal(run.records.length, expectedCount);
if (commonBrowser === null) commonBrowser = run.browser;
else assert.deepEqual(run.browser, commonBrowser, "browser build differs between shards");
const envelopeBytes = await readFile(path.join(shardRoot, "source-envelope.json"));
const envelope = JSON.parse(envelopeBytes);
assert.equal(envelope.generation, generation);
assert.equal(envelope.source_commit, sourceCommit);
assert.deepEqual(envelope.project_posture, run.project_posture);
sourceEnvelopes.push({ bytes: envelopeBytes, hash: sha256(envelopeBytes) });
for (const filename of run.records) {
assert.equal(filename, path.basename(filename), "cell record must be a root filename");
const sourcePath = path.resolve(shardRoot, filename);
assert.ok(inside(shardRoot, sourcePath));
const bytes = await readFile(sourcePath);
assert.ok(bytes.length <= 262144, `${filename} exceeds the 256 KiB record budget`);
const record = JSON.parse(bytes);
assert.equal(record.schema, "pipelinenews.mobile-ui-cell-evidence.v1");
assert.equal(record.generation, generation);
assert.equal(record.source_commit, sourceCommit);
assert.deepEqual(record.project_posture, run.project_posture);
const key = `${record.target.id}::${record.cell.id}`;
assert.ok(!records.has(key), `duplicate record ${key}`);
records.set(key, filename);
await copyFile(sourcePath, path.join(finalRoot, filename));
for (const reference of screenshotReferences(record)) {
assert.match(reference.path, /^screenshots\/[a-zA-Z0-9._-]+\.jpeg$/u);
const screenshotSource = path.resolve(shardRoot, reference.path);
assert.ok(inside(shardRoot, screenshotSource));
const screenshotBytes = await readFile(screenshotSource);
assert.ok(screenshotBytes.length <= 409600, `${reference.path} exceeds 400 KiB`);
assert.equal(screenshotBytes.length, reference.bytes);
assert.equal(sha256(screenshotBytes), reference.sha256);
if (copiedScreenshots.has(reference.path)) {
assert.equal(copiedScreenshots.get(reference.path), reference.sha256,
`conflicting screenshot ${reference.path}`);
} else {
copiedScreenshots.set(reference.path, reference.sha256);
const destination = path.join(finalRoot, reference.path);
await mkdir(path.dirname(destination), { recursive: true });
await copyFile(screenshotSource, destination);
}
}
}
shardSummaries.push({
id: run.shard.id,
started_at: run.started_at,
completed_at: run.completed_at,
record_count: run.records.length,
optional_original_unavailable: run.optional_original_unavailable,
});
planned.delete(run.shard.id);
}
assert.equal(planned.size, 0, "one or more planned shards are absent");
assert.ok(sourceEnvelopes.every(({ hash }) => hash === sourceEnvelopes[0].hash),
"source envelope differs between shards");
await writeFile(path.join(finalRoot, "source-envelope.json"), sourceEnvelopes[0].bytes);
const expectedKeys = new Set();
for (const target of ["candidate", "baseline", "original"]) {
for (const cell of ["P1", "P2", "L1", "L2", "L3", "L4", "T1"]) {
expectedKeys.add(`${target}::${cell}`);
}
}
expectedKeys.add("candidate::R1");