GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Automation and CI / pipelinenews / .github/workflows

PipelineNews Mobile CSS Repair Workflow and 1 more file

A GitHub Actions workflow that builds and publishes the site. Runs on push and by hand.

627 lines of YAML from pipelinenews, in 2 files. Topic: Automation and CI. Section 1844 of 2044.

Cut 2026-12-06T03:07:51+00:00. A copy for reading; the repository at the stated commit is the source.

In the State lines below, domain stage, users and canonical status are rule-based first approximations from code and path evidence (rules explore-agent-rules-v1), not observed facts: the rules.

In this section

  1. PipelineNews Mobile UI Comparator Workflow automation · pipelinenews / .github/workflows/202608271656-mobile-ui-comparator.yml lines 701–1006
  2. PipelineNews Mobile CSS Repair Workflow automation · pipelinenews / .github/workflows/202608272001-mobile-css-repair.yml lines 1–321

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 701–1006 of 1006 · version 2026-08-27 16:56 (continued from section 1843) · 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
none
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:701-1006 · 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
          expectedKeys.add("baseline::R1");
          assert.equal(records.size, 23);
          assert.deepEqual([...records.keys()].sort(), [...expectedKeys].sort(),
            "the reconstructed record matrix is incomplete");

          shardSummaries.sort((left, right) => left.id.localeCompare(right.id));
          const run = {
            schema: "pipelinenews.mobile-ui-browser-run.v1",
            generation,
            project_posture: {
              owner: "Ventus Ltd",
              application: "non-commercial-open-source",
              publisher_redistribution_rights: "source-specific-not-inferred",
            },
            source_commit: sourceCommit,
            candidate_generation: "202608271524",
            contract_schema: "pipelinenews.mobile-ui-invariants.v1",
            mode: "audit",
            deployment: "not-authorised",
            started_at: shardSummaries.map(({ started_at }) => started_at).sort()[0],
            completed_at: shardSummaries.map(({ completed_at }) => completed_at).sort().at(-1),
            browser: commonBrowser,
            records: [...records.values()].sort(),
            expected_record_count: 23,
            shards: shardSummaries,
            required_failures: [],
            optional_original_unavailable: shardSummaries
              .some(({ optional_original_unavailable }) => optional_original_unavailable),
            status: "CAPTURED",
          };
          await writeFile(path.join(finalRoot, "run.json"), `${JSON.stringify(run, null, 2)}\n`);
          NODE

      - name: Run the unchanged comparator contract
        shell: bash
        run: |
          set -euo pipefail
          node "atman/$MOBILE_UI_GENERATION-compare-mobile-ui.mjs" \
            | tee "$RUNNER_TEMP/202608271656-mobile-ui-comparator-stdout.json"

      - name: Prove the bounded evidence closure
        shell: bash
        run: |
          set -euo pipefail
          node --input-type=module <<'NODE'
          import assert from "node:assert/strict";
          import { createHash } from "node:crypto";
          import { lstat, readFile, readdir, stat } from "node:fs/promises";
          import path from "node:path";

          const reportDir = process.env.REPORT_DIR;
          const rawDir = process.env.MOBILE_UI_RAW_DIR;
          const expected = ["artifact-manifest.json", "metrics.json", "report.md"];
          assert.deepEqual((await readdir(reportDir)).sort(), expected);
          const reportBytes = await readFile(path.join(reportDir, "report.md"));
          const metricsBytes = await readFile(path.join(reportDir, "metrics.json"));
          assert.ok(reportBytes.length <= 256 * 1024);
          assert.ok(metricsBytes.length <= 1024 * 1024);
          assert.ok(reportBytes.toString("utf8").includes(process.env.MOBILE_UI_GENERATION));
          assert.ok(reportBytes.toString("utf8").includes(process.env.GITHUB_SHA));
          const metrics = JSON.parse(metricsBytes);
          assert.equal(metrics.schema, "pipelinenews.mobile-ui-comparison.v1");
          assert.equal(metrics.generation, process.env.MOBILE_UI_GENERATION);
          assert.equal(metrics.source_commit, process.env.GITHUB_SHA);
          assert.deepEqual(metrics.project_posture, {
            owner: "Ventus Ltd",
            application: "non-commercial-open-source",
            publisher_redistribution_rights: "source-specific-not-inferred",
          });
          assert.equal(metrics.records.length, 23);
          const manifest = JSON.parse(await readFile(path.join(reportDir, "artifact-manifest.json"), "utf8"));
          assert.equal(manifest.schema, "pipelinenews.mobile-ui-comparator-artifacts.v1");
          assert.deepEqual(manifest.project_posture, metrics.project_posture);
          assert.deepEqual(manifest.compact_files.map(({ path: relative }) => relative).sort(),
            ["metrics.json", "report.md"]);
          for (const record of manifest.compact_files) {
            const bytes = await readFile(path.join(reportDir, record.path));
            assert.equal(bytes.length, record.bytes);
            assert.equal(createHash("sha256").update(bytes).digest("hex"), record.sha256);
          }

          async function walk(directory) {
            const files = [];
            for (const entry of await readdir(directory, { withFileTypes: true })) {
              const filename = path.join(directory, entry.name);
              const metadata = await lstat(filename);
              assert.ok(!metadata.isSymbolicLink(), `symlink entered evidence: ${filename}`);
              if (metadata.isDirectory()) files.push(...await walk(filename));
              else {
                assert.ok(metadata.isFile());
                files.push({ filename, bytes: metadata.size });
              }
            }
            return files;
          }
          const rawFiles = await walk(rawDir);
          assert.ok(rawFiles.reduce((sum, item) => sum + item.bytes, 0) <= 25 * 1024 * 1024);
          const rawRecords = (await Promise.all(rawFiles.map(async ({ filename, bytes }) => {
            const payload = await readFile(filename);
            return {
              path: path.relative(rawDir, filename).split(path.sep).join("/"),
              sha256: createHash("sha256").update(payload).digest("hex"),
              bytes,
            };
          }))).sort((left, right) => left.path.localeCompare(right.path));
          assert.deepEqual(rawRecords, manifest.full_artifacts);
          const closure = createHash("sha256").update(Buffer.from(
            rawRecords.map((record) => `${record.path}\0${record.sha256}\0${record.bytes}\n`).join(""),
            "utf8",
          )).digest("hex");
          assert.equal(closure, manifest.raw_closure_sha256);
          for (const { filename, bytes } of rawFiles.filter(({ filename }) => /\.(?:jpe?g|png)$/iu.test(filename))) {
            assert.ok(bytes <= 409600, `screenshot exceeds 400 KiB: ${filename}`);
          }
          const compactBytes = (await Promise.all(expected.map(async (filename) =>
            (await stat(path.join(reportDir, filename))).size
          ))).reduce((total, size) => total + size, 0);
          assert.ok(compactBytes <= 1536 * 1024);
          NODE
          git diff --quiet
          git diff --cached --quiet

      - name: Publish audit summary
        if: always()
        shell: bash
        run: |
          if [[ -f "$REPORT_DIR/report.md" ]]; then
            cat "$REPORT_DIR/report.md" >> "$GITHUB_STEP_SUMMARY"
          fi

      - name: Upload complete audit and screenshots
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: pipelinenews-mobile-ui-audit-202608271656-${{ github.run_id }}-${{ github.run_attempt }}
          path: |
            ${{ env.MOBILE_UI_RAW_DIR }}
            ${{ env.REPORT_DIR }}
          if-no-files-found: error
          retention-days: 30

      - name: Upload compact evidence for the immutable report commit
        uses: actions/upload-artifact@v4
        with:
          name: pipelinenews-mobile-ui-compact-202608271656-${{ github.run_id }}-${{ github.run_attempt }}
          path: ${{ env.REPORT_DIR }}
          if-no-files-found: error
          retention-days: 30

  commit-evidence:
    name: Commit only compact quarantine evidence
    needs: aggregate
    if: >-
      github.event_name == 'push' &&
      github.ref == 'refs/heads/main' &&
      needs.aggregate.result == 'success'
    runs-on: ubuntu-latest
    timeout-minutes: 10
    permissions:
      contents: write
    steps:
      - name: Checkout the exact audited source
        uses: actions/checkout@v5
        with:
          ref: ${{ github.sha }}
          fetch-depth: 0

      - name: Configure Node
        uses: actions/setup-node@v5
        with:
          node-version: "22"

      - name: Download compact evidence only
        uses: actions/download-artifact@v5
        with:
          name: pipelinenews-mobile-ui-compact-202608271656-${{ github.run_id }}-${{ github.run_attempt }}
          path: ${{ env.MOBILE_UI_WORK_ROOT }}/incoming-compact

      - name: Guard main and materialise exactly three report files
        shell: bash
        run: |
          set -euo pipefail
          incoming="$MOBILE_UI_WORK_ROOT/incoming-compact"
          target="atman/reports/$MOBILE_UI_GENERATION"
          mapfile -t incoming_files < <(find "$incoming" -maxdepth 1 -type f -printf '%f\n' | LC_ALL=C sort)
          expected=(artifact-manifest.json metrics.json report.md)
          test "${#incoming_files[@]}" = "${#expected[@]}"
          for index in "${!expected[@]}"; do
            test "${incoming_files[$index]}" = "${expected[$index]}"
          done
          test -z "$(find "$incoming" -mindepth 1 -maxdepth 1 ! -type f -print -quit)"

          git fetch --no-tags origin refs/heads/main
          remote_head="$(git rev-parse FETCH_HEAD)"
          git merge-base --is-ancestor "$GITHUB_SHA" "$remote_head"
          source_paths=(
            ".github/workflows/$MOBILE_UI_GENERATION-mobile-ui-comparator.yml"
            "atman/$MOBILE_UI_GENERATION-compare-mobile-ui.mjs"
            "atman/$MOBILE_UI_GENERATION-mobile-ui-invariants.mjs"
            "atman/$MOBILE_UI_GENERATION-verify-mobile-ui-browser.mjs"
            "manifests/$MOBILE_UI_GENERATION-mobile-ui-comparator.json"
          )
          git diff --quiet "$GITHUB_SHA" "$remote_head" -- "${source_paths[@]}"
          test -z "$(git ls-tree -r --name-only "$remote_head" -- "$target")"
          git switch --detach "$remote_head"

          mkdir -p "$target"
          cp "$incoming/artifact-manifest.json" "$target/artifact-manifest.json"
          cp "$incoming/metrics.json" "$target/metrics.json"
          cp "$incoming/report.md" "$target/report.md"

          REPORT_DIR="$target" node --input-type=module <<'NODE'
          import assert from "node:assert/strict";
          import { createHash } from "node:crypto";
          import { readFile, readdir, stat } from "node:fs/promises";
          import path from "node:path";
          const root = process.env.REPORT_DIR;
          const expected = ["artifact-manifest.json", "metrics.json", "report.md"];
          assert.deepEqual((await readdir(root)).sort(), expected);
          const reportBytes = await readFile(path.join(root, "report.md"));
          const metricsBytes = await readFile(path.join(root, "metrics.json"));
          assert.ok(reportBytes.length <= 256 * 1024);
          assert.ok(metricsBytes.length <= 1024 * 1024);
          assert.ok(reportBytes.toString("utf8").includes(process.env.MOBILE_UI_GENERATION));
          assert.ok(reportBytes.toString("utf8").includes(process.env.GITHUB_SHA));
          const metrics = JSON.parse(metricsBytes);
          assert.equal(metrics.schema, "pipelinenews.mobile-ui-comparison.v1");
          assert.equal(metrics.generation, process.env.MOBILE_UI_GENERATION);
          assert.equal(metrics.source_commit, process.env.GITHUB_SHA);
          assert.deepEqual(metrics.project_posture, {
            owner: "Ventus Ltd",
            application: "non-commercial-open-source",
            publisher_redistribution_rights: "source-specific-not-inferred",
          });
          const manifest = JSON.parse(await readFile(path.join(root, "artifact-manifest.json"), "utf8"));
          assert.equal(manifest.schema, "pipelinenews.mobile-ui-comparator-artifacts.v1");
          assert.deepEqual(manifest.project_posture, metrics.project_posture);
          assert.equal(manifest.generation, process.env.MOBILE_UI_GENERATION);
          assert.equal(manifest.source_commit, process.env.GITHUB_SHA);
          assert.deepEqual(manifest.compact_files.map(({ path: relative }) => relative).sort(),
            ["metrics.json", "report.md"]);
          for (const record of manifest.compact_files) {
            const bytes = await readFile(path.join(root, record.path));
            assert.equal(bytes.length, record.bytes);
            assert.equal(createHash("sha256").update(bytes).digest("hex"), record.sha256);
          }
          const compactBytes = (await Promise.all(expected.map(async (filename) =>
            (await stat(path.join(root, filename))).size
          ))).reduce((total, size) => total + size, 0);
          assert.ok(compactBytes <= 1536 * 1024);
          NODE

      - name: Commit and push exactly three evidence files
        shell: bash
        run: |
          set -euo pipefail
          target="atman/reports/$MOBILE_UI_GENERATION"
          expected=(
            "$target/artifact-manifest.json"
            "$target/metrics.json"
            "$target/report.md"
          )
          mapfile -t expected_sorted < <(printf '%s\n' "${expected[@]}" | LC_ALL=C sort)

          verify_evidence_commit() {
            mapfile -t committed < <(git diff-tree --no-commit-id --name-only -r HEAD | LC_ALL=C sort)
            test "${#committed[@]}" = "${#expected_sorted[@]}"
            for index in "${!expected_sorted[@]}"; do
              test "${committed[$index]}" = "${expected_sorted[$index]}"
              git show "HEAD:${expected_sorted[$index]}" | cmp - "${expected_sorted[$index]}"
            done
            git diff --quiet
            git diff --cached --quiet
          }

          git config user.name "github-actions[bot]"
          git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
          git add -- "${expected[@]}"
          mapfile -d '' -t staged < <(git diff --cached --name-only -z | LC_ALL=C sort -z)
          test "${#staged[@]}" = "${#expected[@]}"
          for index in "${!expected_sorted[@]}"; do
            test "${staged[$index]}" = "${expected_sorted[$index]}"
          done
          test -z "$(git diff --cached --name-status | awk '$1 != "A" { print; exit }')"
          git commit -m "Record $MOBILE_UI_GENERATION mobile UI audit evidence"
          verify_evidence_commit

          for attempt in 1 2 3; do
            git fetch --no-tags origin refs/heads/main
            remote_head="$(git rev-parse FETCH_HEAD)"
            if [[ "$(git rev-parse HEAD^)" != "$remote_head" ]]; then
              git diff --quiet "$GITHUB_SHA" "$remote_head" -- \
                ".github/workflows/$MOBILE_UI_GENERATION-mobile-ui-comparator.yml" \
                "atman/$MOBILE_UI_GENERATION-compare-mobile-ui.mjs" \
                "atman/$MOBILE_UI_GENERATION-mobile-ui-invariants.mjs" \
                "atman/$MOBILE_UI_GENERATION-verify-mobile-ui-browser.mjs" \
                "manifests/$MOBILE_UI_GENERATION-mobile-ui-comparator.json"
              test -z "$(git ls-tree -r --name-only "$remote_head" -- "$target")"
              git rebase --onto "$remote_head" "$(git rev-parse HEAD^)" HEAD
              verify_evidence_commit
            fi
            if git push origin "HEAD:refs/heads/main"; then
              exit 0
            fi
          done
          exit 1

PipelineNews Mobile CSS Repair Workflow

A GitHub Actions workflow that builds and publishes the site. Runs on push and by hand.

automationpipelinenews / .github/workflows/202608272001-mobile-css-repair.yml · lines 1–321 of 321 · version 2026-08-27 20:01 · 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 202608272001-mobile-css-repair.json; JSON file repair-metrics.json; JSON file artifact-manifest.json. Out: JSON file repair-metrics.json; JSON file artifact-manifest.json; commits pushed to the repository.
Downstream impact
It is itself an entry point (workflow); no other file was found loading it.
What it achieves
Runs Verify Mobile UI Browser (`atman/202608271656-verify-mobile-ui-browser.mjs`).
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
Verify Mobile UI Browser (workflow run)
Used by
none found
Produces
none declared
Defines here
Repair PipelineNews Mobile CSS 202608272001
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/202608272001-mobile-css-repair.yml:1-321 · blob da0cc856dd732b5ea61cb785d34ab56791aee959 · 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: Repair PipelineNews Mobile CSS 202608272001

on:
  workflow_dispatch:
  push:
    branches: [main]
    paths:
      - ".github/workflows/202608272001-mobile-css-repair.yml"
      - "manifests/202608272001-mobile-css-repair.json"

permissions:
  contents: write

concurrency:
  group: pipelinenews-mobile-css-repair-202608272001
  cancel-in-progress: false

env:
  GENERATION: "202608272001"
  SOURCE_PARENT: "4a3cda8ea3eb67f01dad67ffb45b9d49eb83e043"
  INHERITED_CANDIDATE: "202608271524"
  RAW_ROOT: "work/202608272001-mobile-css-repair"

jobs:
  measure:
    if: github.ref == 'refs/heads/main'
    runs-on: ubuntu-latest
    timeout-minutes: 55
    strategy:
      fail-fast: false
      matrix:
        include:
          - shard: static
            cells: P1,P2,L1,L2,L3,L4,T1
            rotate: "false"
          - shard: rotation
            cells: none
            rotate: "true"
    steps:
      - name: Checkout exact successor source
        uses: actions/checkout@v5
        with:
          ref: ${{ github.sha }}
          fetch-depth: 0

      - name: Prove bounded source and governance
        shell: bash
        run: |
          set -euo pipefail
          test "$(git rev-parse HEAD)" = "$GITHUB_SHA"
          expected="$(printf '%s\n' \
            .github/workflows/202608272001-mobile-css-repair.yml \
            manifests/202608272001-mobile-css-repair.json | sort)"
          git merge-base --is-ancestor "$SOURCE_PARENT" "$GITHUB_SHA"
          test "$(git diff --name-only "$SOURCE_PARENT" "$GITHUB_SHA" | sort)" = "$expected"
          node --input-type=module <<'NODE'
          import assert from "node:assert/strict";
          import { createHash } from "node:crypto";
          import { readFile } from "node:fs/promises";
          const manifest = JSON.parse(await readFile(`manifests/${process.env.GENERATION}-mobile-css-repair.json`));
          assert.equal(manifest.schema, "pipelinenews.mobile-css-repair-successor-manifest.v1");
          assert.equal(manifest.generation, process.env.GENERATION);
          assert.equal(manifest.source_parent_commit, process.env.SOURCE_PARENT);
          assert.equal(manifest.corrects_generation, "202608271957");
          assert.equal(manifest.correction, "separate-inherited-runtime-generation-from-repair-generation");
          assert.equal(manifest.deployment, "not-authorised");
          assert.equal(manifest.stable_route_changed, false);
          assert.equal(manifest.current_pointer_changed, false);
          assert.equal(manifest.pages_capability, false);
          assert.equal(manifest.companies_house_data, "forbidden");
          assert.deepEqual(manifest.project_posture, {
            owner: "Ventus Ltd",
            application: "non-commercial-open-source",
            publisher_redistribution_rights: "source-specific-not-inferred",
          });
          for (const record of manifest.hashed_source_files) {
            const bytes = await readFile(record.path);
            assert.equal(bytes.length, record.bytes, `byte drift: ${record.path}`);
            assert.equal(createHash("sha256").update(bytes).digest("hex"), record.sha256,
              `hash drift: ${record.path}`);
          }
          for (const dependency of manifest.frozen_dependencies) {
            const bytes = await readFile(dependency.path);
            assert.equal(createHash("sha256").update(bytes).digest("hex"), dependency.sha256,
              `dependency drift: ${dependency.path}`);
          }
          const workflow = await readFile(`.github/workflows/${process.env.GENERATION}-mobile-css-repair.yml`, "utf8");
          for (const forbidden of [
            ["deploy", "pages@"].join("-"),
            ["upload", "pages-artifact@"].join("-"),
            ["pages", "write"].join(": "),
            ["id-token", "write"].join(": "),
          ]) assert.ok(!workflow.includes(forbidden), `deployment capability entered: ${forbidden}`);
          NODE

      - name: Configure pinned browser
        uses: actions/setup-node@v5
        with:
          node-version: "22"

      - name: Install pinned browser packages
        shell: bash
        run: |
          set -euo pipefail
          npm install --no-save --no-package-lock playwright@1.55.0 sharp@0.34.3
          npx playwright install --with-deps chromium

      - name: Materialise candidate at release-relative path
        shell: bash
        run: |
          set -euo pipefail
          mkdir -p "$RAW_ROOT/${{ matrix.shard }}/raw" releases/styles
          cp repairs/202608271906-mobile-css-repair.css "releases/styles/$GENERATION-v8-fast-css-repair.css"
          python3 - <<'PY'
          from pathlib import Path
          import os
          import re
          generation = os.environ["GENERATION"]
          source = Path("releases/202608271524-v8-fast-candidate.html").read_text()
          source, count = re.subn(
              r'(<meta[^>]+name=["\']viewport["\'][^>]+content=["\'])([^"\']*)(["\'])',
              lambda match: match.group(1) + match.group(2).rstrip(",") + ",viewport-fit=cover" + match.group(3),
              source,
              count=1,
              flags=re.I,
          )
          if count != 1:
              raise SystemExit("exactly one viewport meta element was not found")
          repair = f'<link rel="stylesheet" href="styles/{generation}-v8-fast-css-repair.css">'
          if "</head>" not in source:
              raise SystemExit("candidate head closure absent")
          source = source.replace("</head>", repair + "\n</head>", 1)
          Path(f"releases/{generation}-v8-fast-css-candidate.html").write_text(source)
          PY
          python3 -m http.server 4173 --bind 127.0.0.1 >"$RAW_ROOT/${{ matrix.shard }}/server.log" 2>&1 &
          for attempt in $(seq 1 30); do
            curl -fsS "http://127.0.0.1:4173/releases/$GENERATION-v8-fast-css-candidate.html" >/dev/null && break
            sleep 1
          done
          curl -fsS "http://127.0.0.1:4173/releases/styles/202608270055-v8-fast.css" >/dev/null
          curl -fsS "http://127.0.0.1:4173/releases/javascript/202608271524-v8-fast-runtime.js" >/dev/null

      - name: Measure repair shard
        shell: bash
        env:
          MOBILE_UI_MODE: repair
          MOBILE_UI_SOURCE_COMMIT: ${{ github.sha }}
          MOBILE_UI_CANDIDATE_GENERATION: "202608271524"
          MOBILE_UI_CANDIDATE_URL: "http://127.0.0.1:4173/releases/202608272001-v8-fast-css-candidate.html"
          MOBILE_UI_TARGET_IDS: candidate
          MOBILE_UI_CELL_IDS: ${{ matrix.cells }}
          MOBILE_UI_INCLUDE_ROTATE: ${{ matrix.rotate }}
          MOBILE_UI_SHARD_ID: ${{ matrix.shard }}
          MOBILE_UI_RAW_DIR: work/202608272001-mobile-css-repair/${{ matrix.shard }}/raw
        run: node atman/202608271656-verify-mobile-ui-browser.mjs --out-root "$MOBILE_UI_RAW_DIR"

      - name: Upload complete shard evidence
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: pipelinenews-mobile-css-repair-202608272001-${{ matrix.shard }}-${{ github.run_id }}-${{ github.run_attempt }}
          path: |
            work/202608272001-mobile-css-repair/${{ matrix.shard }}/raw
            work/202608272001-mobile-css-repair/${{ matrix.shard }}/server.log
          retention-days: 30
          if-no-files-found: error

  gate-and-publish:
    needs: measure
    if: always() && needs.measure.result == 'success'
    runs-on: ubuntu-latest
    timeout-minutes: 10
    steps:
      - name: Checkout exact successor source
        uses: actions/checkout@v5
        with:
          ref: ${{ github.sha }}
          fetch-depth: 0

      - name: Download and merge shard evidence
        uses: actions/download-artifact@v5
        with:
          pattern: pipelinenews-mobile-css-repair-202608272001-*
          path: work/merged
          merge-multiple: true

      - name: Compile and enforce bounded gate
        shell: bash
        run: |
          set -euo pipefail
          mkdir -p "atman/reports/$GENERATION" releases/styles
          cp repairs/202608271906-mobile-css-repair.css "releases/styles/$GENERATION-v8-fast-css-repair.css"
          python3 - <<'PY'
          from pathlib import Path
          import os
          import re
          generation = os.environ["GENERATION"]
          source = Path("releases/202608271524-v8-fast-candidate.html").read_text()
          source, count = re.subn(
              r'(<meta[^>]+name=["\']viewport["\'][^>]+content=["\'])([^"\']*)(["\'])',
              lambda match: match.group(1) + match.group(2).rstrip(",") + ",viewport-fit=cover" + match.group(3),
              source,
              count=1,
              flags=re.I,
          )
          if count != 1:
              raise SystemExit("viewport meta element absent")
          source = source.replace("</head>", f'<link rel="stylesheet" href="styles/{generation}-v8-fast-css-repair.css">\n</head>', 1)
          Path(f"releases/{generation}-v8-fast-css-candidate.html").write_text(source)
          PY
          node --input-type=module <<'NODE'
          import { createHash } from "node:crypto";
          import { readdir, readFile, writeFile } from "node:fs/promises";
          import path from "node:path";
          async function walk(root) {
            const out = [];
            for (const entry of await readdir(root, { withFileTypes: true })) {
              const full = path.join(root, entry.name);
              if (entry.isDirectory()) out.push(...await walk(full));
              else out.push(full);
            }
            return out;
          }
          const files = await walk("work/merged");
          const records = [];
          for (const file of files.filter((file) => /candidate--(?:P1|P2|L1|L2|L3|L4|T1|R1)\.json$/u.test(file))) {
            records.push(JSON.parse(await readFile(file, "utf8")));
          }
          if (records.length !== 8) throw new Error(`expected 8 candidate records, got ${records.length}`);
          const failures = [];
          const cells = {};
          for (const record of records) {
            const id = record.cell?.id || record.cell;
            cells[id] = {};
            for (const invariant of record.invariants) {
              cells[id][invariant.id] = invariant.status;
              if (invariant.applicable && invariant.mode === "gated" && invariant.pass !== true)
                failures.push({ cell: id, invariant: invariant.id, name: invariant.name, status: invariant.status });
            }
          }
          const metrics = {
            schema: "pipelinenews.mobile-css-repair-evidence.v1",
            generation: process.env.GENERATION,
            corrects_generation: "202608271957",
            inherited_candidate_generation: process.env.INHERITED_CANDIDATE,
            source_commit: process.env.GITHUB_SHA,
            project_posture: {
              owner: "Ventus Ltd",
              application: "non-commercial-open-source",
              publisher_redistribution_rights: "source-specific-not-inferred",
            },
            deployment: "not-authorised",
            stable_route_changed: false,
            current_pointer_changed: false,
            companies_house_data: "absent",
            gate: failures.length ? "FAIL" : "PASS",
            failures,
            cells,
          };
          await writeFile(`atman/reports/${process.env.GENERATION}/repair-metrics.json`, `${JSON.stringify(metrics, null, 2)}\n`);
          const report = [
            "# PipelineNews mobile CSS repair", "",
            `Generation: \`${process.env.GENERATION}\`  `,
            `Corrects instrument generation: \`202608271957\`  `,
            `Source commit: \`${process.env.GITHUB_SHA}\`  `,
            "Deployment: `not-authorised`", "",
            "Ventus Ltd application posture: **non-commercial open source**. Publisher redistribution rights remain source-specific and are not inferred.", "",
            `Repair gate: **${metrics.gate}**`, "",
            failures.length ? failures.map((x) => `- ${x.cell} ${x.invariant} ${x.name}`).join("\n")
              : "All gated invariants passed across P1, P2, L1-L4, T1 and R1.", "",
            "Stable/current, Pages and Companies House boundaries are unchanged.", "",
          ].join("\n");
          await writeFile(`atman/reports/${process.env.GENERATION}/repair-report.md`, report);
          const outputPaths = [
            `releases/${process.env.GENERATION}-v8-fast-css-candidate.html`,
            `releases/styles/${process.env.GENERATION}-v8-fast-css-repair.css`,
            `atman/reports/${process.env.GENERATION}/repair-metrics.json`,
            `atman/reports/${process.env.GENERATION}/repair-report.md`,
          ];
          const indexed = [];
          for (const file of outputPaths) {
            const bytes = await readFile(file);
            indexed.push({ path: file, bytes: bytes.length, sha256: createHash("sha256").update(bytes).digest("hex") });
          }
          await writeFile(`atman/reports/${process.env.GENERATION}/artifact-manifest.json`,
            `${JSON.stringify({
              schema: "pipelinenews.mobile-css-repair-artifacts.v1",
              generation: process.env.GENERATION,
              source_commit: process.env.GITHUB_SHA,
              github_run_id: process.env.GITHUB_RUN_ID,
              deployment: "not-authorised",
              stable_route_changed: false,
              current_pointer_changed: false,
              companies_house_data: "absent",
              files: indexed,
            }, null, 2)}\n`);
          if (failures.length) throw new Error(`repair gate failed: ${failures.map((x) => `${x.cell}/${x.invariant}`).join(", ")}`);
          NODE

      - name: Publish immutable quarantine candidate and compact proof
        shell: bash
        run: |
          set -euo pipefail
          test "$(git rev-parse HEAD)" = "$GITHUB_SHA"
          expected="$(printf '%s\n' \
            "atman/reports/$GENERATION/artifact-manifest.json" \
            "atman/reports/$GENERATION/repair-metrics.json" \
            "atman/reports/$GENERATION/repair-report.md" \
            "releases/$GENERATION-v8-fast-css-candidate.html" \
            "releases/styles/$GENERATION-v8-fast-css-repair.css" | sort)"
          git add -- \
            "atman/reports/$GENERATION/artifact-manifest.json" \
            "atman/reports/$GENERATION/repair-metrics.json" \
            "atman/reports/$GENERATION/repair-report.md" \
            "releases/$GENERATION-v8-fast-css-candidate.html" \
            "releases/styles/$GENERATION-v8-fast-css-repair.css"
          test "$(git diff --cached --name-only | sort)" = "$expected"
          git config user.name github-actions[bot]
          git config user.email 41898282+github-actions[bot]@users.noreply.github.com
          git commit -m "Publish $GENERATION mobile CSS repair candidate"
          git push origin HEAD:main