GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Automation and CI / pipelinenews / .github/workflow-archive/20260830-email-storm

Atlas Pointer Deep Link Successor and 1 more file

A configuration file in the workflow archive folder of PipelineNews that fetches invalid GridAtlas receiver and fast site from GitHub API. Runs on push, on a schedule and by hand.

700 lines of YAML from pipelinenews, in 2 files. Topic: Automation and CI. Section 1837 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. Atlas V9 Deep Link Successor automation · pipelinenews / .github/workflow-archive/20260830-email-storm/202608291310-atlas-v9-deep-link-successor.yml lines 701–741
  2. Atlas Pointer Deep Link Successor automation · pipelinenews / .github/workflow-archive/20260830-email-storm/202608291504-atlas-pointer-deep-link-successor.yml lines 1–659

Atlas V9 Deep Link Successor

A configuration file in the workflow archive folder of PipelineNews that fetches atlas deep link successor from GitHub API. Runs on push, on a schedule and by hand.

automationpipelinenews / .github/workflow-archive/20260830-email-storm/202608291310-atlas-v9-deep-link-successor.yml · lines 701–741 of 741 · version 2026-08-29 13:10 (continued from section 1836) · Not reached from any entry point (candidate for review)

What it does
It fetches atlas deep link successor, fast site and pointer complete equivalence. Side effects: reads or writes files; makes network requests; starts processes.
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: data source: GitHub API; JSON file current-v3.json; JSON file live-set.json; JSON file 202608291310-atlas-v9-deep-link-successor.json; JSON file 202608282200-v8-fast-site-manifest.json; JSON file 202608291310-complete-equivalence.json; JSON file release-manifest.json; JSON file 202608291310-pointer-complete-equivalence.json.
What it achieves
Named “PipelineNews Atlas V9 timestamp-folder successor”; runs Compile Atlas V9 Deep Link (`index/202608291310-compile-atlas-v9-deep-link.mjs`), `atman/202608291310-public-browser-readback.mjs` and `atman/202608291310-compare-incumbent-successor.mjs`.
Why it matters
No other file in the estate was found to import it.
Application
pipelinenews · .github/workflow-archive/20260830-email-storm · configuration
Uses
Compile Atlas V9 Deep Link (workflow run), Public Browser Readback (workflow run), Compare Incumbent Successor (workflow run), Verify Complete Equivalence (workflow run), Build Live Pointer (workflow run)
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/workflow-archive/20260830-email-storm/202608291310-atlas-v9-deep-link-successor.yml:701-741 · blob f0241ed5bb58bbe607679c48193bbc97c7fdce93 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: filesystem, network, process · domain stage: experimental · users: none · canonical: unreached_review
            --release-b "releases/$RELEASE_ID" \
            --browser-proof reports/202608291310-daily-real-atlas-v9-browser-proof.json \
            --output reports/202608291310-daily-incumbent-successor-comparator.json

      - name: Re-run inherited 420-check matrix in read-only daily mode
        shell: bash
        run: |
          set -euo pipefail
          python3 -m http.server 4173 --bind 127.0.0.1 --directory . >"$RUNNER_TEMP/pipelinenews-daily-matrix.log" 2>&1 &
          server_pid="$!"
          trap 'kill "$server_pid" 2>/dev/null || true' EXIT
          baseline="http://127.0.0.1:4173/releases/202608261927-index.html"
          candidate="http://127.0.0.1:4173/releases/$RELEASE_ID/"
          for url in "$baseline" "$candidate"; do
            for attempt in {1..20}; do
              if curl --fail --silent --show-error "$url" >/dev/null; then break; fi
              sleep 1
            done
            curl --fail --silent --show-error "$url" >/dev/null
          done
          node atman/202608291310-verify-complete-equivalence.mjs \
            --baseline "$baseline" \
            --candidate "$candidate" \
            --phase daily-drift \
            --report reports/202608291310-daily-complete-equivalence.json
          python3 - <<'PY'
          import json
          from pathlib import Path
          report = json.loads(Path("reports/202608291310-daily-complete-equivalence.json").read_text())
          if report.get("summary") != {"checks": 420, "passed": 420, "failed": 0}:
              raise AssertionError(f"daily complete interaction matrix changed: {report.get('summary')}")
          PY

      - name: Upload read-only daily drift evidence
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: pipelinenews-${{ env.RELEASE_ID }}-daily-drift-${{ github.run_id }}
          path: reports/202608291310-daily-*.json
          if-no-files-found: warn
          retention-days: 30

Atlas Pointer Deep Link Successor

A configuration file in the workflow archive folder of PipelineNews that fetches invalid GridAtlas receiver and fast site from GitHub API. Runs on push, on a schedule and by hand.

automationpipelinenews / .github/workflow-archive/20260830-email-storm/202608291504-atlas-pointer-deep-link-successor.yml · lines 1–659 of 845 · version 2026-08-29 15:04 · Not reached from any entry point (candidate for review)

What it does
It fetches invalid GridAtlas receiver and fast site. Side effects: reads or writes files; makes network requests; starts processes.
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: data source: GitHub API; JSON file current-v3.json; JSON file live-set.json; JSON file 202608291504-atlas-pointer-deep-link-successor.json; JSON file invalid-gridatlas-receiver.json; JSON file 202608282200-v8-fast-site-manifest.json; JSON file 202608291504-complete-equivalence.json; JSON file release-manifest.json.
What it achieves
Named “PipelineNews Atlas pointer timestamp-folder successor”; runs Resolve GridAtlas Pointer (`atman/202608291504-resolve-gridatlas-pointer.mjs`), Compile Atlas Pointer Deep Link (`index/202608291504-compile-atlas-pointer-deep-link.mjs`) and `atman/202608291504-public-browser-readback.mjs`.
Why it matters
No other file in the estate was found to import it.
Application
pipelinenews · .github/workflow-archive/20260830-email-storm · configuration
Uses
Resolve GridAtlas Pointer (workflow run), Compile Atlas Pointer Deep Link (workflow run), Public Browser Readback (workflow run), Compare Incumbent Successor (workflow run), Verify Complete Equivalence (workflow run), Build Live Pointer (workflow run), Wake Up Ledger (workflow run)
Used by
none found
Produces
none declared
Defines here
PipelineNews Atlas pointer timestamp-folder successor
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/workflow-archive/20260830-email-storm/202608291504-atlas-pointer-deep-link-successor.yml:1-659 · blob d14fd7d70a8db21651bda6081304df4daed1abec · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: filesystem, network, process · domain stage: experimental · users: none · canonical: unreached_review
name: PipelineNews Atlas pointer timestamp-folder successor

on:
  push:
    branches: [main]
    paths:
      - .github/workflows/pages.yml
      - .github/workflows/202608291504-atlas-pointer-deep-link-successor.yml
      - atman/202608262014-build-pages.py
      - atman/202608291504-build-live-pointer.mjs
      - atman/202608291504-compare-incumbent-successor.mjs
      - atman/202608291504-public-browser-readback.mjs
      - atman/202608291504-resolve-gridatlas-pointer.mjs
      - atman/202608291504-wake-up-ledger.mjs
      - index/202608291504-compile-atlas-pointer-deep-link.mjs
      - manifests/202608291504-atlas-pointer-deep-link-successor.json
      - ui/cartridges/202608291504-atlas-pointer-deep-link.mjs
  workflow_dispatch:
    inputs:
      mode:
        description: Build/stage release or stage proof-bound live pointers
        required: true
        default: build-release
        type: choice
        options:
          - build-release
          - stage-pointer
      pages_run_id:
        description: Successful first Pages run ID, required for stage-pointer
        required: false
        type: string
      deployed_commit:
        description: Exact first Pages deployment commit, required for stage-pointer
        required: false
        type: string
  schedule:
    - cron: "17 3 * * *"

permissions:
  contents: read
  actions: read

concurrency:
  group: pipelinenews-202608291504-atlas-pointer-${{ github.event_name }}
  cancel-in-progress: false

env:
  GENERATION: "202608291504"
  RELEASE_ID: 202608291504-pipelinenews
  SOURCE_PARENT: db9f7583b203d374781e2b38e7c7a8b86e32d8b3
  GRIDATLAS_POINTER_COMMIT: 936a31f703d31bd975af22d7349708d68a143d56
  GRIDATLAS_POINTER_SHA256: 29628a9ba376b24a72248fac7e9333e0487a33e86ad50d309a7b868932fea4d6
  PARENT_RUN_ID: "33211041996"
  PARENT_ARTIFACT_ID: "9701586944"
  PARENT_ARTIFACT_BYTES: "37659"
  PARENT_ARTIFACT_SHA256: 8ec24ba18c70b661ddfc6ff9ca4bb728db5929d5700c147c91449f5e93e9b497
  PLAYWRIGHT_VERSION: "1.55.0"

jobs:
  classify:
    runs-on: ubuntu-latest
    timeout-minutes: 5
    outputs:
      pointer_live: ${{ steps.mode.outputs.pointer_live }}
    steps:
      - name: Checkout current main without credentials
        uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09
        with:
          ref: main
          fetch-depth: 1
          persist-credentials: false

      - name: Classify build or pointer-gated daily drift mode
        id: mode
        shell: bash
        run: |
          set -euo pipefail
          python3 - <<'PY'
          import json
          import os
          from pathlib import Path

          release_id = os.environ["RELEASE_ID"]
          pointer_paths = [Path("releases/current-v3.json"), Path("state/live-set.json")]
          live = all(path.is_file() for path in pointer_paths)
          if live:
              for path in pointer_paths:
                  value = json.loads(path.read_text(encoding="utf-8"))
                  if release_id not in json.dumps(value, sort_keys=True):
                      live = False
                      break
          output = Path(os.environ["GITHUB_OUTPUT"])
          with output.open("a", encoding="utf-8") as handle:
              handle.write(f"pointer_live={'true' if live else 'false'}\n")
          print(json.dumps({
              "event": os.environ["GITHUB_EVENT_NAME"],
              "release_id": release_id,
              "pointer_live": live,
              "schedule_behavior": "read-only drift" if live else "clean pointer-gated no-op",
          }))
          PY

  build:
    if: github.event_name != 'schedule' && (github.event_name != 'workflow_dispatch' || inputs.mode == 'build-release')
    needs: classify
    runs-on: ubuntu-latest
    timeout-minutes: 30
    outputs:
      source_sha: ${{ steps.source.outputs.source_sha }}
      release_manifest_sha256: ${{ steps.release.outputs.manifest_sha256 }}
    steps:
      - name: Checkout exact immutable source commit
        uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09
        with:
          ref: ${{ github.sha }}
          fetch-depth: 2
          persist-credentials: false

      - name: Verify exact source phase and hash boundary
        id: source
        shell: bash
        run: |
          set -euo pipefail
          test "$(git rev-parse HEAD^)" = "$SOURCE_PARENT"
          python3 - <<'PY'
          import hashlib
          import json
          import os
          from pathlib import Path
          import subprocess

          expected = {
              ".github/workflows/pages.yml",
              ".github/workflows/202608291504-atlas-pointer-deep-link-successor.yml",
              "atman/202608262014-build-pages.py",
              "atman/202608291504-build-live-pointer.mjs",
              "atman/202608291504-compare-incumbent-successor.mjs",
              "atman/202608291504-public-browser-readback.mjs",
              "atman/202608291504-resolve-gridatlas-pointer.mjs",
              "atman/202608291504-wake-up-ledger.mjs",
              "index/202608291504-compile-atlas-pointer-deep-link.mjs",
              "manifests/202608291504-atlas-pointer-deep-link-successor.json",
              "ui/cartridges/202608291504-atlas-pointer-deep-link.mjs",
          }
          changed = set(subprocess.check_output([
              "git", "diff-tree", "--no-commit-id", "--name-only", "-r", "HEAD"
          ], text=True).splitlines())
          if changed != expected:
              raise AssertionError(f"source commit boundary changed: {sorted(changed ^ expected)}")

          manifest = json.loads(Path("manifests/202608291504-atlas-pointer-deep-link-successor.json").read_text())
          if manifest.get("source_parent_commit") != os.environ["SOURCE_PARENT"]:
              raise AssertionError("source parent changed")
          if set(manifest.get("source_boundary", [])) != expected:
              raise AssertionError("manifest source boundary changed")
          pins = manifest.get("source_files", [])
          if len(pins) != 10:
              raise AssertionError("source manifest must hash all boundary files except itself")
          if {record.get("path") for record in pins} != expected - {"manifests/202608291504-atlas-pointer-deep-link-successor.json"}:
              raise AssertionError("source hash set changed")
          for record in pins:
              raw = Path(record["path"]).read_bytes()
              actual = {"path": record["path"], "bytes": len(raw), "sha256": hashlib.sha256(raw).hexdigest()}
              if actual != record:
                  raise AssertionError(f"source hash drift: {record['path']}")
          PY
          echo "source_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"

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

      - name: Resolve and authenticate exact GridAtlas live pointer
        shell: bash
        env:
          GH_TOKEN: ${{ github.token }}
        run: |
          set -euo pipefail
          mkdir -p work/202608291504-ci
          node atman/202608291504-resolve-gridatlas-pointer.mjs \
            --repository Ventusltd/gridatlas \
            --expected-commit "$GRIDATLAS_POINTER_COMMIT" \
            --expected-pointer-sha256 "$GRIDATLAS_POINTER_SHA256" \
            --output work/202608291504-ci/gridatlas-receiver.json

      - name: Prove GridAtlas pointer authentication fails closed
        shell: bash
        env:
          GH_TOKEN: ${{ github.token }}
        run: |
          set -euo pipefail
          if node atman/202608291504-resolve-gridatlas-pointer.mjs \
            --repository Ventusltd/gridatlas \
            --expected-commit "$GRIDATLAS_POINTER_COMMIT" \
            --expected-pointer-sha256 "$(printf '0%.0s' {1..64})" \
            --output "$RUNNER_TEMP/invalid-gridatlas-receiver.json"; then
            echo "tampered GridAtlas pointer digest was accepted" >&2
            exit 1
          fi
          test ! -e "$RUNNER_TEMP/invalid-gridatlas-receiver.json"

      - name: Fetch and authenticate exact green parent artifact
        shell: bash
        env:
          GH_TOKEN: ${{ github.token }}
        run: |
          set -euo pipefail
          mkdir -p work/202608291504-ci/parent
          python3 - <<'PY'
          import json
          import os
          import time
          from urllib.request import Request, urlopen

          repository = os.environ["GITHUB_REPOSITORY"]
          artifact_id = os.environ["PARENT_ARTIFACT_ID"]
          request = Request(
              f"https://api.github.com/repos/{repository}/actions/artifacts/{artifact_id}",
              headers={
                  "Accept": "application/vnd.github+json",
                  "Authorization": f"Bearer {os.environ['GH_TOKEN']}",
                  "User-Agent": "PipelineNews-Atlas-V9-Successor/1",
                  "X-GitHub-Api-Version": "2022-11-28",
              },
          )
          with urlopen(request, timeout=30) as response:
              artifact = json.load(response)
          checks = {
              "id": (str(artifact.get("id")), artifact_id),
              "expired": (artifact.get("expired"), False),
              "size": (str(artifact.get("size_in_bytes")), os.environ["PARENT_ARTIFACT_BYTES"]),
              "run": (str(artifact.get("workflow_run", {}).get("id")), os.environ["PARENT_RUN_ID"]),
          }
          for label, (actual, expected) in checks.items():
              if actual != expected:
                  raise AssertionError(f"parent artifact {label}: expected {expected!r}, got {actual!r}")
          digest = artifact.get("digest")
          if digest is not None and digest != f"sha256:{os.environ['PARENT_ARTIFACT_SHA256']}":
              raise AssertionError(f"parent artifact API digest changed: {digest}")
          print(json.dumps({"artifact_id": artifact_id, "run_id": os.environ["PARENT_RUN_ID"], "expired": False}))
          PY
          curl --fail --silent --show-error --location \
            --header "Accept: application/vnd.github+json" \
            --header "Authorization: Bearer $GH_TOKEN" \
            --header "X-GitHub-Api-Version: 2022-11-28" \
            "https://api.github.com/repos/$GITHUB_REPOSITORY/actions/artifacts/$PARENT_ARTIFACT_ID/zip" \
            --output work/202608291504-ci/parent.zip
          test "$(stat -c %s work/202608291504-ci/parent.zip)" = "$PARENT_ARTIFACT_BYTES"
          test "$(sha256sum work/202608291504-ci/parent.zip | cut -d' ' -f1)" = "$PARENT_ARTIFACT_SHA256"
          unzip -q work/202608291504-ci/parent.zip -d work/202608291504-ci/parent

      - name: Verify exact parent output closure
        shell: bash
        run: |
          set -euo pipefail
          python3 - <<'PY'
          import hashlib
          import json
          from pathlib import Path

          root = Path("work/202608291504-ci/parent")
          manifest_path = root / "build/202608282200-v8-fast-site-manifest.json"
          raw = manifest_path.read_bytes()
          if len(raw) != 25073 or hashlib.sha256(raw).hexdigest() != "025daf70f1c4b9c9a7c84a70d41ceb50e96232771f736faa309ca92c2c9c134d":
              raise AssertionError("parent manifest drift")
          manifest = json.loads(raw)
          compact = json.dumps(manifest["outputs"], sort_keys=True, separators=(",", ":"), ensure_ascii=False).encode()
          if hashlib.sha256(compact).hexdigest() != "bc25c04b0fd24ed418a86a3bc7157678c3bbd4371a3117854b56e4c0520855c5":
              raise AssertionError("parent output-record closure drift")
          expected = {"build/202608282200-v8-fast-site-manifest.json"}
          for record in manifest["outputs"]:
              path = root / record["path"]
              payload = path.read_bytes()
              if len(payload) != record["bytes"] or hashlib.sha256(payload).hexdigest() != record["sha256"]:
                  raise AssertionError(f"parent output drift: {record['path']}")
              expected.add(record["path"])
          actual = {path.relative_to(root).as_posix() for path in root.rglob("*") if path.is_file()}
          if actual != expected:
              raise AssertionError(f"parent artifact closure changed: {sorted(actual ^ expected)}")
          PY

      - name: Compile deterministic A/B timestamp folders
        shell: bash
        env:
          SOURCE_SHA: ${{ steps.source.outputs.source_sha }}
        run: |
          set -euo pipefail
          committed_at="$(git show -s --format=%cI "$SOURCE_SHA")"
          for output in release-a release-b; do
            node index/202608291504-compile-atlas-pointer-deep-link.mjs \
              --parent-root work/202608291504-ci/parent \
              --out-root "work/202608291504-ci/$output" \
              --source-commit "$SOURCE_SHA" \
              --source-committed-at "$committed_at" \
              --atlas-receiver work/202608291504-ci/gridatlas-receiver.json
          done
          diff --no-dereference --recursive --brief \
            work/202608291504-ci/release-a \
            work/202608291504-ci/release-b
          test "$(find work/202608291504-ci/release-a/releases/$RELEASE_ID -type f | wc -l)" = 40
          find work/202608291504-ci/release-a/releases/$RELEASE_ID -type f \( -name '*.mjs' -o -name '*.js' \) -print0 \
            | xargs -0 -n1 node --check

      - name: Install pinned real-browser harness
        shell: bash
        run: |
          set -euo pipefail
          npm install --no-save --no-package-lock "playwright@$PLAYWRIGHT_VERSION"
          npx playwright install --with-deps chromium

      - name: Prove inbound PipelineNews and outbound real Atlas V9 readback
        shell: bash
        run: |
          set -euo pipefail
          mkdir -p reports
          python3 -m http.server 4173 --bind 127.0.0.1 --directory work/202608291504-ci/release-a >"$RUNNER_TEMP/pipelinenews-atlas-v9.log" 2>&1 &
          server_pid="$!"
          trap 'kill "$server_pid" 2>/dev/null || true' EXIT
          candidate="http://127.0.0.1:4173/releases/$RELEASE_ID/"
          for attempt in {1..20}; do
            if curl --fail --silent --show-error "$candidate" >/dev/null; then break; fi
            sleep 1
          done
          curl --fail --silent --show-error "$candidate" >/dev/null
          node atman/202608291504-public-browser-readback.mjs \
            --candidate "$candidate" \
            --output reports/202608291504-real-atlas-v9-browser-proof.json

      - name: Compare against exact incumbent and reject regression or unknown
        shell: bash
        run: |
          set -euo pipefail
          node atman/202608291504-compare-incumbent-successor.mjs \
            --parent-root work/202608291504-ci/parent \
            --release-a work/202608291504-ci/release-a/releases/$RELEASE_ID \
            --release-b work/202608291504-ci/release-b/releases/$RELEASE_ID \
            --browser-proof reports/202608291504-real-atlas-v9-browser-proof.json \
            --output reports/202608291504-incumbent-successor-comparator.json

      - name: Re-run inherited 420-check complete interaction matrix
        shell: bash
        run: |
          set -euo pipefail
          python3 -m http.server 4173 --bind 127.0.0.1 --directory . >"$RUNNER_TEMP/pipelinenews-complete-matrix.log" 2>&1 &
          server_pid="$!"
          trap 'kill "$server_pid" 2>/dev/null || true' EXIT
          baseline="http://127.0.0.1:4173/releases/202608261927-index.html"
          candidate="http://127.0.0.1:4173/work/202608291504-ci/release-a/releases/$RELEASE_ID/"
          for url in "$baseline" "$candidate"; do
            for attempt in {1..20}; do
              if curl --fail --silent --show-error "$url" >/dev/null; then break; fi
              sleep 1
            done
            curl --fail --silent --show-error "$url" >/dev/null
          done
          node atman/202608291310-verify-complete-equivalence.mjs \
            --baseline "$baseline" \
            --candidate "$candidate" \
            --phase source-build \
            --report reports/202608291504-complete-equivalence.json
          python3 - <<'PY'
          import json
          from pathlib import Path
          report = json.loads(Path("reports/202608291504-complete-equivalence.json").read_text())
          if report.get("summary") != {"checks": 420, "passed": 420, "failed": 0}:
              raise AssertionError(f"complete interaction matrix changed: {report.get('summary')}")
          PY

      - name: Record accepted immutable release manifest
        id: release
        shell: bash
        run: |
          set -euo pipefail
          manifest="work/202608291504-ci/release-a/releases/$RELEASE_ID/release-manifest.json"
          echo "manifest_sha256=$(sha256sum "$manifest" | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"

      - name: Upload accepted release and evidence
        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
        with:
          name: pipelinenews-${{ env.RELEASE_ID }}-${{ steps.source.outputs.source_sha }}
          path: |
            work/202608291504-ci/release-a/releases/202608291504-pipelinenews
            reports/202608291504-real-atlas-v9-browser-proof.json
            reports/202608291504-incumbent-successor-comparator.json
            reports/202608291504-complete-equivalence.json
            work/202608291504-ci/gridatlas-receiver.json
          if-no-files-found: error
          retention-days: 30

  stage-ci-branch:
    if: github.event_name != 'schedule' && (github.event_name != 'workflow_dispatch' || inputs.mode == 'build-release')
    needs: build
    runs-on: ubuntu-latest
    timeout-minutes: 10
    permissions:
      contents: write
      actions: read
    steps:
      - name: Checkout exact accepted source without credentials
        uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09
        with:
          ref: ${{ needs.build.outputs.source_sha }}
          fetch-depth: 1
          persist-credentials: false

      - name: Download accepted immutable release
        uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0
        with:
          name: pipelinenews-${{ env.RELEASE_ID }}-${{ needs.build.outputs.source_sha }}
          path: work/202608291504-stage

      - name: Commit only immutable folder and CAS-push only ci namespace
        shell: bash
        env:
          GH_TOKEN: ${{ github.token }}
          SOURCE_SHA: ${{ needs.build.outputs.source_sha }}
          EXPECTED_MANIFEST_SHA256: ${{ needs.build.outputs.release_manifest_sha256 }}
          STAGE_BRANCH: ci/202608291504-atlas-pointer-release
        run: |
          set -euo pipefail
          release_source="work/202608291504-stage/work/202608291504-ci/release-a/releases/$RELEASE_ID"
          if [[ ! -d "$release_source" ]]; then
            release_source="work/202608291504-stage/$RELEASE_ID"
          fi
          test -d "$release_source"
          test "$(find "$release_source" -type f | wc -l)" = 40
          test "$(sha256sum "$release_source/release-manifest.json" | cut -d' ' -f1)" = "$EXPECTED_MANIFEST_SHA256"

          remote_url="https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
          if git ls-remote --exit-code --heads "$remote_url" "refs/heads/$STAGE_BRANCH" >"$RUNNER_TEMP/stage-ref"; then
            echo "Immutable CI stage branch already exists; refusing to rewrite it." >&2
            exit 1
          fi
          git switch --create "$STAGE_BRANCH" "$SOURCE_SHA"
          mkdir -p "releases/$RELEASE_ID"
          cp -a "$release_source/." "releases/$RELEASE_ID/"
          git add -- "releases/$RELEASE_ID"
          test "$(git diff --cached --name-only | wc -l)" = 40
          test -z "$(git diff --cached --name-only | grep -v "^releases/$RELEASE_ID/" || true)"
          git config user.name github-actions[bot]
          git config user.email 41898282+github-actions[bot]@users.noreply.github.com
          git commit -m "stage: immutable PipelineNews Atlas V9 release $RELEASE_ID"
          git push "$remote_url" "HEAD:refs/heads/$STAGE_BRANCH"

  stage-pointer-ci-branch:
    if: github.event_name == 'workflow_dispatch' && inputs.mode == 'stage-pointer'
    needs: classify
    runs-on: ubuntu-latest
    timeout-minutes: 30
    permissions:
      contents: write
      actions: read
    steps:
      - name: Checkout exact release-owning main without persisted credentials
        uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09
        with:
          ref: main
          fetch-depth: 2
          persist-credentials: false

      - name: Verify successful first Pages run and exact deployed main
        id: pages-run
        shell: bash
        env:
          GH_TOKEN: ${{ github.token }}
          PAGES_RUN_ID: ${{ inputs.pages_run_id }}
          DEPLOYED_COMMIT: ${{ inputs.deployed_commit }}
        run: |
          set -euo pipefail
          [[ "$PAGES_RUN_ID" =~ ^[0-9]+$ ]]
          [[ "$DEPLOYED_COMMIT" =~ ^[0-9a-f]{40}$ ]]
          test "$(git rev-parse HEAD)" = "$DEPLOYED_COMMIT"
          git fetch --no-tags origin refs/heads/main
          test "$(git rev-parse FETCH_HEAD)" = "$DEPLOYED_COMMIT"
          test -f "releases/$RELEASE_ID/release-manifest.json"
          python3 - <<'PY'
          import json
          import os
          import time
          from urllib.request import Request, urlopen

          request = Request(
              f"https://api.github.com/repos/{os.environ['GITHUB_REPOSITORY']}/actions/runs/{os.environ['PAGES_RUN_ID']}",
              headers={
                  "Accept": "application/vnd.github+json",
                  "Authorization": f"Bearer {os.environ['GH_TOKEN']}",
                  "User-Agent": "PipelineNews-Live-Pointer-Gate/1",
                  "X-GitHub-Api-Version": "2022-11-28",
              },
          )
          run = None
          for attempt in range(60):
              with urlopen(request, timeout=30) as response:
                  run = json.load(response)
              if run.get("status") == "completed":
                  break
              if attempt == 59:
                  raise AssertionError("first Pages run did not complete before pointer staging deadline")
              time.sleep(5)
          checks = {
              "path": (run.get("path"), ".github/workflows/pages.yml"),
              "event": (run.get("event"), "push"),
              "status": (run.get("status"), "completed"),
              "conclusion": (run.get("conclusion"), "success"),
              "head_sha": (run.get("head_sha"), os.environ["DEPLOYED_COMMIT"]),
              "repository": (run.get("repository", {}).get("full_name"), os.environ["GITHUB_REPOSITORY"]),
          }
          for label, (actual, expected) in checks.items():
              if actual != expected:
                  raise AssertionError(f"Pages run {label}: expected {expected!r}, got {actual!r}")
          with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as output:
              output.write(f"verified_at_utc={run['updated_at']}\n")
          print(json.dumps({"pages_run_id": os.environ["PAGES_RUN_ID"], "deployed_commit": run["head_sha"], "conclusion": "success"}))
          PY

      - name: Download exact first Pages live evidence artifact
        uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0
        with:
          pattern: pipelinenews-*-live-${{ inputs.deployed_commit }}
          path: work/202608291504-pages-proof
          merge-multiple: true
          github-token: ${{ github.token }}
          repository: ${{ github.repository }}
          run-id: ${{ inputs.pages_run_id }}

      - name: Validate exact first Pages evidence boundary
        shell: bash
        run: |
          set -euo pipefail
          pages_proof="$(find work/202608291504-pages-proof -type f -name "browser-$RELEASE_ID-atlas-v9-live.json" -print -quit)"
          closure_proof="$(find work/202608291504-pages-proof -type f -name "timestamp-folder-live-closure-$RELEASE_ID.json" -print -quit)"
          test -n "$pages_proof"
          test -n "$closure_proof"
          python3 - "$pages_proof" "$closure_proof" <<'PY'
          import json
          import sys
          browser = json.load(open(sys.argv[1], encoding="utf-8"))
          closure = json.load(open(sys.argv[2], encoding="utf-8"))
          if browser.get("classification") != "VERIFIED_REAL_ATLAS_V9_RECEIVER":
              raise AssertionError("first Pages browser proof is not green")
          golden = browser.get("contractual_golden", {})
          if (
              golden.get("repd_ref") != "16135"
              or golden.get("receiver_present") is not True
              or golden.get("pipeline_present") is not False
              or golden.get("tested") is not True
              or not golden.get("receiver_url", "").endswith("?repd_ref=16135")
              or not golden.get("receiver_evidence", {}).get("cards")
          ):
              raise AssertionError("first Pages proof has no durable contractual-golden receiver card")
          for optional in browser.get("optional_sentinels", []):
              if optional.get("repd_ref") not in {"17494", "13599"}:
                  raise AssertionError("first Pages proof contains an unknown optional sentinel")
              if optional.get("present") and (
                  optional.get("tested") is not True
                  or not optional.get("receiver_url", "").endswith(f"?repd_ref={optional['repd_ref']}")
                  or not optional.get("receiver_evidence", {}).get("cards")
              ):
                  raise AssertionError("present optional sentinel has no durable receiver-card proof")
          if closure.get("status") != "PASS" or closure.get("verified_file_count") != 40:
              raise AssertionError("first Pages closure proof is incomplete")
          PY

      - name: Configure Node and install pinned real-browser harness
        uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444
        with:
          node-version: "22"

      - name: Install browser
        shell: bash
        run: |
          set -euo pipefail
          npm install --no-save --no-package-lock "playwright@$PLAYWRIGHT_VERSION"
          npx playwright install --with-deps chromium

      - name: Re-prove public folder to both real Atlas V9 sentinels
        shell: bash
        run: |
          set -euo pipefail
          mkdir -p reports
          node atman/202608291504-public-browser-readback.mjs \
            --candidate "https://ventusltd.github.io/pipelinenews/releases/$RELEASE_ID/" \
            --output reports/202608291504-pointer-public-browser-proof.json

      - name: Re-run comparator and inherited 420 checks before pointer construction
        shell: bash
        run: |
          set -euo pipefail
          pages_proof="$(find work/202608291504-pages-proof -type f -name "browser-$RELEASE_ID-atlas-v9-live.json" -print -quit)"
          node atman/202608291504-compare-incumbent-successor.mjs \
            --release-a "releases/$RELEASE_ID" \
            --release-b "releases/$RELEASE_ID" \
            --browser-proof "$pages_proof" \
            --output reports/202608291504-pointer-comparator.json
          python3 -m http.server 4173 --bind 127.0.0.1 --directory . >"$RUNNER_TEMP/pipelinenews-pointer-matrix.log" 2>&1 &
          server_pid="$!"
          trap 'kill "$server_pid" 2>/dev/null || true' EXIT
          for url in \
            http://127.0.0.1:4173/releases/202608261927-index.html \
            "http://127.0.0.1:4173/releases/$RELEASE_ID/"; do
            for attempt in {1..20}; do
              if curl --fail --silent --show-error "$url" >/dev/null; then break; fi
              sleep 1
            done
            curl --fail --silent --show-error "$url" >/dev/null
          done
          node atman/202608291310-verify-complete-equivalence.mjs \
            --baseline http://127.0.0.1:4173/releases/202608261927-index.html \
            --candidate "http://127.0.0.1:4173/releases/$RELEASE_ID/" \
            --phase pointer-stage \
            --report reports/202608291504-pointer-complete-equivalence.json
          python3 - <<'PY'
          import json
          from pathlib import Path
          report = json.loads(Path("reports/202608291504-pointer-complete-equivalence.json").read_text())
          if report.get("summary") != {"checks": 420, "passed": 420, "failed": 0}:
              raise AssertionError(f"pointer complete interaction matrix changed: {report.get('summary')}")
          PY

      - name: Build deterministic byte-identical pointer A/B
        shell: bash
        env:
          PAGES_RUN_ID: ${{ inputs.pages_run_id }}
          DEPLOYED_COMMIT: ${{ inputs.deployed_commit }}
          VERIFIED_AT_UTC: ${{ steps.pages-run.outputs.verified_at_utc }}
        run: |
          set -euo pipefail
          pages_proof="$(find work/202608291504-pages-proof -type f -name "browser-$RELEASE_ID-atlas-v9-live.json" -print -quit)"
          for output in pointer-a pointer-b; do
            node atman/202608291504-build-live-pointer.mjs \
              --root . \
              --browser-proof "$pages_proof" \
              --comparator-report reports/202608291504-pointer-comparator.json \
              --equivalence-report reports/202608291504-pointer-complete-equivalence.json \
              --pages-run-id "$PAGES_RUN_ID" \
              --deployed-commit "$DEPLOYED_COMMIT" \
              --verified-at-utc "$VERIFIED_AT_UTC" \
              --out-root "work/202608291504-pointer/$output"
          done
          diff --no-dereference --recursive --brief \
            work/202608291504-pointer/pointer-a \
            work/202608291504-pointer/pointer-b
          cmp work/202608291504-pointer/pointer-a/releases/current-v3.json \
              work/202608291504-pointer/pointer-a/state/live-set.json

      - name: Commit only two live pointers and CAS-push only ci namespace
        shell: bash
        env:
          GH_TOKEN: ${{ github.token }}
          STAGE_BRANCH: ci/202608291504-atlas-pointer-live-pointer
        run: |
          set -euo pipefail
          remote_url="https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
          if git ls-remote --exit-code --heads "$remote_url" "refs/heads/$STAGE_BRANCH" >"$RUNNER_TEMP/pointer-stage-ref"; then
            echo "Immutable pointer stage branch already exists; refusing to rewrite it." >&2
            exit 1
          fi
          git switch --create "$STAGE_BRANCH"