diff --git a/scripts/check_agent_review_workflow.py b/scripts/check_agent_review_workflow.py index dea3058..6f52cb6 100644 --- a/scripts/check_agent_review_workflow.py +++ b/scripts/check_agent_review_workflow.py @@ -9,7 +9,10 @@ # Existing caller-policy contract: approve a source/shape on main, migrate, # then remove the predecessor approval. Never execute proposed target code. MAX_WORKFLOW_BYTES = 65536 -APPROVED_REVIEWER_SHAS = ("856e474c1697f3897ccaa156f083e0b9504196e0",) +APPROVED_REVIEWER_SHAS = ( + "856e474c1697f3897ccaa156f083e0b9504196e0", + "ca0e322521d6d0f8b651546a7d935a93026d71f7", +) EXPECTED_CONTRACTS = ( "name: Review caller contract\n\non:\n pull_request:\n types: [opened, synchronize, reopened]\n paths:\n - '.github/workflows/agent-review.yaml'\n - '.github/agent-review.toml'\n - '.github/workflows/review-caller-contract.yaml'\n - 'scripts/check_agent_review_workflow.py'\n pull_request_target:\n types: [opened, synchronize, reopened]\n paths:\n - '.github/workflows/agent-review.yaml'\n - '.github/agent-review.toml'\n - '.github/workflows/review-caller-contract.yaml'\n - 'scripts/check_agent_review_workflow.py'\n push:\n branches: [main]\n paths:\n - '.github/workflows/agent-review.yaml'\n - '.github/agent-review.toml'\n - '.github/workflows/review-caller-contract.yaml'\n - 'scripts/check_agent_review_workflow.py'\n\npermissions:\n contents: read\n\njobs:\n bootstrap:\n if: github.event_name == 'pull_request'\n runs-on: ubuntu-latest\n timeout-minutes: 5\n steps:\n - name: Check out proposed policy for unprivileged installation tests\n uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7\n with:\n persist-credentials: false\n - name: Check the proposed installation without provider secrets\n run: python3 -I scripts/check_agent_review_workflow.py --root . --output \"$GITHUB_OUTPUT\"\n contract:\n if: github.event_name != 'pull_request'\n runs-on: ubuntu-latest\n timeout-minutes: 5\n steps:\n - name: Check out the caller validator\n uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7\n with:\n repository: ${{ github.repository }}\n ref: ${{ github.sha }}\n path: trusted-validator\n persist-credentials: false\n sparse-checkout: scripts/check_agent_review_workflow.py\n sparse-checkout-cone-mode: false\n - name: Check out proposed policy as data\n uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7\n with:\n repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}\n ref: ${{ github.event.pull_request.head.sha || github.sha }}\n allow-unsafe-pr-checkout: true\n path: proposed\n persist-credentials: false\n sparse-checkout: |\n .github/workflows/agent-review.yaml\n .github/agent-review.toml\n .github/workflows/review-caller-contract.yaml\n sparse-checkout-cone-mode: false\n - name: Check approved source and checking workflow before loading shared code\n id: policy\n run: python3 -I trusted-validator/scripts/check_agent_review_workflow.py --root proposed --output \"$GITHUB_OUTPUT\"\n - name: Check out the approved immutable shared validator\n uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7\n with:\n repository: pipelab-org/agent-review\n ref: ${{ steps.policy.outputs.reviewer_sha }}\n path: trusted-reviewer\n persist-credentials: false\n sparse-checkout: scripts/agent_review_contract.py\n sparse-checkout-cone-mode: false\n - name: Validate caller and profile with approved shared code\n env:\n REVIEW_SOURCE_SHA: ${{ steps.policy.outputs.reviewer_sha }}\n run: |\n python3 -I - <<'PYCODE'\n import os\n import pathlib\n import runpy\n\n contract = runpy.run_path(\"trusted-reviewer/scripts/agent_review_contract.py\")\n root = pathlib.Path(\"proposed\")\n contract[\"validate_caller\"](\n root / \".github/workflows/agent-review.yaml\", os.environ[\"REVIEW_SOURCE_SHA\"],\n )\n contract[\"load_profile\"](root / \".github/agent-review.toml\")\n print(\"Review caller and profile contract passed\")\n PYCODE\n", ) @@ -52,7 +55,7 @@ def validate_policy(root): caller, re.MULTILINE, ) - if len(pins) != 1 or pins[0] not in APPROVED_REVIEWER_SHAS: + if len(set(pins)) != 1 or pins[0] not in APPROVED_REVIEWER_SHAS: raise ValueError("approve the immutable reviewer source on main before migrating") contract = read_workflow(root / ".github/workflows/review-caller-contract.yaml") if contract not in EXPECTED_CONTRACTS: