GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Automation and CI / companies / .github/workflow-history

Bounded Companies House Candidate and 1 more file

A configuration file in the workflow history folder that reads the Renewable Energy Planning Database (REPD) register. Runs on push.

624 lines of YAML from companies, in 2 files. Topic: Automation and CI. Section 1686 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. Normalise Companies Candidate automation · companies / .github/workflow-history/202608271634-normalise-companies-candidate.yml lines 1–201
  2. Bounded Companies House Candidate automation · companies / .github/workflow-history/202608272155-bounded-companies-house-candidate.yml lines 1–423

Normalise Companies Candidate

A configuration file in the workflow history folder. Runs by hand.

automationcompanies / .github/workflow-history/202608271634-normalise-companies-candidate.yml · lines 1–201 of 201 · version 2026-08-27 16:34 · Not reached from any entry point (candidate for review)

What it does
It loads data. Side effects: uses storage (browser storage, DuckDB or Parquet).
Inputs & outputs
In: DuckDB queries.
What it achieves
Runs Test Candidate Semantics (`tests/test_202608271634_candidate_semantics.py`) and `build/python/202608271634-normalise-companies-candidate.py`.
Why it matters
No other file in the estate was found to import it.
Application
companies · .github/workflow-history · configuration
Uses
Test Candidate Semantics (workflow run)
Used by
none found
Produces
none declared
Defines here
202608271634 Companies Candidate Semantics
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
companies@1371da4d0166eef13f98fc3847c5bb1e38e8f571 .github/workflow-history/202608271634-normalise-companies-candidate.yml:1-201 · blob 79442caddd62de9d9326a679113657423c59ca4d · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: ingest · effects: storage · domain stage: unknown · users: none · canonical: unreached_review
name: 202608271634 Companies Candidate Semantics

on:
  workflow_dispatch:

concurrency:
  group: companies-candidate-semantics-202608271634
  cancel-in-progress: false

env:
  GENERATION: "202608271634"
  BASE_COMMIT: "4012964c3ab1e2f559e4836d697b99a74c7291e2"
  PARENT_GENERATION: "202608271547"
  SOURCE_MANIFEST: manifests/202608271634-companies-candidate-semantics.json

jobs:
  source-boundary:
    runs-on: ubuntu-latest
    timeout-minutes: 5
    permissions:
      contents: read
    outputs:
      source_sha: ${{ steps.boundary.outputs.source_sha }}
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
        with:
          ref: main
          fetch-depth: 2
          persist-credentials: false
      - id: boundary
        name: Prove the four-file immutable source boundary
        shell: bash
        run: |
          set -euo pipefail
          test "$GITHUB_REF" = "refs/heads/main"
          test "$(git rev-parse HEAD^)" = "$BASE_COMMIT"
          git diff --name-only "$BASE_COMMIT" HEAD | sort > /tmp/actual-files
          jq -r '.source_files[].path' "$SOURCE_MANIFEST" | sort > /tmp/expected-files
          diff -u /tmp/expected-files /tmp/actual-files
          test "$(wc -l < /tmp/actual-files)" -eq 4
          while IFS=$'\t' read -r expected path; do
            if [ "$expected" = "SELF" ]; then
              test "$path" = "$SOURCE_MANIFEST"
            else
              test "$(sha256sum "$path" | cut -d' ' -f1)" = "$expected"
            fi
          done < <(jq -r '[.source_files[],.dependencies[]] | .[] | [.sha256,.path] | @tsv' "$SOURCE_MANIFEST")
          test "$(jq -r '.generation' "$SOURCE_MANIFEST")" = "$GENERATION"
          test "$(jq -r '.base_commit' "$SOURCE_MANIFEST")" = "$BASE_COMMIT"
          test "$(jq -r '.deployment_state' "$SOURCE_MANIFEST")" = "not-authorised"
          test "$(jq -r '.usage_context' "$SOURCE_MANIFEST")" = "NON_COMMERCIAL_OPEN_SOURCE"
          test "$(jq -r '.source_licence' "$SOURCE_MANIFEST")" = "Open Government Licence v3.0"
          test "$(jq -r '.repository_boundary.successor_foreign_repository_access' "$SOURCE_MANIFEST")" = false
          echo "source_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"

  validate:
    needs: source-boundary
    runs-on: ubuntu-latest
    timeout-minutes: 10
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
        with:
          ref: ${{ needs.source-boundary.outputs.source_sha }}
          persist-credentials: false
      - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
        with:
          python-version: "3.12"
      - name: Install the pinned Parquet verifier
        run: python -m pip install --disable-pip-version-check --no-cache-dir duckdb==1.3.2
      - name: Compile the successor source
        run: python -m py_compile build/python/202608271634-normalise-companies-candidate.py tests/test_202608271634_candidate_semantics.py
      - name: Run deterministic semantics, codec and divergence fixtures
        run: python tests/test_202608271634_candidate_semantics.py

  normalise:
    needs: [source-boundary, validate]
    runs-on: ubuntu-latest
    timeout-minutes: 30
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
        with:
          ref: ${{ needs.source-boundary.outputs.source_sha }}
          fetch-depth: 1
          persist-credentials: false
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
        with:
          repository: ${{ github.repository }}
          ref: candidate/202608271547
          path: work/parent
          fetch-depth: 2
          persist-credentials: false
      - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
        with:
          python-version: "3.12"
      - name: Install the pinned Parquet verifier
        run: python -m pip install --disable-pip-version-check --no-cache-dir duckdb==1.3.2
      - id: parent
        name: Freeze the same-repository parent candidate
        shell: bash
        run: |
          set -euo pipefail
          parent_commit="$(git -C work/parent rev-parse HEAD)"
          test "$(git -C work/parent rev-parse HEAD^)" = "$BASE_COMMIT"
          git -C work/parent diff --name-only "$BASE_COMMIT" "$parent_commit" | sort > /tmp/parent-files
          test -s /tmp/parent-files
          while IFS= read -r path; do
            case "$path" in
              data/candidates/202608271547/*) ;;
              *) echo "Parent candidate escaped its immutable path: $path" >&2; exit 1 ;;
            esac
          done < /tmp/parent-files
          test -f work/parent/data/candidates/202608271547/manifest-v1.json
          test ! -e data/current
          echo "commit=$parent_commit" >> "$GITHUB_OUTPUT"
      - name: Build the semantics overlay twice
        run: |
          python build/python/202608271634-normalise-companies-candidate.py \
            --normalise \
            --parent work/parent/data/candidates/202608271547 \
            --output work/overlay-a \
            --parent-commit "${{ steps.parent.outputs.commit }}" \
            --source-manifest manifests/202608271547-bounded-companies-house-candidate.json
          python build/python/202608271634-normalise-companies-candidate.py \
            --normalise \
            --parent work/parent/data/candidates/202608271547 \
            --output work/overlay-b \
            --parent-commit "${{ steps.parent.outputs.commit }}" \
            --source-manifest manifests/202608271547-bounded-companies-house-candidate.json
          diff -qr work/overlay-a work/overlay-b
      - name: Independently verify the quarantined overlay
        run: |
          python build/python/202608271634-normalise-companies-candidate.py \
            --verify \
            --parent work/parent/data/candidates/202608271547 \
            --input work/overlay-a \
            --parent-commit "${{ steps.parent.outputs.commit }}" \
            --source-manifest manifests/202608271547-bounded-companies-house-candidate.json \
            --report work/overlay-verification.json
          test "$(jq -r '.deployment_state' work/overlay-a/manifest-v1.json)" = not-authorised
          test "$(jq -r '.promotion_eligible' work/overlay-a/manifest-v1.json)" = false
          test "$(jq -r '.usage_context' work/overlay-a/manifest-v1.json)" = NON_COMMERCIAL_OPEN_SOURCE
          test "$(jq -r '.source_licence' work/overlay-a/manifest-v1.json)" = "Open Government Licence v3.0"
          test "$(jq -r '.data_discipline | has("licensing_posture")' work/overlay-a/manifest-v1.json)" = false
          test "$(jq -r '.data_law.compression_codecs == ["ZSTD"]' work/overlay-a/verification-v1.json)" = true
          test "$(jq -r '.data_law.rows == .data_law.distinct_keys' work/overlay-a/verification-v1.json)" = true
          test "$(jq -r '.data_law.null_keys' work/overlay-a/verification-v1.json)" -eq 0
          test "$(jq -r '.data_law.duplicate_key_groups' work/overlay-a/verification-v1.json)" -eq 0
          test "$(jq -r '.data_law.json_record_universe_sha256 == .data_law.parquet_record_universe_sha256' work/overlay-a/verification-v1.json)" = true
          test ! -e data/current
      - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
        with:
          name: companies-candidate-semantics-202608271634
          path: |
            work/overlay-a/
            work/overlay-verification.json
          if-no-files-found: error
          retention-days: 1

  publish-candidate-branch:
    needs: [source-boundary, normalise]
    runs-on: ubuntu-latest
    timeout-minutes: 10
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
        with:
          ref: ${{ needs.source-boundary.outputs.source_sha }}
          fetch-depth: 1
      - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
        with:
          name: companies-candidate-semantics-202608271634
          path: staged
      - name: Commit only the immutable semantics overlay
        shell: bash
        run: |
          set -euo pipefail
          test "$(git rev-parse HEAD)" = "${{ needs.source-boundary.outputs.source_sha }}"
          test ! -e data/current
          if git ls-remote --exit-code --heads origin "refs/heads/candidate/$GENERATION" >/dev/null 2>&1; then
            echo "Immutable candidate branch already exists" >&2
            exit 1
          fi
          mkdir -p "data/candidates/$GENERATION"
          cp -R staged/overlay-a/. "data/candidates/$GENERATION/"
          git add "data/candidates/$GENERATION"
          test "$(git diff --cached --name-only | wc -l)" -eq 2
          while IFS= read -r path; do
            case "$path" in
              data/candidates/202608271634/*) ;;
              *) echo "Semantics overlay escaped its candidate path: $path" >&2; exit 1 ;;
            esac
          done < <(git diff --cached --name-only)
          git config user.name "github-actions[bot]"
          git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
          git commit -m "data: quarantine Companies semantics $GENERATION"
          git push origin "HEAD:refs/heads/candidate/$GENERATION"

Bounded Companies House Candidate

A configuration file in the workflow history folder that reads the Renewable Energy Planning Database (REPD) register. Runs on push.

automationcompanies / .github/workflow-history/202608272155-bounded-companies-house-candidate.yml · lines 1–423 of 423 · version 2026-08-27 21:55 · Not reached from any entry point (candidate for review)

What it does
It loads the REPD register. Side effects: uses storage (browser storage, DuckDB or Parquet).
Why it exists in the grid workflow
Domain terms in the code: the REPD register.
Inputs & outputs
In: JSON file manifest-v2.json; DuckDB queries.
What it achieves
Runs Test Bounded Companies House (`tests/test_202608271507_bounded_companies_house.py`), Test Document Ceiling (`tests/test_202608272016_document_ceiling.py`) and `tests/test_202608272035_company_identity_and_grains.py`.
Why it matters
No other file in the estate was found to import it.
Application
companies · .github/workflow-history · configuration
Uses
Test Sharded Cartridges (workflow run), Test Bounded Companies House (workflow run), Test Document Ceiling (workflow run), Test Company Identity and Grains (workflow run)
Used by
none found
Produces
none declared
Defines here
202608272155 Bounded Companies House Candidate
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
companies@1371da4d0166eef13f98fc3847c5bb1e38e8f571 .github/workflow-history/202608272155-bounded-companies-house-candidate.yml:1-423 · blob ee797d12327f8df2d969453dcd6b055c550fb268 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: ingest · effects: storage · domain stage: unknown · users: none · canonical: unreached_review
name: 202608272155 Bounded Companies House Candidate

on:
  push:
    branches: [main]
    paths:
      - .github/workflows/202608272155-bounded-companies-house-candidate.yml
      - build/python/202608272155-freeze-companies-house-plan.py
      - build/python/202608272155-download-planned-archive.py
      - build/python/202608272155-extract-bounded-accounts.py
      - build/python/202608272155-verify-companies-house-candidate.py
      - tests/test_202608272155_sharded_cartridges.py
      - manifests/202608272155-bounded-companies-house-candidate.json

concurrency:
  group: companies-house-candidate-202608272155
  cancel-in-progress: false

env:
  GENERATION: "202608272155"
  BASE_COMMIT: "edc8d5d08ca6e224af0a907af90d0ed253d1c60d"
  PIPELINENEWS_COMMIT: "35f35ada161223fb3ee19e525664ee7f17df1ddd"
  FIXED_GENERATED_AT: "2026-08-27T21:55:00Z"
  SOURCE_MANIFEST: manifests/202608272155-bounded-companies-house-candidate.json

jobs:
  source-boundary:
    runs-on: ubuntu-latest
    timeout-minutes: 5
    permissions:
      contents: read
    outputs:
      source_sha: ${{ steps.boundary.outputs.source_sha }}
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
        with:
          ref: ${{ github.sha }}
          fetch-depth: 2
          persist-credentials: false
      - id: boundary
        name: Prove the exact direct-parent push-main source closure
        shell: bash
        run: |
          set -euo pipefail
          test "$GITHUB_EVENT_NAME" = push
          test "$GITHUB_REF" = refs/heads/main
          test "$(git rev-parse HEAD)" = "$GITHUB_SHA"
          test "$(git rev-list --parents -n 1 HEAD | wc -w)" -eq 2
          test "$(git rev-parse HEAD^)" = "$BASE_COMMIT"
          git diff --name-only "$BASE_COMMIT" HEAD | sort > /tmp/actual-files
          jq -r '.source_files[].path' "$SOURCE_MANIFEST" | sort > /tmp/expected-files
          diff -u /tmp/expected-files /tmp/actual-files
          test "$(wc -l < /tmp/actual-files)" -eq 7
          while IFS=$'\t' read -r expected path; do
            if [ "$expected" = SELF ]; then
              test "$path" = "$SOURCE_MANIFEST"
            else
              test "$(sha256sum "$path" | cut -d' ' -f1)" = "$expected"
            fi
          done < <(jq -r '[.source_files[],.dependencies[]] | .[] | [.sha256,.path] | @tsv' "$SOURCE_MANIFEST")
          test "$(jq -r '.generation' "$SOURCE_MANIFEST")" = "$GENERATION"
          test "$(jq -r '.base_commit' "$SOURCE_MANIFEST")" = "$BASE_COMMIT"
          test "$(jq -r '.deployment_state' "$SOURCE_MANIFEST")" = not-authorised
          test "$(jq -r '.usage_context' "$SOURCE_MANIFEST")" = NON_COMMERCIAL_OPEN_SOURCE
          test "$(jq -r '.source_rights_are_distinct_from_usage_context' "$SOURCE_MANIFEST")" = true
          test "$(jq -r '.runtime_sources.repd.commit' "$SOURCE_MANIFEST")" = "$PIPELINENEWS_COMMIT"
          test "$(jq -r '.publication.promotion_eligible' "$SOURCE_MANIFEST")" = false
          echo "source_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"

  validate:
    needs: source-boundary
    runs-on: ubuntu-latest
    timeout-minutes: 10
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
        with:
          ref: ${{ needs.source-boundary.outputs.source_sha }}
          persist-credentials: false
      - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
        with:
          python-version: "3.12"
      - name: Install the pinned analytical verifier
        run: python -m pip install --disable-pip-version-check --no-cache-dir duckdb==1.3.2
      - name: Compile the exact source closure
        run: python -m py_compile build/python/202608272155-*.py tests/test_202608272155_sharded_cartridges.py
      - name: Run inherited and successor contracts
        run: |
          python tests/test_202608271507_bounded_companies_house.py
          python tests/test_202608272016_document_ceiling.py
          python tests/test_202608272035_company_identity_and_grains.py
          python tests/test_202608272120_company_identity_and_grains.py
          python tests/test_202608272155_sharded_cartridges.py

  plan:
    needs: [source-boundary, validate]
    runs-on: ubuntu-latest
    timeout-minutes: 10
    permissions:
      contents: read
    outputs:
      accounts: ${{ steps.matrix.outputs.accounts }}
      basic_index: ${{ steps.matrix.outputs.basic_index }}
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
        with:
          ref: ${{ needs.source-boundary.outputs.source_sha }}
          persist-credentials: false
      - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
        with:
          python-version: "3.12"
      - name: Re-probe the four source-pinned official archives
        run: |
          python build/python/202608272155-freeze-companies-house-plan.py \
            --output work/plan.json \
            --rest-evidence work/rest-evidence.json
      - id: matrix
        shell: bash
        run: |
          set -euo pipefail
          echo "accounts=$(jq -c '[.files | to_entries[] | select(.value.kind == "accounts") | {index:.key,filename:.value.filename}]' work/plan.json)" >> "$GITHUB_OUTPUT"
          echo "basic_index=$(jq -r '.files | to_entries[] | select(.value.kind == "basic") | .key' work/plan.json)" >> "$GITHUB_OUTPUT"
          test "$(jq '[.files[] | select(.kind == "accounts")] | length' work/plan.json)" -eq 3
          test "$(jq '[.files[] | select(.kind == "basic")] | length' work/plan.json)" -eq 1
          test "$(jq -r '.total_bytes' work/plan.json)" -eq 7046921879
          test "$(jq -r '.planned_at' work/plan.json)" = "$FIXED_GENERATED_AT"
          test "$(sha256sum work/plan.json | cut -d' ' -f1)" = 4451ed5da8cc2f9246f2e6cc06f120faec8efeb8e19c3bac3919975073e7025e
          test "$(sha256sum work/rest-evidence.json | cut -d' ' -f1)" = a6f6334f4d878644183cd2261caa258a16c8bbdd9f5bf547b75cfc44b77dac6f
      - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
        with:
          name: companies-plan-202608272155-${{ github.run_id }}
          path: |
            work/plan.json
            work/rest-evidence.json
          if-no-files-found: error
          overwrite: true
          retention-days: 7

  accounts-month:
    needs: [source-boundary, plan]
    strategy:
      fail-fast: false
      max-parallel: 3
      matrix:
        archive: ${{ fromJson(needs.plan.outputs.accounts) }}
    runs-on: ubuntu-latest
    timeout-minutes: 180
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
        with:
          ref: ${{ needs.source-boundary.outputs.source_sha }}
          persist-credentials: false
      - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
        with:
          python-version: "3.12"
      - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
        with:
          name: companies-plan-202608272155-${{ github.run_id }}
          path: work
      - name: Redownload one exact planned archive
        run: |
          python build/python/202608272155-download-planned-archive.py \
            --plan work/plan.json \
            --index "${{ matrix.archive.index }}" \
            --output work/raw \
            --receipt "work/receipt-${{ matrix.archive.index }}.json"
      - name: Re-extract twice with the full company-number domain
        shell: bash
        run: |
          set -euo pipefail
          archive="$(find work/raw -maxdepth 1 -type f -name '*.zip' -print -quit)"
          test -n "$archive"
          python build/python/202608272155-extract-bounded-accounts.py --input "$archive" --output "work/accounts-${{ matrix.archive.index }}-a.ndjson" --report "work/extraction-${{ matrix.archive.index }}-a.json"
          python build/python/202608272155-extract-bounded-accounts.py --input "$archive" --output "work/accounts-${{ matrix.archive.index }}-b.ndjson" --report "work/extraction-${{ matrix.archive.index }}-b.json"
          cmp "work/accounts-${{ matrix.archive.index }}-a.ndjson" "work/accounts-${{ matrix.archive.index }}-b.ndjson"
          cmp "work/extraction-${{ matrix.archive.index }}-a.json" "work/extraction-${{ matrix.archive.index }}-b.json"
          mv "work/accounts-${{ matrix.archive.index }}-a.ndjson" "work/accounts-${{ matrix.archive.index }}.ndjson"
          mv "work/extraction-${{ matrix.archive.index }}-a.json" "work/extraction-${{ matrix.archive.index }}.json"
          rm -f "work/accounts-${{ matrix.archive.index }}-b.ndjson" "work/extraction-${{ matrix.archive.index }}-b.json"
      - name: Exclude raw archives from transport
        run: |
          test "$(find work/raw -type f -name '*.zip' | wc -l)" -eq 1
          find work/raw -type f -name '*.zip' -delete
          test "$(find work/raw -type f | wc -l)" -eq 0
      - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
        with:
          name: accounts-202608272155-${{ github.run_id }}-${{ matrix.archive.index }}
          path: |
            work/accounts-${{ matrix.archive.index }}.ndjson
            work/receipt-${{ matrix.archive.index }}.json
            work/extraction-${{ matrix.archive.index }}.json
          if-no-files-found: error
          overwrite: true
          retention-days: 7

  compose:
    needs: [source-boundary, plan, accounts-month]
    runs-on: ubuntu-latest
    timeout-minutes: 180
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
        with:
          ref: ${{ needs.source-boundary.outputs.source_sha }}
          persist-credentials: false
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
        with:
          repository: Ventusltd/pipelinenews
          ref: ${{ env.PIPELINENEWS_COMMIT }}
          path: work/repd-source
          sparse-checkout: |
            /data/projects/
            /data/manifests/202608261927-build-manifest-v9-1.json
          sparse-checkout-cone-mode: false
          persist-credentials: false
      - name: Prove the read-only REPD runtime source
        shell: bash
        run: |
          set -euo pipefail
          test "$(git -C work/repd-source rev-parse HEAD)" = "$PIPELINENEWS_COMMIT"
          test "$(sha256sum work/repd-source/data/manifests/202608261927-build-manifest-v9-1.json | cut -d' ' -f1)" = 67976a1bbcaf383ed7121b13060db3b864db9ce33dfc721a88b59c8ca8b8e06c
          test "$(jq -r '.source_dataset' work/repd-source/data/manifests/202608261927-build-manifest-v9-1.json)" = "DESNZ Renewable Energy Planning Database Q2 2026"
          {
            printf '%s\n' data/manifests/202608261927-build-manifest-v9-1.json
            for index in {01..16}; do
              printf 'data/projects/202608261927-project-partition-v9-1-%s.json\n' "$index"
            done
          } | sort > /tmp/expected-repd-files
          find work/repd-source -path 'work/repd-source/.git' -prune -o -type f -printf '%P\n' | sort > /tmp/actual-repd-files
          diff -u /tmp/expected-repd-files /tmp/actual-repd-files
          test -z "$(git -C work/repd-source status --short)"
      - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
        with:
          python-version: "3.12"
      - name: Install the pinned Parquet and DuckDB engine
        run: python -m pip install --disable-pip-version-check --no-cache-dir duckdb==1.3.2
      - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
        with:
          name: companies-plan-202608272155-${{ github.run_id }}
          path: work/plan
      - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
        with:
          pattern: accounts-202608272155-${{ github.run_id }}-*
          path: work/months
          merge-multiple: true
      - name: Merge the fixed re-extraction once
        run: python build/python/202608262245-merge-accounts.py --input work/months --output work/accounts-latest.ndjson
      - name: Redownload and validate the exact basic snapshot
        shell: bash
        run: |
          set -euo pipefail
          python build/python/202608272155-download-planned-archive.py --plan work/plan/plan.json --index "${{ needs.plan.outputs.basic_index }}" --output work/basic/raw --receipt "work/months/receipt-${{ needs.plan.outputs.basic_index }}.json"
          archive="$(find work/basic/raw -maxdepth 1 -type f -name '*.zip' -print -quit)"
          test -n "$archive"
          python build/python/202608272155-extract-bounded-accounts.py --kind basic --input "$archive" --report work/months/basic-validation.json
      - name: Compile twice from the identical frozen closure
        run: |
          python build/python/202608262245-compile-companies-house.py --raw work/basic/raw --accounts work/accounts-latest.ndjson --repd work/repd-source/data/projects --output work/raw-a --stamp "$GENERATION"
          python build/python/202608262245-compile-companies-house.py --raw work/basic/raw --accounts work/accounts-latest.ndjson --repd work/repd-source/data/projects --output work/raw-b --stamp "$GENERATION"
      - name: Seal two deterministic uniformly sharded two-grain candidates
        shell: bash
        run: |
          set +e
          python build/python/202608272155-verify-companies-house-candidate.py --seal --input work/raw-a --output work/candidate-a --plan work/plan/plan.json --receipts work/months --reports work/months --repd work/repd-source/data/projects --basic work/basic/raw --accounts work/accounts-latest.ndjson --rest-evidence work/plan/rest-evidence.json --basic-report work/months/basic-validation.json --s  … [line shortened here: 488 characters; full line on GitHub]
          seal_a=$?
          python build/python/202608272155-verify-companies-house-candidate.py --seal --input work/raw-b --output work/candidate-b --plan work/plan/plan.json --receipts work/months --reports work/months --repd work/repd-source/data/projects --basic work/basic/raw --accounts work/accounts-latest.ndjson --rest-evidence work/plan/rest-evidence.json --basic-report work/months/basic-validation.json --s  … [line shortened here: 488 characters; full line on GitHub]
          seal_b=$?
          diff -qr work/candidate-a work/candidate-b
          tree_diff=$?
          printf 'seal_a=%s\nseal_b=%s\ntree_diff=%s\n' "$seal_a" "$seal_b" "$tree_diff" > work/seal-status.env
          exit 0
      - name: Independently read back both actual landed grains
        shell: bash
        run: |
          set +e
          python build/python/202608272155-verify-companies-house-candidate.py --verify --input work/candidate-a --report work/verification-a.json
          verify_a=$?
          python build/python/202608272155-verify-companies-house-candidate.py --verify --input work/candidate-b --report work/verification-b.json
          verify_b=$?
          cmp work/verification-a.json work/verification-b.json
          verification_diff=$?
          set -euo pipefail
          source work/seal-status.env
          printf 'verify_a=%s\nverify_b=%s\nverification_diff=%s\n' "$verify_a" "$verify_b" "$verification_diff" > work/verification-status.env
          if [ "$seal_a" -ne 0 ] || [ "$seal_b" -ne 0 ] || [ "$tree_diff" -ne 0 ] || [ "$verify_a" -ne 0 ] || [ "$verify_b" -ne 0 ] || [ "$verification_diff" -ne 0 ]; then
            cat work/seal-a.json work/seal-b.json work/verification-a.json work/verification-b.json
            exit 1
          fi
          for candidate in work/candidate-a work/candidate-b; do
            manifest="$candidate/manifest-v2.json"
            test "$(jq -r '.schema' "$manifest")" = companies-house-bounded-candidate-v2
            test "$(jq -r '.inputs.generation_source_commit' "$manifest")" = "${{ needs.source-boundary.outputs.source_sha }}"
            test "$(jq -r '.deployment_state' "$manifest")" = not-authorised
            test "$(jq -r '.promotion_eligible' "$manifest")" = false
            test "$(jq -r '.usage_context' "$manifest")" = NON_COMMERCIAL_OPEN_SOURCE
            test "$(jq -r '.source_rights_are_distinct_from_usage_context' "$manifest")" = true
            test "$(jq -r '.source_licences.repd.licence.name' "$manifest")" = "Open Government Licence v3.0"
            test "$(jq -r '.data_discipline.foreign_repository_files_committed' "$manifest")" = false
            test "$(jq -r '.data_discipline.foreign_data_materialised' "$manifest")" = true
            test "$(jq -r '.candidate_outputs.logical_json_cartridges' "$manifest")" -eq 5
            test "$(jq -r '.candidate_outputs.shard_target_bytes' "$manifest")" -eq 64000000
            test "$(jq -r '.candidate_outputs.maximum_published_file_bytes' "$manifest")" -eq 90000000
            test "$(jq -r '.candidate_outputs.maximum_candidate_total_bytes' "$manifest")" -eq 200000000
            test "$(jq -r '.analytical_dataset.compression_codecs == ["ZSTD"]' "$manifest")" = true
            test "$(jq -r '.analytical_dataset.rows == .analytical_dataset.distinct_keys' "$manifest")" = true
            test "$(jq -r '.analytical_dataset.null_keys + .analytical_dataset.duplicate_key_groups + .analytical_dataset.typed_column_mismatches' "$manifest")" -eq 0
            test "$(jq -r '.relationship_dataset.compression_codecs == ["ZSTD"]' "$manifest")" = true
            test "$(jq -r '.relationship_dataset.rows == .relationship_dataset.distinct_keys' "$manifest")" = true
            test "$(jq -r '.relationship_dataset.null_keys + .relationship_dataset.duplicate_key_groups + .relationship_dataset.typed_column_mismatches' "$manifest")" -eq 0
            test "$(jq -c '.relationship_dataset.declared_key' "$manifest")" = '["company_number","repd_ref","match_type"]'
            test -z "$(find "$candidate" -type l -print -quit)"
            test -z "$(find "$candidate" -type f -size +90000000c -print -quit)"
            test "$(find "$candidate" -type f -printf '%s\n' | awk '{sum += $1} END {print sum + 0}')" -le 200000000
            jq -e '[.cartridges[] | .shards[] | select(.bytes > 64000000 or .bytes > 90000000)] | length == 0' "$manifest"
          done
          test ! -e data/current
      - name: Retain a structured quarantine failure without publishing candidate bytes
        if: failure()
        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
        with:
          name: companies-quarantine-202608272155-${{ github.run_id }}
          path: |
            work/seal-a.json
            work/seal-b.json
            work/verification-a.json
            work/verification-b.json
            work/seal-status.env
            work/verification-status.env
          if-no-files-found: error
          overwrite: true
          retention-days: 7
      - name: Remove every raw archive before artifact publication
        run: |
          find work -type f -name '*.zip' -delete
          test "$(find work -type f -name '*.zip' | wc -l)" -eq 0
      - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
        with:
          name: companies-candidate-202608272155-${{ github.run_id }}
          path: |
            work/candidate-a/
            work/verification-a.json
            work/verification-b.json
          if-no-files-found: error
          overwrite: true
          retention-days: 7

  publish-candidate-branch:
    needs: [source-boundary, compose]
    runs-on: ubuntu-latest
    timeout-minutes: 10
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
        with:
          ref: ${{ needs.source-boundary.outputs.source_sha }}
          fetch-depth: 1
      - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
        with:
          name: companies-candidate-202608272155-${{ github.run_id }}
          path: staged
      - name: Atomically create or verify the immutable candidate branch
        shell: bash
        run: |
          set -euo pipefail
          test "$(git rev-parse HEAD)" = "${{ needs.source-boundary.outputs.source_sha }}"
          test ! -e data/current
          staged_candidate=staged/candidate-a
          staged_manifest="$staged_candidate/manifest-v2.json"
          test -f "$staged_manifest"
          test -z "$(find "$staged_candidate" -type l -print -quit)"
          {
            printf '%s\n' manifest-v2.json
            jq -r '.cartridges[] | .shards[].path' "$staged_manifest"
            jq -r '.evidence[].path' "$staged_manifest"
            jq -r '.analytical_dataset.file.path,.relationship_dataset.file.path,.audits[].path' "$staged_manifest"
          } | sort -u > /tmp/expected-candidate-files
          find "$staged_candidate" -type f -printf '%P\n' | sort > /tmp/actual-candidate-files
          diff -u /tmp/expected-candidate-files /tmp/actual-candidate-files
          test -z "$(find "$staged_candidate" -type f -size +90000000c -print -quit)"
          test "$(find "$staged_candidate" -type f -printf '%s\n' | awk '{sum += $1} END {print sum + 0}')" -le 200000000
          jq -e '.deployment_state == "not-authorised" and .promotion_eligible == false and .publication.stable_path_must_change == false and .publication.pages_must_change == false' "$staged_manifest"
          mkdir -p "data/candidates/$GENERATION"
          cp -R "$staged_candidate/." "data/candidates/$GENERATION/"
          git add "data/candidates/$GENERATION"
          test -n "$(git diff --cached --name-only)"
          staged_total=0
          while IFS= read -r path; do
            case "$path" in
              data/candidates/202608272155/*) ;;
              *) echo "Candidate commit escaped its immutable path: $path" >&2; exit 1 ;;
            esac
            mode="$(git ls-files -s -- "$path" | awk '{print $1}')"
            test "$mode" = 100644
            blob_size="$(git cat-file -s ":$path")"
            test "$blob_size" -le 90000000
            staged_total=$((staged_total + blob_size))
          done < <(git diff --cached --name-only)
          test "$staged_total" -le 200000000
          if git diff --cached --name-only | grep -Eq '(^|/)current/|pages|releases'; then
            echo "Candidate commit attempted a stable or deployment mutation" >&2
            exit 1
          fi
          git config user.name "github-actions[bot]"
          git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
          GIT_AUTHOR_DATE="$FIXED_GENERATED_AT" GIT_COMMITTER_DATE="$FIXED_GENERATED_AT" \
            git commit -m "data: quarantine Companies candidate $GENERATION"
          candidate_commit="$(git rev-parse HEAD)"
          candidate_ref="refs/heads/candidate/$GENERATION"
          if git push --force-with-lease="$candidate_ref:" origin "HEAD:$candidate_ref"; then
            exit 0
          fi
          git fetch --no-tags origin "$candidate_ref"
          if [ "$(git rev-parse FETCH_HEAD)" = "$candidate_commit" ]; then
            echo "Exact immutable candidate commit already exists"
            exit 0
          fi
          echo "Immutable candidate branch collision" >&2
          exit 1