GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Electricity markets and data pipelines / neural-link-between-agents / CONTRACTS

PipelineNews Pages and 4 more files

A configuration file that fetches migration, official collisions and part. Runs on push and by hand.

686 lines of YAML and JavaScript from neural-link-between-agents, pipelinenews, in 5 files. Topic: Electricity markets and data pipelines. Section 979 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. Renewable Energy Planning Database (REPD) Cockpit Skin V1 energy-data · neural-link-between-agents / CONTRACTS/repd-cockpit-skin.v1.mjs lines 1–155
  2. PipelineNews Analytics automation · pipelinenews / archive/202608261547-pipelinenews/.github/workflows/analytics.yml lines 1–64
  3. PipelineNews Import V1 9 Legacy automation · pipelinenews / archive/202608261547-pipelinenews/.github/workflows/import-v1-9-legacy.yml lines 1–82
  4. PipelineNews Official Source Frontier automation · pipelinenews / archive/202608261547-pipelinenews/.github/workflows/official-source-frontier.yml lines 1–53
  5. PipelineNews Pages automation · pipelinenews / archive/202608261547-pipelinenews/.github/workflows/pages.yml lines 1–332

Renewable Energy Planning Database (REPD) Cockpit Skin V1

A JavaScript module in Neural Link Between Agents that reads var (`readVar`) and validates REPD skin parity (`validateRepdSkinParity`) (units: MW), covering the REPD register, solar and battery storage (BESS).

energy-dataneural-link-between-agents / CONTRACTS/repd-cockpit-skin.v1.mjs · lines 1–155 of 155 · Not reached from any entry point (candidate for review)

What it does
Defines captureNativeRepdSkin, pick, readVar, bindNativeRepdSkinToReportHost, validateRepdSkinParity. Side effects: changes the web page (DOM).
Why it exists in the grid workflow
Domain stage upstream_foresight (path word 'repd'): 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: the REPD register, solar, battery storage (BESS).
What it achieves
It reads var (`readVar`) and validates REPD skin parity (`validateRepdSkinParity`). REPD Cockpit visual skin — coordination/reference module v1.
Why it matters
No other file in the estate was found to import it.
Application
neural-link-between-agents · CONTRACTS · JavaScript module
Uses
none found
Used by
none found
Produces
REPD_SKIN_CONTRACT_V1, captureNativeRepdSkin, bindNativeRepdSkinToReportHost, validateRepdSkinParity
Defines here
captureNativeRepdSkin, pick, readVar, bindNativeRepdSkinToReportHost, validateRepdSkinParity
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
neural-link-between-agents@598eff3f59afe11738d64cb14cb8befe5e37cdc2 CONTRACTS/repd-cockpit-skin.v1.mjs:1-155 · blob a40a18a25b646ffb14e3e35c1d0ca484fa513119 · GitHub at these lines
State
achieves: comment · context: auto · stage: output · effects: dom · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer, ai_agent · canonical: unreached_review
/**
 * REPD Cockpit visual skin — coordination/reference module v1.
 * Source of truth: the existing native V9.73 REPD table CSS and computed styles.
 *
 * This is a read-only design reference in Neural Link, NOT imported by a live
 * Pipeline News release. A release owner must transplant and test it separately.
 * Do not repaint the existing REPD table, gauges, ticker or MAP/A4.
 */
export const REPD_SKIN_CONTRACT_V1 = Object.freeze({
  sourceRepository: 'Ventusltd/globalgrid2050',
  sourceEdition: 'uk_renewables_pipeline/202611222330/',
  anchors: Object.freeze([
    '#repdScroll thead th',
    '#repdScroll tbody .mw',
    '#repdScroll tbody .site',
    '#repdScroll tbody td'
  ]),
  sourceCss: Object.freeze([
    'styles/v7.css',
    'styles/repd-scan.css',
    'styles/repd-expanded.css',
    'styles/hud-v955.css',
    'styles/repd-reports.css'
  ]),
  secondaryScadaReference: Object.freeze({
    repository: 'Ventusltd/gridatlas',
    edition: 'atlas/releases/202608300453-atlas-v9/',
    css: 'ventusv8.css',
    shell: 'index.html',
    liveGenerationAtStudy: '202611222343',
    visualRoles: Object.freeze({
      shell: '#000000',
      hud: '#0a0a0a',
      instrument: '#00ffff',
      news: '#ffae00',
      active: '#00ffff',
      panel: '#050505'
    }),
    constraint: 'SCADA is a secondary stylistic reference; never replace established native REPD table or physics-significant GridAtlas voltage colours.'
  }),
  crossDisciplineAudit: Object.freeze({
    datacentres: Object.freeze({
      source: 'automation/news/datacentre-ui/styles.css',
      mismatch: 'yellow (#f4df73) headers, alternate teal (#62e7ed) and #142328 headings; different input/border colours',
      action: 'new scoped adapter must inherit REPD table header cyan, row text, dark substrate and controls'
    }),
    gridAndOfftakers: Object.freeze({
      source: 'uk_renewables_pipeline/202611222330/scripts/layers/pipeline-layers.css',
      mismatch: 'selected button amber (#ffd24a), unlike native REPD cyan; source counts also amber',
      action: 'normalise controls/labels only; preserve true kV and engineering-layer encoding'
    }),
    prices: Object.freeze({
      source: 'automation/price_daily_ui/78d5360239e1a5fcffa83fcb30d5937c5521acb9/styles.css',
      mismatch: '10px rounded/glowing cards and red (#ff5555) statistical labels unlike REPD restrained cockpit',
      action: 'adopt REPD borders, radii, header and neutral data-label hierarchy; keep genuine alarms red'
    })
  }),
  unchangedTechnologyColors: Object.freeze({
    solar: '#ffff00',
    bess: '#ffae00',
    wind_onshore: '#00ffff',
    wind_offshore: '#0066ff',
    interconnector: '#0066ff'
  }),
  unchangedTickerColor: '#ff3038',
  policy: 'Capture and reuse native computed colours. Never override native REPD selectors. Fail closed if anchors cannot be found.'
});

const ROLES = Object.freeze({
  surface: '--pn-repd-match-surface',
  panel: '--pn-repd-match-panel',
  border: '--pn-repd-match-border',
  headerBackground: '--pn-repd-match-header-bg',
  headerText: '--pn-repd-match-header-text',
  rowText: '--pn-repd-match-row-text',
  projectText: '--pn-repd-match-project-text',
  capacityText: '--pn-repd-match-capacity-text',
  accent: '--pn-repd-match-accent',
  solar: '--pn-repd-match-solar',
  bess: '--pn-repd-match-bess',
  onshore: '--pn-repd-match-onshore',
  offshore: '--pn-repd-match-offshore',
  ticker: '--pn-repd-match-ticker'
});

export function captureNativeRepdSkin(doc) {
  if (!doc || !doc.defaultView || typeof doc.defaultView.getComputedStyle !== 'function') {
    throw new Error('A rendered REPD document is required to capture the native skin');
  }
  const pick = (selector) => {
    const node = doc.querySelector(selector);
    if (!node) throw new Error('Native REPD skin anchor missing: ' + selector);
    return doc.defaultView.getComputedStyle(node);
  };
  const root = pick(':root');
  const header = pick('#repdScroll thead th');
  const mw = pick('#repdScroll tbody .mw');
  const site = pick('#repdScroll tbody .site');
  const row = pick('#repdScroll tbody td');
  const panel = pick('#repdScroll');
  const readVar = (name) => {
    const value = root.getPropertyValue(name).trim();
    if (!value) throw new Error('Missing existing REPD CSS token: ' + name);
    return value;
  };
  const ticker = doc.querySelector('#headlineTicker .pn-ticker-title');
  return Object.freeze({
    surface: readVar('--bg'),
    panel: panel.backgroundColor,
    border: readVar('--line'),
    headerBackground: header.backgroundColor,
    headerText: header.color,
    rowText: row.color,
    projectText: site.color,
    capacityText: mw.color,
    accent: readVar('--accent'),
    solar: readVar('--solar'),
    bess: readVar('--bess'),
    onshore: readVar('--accent'),
    offshore: readVar('--off'),
    ticker: ticker ? doc.defaultView.getComputedStyle(ticker).color : null
  });
}

/**
 * Assigns ONLY scoped custom properties on a NEW report host. It does not
 * change existing table, controls, gauges, ticker, body or other disciplines.
 * Pair with scoped CSS that consumes these --pn-repd-match-* variables.
 */
export function bindNativeRepdSkinToReportHost(host) {
  if (!host || !host.ownerDocument || typeof host.style?.setProperty !== 'function') {
    throw new Error('A rendered report host element is required');
  }
  if (host.matches('#repdScroll, #officialRegister, #repdPanel, body, html')) {
    throw new Error('Refusing to restyle a native REPD container');
  }
  const native = captureNativeRepdSkin(host.ownerDocument);
  for (const [role, property] of Object.entries(ROLES)) {
    if (native[role]) host.style.setProperty(property, native[role]);
  }
  host.dataset.repdSkinContract = 'native-v973-parity-v1';
  return native;
}

export function validateRepdSkinParity(host) {
  const native = captureNativeRepdSkin(host.ownerDocument);
  const missing = [];
  for (const [role, property] of Object.entries(ROLES)) {
    const expected = native[role];
    if (!expected) continue;
    const actual = host.style.getPropertyValue(property).trim();
    if (actual !== expected) missing.push({role, expected, actual});
  }
  return Object.freeze({pass: missing.length === 0, missing, sourceEdition: REPD_SKIN_CONTRACT_V1.sourceEdition});
}

PipelineNews Analytics

A configuration file. Runs on push and by hand.

automationpipelinenews / archive/202608261547-pipelinenews/.github/workflows/analytics.yml · lines 1–64 of 64 · version 2026-08-26 15:47 · Not reached from any entry point (candidate for review)

Why it exists in the grid workflow
Domain stage experimental (path word 'archive'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
What it achieves
Runs `analytics_v1/tests/run-parquet.sh` and `consumer_v1/tests/run_consumer.sh`.
Why it matters
No other file in the estate was found to import it.
Application
pipelinenews · archive/202608261547-pipelinenews/.github/workflows · configuration
Uses
none found
Used by
none found
Produces
none declared
Defines here
Build PipelineNews Analytics
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 archive/202608261547-pipelinenews/.github/workflows/analytics.yml:1-64 · blob aface73dbe22766c9e394a229ce791e3708e4eed · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: unknown · effects: none found · domain stage: experimental · users: none · canonical: unreached_review
name: Build PipelineNews Analytics
# Movement 5/6 build-audit-publish gate; generated outputs do not retrigger this workflow.

on:
  workflow_dispatch:
  push:
    branches: [main]
    paths:
      - ".github/workflows/analytics.yml"
      - "analytics_v1/contracts/**"
      - "analytics_v1/scripts/build_parquet.py"
      - "analytics_v1/tests/verify_parquet.py"
      - "analytics_v1/tests/run-parquet.sh"
      - "analytics_v1/requirements.lock"
      - "consumer_v1/contracts/**"
      - "consumer_v1/scripts/**"
      - "consumer_v1/sql/**"
      - "consumer_v1/tests/**"

permissions:
  contents: write

concurrency:
  group: pipelinenews-analytics
  cancel-in-progress: false

jobs:
  build-audit-publish:
    runs-on: ubuntu-latest
    timeout-minutes: 15
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.11"
          cache: pip
          cache-dependency-path: analytics_v1/requirements.lock
      - name: Install pinned analytical engines
        run: python -m pip install -r analytics_v1/requirements.lock
      - name: Write, read back and independently verify
        run: bash analytics_v1/tests/run-parquet.sh
      - name: Build and verify ordered consumer projections
        run: bash consumer_v1/tests/run_consumer.sh
      - name: Prove deterministic rebuild
        shell: bash
        run: |
          set -euo pipefail
          find analytics_v1/parquet -type f -print0 | sort -z | xargs -0 sha256sum > "$RUNNER_TEMP/first.sha256"
          sha256sum analytics_v1/data/parquet_manifest.json analytics_v1/reports/parquet_audit.json analytics_v1/sql/views.sql >> "$RUNNER_TEMP/first.sha256"
          bash analytics_v1/tests/run-parquet.sh
          sha256sum -c "$RUNNER_TEMP/first.sha256"
          find consumer_v1/data -type f -print0 | sort -z | xargs -0 sha256sum > "$RUNNER_TEMP/consumer-first.sha256"
          bash consumer_v1/tests/run_consumer.sh
          sha256sum -c "$RUNNER_TEMP/consumer-first.sha256"
      - name: Commit validated analytical artifacts
        shell: bash
        run: |
          set -euo pipefail
          git add analytics_v1/parquet analytics_v1/data/parquet_manifest.json analytics_v1/reports/parquet_audit.json analytics_v1/sql/views.sql consumer_v1/data
          if git diff --cached --quiet; then exit 0; fi
          git config user.name "github-actions[bot]"
          git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
          git commit -m "data: publish validated Movement 5/6 artifacts"
          git push origin HEAD:main

PipelineNews Import V1 9 Legacy

A configuration file. Runs on push and by hand.

automationpipelinenews / archive/202608261547-pipelinenews/.github/workflows/import-v1-9-legacy.yml · lines 1–82 of 82 · version 2026-08-26 15:47 · Not reached from any entry point (candidate for review)

Why it exists in the grid workflow
Domain stage experimental (path word 'archive'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
What it achieves
Named “Import V1-V9 Legacy Lessons”.
Why it matters
No other file in the estate was found to import it.
Application
pipelinenews · archive/202608261547-pipelinenews/.github/workflows · configuration
Uses
none found
Used by
none found
Produces
none declared
Defines here
Import V1-V9 Legacy Lessons
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 archive/202608261547-pipelinenews/.github/workflows/import-v1-9-legacy.yml:1-82 · blob 98701e9120b3b1e9cbc64b069d71aa9f6bb68311 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: unknown · effects: none found · domain stage: experimental · users: none · canonical: unreached_review
name: Import V1-V9 Legacy Lessons

on:
  workflow_dispatch:
  push:
    branches: [main]
    paths:
      - ".github/workflows/import-v1-9-legacy.yml"

permissions:
  contents: write

concurrency:
  group: import-v1-9-legacy
  cancel-in-progress: false

jobs:
  import:
    runs-on: ubuntu-latest
    timeout-minutes: 20
    steps:
      - name: Checkout Pipeline News
        uses: actions/checkout@v4
        with:
          fetch-depth: 1

      - name: Import exact V1-V9 legacy files
        shell: bash
        run: |
          set -euo pipefail

          archive="v1-9-legacy-lessons"
          if [[ -d "$archive" ]]; then
            echo "$archive already exists; refusing to overwrite the immutable archive."
            exit 0
          fi

          source_repo="$RUNNER_TEMP/globalgrid2050"
          git clone --depth 1 --branch main https://github.com/Ventusltd/globalgrid2050.git "$source_repo"
          source_sha="$(git -C "$source_repo" rev-parse HEAD)"

          mkdir -p "$archive/uk_renewables_pipeline"
          find "$source_repo/uk_renewables_pipeline" -maxdepth 1 -type f -exec cp -p {} "$archive/uk_renewables_pipeline/" \;
          cp -a "$source_repo/uk_renewables_pipeline/v7" "$archive/uk_renewables_pipeline/v7"
          cp -a "$source_repo/uk_renewables_pipeline/v8" "$archive/uk_renewables_pipeline/v8"
          cp -a "$source_repo/uk_renewables_pipeline/v9" "$archive/uk_renewables_pipeline/v9"
          find "$archive" -type d -name __pycache__ -prune -exec rm -rf {} +

          cat > "$archive/README.md" <<EOF
          # V1-V9 Legacy Lessons

          This directory is an immutable engineering archive copied from
          [Ventusltd/globalgrid2050](https://github.com/Ventusltd/globalgrid2050).

          Source commit: \`$source_sha\`

          Included boundaries:

          - V1-V6 standalone files and associated notes from
            \`uk_renewables_pipeline/\`;
          - the complete \`uk_renewables_pipeline/v7/\` directory;
          - the complete \`uk_renewables_pipeline/v8/\` directory;
          - the complete \`uk_renewables_pipeline/v9/\` directory.

          This material is reference-only. Do not implement Pipeline News by
          modifying these files. Preserve official-source identity discipline,
          news/official-data separation, deterministic safety gates, hostile
          regression fixtures, and abstention behaviour in the new architecture.
          EOF
          sed -i 's/^          //' "$archive/README.md"

          printf '%s\n' "$source_sha" > "$archive/SOURCE_COMMIT"

          git add "$archive"
          if git diff --cached --quiet; then
            echo "No import changes to commit."
            exit 0
          fi
          git config user.name "github-actions[bot]"
          git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
          git commit -m "Import V1-V9 legacy lessons from GlobalGrid2050"
          git push origin HEAD:main

PipelineNews Official Source Frontier

A configuration file. Runs on push, on a schedule and by hand.

automationpipelinenews / archive/202608261547-pipelinenews/.github/workflows/official-source-frontier.yml · lines 1–53 of 53 · version 2026-08-26 15:47 · Not reached from any entry point (candidate for review)

Why it exists in the grid workflow
Domain stage experimental (path word 'archive'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow. README: "The current official-source frontier is 60 of 6,870 reference groups with 174 observations: 29 authority-safe primary matches and 145 abstentions."
What it achieves
Runs `tests/run-current-timestamp-release.sh`, `tests/check-official-source-v4.mjs` and `tooling/poll-official-sources-v4.mjs`.
Why it matters
No other file in the estate was found to import it.
Application
pipelinenews · archive/202608261547-pipelinenews/.github/workflows · configuration
Uses
none found
Used by
none found
Produces
none declared
Defines here
Official source frontier
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 archive/202608261547-pipelinenews/.github/workflows/official-source-frontier.yml:1-53 · blob 6c3097b64e003b8ef8a36c342d93b5ea986d4640 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: unknown · effects: none found · domain stage: experimental · users: none · canonical: unreached_review
name: Official source frontier

on:
  workflow_dispatch:
  push:
    branches: [main]
    paths:
      - "tooling/poll-official-sources-v3.mjs"
      - "tooling/official-frontier-engine-v4.mjs"
      - "tooling/poll-official-sources-v4.mjs"
      - "tests/check-official-source-v4.mjs"
      - "objects/js/sha256/**"
      - "releases/*.json"
      - ".github/workflows/official-source-frontier.yml"
  schedule:
    - cron: "17 5 * * *"

permissions:
  contents: write

concurrency:
  group: pipelinenews-data-writers
  cancel-in-progress: false

jobs:
  poll:
    runs-on: ubuntu-latest
    timeout-minutes: 6
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: actions/setup-node@v4
        with:
          node-version: 22
      - name: Verify release before network work
        run: |
          bash tests/run-current-timestamp-release.sh
          node tests/check-official-source-v4.mjs
      - name: Poll bounded official-source batch
        env:
          PLANIT_BUDGET: "48"
        run: node tooling/poll-official-sources-v4.mjs
      - name: Commit cursor and admitted observations
        run: |
          git config user.name "PipelineNews Bot"
          git config user.email "actions@users.noreply.github.com"
          git add data/official-source/latest.json state/official-source-cursor.json
          git diff --cached --quiet && exit 0
          git commit -m "data: advance official-source frontier"
          git pull --rebase origin main
          git push

PipelineNews Pages

A configuration file that fetches migration, official collisions and part. Runs on push and by hand.

automationpipelinenews / archive/202608261547-pipelinenews/.github/workflows/pages.yml · lines 1–332 of 332 · version 2026-08-26 15:47 · Not reached from any entry point (candidate for review)

What it does
It fetches migration, official collisions and part. Side effects: makes network requests.
Why it exists in the grid workflow
Domain stage experimental (path word 'archive'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
Inputs & outputs
In: JSON file MIGRATION_MANIFEST.json; JSON file official-source-v3-collisions.json; JSON file candidate.json; JSON file current.json; JSON file part-016.json; JSON file major_project_news_v9_5_1.json; JSON file cumulative_intelligence.json.
What it achieves
Runs `newsv7/tests/run_newsv7.sh`, `tests/run-current-timestamp-release.sh` and `tests/browser-202608260159-pipelinenews.mjs`; publishes to GitHub Pages.
Why it matters
No other file in the estate was found to import it.
Application
pipelinenews · archive/202608261547-pipelinenews/.github/workflows · configuration
Uses
none found
Used by
none found
Produces
none declared
Defines here
Deploy PipelineNews Pages
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 archive/202608261547-pipelinenews/.github/workflows/pages.yml:1-332 · blob 04e1e1431d657a854e757c6938e99bfdd1e1dc82 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: ingest · effects: network · domain stage: experimental · users: none · canonical: unreached_review
name: Deploy PipelineNews Pages
# Static public-app artifacts only; Jekyll is deliberately bypassed.

on:
  workflow_dispatch:
  push:
    branches: [main]
    paths:
      - "newsv1/index.html"
      - "newsv1/scripts/**"
      - "newsv1/styles/**"
      - "newsv1/contracts/**"
      - "newsv1/data/**"
      - "newsv1/dist/**"
      - "newsv1/tests/check_newsv1.mjs"
      - "newsv1/tests/run_newsv1.sh"
      - "newsv1/MIGRATION_MANIFEST.json"
      - "newsv7/**"
      - "*-PipelineNews/**"
      - "*-pipelinenews/**"
      - "objects/**"
      - "releases/**"
      - "reports/**"
      - "attestations/**"
      - "tooling/build-202608251750-release.mjs"
      - "tooling/build-202608251929-release.mjs"
      - "tooling/templates/202608251929-app.js"
      - "tooling/templates/202608251929-app.css"
      - "tooling/poll-official-sources-v3.mjs"
      - "tests/check-202608251750-pipelinenews.mjs"
      - "tests/check-202608251929-pipelinenews.mjs"
      - "tests/browser-live-202608251929.mjs"
      - "tests/check-frozen-release-trees.sh"
      - "tests/check-current-timestamp-release.mjs"
      - "tests/check-official-source-v3.mjs"
      - "tests/fixtures/official-source-v3-collisions.json"
      - "tests/run-current-timestamp-release.sh"
      - ".github/workflows/pages.yml"

permissions:
  contents: read
  pages: write
  id-token: write

concurrency:
  group: pages
  cancel-in-progress: true

jobs:
  build:
    runs-on: ubuntu-latest
    timeout-minutes: 8
    outputs:
      deploy_ready: ${{ steps.publication-gate.outputs.deploy_ready }}
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Configure Pages
        uses: actions/configure-pages@v5

      - name: Verify cumulative News V7 release contract
        run: bash newsv7/tests/run_newsv7.sh

      - name: Verify current timestamp release contract
        run: bash tests/run-current-timestamp-release.sh

      - name: Stage News V1 runtime
        shell: bash
        run: |
          set -euo pipefail

          release="_site/newsv1"
          mkdir -p \
            "$release/scripts" \
            "$release/styles" \
            "$release/contracts" \
            "$release/data/v9.1" \
            "$release/data/v9.7" \
            "$release/dist"

          cp newsv1/index.html "$release/index.html"
          cp newsv1/MIGRATION_MANIFEST.json "$release/"

          # Exact browser-module closure for index.html. Legacy app modules,
          # build utilities and test harnesses are intentionally not published.
          runtime_modules=(
            scripts/app-newsv1.js
            scripts/core/plugin-host.js
            scripts/core/project-filter-v9-2.js
            scripts/core/state.js
            scripts/core/utils.js
            scripts/data/canonical-projects-newsv1-release.js
            scripts/data/canonical-projects-newsv1.js
            scripts/plugins/capacity-presentation-v9-3.js
            scripts/plugins/gauges-v9-2.js
            scripts/plugins/newspaper-newsv1-base.js
            scripts/plugins/newspaper-newsv1.js
            scripts/plugins/projects-newsv1.js
          )
          for module in "${runtime_modules[@]}"; do
            install -Dm0644 "newsv1/$module" "$release/$module"
          done

          cp \
            newsv1/styles/v7.css \
            newsv1/styles/mobile.css \
            newsv1/styles/v9-3.css \
            newsv1/styles/v9-4.css \
            newsv1/styles/v9-5-1.css \
            newsv1/styles/v9-6-1.css \
            newsv1/styles/performance-newsv1.css \
            "$release/styles/"

          cp \
            newsv1/contracts/release.newsv1.json \
            newsv1/contracts/release.v9.1.json \
            "$release/contracts/"

          cp newsv1/data/v9.1/build_manifest.json "$release/data/v9.1/"
          cp -a newsv1/data/v9.1/projects "$release/data/v9.1/"
          cp \
            newsv1/data/v9.7/regional_manifest.json \
            newsv1/data/v9.7/regional_news.json \
            "$release/data/v9.7/"
          cp newsv1/dist/major_project_news_v9_5_1.json "$release/dist/"

          release_v7="_site/newsv7"
          mkdir -p \
            "$release_v7/scripts" \
            "$release_v7/styles" \
            "$release_v7/contracts" \
            "$release_v7/data/v9.1" \
            "$release_v7/data/v9.7" \
            "$release_v7/data/newsv7" \
            "$release_v7/dist"

          cp newsv7/index.html "$release_v7/index.html"
          cp newsv7/MIGRATION_MANIFEST.json "$release_v7/"

          runtime_modules_v7=(
            scripts/app-newsv7.js
            scripts/core/plugin-host.js
            scripts/core/project-filter-v9-2.js
            scripts/core/state.js
            scripts/core/utils.js
            scripts/data/canonical-projects-newsv7-release.js
            scripts/data/canonical-projects-newsv7.js
            scripts/plugins/capacity-presentation-v9-3.js
            scripts/plugins/gauges-v9-2.js
            scripts/plugins/intelligence-newsv7.js
            scripts/plugins/newspaper-newsv7-base.js
            scripts/plugins/newspaper-newsv7.js
            scripts/plugins/projects-newsv7.js
          )
          for module in "${runtime_modules_v7[@]}"; do
            install -Dm0644 "newsv7/$module" "$release_v7/$module"
          done

          cp \
            newsv7/styles/v7.css \
            newsv7/styles/mobile.css \
            newsv7/styles/v9-3.css \
            newsv7/styles/v9-4.css \
            newsv7/styles/v9-5-1.css \
            newsv7/styles/v9-6-1.css \
            newsv7/styles/performance-newsv7.css \
            newsv7/styles/intelligence-newsv7.css \
            "$release_v7/styles/"

          cp \
            newsv7/contracts/release.newsv7.json \
            newsv7/contracts/release.v9.1.json \
            "$release_v7/contracts/"

          cp newsv7/data/v9.1/build_manifest.json "$release_v7/data/v9.1/"
          cp -a newsv7/data/v9.1/projects "$release_v7/data/v9.1/"
          cp \
            newsv7/data/v9.7/regional_manifest.json \
            newsv7/data/v9.7/regional_news.json \
            "$release_v7/data/v9.7/"
          cp \
            newsv7/data/newsv7/cumulative_intelligence.json \
            newsv7/data/newsv7/build_manifest.json \
            "$release_v7/data/newsv7/"
          cp newsv7/dist/major_project_news_v9_5_1.json "$release_v7/dist/"

          # Publish every lightweight timestamped shell plus its shared, content-addressed objects.
          while IFS= read -r timestamp_release; do
            cp -a "$timestamp_release" _site/
          done < <(find . -maxdepth 1 -mindepth 1 -type d \( -name '*-PipelineNews' -o -name '*-pipelinenews' \) -printf '%f\n' | sort)
          cp -a objects _site/
          cp -a releases _site/
          if test -d attestations; then
            cp -a attestations _site/
          fi

          pointer_path="releases/candidate.json"
          if test -f attestations/202608260159-pipelinenews-closure.json; then
            pointer_path="releases/current.json"
          fi
          current_manifest="$(jq -r '.manifest' "$pointer_path")"
          current_release="$(jq -r '.release_id' "$pointer_path")"
          test -f "$current_manifest"
          test -d "$current_release"

          # Timestamp shells may link to their governed reports. Publish only
          # the report closure declared by the current manifest.
          while IFS= read -r report_path; do
            test -f "$report_path"
            install -Dm0644 "$report_path" "_site/$report_path"
          done < <(jq -r '.proof[]? | select(.path | startswith("reports/")) | .path' "$current_manifest")

          touch _site/.nojekyll

          test -f "$release/index.html"
          test -f "$release/MIGRATION_MANIFEST.json"
          test -f "$release/scripts/app-newsv1.js"
          test -f "$release/data/v9.1/projects/part-016.json"
          test -f "$release/dist/major_project_news_v9_5_1.json"
          test -f "$release_v7/index.html"
          test -f "$release_v7/scripts/app-newsv7.js"
          test -f "$release_v7/data/newsv7/cumulative_intelligence.json"
          test -f "$release_v7/data/v9.1/projects/part-016.json"
          test -f "_site/$current_release/index.html"
          test -f "_site/$current_manifest"
          while IFS= read -r object_path; do
            test -f "_site/$object_path"
          done < <(jq -r '.objects | to_entries[] | .value.path' "$current_manifest")
          test -f _site/objects/data/sha256/3d2cd9cba8581bbc8c4e7434deb0c584d3969639a00926393cf011e2c3f8a00b.json
          ! find _site -type d \( -name tests -o -name node_modules -o -name v1-9-legacy-lessons \) -print -quit | grep -q .

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

      - name: Browser-check staged Pages artifact before deployment
        shell: bash
        env:
          QA_SCREENSHOT_DIR: reports/browser-202608260159-preview
        run: |
          set -euo pipefail
          python3 -m http.server 4173 --bind 127.0.0.1 --directory _site >"$RUNNER_TEMP/pipelinenews-preview-server.log" 2>&1 &
          server_pid="$!"
          trap 'kill "$server_pid" 2>/dev/null || true' EXIT
          for attempt in {1..20}; do
            if curl --fail --silent --show-error http://127.0.0.1:4173/202608260159-pipelinenews/ >/dev/null; then
              break
            fi
            sleep 1
          done
          PIPELINENEWS_BASE_URL=http://127.0.0.1:4173 PIPELINENEWS_DEPLOY_SHA="preview-$GITHUB_SHA" node tests/browser-202608260159-pipelinenews.mjs

      - name: Upload predeployment browser evidence
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: pipelinenews-202608260159-preview-${{ github.sha }}
          path: reports/browser-202608260159-preview
          if-no-files-found: error
          retention-days: 30

      - name: Enforce reviewed-preview publication gate
        id: publication-gate
        shell: bash
        run: |
          set -euo pipefail
          if test -f attestations/202608260159-pipelinenews-preview.json; then
            echo "deploy_ready=true" >> "$GITHUB_OUTPUT"
            echo "Reviewed preview attestation present; deployment may proceed."
          else
            echo "deploy_ready=false" >> "$GITHUB_OUTPUT"
            echo "Prepublication checkpoint only; deployment is disabled."
          fi

      - name: Upload Pages artifact
        uses: actions/upload-pages-artifact@v3
        with:
          path: _site

  deploy:
    if: needs.build.outputs.deploy_ready == 'true'
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}202608260159-pipelinenews/
    runs-on: ubuntu-latest
    needs: build
    timeout-minutes: 8
    outputs:
      page_url: ${{ steps.deployment.outputs.page_url }}
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4

  verify-live:
    runs-on: ubuntu-latest
    needs: deploy
    timeout-minutes: 8
    steps:
      - name: Checkout exact head
        uses: actions/checkout@v4

      - name: Configure Node
        uses: actions/setup-node@v4
        with:
          node-version: "20"

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

      - name: Verify exact deployed release at desktop and 390 CSS pixels
        env:
          PIPELINENEWS_BASE_URL: ${{ needs.deploy.outputs.page_url }}
          PIPELINENEWS_DEPLOY_SHA: ${{ github.sha }}
          QA_SCREENSHOT_DIR: reports/browser-202608260159
        run: node tests/browser-202608260159-pipelinenews.mjs

      - name: Upload browser evidence
        uses: actions/upload-artifact@v4
        with:
          name: pipelinenews-202608260159-browser-${{ github.sha }}
          path: reports/browser-202608260159
          if-no-files-found: error
          retention-days: 30