From 854bc8a42e1e42b782c71ba37ee6a341ae20c392 Mon Sep 17 00:00:00 2001 From: Alex Wang Date: Tue, 6 Oct 2026 00:28:27 +0000 Subject: [PATCH 1/5] ci: probe runner account assumptions on CodeBuild --- .../codebuild-runner-account-probe.yml | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 .github/workflows/codebuild-runner-account-probe.yml diff --git a/.github/workflows/codebuild-runner-account-probe.yml b/.github/workflows/codebuild-runner-account-probe.yml new file mode 100644 index 000000000..0506c6e40 --- /dev/null +++ b/.github/workflows/codebuild-runner-account-probe.yml @@ -0,0 +1,98 @@ +name: CodeBuild runner account probe + +# Temporary probe: records which account the CodeBuild-hosted runner executes +# as, whether the GitHub-hosted `runner` account and /home/runner exist, where +# GITHUB_WORKSPACE lives, and what a freshly created unprivileged user can see +# (sudoers env_keep behaviour, credential endpoint, root process environ). +# Run side by side on the CodeBuild project default and on ubuntu-latest. +# Not for merge. + +on: + workflow_dispatch: + pull_request: + paths: + - .github/workflows/codebuild-runner-account-probe.yml + +permissions: {} + +env: + PROBE_SCRIPT: | + set -u + section() { printf '\n== %s\n' "$1"; } + + section "invoking account" + id + echo "HOME=$HOME" + echo "whoami=$(whoami)" + + section "runner account / home" + getent passwd runner || echo "no 'runner' user in passwd" + getent group runner || echo "no 'runner' group" + ls -ld /home/runner 2>&1 || true + + section "workspace location and parent chain" + echo "GITHUB_WORKSPACE=$GITHUB_WORKSPACE" + echo "RUNNER_TEMP=${RUNNER_TEMP:-unset}" + echo "RUNNER_TOOL_CACHE=${RUNNER_TOOL_CACHE:-unset}" + namei -l "$GITHUB_WORKSPACE" || true + + section "sudo" + if sudo -n true 2>/dev/null; then echo "passwordless sudo: yes"; else echo "passwordless sudo: no"; fi + command -v visudo >/dev/null && echo "visudo: present" || echo "visudo: absent" + command -v setfacl >/dev/null && echo "setfacl: present" || echo "setfacl: absent" + + section "ambient AWS credential plumbing (names only, no values)" + env | awk -F= '/^AWS_CONTAINER_CREDENTIALS|^AWS_CONTAINER_AUTHORIZATION|^ECS_CONTAINER_METADATA|^AWS_EXECUTION_ENV|^CODEBUILD_/ {print $1}' | sort || true + curl -s -m 3 -o /dev/null -w 'cred endpoint 169.254.170.2: http %{http_code}\n' http://169.254.170.2/ || echo "cred endpoint 169.254.170.2: unreachable" + curl -s -m 3 -o /dev/null -w 'imds 169.254.169.254: http %{http_code}\n' http://169.254.169.254/latest/meta-data/ || echo "imds 169.254.169.254: unreachable" + + if ! sudo -n true 2>/dev/null; then + echo; echo "no sudo: skipping unprivileged-user experiments"; exit 0 + fi + + section "sudoers env_keep: does 'Defaults:runner' match the invoker?" + export PROBE_KEEP_RUNNER=via-runner-rule PROBE_KEEP_SELF=via-self-rule + sudo useradd -m probe-user + me="$(id -un)" + printf 'Defaults:runner env_keep += "PROBE_KEEP_RUNNER"\nDefaults:%s env_keep += "PROBE_KEEP_SELF"\n' "$me" | sudo tee /etc/sudoers.d/probe >/dev/null + sudo chmod 0440 /etc/sudoers.d/probe + sudo visudo -cf /etc/sudoers.d/probe || true + sudo -u probe-user env | grep -E '^PROBE_KEEP_RUNNER=' || echo "PROBE_KEEP_RUNNER: dropped (Defaults:runner did not match invoker '$me')" + sudo -u probe-user env | grep -E '^PROBE_KEEP_SELF=' || echo "PROBE_KEEP_SELF: dropped" + + section "as probe-user: what can it reach?" + sudo -u probe-user env GITHUB_WORKSPACE="$GITHUB_WORKSPACE" bash -c ' + id + env | awk -F= "/^AWS_CONTAINER|^AWS_ACCESS|^AWS_SECRET|^AWS_SESSION/ {print \$1}" | sort + env | grep -q "^AWS_CONTAINER" || echo "no AWS_CONTAINER_* vars inherited" + curl -s -m 3 -o /dev/null -w "cred endpoint 169.254.170.2: http %{http_code}\n" http://169.254.170.2/ || echo "cred endpoint 169.254.170.2: unreachable" + curl -s -m 3 -o /dev/null -w "imds 169.254.169.254: http %{http_code}\n" http://169.254.169.254/latest/meta-data/ || echo "imds 169.254.169.254: unreachable" + if cat /proc/1/environ >/dev/null 2>&1; then echo "CAN read /proc/1/environ"; else echo "cannot read /proc/1/environ"; fi + ppid=$(ps -o ppid= -p $$ | tr -d " ") + if cat /proc/$ppid/environ >/dev/null 2>&1; then echo "CAN read parent (sudo) environ"; else echo "cannot read parent (sudo) environ"; fi + if test -x "$GITHUB_WORKSPACE"; then echo "workspace traversable: yes"; else echo "workspace traversable: no"; fi + if test -r "$GITHUB_WORKSPACE"; then echo "workspace readable: yes"; else echo "workspace readable: no"; fi + if test -x /home/runner 2>/dev/null; then echo "/home/runner traversable: yes"; else echo "/home/runner traversable: no or absent"; fi + ' + + section "chown to the literal runner account (what the scripts do today)" + tmp="$(mktemp -d)" + if sudo chown runner:probe-user "$tmp" 2>&1; then echo "chown runner:probe-user: ok"; else echo "chown runner:probe-user: FAILED"; fi + if sudo install -d -o runner -g probe-user "$tmp/x" 2>&1; then echo "install -o runner: ok"; else echo "install -o runner: FAILED"; fi + if sudo chown "$me:probe-user" "$tmp" 2>&1; then echo "chown $me:probe-user: ok"; else echo "chown $me:probe-user: FAILED"; fi + +jobs: + codebuild-default: + name: codebuild (project default) + runs-on: + - codebuild-github-actions-runner-${{ github.run_id }}-${{ github.run_attempt }} + steps: + - name: Probe runner account + run: bash -c "$PROBE_SCRIPT" + + github-hosted: + name: ubuntu-latest (control) + runs-on: ubuntu-latest + steps: + - name: Probe runner account + run: bash -c "$PROBE_SCRIPT" From 54993605ac26f42226f391814de6bf68b6f1adb5 Mon Sep 17 00:00:00 2001 From: Alex Wang Date: Tue, 6 Oct 2026 20:38:50 +0000 Subject: [PATCH 2/5] ci: probe docker build and run on the CodeBuild runner Adds a step that mirrors the Docker usage of llrt-cloud-test.js (busybox-based linux/amd64 build, then run) on both the CodeBuild project default and ubuntu-latest. The real LLRT workflow cannot be dispatched from this branch because the test role's OIDC trust only covers pull_request, main and tag subjects. --- .../codebuild-runner-account-probe.yml | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/.github/workflows/codebuild-runner-account-probe.yml b/.github/workflows/codebuild-runner-account-probe.yml index 0506c6e40..b8b945eee 100644 --- a/.github/workflows/codebuild-runner-account-probe.yml +++ b/.github/workflows/codebuild-runner-account-probe.yml @@ -81,6 +81,41 @@ env: if sudo install -d -o runner -g probe-user "$tmp/x" 2>&1; then echo "install -o runner: ok"; else echo "install -o runner: FAILED"; fi if sudo chown "$me:probe-user" "$tmp" 2>&1; then echo "chown $me:probe-user: ok"; else echo "chown $me:probe-user: FAILED"; fi + # Mirrors what llrt-cloud-test.js does with Docker (build a busybox-based + # image for linux/amd64, then the image would be pushed with credentials from + # `aws ecr get-login-password`). The push needs the test role, which the OIDC + # trust policy only grants to pull_request / main / tag subjects, so the probe + # stops at build + run and only checks the aws CLI is present. + DOCKER_PROBE_SCRIPT: | + set -u + section() { printf '\n== %s\n' "$1"; } + + section "docker client / daemon" + command -v docker || { echo "docker: absent"; exit 1; } + docker version --format 'client {{.Client.Version}} server {{.Server.Version}}' || { echo "docker daemon: unreachable"; exit 1; } + docker info --format 'driver={{.Driver}} cgroup={{.CgroupDriver}} rootless={{.SecurityOptions}}' || true + docker buildx version 2>/dev/null || echo "buildx: absent" + + section "aws cli (used for ecr get-login-password / sts in the real test)" + command -v aws && aws --version || echo "aws cli: absent" + + section "build a linux/amd64 busybox image the way the llrt test does" + work="$(mktemp -d)" + printf 'echo hello from probe\n' > "$work/handler.sh" + cat > "$work/Dockerfile" <<'EOF' + FROM --platform=linux/amd64 busybox + WORKDIR /var/task/ + COPY handler.sh ./ + RUN chmod +x /var/task/handler.sh + CMD [ "sh", "/var/task/handler.sh" ] + EOF + time docker build --platform linux/amd64 -t codebuild-probe:1 "$work" + + section "run the built image" + docker run --rm codebuild-probe:1 + docker run --rm codebuild-probe:1 uname -m + docker image inspect codebuild-probe:1 --format 'arch={{.Architecture}} os={{.Os}} size={{.Size}}' + jobs: codebuild-default: name: codebuild (project default) @@ -89,6 +124,8 @@ jobs: steps: - name: Probe runner account run: bash -c "$PROBE_SCRIPT" + - name: Probe docker + run: bash -c "$DOCKER_PROBE_SCRIPT" github-hosted: name: ubuntu-latest (control) @@ -96,3 +133,5 @@ jobs: steps: - name: Probe runner account run: bash -c "$PROBE_SCRIPT" + - name: Probe docker + run: bash -c "$DOCKER_PROBE_SCRIPT" From ef44903515c2a9c00b2c329bf9f2e0f9d0530b88 Mon Sep 17 00:00:00 2001 From: Alex Wang Date: Tue, 6 Oct 2026 22:18:59 +0000 Subject: [PATCH 3/5] ci: probe the CI toolkit model-user scripts on the CodeBuild runner Runs prepare_ai_review_user.sh (claude-review, codex-review), prepare_ai_summary_user.sh and prepare_codex_implementation_user.sh from aws-durable-execution-ci@d901b2f as the real job account on the CodeBuild project default (root) and on ubuntu-latest (runner), then mirrors each workflow's env -i launch with a stub binary to show exactly which variables reach the model process. --- .../workflows/ci-toolkit-scripts-probe.yml | 214 ++++++++++++++++++ 1 file changed, 214 insertions(+) create mode 100644 .github/workflows/ci-toolkit-scripts-probe.yml diff --git a/.github/workflows/ci-toolkit-scripts-probe.yml b/.github/workflows/ci-toolkit-scripts-probe.yml new file mode 100644 index 000000000..4859d0c7d --- /dev/null +++ b/.github/workflows/ci-toolkit-scripts-probe.yml @@ -0,0 +1,214 @@ +name: CI toolkit scripts probe + +# Temporary probe: runs the model-user preparation scripts from +# aws/aws-durable-execution-ci (ci/runs-on-input branch) as the real job +# account on the CodeBuild project default (root) and on ubuntu-latest +# (runner), then mirrors each workflow's `env -i` launch with a stub binary +# to show which variables reach the model process. One job per script, +# because each script re-owns the workspace for its own user. Not for merge. + +on: + workflow_dispatch: + pull_request: + paths: + - .github/workflows/ci-toolkit-scripts-probe.yml + +permissions: + contents: read + +env: + TOOLKIT_REPO: aws/aws-durable-execution-ci + TOOLKIT_REF: d901b2f1a50731f46bb791b7cae6cbe7f56ae917 + # Fake credentials: values only have to survive the launch intact. + AWS_ACCESS_KEY_ID: PROBE-ACCESS-KEY + AWS_SECRET_ACCESS_KEY: PROBE-SECRET + AWS_SESSION_TOKEN: PROBE-SESSION + AWS_REGION: us-west-2 + AWS_DEFAULT_REGION: us-west-2 + PROBE_LEAK: must-not-reach-the-model + + PROBE_SCRIPT: | + set -euo pipefail + section() { printf '\n== %s\n' "$1"; } + expect_has() { if grep -qx "$1" "$2"; then echo "ok $1"; else echo "FAIL missing: $1"; exit 1; fi; } + expect_not() { if grep -q "$1" "$2"; then echo "FAIL leaked: $1"; exit 1; else echo "ok absent: $1"; fi; } + + section "job account" + id; echo "HOME=$HOME"; echo "GITHUB_WORKSPACE=$GITHUB_WORKSPACE" + + case "$PROBE_TARGET" in + claude-review) + section "prepare_ai_review_user.sh claude-review" + # Stub the pinned action layout run_claude_isolated.sh expects. + action="$GITHUB_WORKSPACE/.stub-claude-action" + install -d "$action/node_modules/@anthropic-ai/claude-agent-sdk-linux-x64" "$action/bin" + printf '#!/bin/sh\nenv | sort\n' > "$action/node_modules/@anthropic-ai/claude-agent-sdk-linux-x64/claude" + printf '#!/bin/sh\nexit 0\n' > "$action/bin/bun" + chmod 755 "$action/node_modules/@anthropic-ai/claude-agent-sdk-linux-x64/claude" "$action/bin/bun" + time bash .ai-review-toolkit/scripts/prepare_ai_review_user.sh claude-review + sudo -u claude-review test -r "$GITHUB_WORKSPACE/README.md" && echo "ok claude-review reads workspace README" + sudo -u claude-review test -d /home/claude-review/.claude && echo "ok private .claude dir" + sudo -u claude-review test -d /home/claude-review/tmp && echo "ok private tmp dir" + if sudo -u claude-review test -r "$HOME"; then echo "note claude-review CAN read job HOME $HOME"; else echo "ok claude-review cannot read job HOME $HOME"; fi + getfacl -p "$(dirname "$GITHUB_WORKSPACE")" 2>/dev/null | grep -E '^user:claude-review' || echo "note no ACL needed on $(dirname "$GITHUB_WORKSPACE")" + + section "run_claude_isolated.sh with stub claude (what the model sees)" + export GITHUB_ACTION_PATH="$action" + export CLAUDE_CODE_USE_BEDROCK=1 CLAUDE_CODE_ENTRYPOINT=probe + out="$(mktemp)" + bash .ai-review-toolkit/scripts/run_claude_isolated.sh > "$out" + expect_has "AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID" "$out" + expect_has "AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN" "$out" + expect_has "CLAUDE_CODE_USE_BEDROCK=1" "$out" + expect_has "HOME=/home/claude-review" "$out" + expect_has "USER=claude-review" "$out" + expect_has "AWS_EC2_METADATA_DISABLED=true" "$out" + expect_not "PROBE_LEAK" "$out" + expect_not "AWS_BEARER_TOKEN_BEDROCK" "$out" + expect_not "GITHUB_" "$out" + expect_not "AWS_CONTAINER" "$out" + echo "model env var count: $(wc -l < "$out")" + ;; + + codex-review) + section "prepare_ai_review_user.sh codex-review" + time bash .ai-review-toolkit/scripts/prepare_ai_review_user.sh codex-review + sudo -u codex-review test -r "$GITHUB_WORKSPACE/README.md" && echo "ok codex-review reads workspace README" + sudo -u codex-review test -d /home/codex-review/.codex && echo "ok private .codex dir" + if sudo -u codex-review test -w "$GITHUB_WORKSPACE/README.md"; then echo "FAIL codex-review can write workspace"; exit 1; else echo "ok workspace read-only for codex-review"; fi + + section "codex-review.yml launch with /usr/bin/env as the model" + out="$(mktemp)" + sudo -u codex-review -- env -i \ + AWS_ACCESS_KEY_ID="$AWS_ACCESS_KEY_ID" \ + AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY" \ + AWS_SESSION_TOKEN="$AWS_SESSION_TOKEN" \ + AWS_REGION="$AWS_REGION" \ + AWS_DEFAULT_REGION="$AWS_DEFAULT_REGION" \ + AWS_EC2_METADATA_DISABLED=true \ + CODEX_HOME=/home/codex-review/.codex \ + HOME=/home/codex-review \ + LANG=C.UTF-8 \ + LOGNAME=codex-review \ + PATH="$PATH" \ + SHELL=/bin/bash \ + USER=codex-review \ + /usr/bin/timeout --signal=TERM --kill-after=30s 20m \ + /usr/bin/env | sort > "$out" + expect_has "AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID" "$out" + expect_has "CODEX_HOME=/home/codex-review/.codex" "$out" + expect_has "USER=codex-review" "$out" + expect_not "PROBE_LEAK" "$out" + expect_not "GITHUB_" "$out" + expect_not "AWS_CONTAINER" "$out" + echo "model env var count: $(wc -l < "$out")" + ;; + + summary) + section "prepare_ai_summary_user.sh" + time bash .notification-toolkit/scripts/prepare_ai_summary_user.sh + if sudo -u codex-summary test -r "$GITHUB_WORKSPACE/README.md"; then echo "FAIL codex-summary can read workspace"; exit 1; else echo "ok workspace hidden from codex-summary"; fi + sudo -u codex-summary test -d /home/codex-summary/.codex && echo "ok private .codex dir" + echo "userns_clone=$(sysctl -n kernel.unprivileged_userns_clone 2>/dev/null || echo n/a) apparmor_restrict=$(sysctl -n kernel.apparmor_restrict_unprivileged_userns 2>/dev/null || echo n/a)" + + section "notify.yml launch with /usr/bin/env as the model" + out="$(mktemp)" + sudo -u codex-summary -- env -i \ + AWS_ACCESS_KEY_ID="$AWS_ACCESS_KEY_ID" \ + AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY" \ + AWS_SESSION_TOKEN="$AWS_SESSION_TOKEN" \ + AWS_REGION="$AWS_REGION" \ + AWS_DEFAULT_REGION="$AWS_DEFAULT_REGION" \ + AWS_EC2_METADATA_DISABLED=true \ + CODEX_HOME=/home/codex-summary/.codex \ + HOME=/home/codex-summary \ + LANG=C.UTF-8 \ + LOGNAME=codex-summary \ + PATH="$PATH" \ + SHELL=/bin/bash \ + USER=codex-summary \ + /usr/bin/timeout --signal=TERM --kill-after=15s 2m \ + /usr/bin/env | sort > "$out" + expect_has "AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID" "$out" + expect_has "USER=codex-summary" "$out" + expect_not "PROBE_LEAK" "$out" + expect_not "GITHUB_" "$out" + echo "model env var count: $(wc -l < "$out")" + ;; + + implementation) + section "prepare_codex_implementation_user.sh" + time bash .ai-review-toolkit/scripts/prepare_codex_implementation_user.sh + sudo -u codex-implement test -r "$GITHUB_WORKSPACE/.git/HEAD" && echo "ok codex-implement reads .git/HEAD" + sudo -u codex-implement env HOME=/home/codex-implement GIT_OPTIONAL_LOCKS=0 git -C "$GITHUB_WORKSPACE" rev-parse --short HEAD && echo "ok git rev-parse as codex-implement" + sudo -u codex-implement touch "$GITHUB_WORKSPACE/probe-write" && echo "ok worktree writable" + if sudo -u codex-implement touch "$GITHUB_WORKSPACE/.git/probe-write" 2>/dev/null; then echo "FAIL .git writable by codex-implement"; exit 1; else echo "ok .git read-only for codex-implement"; fi + stat -c 'workspace mode=%a owner=%U:%G' "$GITHUB_WORKSPACE" + stat -c '.git mode=%a owner=%U:%G' "$GITHUB_WORKSPACE/.git" + ;; + + *) echo "unknown PROBE_TARGET=$PROBE_TARGET"; exit 2 ;; + esac + echo; echo "PROBE OK: $PROBE_TARGET" + +jobs: + codebuild: + name: codebuild / ${{ matrix.target }} + runs-on: + - codebuild-github-actions-runner-${{ github.run_id }}-${{ github.run_attempt }} + strategy: + fail-fast: false + matrix: + target: [claude-review, codex-review, summary, implementation] + steps: + - uses: actions/checkout@v7 + - name: Check out CI toolkit (review/implementation layout) + if: matrix.target != 'summary' + uses: actions/checkout@v7 + with: + repository: ${{ env.TOOLKIT_REPO }} + ref: ${{ env.TOOLKIT_REF }} + path: .ai-review-toolkit + sparse-checkout: scripts + - name: Check out CI toolkit (notification layout) + if: matrix.target == 'summary' + uses: actions/checkout@v7 + with: + repository: ${{ env.TOOLKIT_REPO }} + ref: ${{ env.TOOLKIT_REF }} + path: .notification-toolkit + sparse-checkout: scripts + - name: Run ${{ matrix.target }} preparation as the job account + env: + PROBE_TARGET: ${{ matrix.target }} + run: bash -c "$PROBE_SCRIPT" + + github-hosted: + name: ubuntu-latest / ${{ matrix.target }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + target: [claude-review, codex-review, summary, implementation] + steps: + - uses: actions/checkout@v7 + - name: Check out CI toolkit (review/implementation layout) + if: matrix.target != 'summary' + uses: actions/checkout@v7 + with: + repository: ${{ env.TOOLKIT_REPO }} + ref: ${{ env.TOOLKIT_REF }} + path: .ai-review-toolkit + sparse-checkout: scripts + - name: Check out CI toolkit (notification layout) + if: matrix.target == 'summary' + uses: actions/checkout@v7 + with: + repository: ${{ env.TOOLKIT_REPO }} + ref: ${{ env.TOOLKIT_REF }} + path: .notification-toolkit + sparse-checkout: scripts + - name: Run ${{ matrix.target }} preparation as the job account + env: + PROBE_TARGET: ${{ matrix.target }} + run: bash -c "$PROBE_SCRIPT" From 6ff663bfa743cf502e9206976085297eada94fb0 Mon Sep 17 00:00:00 2001 From: Alex Wang Date: Tue, 6 Oct 2026 22:37:20 +0000 Subject: [PATCH 4/5] ci: run the real Codex review on the CodeBuild runner --- .../codebuild-codex-review-probe.yml | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/codebuild-codex-review-probe.yml diff --git a/.github/workflows/codebuild-codex-review-probe.yml b/.github/workflows/codebuild-codex-review-probe.yml new file mode 100644 index 000000000..06d369c72 --- /dev/null +++ b/.github/workflows/codebuild-codex-review-probe.yml @@ -0,0 +1,30 @@ +name: CodeBuild Codex review probe + +# Temporary probe: runs the real Codex review (aws/aws-durable-execution-ci +# codex-review.yml from the ci/runs-on-input branch) on the CodeBuild project +# default runner. The normal entry workflow only accepts pull_request_target / +# issue_comment events, which read the default branch's workflow files, so a +# pull request cannot exercise the CodeBuild path through it; this caller +# bypasses the entry and feeds the inputs resolve_review would compute. The +# review it produces lands on this PR. Not for merge. + +on: + pull_request: + paths: + - .github/workflows/codebuild-codex-review-probe.yml + +permissions: {} + +jobs: + codex-review: + permissions: + contents: write + id-token: write + pull-requests: write + uses: aws/aws-durable-execution-ci/.github/workflows/codex-review.yml@d901b2f1a50731f46bb791b7cae6cbe7f56ae917 + with: + runs-on: codebuild-github-actions-runner-${{ github.run_id }}-${{ github.run_attempt }} + pull-request-number: ${{ format('{0}', github.event.pull_request.number) }} + base-sha: ${{ github.event.pull_request.base.sha }} + head-sha: ${{ github.event.pull_request.head.sha }} + secrets: inherit From d22bc1a89fd8c71b82984b232e6ad51bfc6b7eea Mon Sep 17 00:00:00 2001 From: Alex Wang Date: Tue, 6 Oct 2026 22:44:35 +0000 Subject: [PATCH 5/5] ci: trigger the Codex review probe on push to satisfy the environment branch policy --- .../codebuild-codex-review-probe.yml | 50 ++++++++++++++++--- 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/.github/workflows/codebuild-codex-review-probe.yml b/.github/workflows/codebuild-codex-review-probe.yml index 06d369c72..9d60ea503 100644 --- a/.github/workflows/codebuild-codex-review-probe.yml +++ b/.github/workflows/codebuild-codex-review-probe.yml @@ -5,18 +5,56 @@ name: CodeBuild Codex review probe # default runner. The normal entry workflow only accepts pull_request_target / # issue_comment events, which read the default branch's workflow files, so a # pull request cannot exercise the CodeBuild path through it; this caller -# bypasses the entry and feeds the inputs resolve_review would compute. The -# review it produces lands on this PR. Not for merge. +# bypasses the entry and feeds the inputs resolve_review would compute. +# +# Triggered on push rather than pull_request: the ai-pr-review-runtime +# environment has a branch policy, and pull_request jobs run on the synthetic +# ref refs/pull/N/merge, which can never match one. A push to this branch runs +# on refs/heads/, which the temporary policy entry allows. +# The review it produces lands on PR #968. Not for merge. on: - pull_request: + push: + branches: + - ci/codebuild-runner-account-probe paths: - .github/workflows/codebuild-codex-review-probe.yml permissions: {} +env: + PROBE_PR: "968" + jobs: + resolve: + runs-on: + - codebuild-github-actions-runner-${{ github.run_id }}-${{ github.run_attempt }} + permissions: + pull-requests: read + outputs: + number: ${{ steps.pr.outputs.number }} + base-sha: ${{ steps.pr.outputs.base }} + head-sha: ${{ steps.pr.outputs.head }} + steps: + - id: pr + env: + GH_TOKEN: ${{ github.token }} + run: | + set -euo pipefail + base="$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PROBE_PR}" --jq .base.sha)" + head="$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PROBE_PR}" --jq .head.sha)" + if [[ "$head" != "$GITHUB_SHA" ]]; then + echo "::error::PR #${PROBE_PR} head ${head} is not the pushed commit ${GITHUB_SHA}" + exit 1 + fi + { + echo "number=${PROBE_PR}" + echo "base=${base}" + echo "head=${head}" + } >> "$GITHUB_OUTPUT" + codex-review: + needs: resolve permissions: contents: write id-token: write @@ -24,7 +62,7 @@ jobs: uses: aws/aws-durable-execution-ci/.github/workflows/codex-review.yml@d901b2f1a50731f46bb791b7cae6cbe7f56ae917 with: runs-on: codebuild-github-actions-runner-${{ github.run_id }}-${{ github.run_attempt }} - pull-request-number: ${{ format('{0}', github.event.pull_request.number) }} - base-sha: ${{ github.event.pull_request.base.sha }} - head-sha: ${{ github.event.pull_request.head.sha }} + pull-request-number: ${{ needs.resolve.outputs.number }} + base-sha: ${{ needs.resolve.outputs.base-sha }} + head-sha: ${{ needs.resolve.outputs.head-sha }} secrets: inherit