GLOBALGRID2050 / EXPLORE CODE

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

GridAtlas Verify Live Workflow and 1 more file

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

596 lines of YAML from gridatlas, in 2 files. Topic: Automation and CI. Section 1812 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. GridAtlas Scope Loop Workflow automation · gridatlas / .github/workflows/202608301321-scope-loop.yml lines 1–106
  2. GridAtlas Verify Live Workflow automation · gridatlas / .github/workflows/202608301321-verify-live.yml lines 1–490

GridAtlas Scope Loop Workflow

A GitHub Actions workflow. Runs by hand.

automationgridatlas / .github/workflows/202608301321-scope-loop.yml · lines 1–106 of 106 · version 2026-08-30 13:21 · Entry point

What it does
It runs automated jobs on GitHub Actions. Side effects: starts processes.
Why it exists in the grid workflow
Domain stage upstream_foresight (repository name word 'gridatlas'): 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
Out: commits pushed to the repository.
Downstream impact
It is itself an entry point (workflow); no other file was found loading it.
What it achieves
Scope-loop-mode: retired.
Why it matters
No other file in the estate was found to import it; it is an entry point.
Application
gridatlas · .github/workflows · workflow
Uses
Bootstrap (workflow run), Loop (workflow run), Run Current (workflow run), Advance (workflow run), Verify Compose (workflow run)
Used by
none found
Produces
none declared
Defines here
202608301321 GridAtlas bounded scope loop
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 .github/workflows/202608301321-scope-loop.yml:1-106 · blob 58bc138c5b0803014570496b7afe4a401f3271b3 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: unknown · effects: process · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
# scope-loop-mode: retired
name: 202608301321 GridAtlas bounded scope loop

# BEGIN ACTIVE TRIGGERS
on:
  workflow_dispatch:
# END ACTIVE TRIGGERS

permissions:
  actions: write
  contents: write
  pages: write

concurrency:
  group: gridatlas-bounded-scope-loop
  cancel-in-progress: false

jobs:
  one-scope:
    runs-on: ubuntu-24.04
    timeout-minutes: 20
    env:
      GH_TOKEN: ${{ secrets.GRIDATLAS_SCOPE_TOKEN || github.token }}
    steps:
      - name: Checkout exact main state
        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
        with:
          fetch-depth: 0
          token: ${{ secrets.GRIDATLAS_SCOPE_TOKEN || github.token }}

      - name: Materialise the timestamped scope ledger once
        id: bootstrap
        run: node tools/scope/bootstrap.mjs

      - name: Reconstruct durable context and lint antibodies
        run: |
          node --version
          node tools/scope/loop.mjs lint
          node tools/scope/loop.mjs state
          node tools/proofs/run-current.mjs

      - name: Read the one active scope
        id: before
        run: node tools/scope/loop.mjs next

      - name: Execute exactly one deterministic scope
        id: advance
        if: steps.bootstrap.outputs.bootstrapped != 'true' && steps.before.outputs.pending == 'true'
        run: node tools/scope/advance.mjs

      - name: Verify composition and post-scope antibodies
        if: steps.bootstrap.outputs.bootstrapped != 'true' && steps.before.outputs.pending == 'true'
        run: |
          node tools/scope/verify-compose.mjs
          node tools/proofs/run-current.mjs
          node tools/scope/loop.mjs lint
          node tools/scope/loop.mjs state

      - name: Commit the bounded scope
        id: commit
        if: steps.bootstrap.outputs.bootstrapped == 'true' || steps.before.outputs.pending == 'true'
        env:
          BOOTSTRAPPED: ${{ steps.bootstrap.outputs.bootstrapped }}
          ADVANCE_MESSAGE: ${{ steps.advance.outputs.commit_message }}
        run: |
          git config user.name "gridatlas-scope-loop"
          if [ "$BOOTSTRAPPED" = "true" ]; then
            COMMIT_MESSAGE="202608301321-gridatlas: establish durable scope ledger and antibodies"
          else
            COMMIT_MESSAGE="$ADVANCE_MESSAGE"
          fi
          git config user.email "actions@users.noreply.github.com"
          git add -A
          if git diff --cached --quiet; then
            echo "committed=false" >> "$GITHUB_OUTPUT"
            exit 0
          fi
          git commit -m "$COMMIT_MESSAGE"
          git pull --rebase origin main
          git push origin HEAD:main
          echo "committed=true" >> "$GITHUB_OUTPUT"
          echo "commit_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"

      - name: Request a Pages rebuild for the committed state
        if: steps.commit.outputs.committed == 'true'
        continue-on-error: true
        run: gh api --method POST "repos/${GITHUB_REPOSITORY}/pages/builds"

      - name: Read successor after commit
        id: after
        if: steps.bootstrap.outputs.bootstrapped == 'true' || steps.before.outputs.pending == 'true'
        run: node tools/scope/loop.mjs next

      - name: Dispatch the next bounded scope in a new timestamp minute
        if: steps.after.outputs.pending == 'true'
        env:
          BOOTSTRAPPED: ${{ steps.bootstrap.outputs.bootstrapped }}
        run: |
          if [ "$BOOTSTRAPPED" = "true" ]; then sleep 5; else sleep 65; fi
          gh workflow run 202608301321-scope-loop.yml --ref main

      - name: Dispatch final public acceptance after closure
        if: steps.bootstrap.outputs.bootstrapped != 'true' && steps.before.outputs.pending == 'true' && steps.after.outputs.pending == 'false'
        run: |
          sleep 20
          gh workflow run 202608301321-verify-live.yml --ref main

GridAtlas Verify Live Workflow

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

automationgridatlas / .github/workflows/202608301321-verify-live.yml · lines 1–490 of 490 · version 2026-08-30 13:21 · Entry point

What it does
It builds and publishes A roads. 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 'gridatlas'): 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. Domain terms in the code: A roads.
Inputs & outputs
In: JSON file current.json. Out: JSON file cvaa-selected-gates.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
Named “Build, deploy and verify modular GridAtlas v9.5”; runs Build Streaming Bridge (`tools/v9_5/build_streaming_bridge.py`), Release Stream Payload Cache (`tools/v9_5/release_stream_payload_cache.py`) and Verify Compose (`tools/scope/verify-compose.mjs`).
Why it matters
No other file in the estate was found to import it; it is an entry point.
Application
gridatlas · .github/workflows · workflow
Uses
Build Streaming Bridge (workflow run), Release Stream Payload Cache (workflow run), Verify Compose (workflow run), Verify Streaming Roads (workflow run), Verify V9 5 Search (workflow run), Verify Live Bytes (workflow run), CI Live Bytes Issue (workflow run), Preserve (workflow run), and 5 more
Used by
none found
Produces
none declared
Defines here
202608301321 Build, deploy and verify modular GridAtlas v9.5
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 .github/workflows/202608301321-verify-live.yml:1-490 · blob a92c91906434ff0628267903c58f6cdc0eb80979 · 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: 202608301321 Build, deploy and verify modular GridAtlas v9.5

# Two jobs share this workflow so the active-workflow budget in
# tools/scope/loop.mjs (ACTIVE_WORKFLOWS) and STATE.md stay unchanged:
#
#   build-deploy-verify  compiles, commits and publishes a streaming-road
#                        cartridge. It runs only when a push to main touches
#                        its source paths, or when dispatched with
#                        mode=build-deploy-verify. It is never the default.
#   live-bytes           after every push to main (and on dispatch, the
#                        default mode) waits for GitHub Pages and proves the
#                        public site serves byte-identical copies of
#                        atlas/current.json, atlas/index.html, every file that
#                        current.json references (each cartridge path first)
#                        and every atlas/v/<gen>/ preview file. It retries for
#                        Pages/CDN lag and fails with a per-path report.
#   twin                 dispatch only (mode=twin), read-only: preservation,
#                        the register of keys, then the live generation rebuilt
#                        from its commit-pinned source and compared byte for
#                        byte (tools/twin/, docs/CI.md). The same checks run on
#                        pull requests in pr-file-size-guard.yml.

on:
  workflow_dispatch:
    inputs:
      mode:
        description: 'live-bytes = read-only public byte check; served-homepage = read-only www.globalgrid2050.com check; twin = read-only rebuild of the live generation from its pinned source, with preservation and keys; build-deploy-verify = compile, push to main and publish a streaming-road cartridge'
        type: choice
        options:
          - live-bytes
          - served-homepage
          - twin
          - build-deploy-verify
        default: live-bytes
      compare_ref:
        description: 'live-bytes only: the committed ref whose bytes the public site must equal'
        type: string
        default: main
  push:
    branches: [main]

permissions:
  actions: read
  contents: write
  pages: write

jobs:
  changes:
    runs-on: ubuntu-24.04
    timeout-minutes: 5
    permissions:
      contents: read
    outputs:
      build: ${{ steps.decide.outputs.build }}
    steps:
      - name: Checkout history without blobs
        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
        with:
          fetch-depth: 0
          filter: blob:none
          persist-credentials: false

      - name: Decide whether the streaming-road builder must run
        id: decide
        env:
          EVENT: ${{ github.event_name }}
          MODE: ${{ inputs.mode }}
          BEFORE: ${{ github.event.before }}
        shell: bash
        run: |
          set -euo pipefail
          build=false
          if [ "$EVENT" = workflow_dispatch ]; then
            [ "$MODE" = build-deploy-verify ] && build=true
          elif [ "$EVENT" = push ]; then
            # The former push.paths filter, applied per job so live-bytes can
            # run on every push while the builder keeps its narrow trigger.
            if [ -z "$BEFORE" ] || ! git cat-file -e "$BEFORE^{commit}" 2>/dev/null; then
              changed="$(git show --name-only --format= "$GITHUB_SHA")"
            else
              changed="$(git diff --name-only "$BEFORE" "$GITHUB_SHA")"
            fi
            if printf '%s\n' "$changed" | grep -Exq 'state/streaming-road-fix\.json|tools/v9_5/build_streaming_bridge\.py|tools/v9_5/release_stream_payload_cache\.py|atman/verify_streaming_roads\.mjs'; then
              build=true
            fi
          fi
          echo "build=$build" | tee -a "$GITHUB_OUTPUT"

  build-deploy-verify:
    needs: changes
    if: needs.changes.outputs.build == 'true'
    concurrency:
      group: gridatlas-v9-5-modular-promotion
      cancel-in-progress: false
    outputs:
      commit_sha: ${{ steps.candidate.outputs.commit_sha }}
    runs-on: ubuntu-24.04
    timeout-minutes: 45
    env:
      GH_TOKEN: ${{ secrets.GRIDATLAS_SCOPE_TOKEN || github.token }}
      GRIDATLAS_BASE_URL: https://ventusltd.github.io/gridatlas/
      CVAA_SHA: d2ebc01f6eab41f2a84b0c53c4cfae0d2625ec5e
    steps:
      - name: Checkout complete GridAtlas history
        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
        with:
          fetch-depth: 0
          token: ${{ secrets.GRIDATLAS_SCOPE_TOKEN || github.token }}

      - name: Checkout pinned CVAA with complete history
        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
        with:
          repository: Ventusltd/cvaa
          ref: ${{ env.CVAA_SHA }}
          path: work/cvaa
          fetch-depth: 0
          persist-credentials: false

      - name: Configure exact Node and Chromium
        uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v4.4.0
        with:
          node-version: '22.18.0'
          cache: npm

      - name: Install pinned browser runtime before reading the UTC generation
        run: |
          set -euo pipefail
          npm ci --ignore-scripts
          npx playwright install --with-deps chromium

      - name: Compile and locally commit one transport cartridge at the UTC minute
        id: candidate
        shell: bash
        run: |
          set -euo pipefail
          G="$(date -u +%Y%m%d%H%M)"
          echo "generation=$G" >> "$GITHUB_OUTPUT"
          mkdir -p work
          python3 tools/v9_5/build_streaming_bridge.py \
            --generation "$G" \
            --request state/streaming-road-fix.json \
            --report work/streaming-road-build.json
          python3 tools/v9_5/release_stream_payload_cache.py \
            --generation "$G" \
            --report work/streaming-road-build.json
          node tools/scope/verify-compose.mjs
          test "$(jq -r .full_application_copies_created work/streaming-road-build.json)" = 0
          test "$(jq -r .immutable_shell_modified work/streaming-road-build.json)" = false
          test "$(jq -r .payload_cache_released_after_serialisation work/streaming-road-build.json)" = true
          test "$(jq -r .generation atlas/current.json)" = "$G"
          test "$(jq -r '.cartridge_order | join(",")' atlas/current.json)" = 'streaming-parquet-bridge,uk-gazetteer-flyto'

          cartridge="atlas/cartridges/${G}-streaming-parquet-bridge-v9-5.js"
          contract="ui/cartridges/${G}-streaming-parquet-bridge-v9-5.mjs"
          manifest="atlas/manifests/${G}-composition.json"
          git add atlas/current.json "$cartridge" "$contract" "$manifest"
          allowed="^(atlas/current.json|${cartridge}|${contract}|${manifest})$"
          test "$(git diff --cached --name-only | grep -Evc "$allowed" || true)" = 0
          git config user.name gridatlas-streaming-road-builder
          git config user.email actions@users.noreply.github.com
          git commit -m "$G-gridatlas-v9.5: stream roads and release reconstructed payload cache"
          echo "commit_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"

      - name: Prove selected CVAA contracts on the locally committed candidate
        shell: bash
        run: |
          set -euo pipefail
          set +e
          node work/cvaa/inoculate.mjs . --json --no-write > work/cvaa-candidate.txt 2>&1
          echo "$?" > work/cvaa-candidate.exit
          set -e
          python3 - <<'PY'
          import json
          from pathlib import Path
          payload = None
          for line in reversed(Path('work/cvaa-candidate.txt').read_text(encoding='utf-8').splitlines()):
              try:
                  candidate = json.loads(line)
              except json.JSONDecodeError:
                  continue
              if candidate.get('schema') == 'cvaa.run.v1':
                  payload = candidate
                  break
          if payload is None:
              raise SystemExit('CVAA JSON result missing')
          if payload.get('shallow') is not False:
              raise SystemExit('CVAA saw a shallow checkout')
          states = {row['vaccine']: row for row in payload['results']}
          selected = ('full-history-checkout', 'no-app-copies', 'registry-integrity', 'no-dangerous-apis')
          for vaccine in selected:
              row = states.get(vaccine)
              if not row or row.get('state') != 'immune':
                  raise SystemExit(f'{vaccine} is not immune: {row}')
          Path('work/cvaa-selected-gates.json').write_text(json.dumps({
              'schema': 'gridatlas.cvaa-selected-gates.v1',
              'cvaa_sha': 'd2ebc01f6eab41f2a84b0c53c4cfae0d2625ec5e',
              'selected': {name: states[name] for name in selected},
              'all_findings': payload.get('findings'),
          }, indent=2) + '\n', encoding='utf-8')
          PY

      - name: Serve the exact locally committed Pages path
        run: |
          set -euo pipefail
          mkdir -p work/site
          ln -s "$GITHUB_WORKSPACE" work/site/gridatlas
          python3 -m http.server 4173 --bind 127.0.0.1 --directory work/site > work/local-http.log 2>&1 &
          echo $! > work/local-http.pid
          for attempt in $(seq 1 30); do
            curl --fail --silent http://127.0.0.1:4173/gridatlas/atlas/current.json >/dev/null && exit 0
            sleep 1
          done
          exit 1

      - name: Prove A-road transport locally in Chromium
        env:
          GRIDATLAS_URL: http://127.0.0.1:4173/gridatlas/atlas/
          EXPECTED_GENERATION: ${{ steps.candidate.outputs.generation }}
          OUTPUT: work/streaming-road-local-proof.json
        run: node atman/verify_streaming_roads.mjs

      - name: Prove the existing search cartridge was not lost
        env:
          GRIDATLAS_URL: http://127.0.0.1:4173/gridatlas/atlas/
          EXPECTED_GENERATION: ${{ steps.candidate.outputs.generation }}
          OUTPUT: work/v9-5-search-local-proof.json
        run: node atman/202608301624-verify-v9-5-search.mjs

      - name: Stop local server
        if: always()
        run: test ! -f work/local-http.pid || kill "$(cat work/local-http.pid)" 2>/dev/null || true

      - name: Push only after local browser and CVAA gates pass
        run: |
          set -euo pipefail
          test "$(git rev-parse HEAD)" = "${{ steps.candidate.outputs.commit_sha }}"
          git fetch --no-tags origin main:refs/remotes/origin/main
          test "$(git rev-parse HEAD^)" = "$(git rev-parse origin/main)"
          git push origin HEAD:main

      - name: Request GitHub Pages deployment
        run: |
          set -euo pipefail
          for attempt in 1 2 3; do
            gh api --method POST "repos/${GITHUB_REPOSITORY}/pages/builds" && exit 0
            sleep 10
          done
          echo 'Pages build request was already active; public generation polling remains authoritative.'

      - name: Wait for the exact public composition
        env:
          GENERATION: ${{ steps.candidate.outputs.generation }}
        run: |
          set -euo pipefail
          public="${GRIDATLAS_BASE_URL}atlas/current.json"
          for attempt in $(seq 1 120); do
            payload="$(curl --fail --location --silent --show-error -H 'Cache-Control: no-cache' "${public}?generation=${GENERATION}&attempt=${attempt}" || true)"
            if test -n "$payload" \
              && test "$(printf '%s' "$payload" | jq -r '.generation // empty')" = "$GENERATION" \
              && test "$(printf '%s' "$payload" | jq -r '.composition_version // empty')" = v9.5 \
              && test "$(printf '%s' "$payload" | jq -r '.cartridge_order | join(",")')" = 'streaming-parquet-bridge,uk-gazetteer-flyto'; then
              exit 0
            fi
            sleep 5
          done
          exit 1

      - name: Prove A-road transport on the public deployment
        env:
          GRIDATLAS_URL: https://ventusltd.github.io/gridatlas/atlas/
          EXPECTED_GENERATION: ${{ steps.candidate.outputs.generation }}
          OUTPUT: work/streaming-road-public-proof.json
        run: node atman/verify_streaming_roads.mjs

      - name: Prove public search and deep links remain intact
        env:
          GRIDATLAS_URL: https://ventusltd.github.io/gridatlas/atlas/
          EXPECTED_GENERATION: ${{ steps.candidate.outputs.generation }}
          OUTPUT: work/v9-5-search-public-proof.json
        run: node atman/202608301624-verify-v9-5-search.mjs

      - name: Retain source, CVAA and browser evidence
        if: always()
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v4.4.3
        with:
          name: gridatlas-streaming-roads-${{ github.run_id }}
          path: |
            work/streaming-road-build.json
            work/cvaa-candidate.txt
            work/cvaa-candidate.exit
            work/cvaa-selected-gates.json
            work/streaming-road-local-proof.json
            work/streaming-road-public-proof.json
            work/v9-5-search-local-proof.json
            work/v9-5-search-public-proof.json
            work/local-http.log
          if-no-files-found: warn
          retention-days: 90
          compression-level: 6

  live-bytes:
    needs: [changes, build-deploy-verify]
    # Runs after the builder when it ran, and on its own otherwise. Skipped only
    # for a dispatch that asked for the builder (which verifies its own deploy).
    if: >-
      always()
      && needs.changes.result == 'success'
      && needs.build-deploy-verify.result != 'failure'
      && needs.build-deploy-verify.result != 'cancelled'
      && !(github.event_name == 'workflow_dispatch' && inputs.mode == 'build-deploy-verify')
      && !(github.event_name == 'workflow_dispatch' && inputs.mode == 'served-homepage')
      && !(github.event_name == 'workflow_dispatch' && inputs.mode == 'twin')
    runs-on: ubuntu-24.04
    timeout-minutes: 30
    permissions:
      contents: read
      issues: write   # the "live-bytes" issue only (tools/ci/live-bytes-issue.mjs)
    concurrency:
      group: gridatlas-live-bytes-${{ github.ref }}
      cancel-in-progress: false
    env:
      GRIDATLAS_BASE_URL: https://ventusltd.github.io/gridatlas/
      LIVE_BYTES_TIMEOUT_S: '1200'
      LIVE_BYTES_INTERVAL_S: '20'
    steps:
      - name: Checkout the verifier and full history
        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
        with:
          fetch-depth: 0
          persist-credentials: false

      - name: Configure exact Node
        uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v4.4.0
        with:
          node-version: '22.18.0'

      - name: Resolve the committed tree the public site must equal
        id: target
        env:
          EVENT: ${{ github.event_name }}
          COMPARE_REF: ${{ inputs.compare_ref }}
          BUILT_SHA: ${{ needs.build-deploy-verify.outputs.commit_sha }}
        shell: bash
        run: |
          set -euo pipefail
          git fetch --no-tags origin '+refs/heads/*:refs/remotes/origin/*'
          if [ "$EVENT" = workflow_dispatch ]; then
            ref="${COMPARE_REF:-main}"
            sha="$(git rev-parse --verify "origin/$ref^{commit}" 2>/dev/null || git rev-parse --verify "$ref^{commit}")"
          elif [ -n "$BUILT_SHA" ]; then
            sha="$BUILT_SHA"
          else
            sha="$GITHUB_SHA"
          fi
          git worktree add --detach work/compare "$sha"
          echo "sha=$sha" | tee -a "$GITHUB_OUTPUT"
          echo "generation=$(jq -r .generation work/compare/atlas/current.json)" | tee -a "$GITHUB_OUTPUT"

      - name: Prove the public site serves the committed bytes
        id: prove
        env:
          EVENT: ${{ github.event_name }}
          TARGET_SHA: ${{ steps.target.outputs.sha }}
        shell: bash
        run: |
          set -euo pipefail
          # Pages publishes main within about two minutes and its CDN may serve
          # stale copies for up to ten more; the verifier retries with
          # cache-busting queries for LIVE_BYTES_TIMEOUT_S before failing.
          status=0
          node tools/scope/verify-live-bytes.mjs --root work/compare --report work/live-bytes.json || status=$?
          if [ "$status" -ne 0 ] && [ "$EVENT" = push ]; then
            head="$(git ls-remote origin refs/heads/main | cut -f1)"
            if [ -n "$head" ] && [ "$head" != "$TARGET_SHA" ]; then
              echo "::warning title=live-bytes superseded::main moved from $TARGET_SHA to $head during verification; the run for $head is authoritative."
              echo "superseded=true" >> "$GITHUB_OUTPUT"
              exit 0
            fi
          fi
          exit "$status"

      - name: Summarise
        if: always()
        shell: bash
        run: |
          test -f work/live-bytes.json || exit 0
          jq -r '"### Live bytes: \(.status)\n\n\(.paths_matched)/\(.paths_checked) paths byte-identical at \(.base_url) for commit `\(.commit)` (generation \(.generation)) after \(.attempts) attempt(s).\n" , (.problems[] | "- problem: \(.)"), (.mismatches[] | "- MISMATCH `\(.path)` (\(.why)): HTTP \(.http), committed \(.expected.bytes) B, live \(.live.bytes // "none") B")' work/live-bytes.json >>  … [line shortened here: 423 characters; full line on GitHub]

      # One open issue labelled "live-bytes" while the public site does not
      # serve main's bytes; closed by the next passing check (docs/OPERATIONS.md).
      # Only for main: a dispatch that compares another ref is an ad-hoc check.
      # A superseded run (main moved) leaves the issue to the newer run.
      - name: Open, refresh or close the live-bytes issue
        if: >-
          always()
          && (github.event_name == 'push' || inputs.compare_ref == 'main' || inputs.compare_ref == '')
        continue-on-error: true
        env:
          GH_TOKEN: ${{ github.token }}
          OUTCOME: ${{ steps.prove.outputs.superseded == 'true' && 'superseded' || steps.prove.outcome }}
          RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
        shell: bash
        run: node tools/ci/live-bytes-issue.mjs --report work/live-bytes.json --outcome "$OUTCOME" --run-url "$RUN_URL"

      - name: Retain live byte evidence
        if: always()
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v4.4.3
        with:
          name: gridatlas-live-bytes-${{ github.run_id }}
          path: work/live-bytes.json
          if-no-files-found: warn
          retention-days: 90

  # Offline first, then network (Ventusltd/testcode README): preservation and the
  # keys need no socket and run first; a red offline step stops the job before
  # anything is fetched. Read-only: contents: read, no push, no Pages, no pointer.
  twin:
    if: github.event_name == 'workflow_dispatch' && inputs.mode == 'twin'
    runs-on: ubuntu-24.04
    timeout-minutes: 15
    permissions:
      contents: read
    steps:
      - name: Checkout the ref the workflow was dispatched on
        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
        with:
          fetch-depth: 2
          persist-credentials: false
      - name: Configure exact Node
        uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v4.4.0
        with:
          node-version: '22.23.4'
      - name: Offline - every earlier generation is preserved, and the previous live one still composes
        run: node tools/twin/preserve.mjs --base HEAD~1 | tee -a "$GITHUB_STEP_SUMMARY"
        shell: bash -eo pipefail {0}
      - name: Offline - the cartridges the live generation cut rebuild byte for byte
        run: node tools/twin/replicate-generation.mjs --offline | tee -a "$GITHUB_STEP_SUMMARY"
        shell: bash -eo pipefail {0}
      - name: Offline - every claim in the register of keys still holds
        run: node tools/twin/keys.mjs --check | tee -a "$GITHUB_STEP_SUMMARY"
        shell: bash -eo pipefail {0}
      - name: Network - the Pipeline News ref list equals the pinned release
        run: node tools/twin/keys.mjs --check --pipeline-refs-network | tail -3 | tee -a "$GITHUB_STEP_SUMMARY"
        shell: bash -eo pipefail {0}
      - name: Network - rebuild the data files from the pinned source register and compare every byte
        shell: bash -eo pipefail {0}
        run: |
          python3 -m venv "$RUNNER_TEMP/twin-venv"
          "$RUNNER_TEMP/twin-venv/bin/pip" install --quiet --require-virtualenv -r requirements.lock
          node tools/twin/replicate-generation.mjs --network --python "$RUNNER_TEMP/twin-venv/bin/python" | tee -a "$GITHUB_STEP_SUMMARY"

  served-homepage:
    if: github.event_name == 'workflow_dispatch' && inputs.mode == 'served-homepage'
    runs-on: ubuntu-24.04
    timeout-minutes: 20
    permissions:
      contents: read
    env:
      GH_TOKEN: ${{ github.token }}
    steps:
      - name: Checkout the checker
        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
        with:
          fetch-depth: 1
          sparse-checkout: tools
          persist-credentials: false

      - name: Configure exact Node
        uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v4.4.0
        with:
          node-version: '22.18.0'

      - name: Prove www.globalgrid2050.com serves the pinned homepage with the live GridAtlas label
        run: node tools/release/check-served.mjs --timeout-s 600 --report work/served-homepage.json

      - name: Summarise
        if: always()
        shell: bash
        run: |
          test -f work/served-homepage.json || exit 0
          jq -r '"### Served homepage: \(.status)\n\nGridAtlas \(.generation) \"\(.label)\" (pin \(.pin))\n", (.checks[] | "- \(if .ok then "OK" else "DIFF" end) `\(.path)` HTTP \(.http)"), (.problems[] | "- problem: \(.)")' work/served-homepage.json >> "$GITHUB_STEP_SUMMARY"

      - name: Retain served-homepage evidence
        if: always()
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v4.4.3
        with:
          name: gridatlas-served-homepage-${{ github.run_id }}
          path: work/served-homepage.json
          if-no-files-found: warn
          retention-days: 90