Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/ai-issue-implementation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ on:
default: false
workflow_call:
inputs:
runs-on:
description: Runner label for every job in this workflow
required: false
type: string
default: ubuntu-latest
issue-number:
description: Optional authorized issue number to implement
required: false
Expand Down Expand Up @@ -93,6 +98,7 @@ jobs:
pull-requests: read
uses: ./.github/workflows/ai-work-item-resolver.yml
with:
runs-on: ${{ inputs['runs-on'] || 'ubuntu-latest' }}
work-scope: implementation
requested-issue-number: ${{ inputs['issue-number'] || '' }}
no-pr-label: >-
Expand All @@ -113,6 +119,7 @@ jobs:
pull-requests: write
uses: ./.github/workflows/codex-issue-worker.yml
with:
runs-on: ${{ inputs['runs-on'] || 'ubuntu-latest' }}
issue-number: ${{ matrix.issue_number }}
pull-request-number: ${{ matrix.pull_request_number }}
address-only: ${{ matrix.address_only }}
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/ai-pr-review-address.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ on:
type: string
workflow_call:
inputs:
runs-on:
description: Runner label for every job in this workflow
required: false
type: string
default: ubuntu-latest
pull-request-number:
description: Optional pull request number with authorized feedback
required: false
Expand Down Expand Up @@ -67,7 +72,7 @@ jobs:
validate-dispatch:
name: Validate manual dispatch ref
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
runs-on: ${{ inputs['runs-on'] || 'ubuntu-latest' }}
timeout-minutes: 5

steps:
Expand Down Expand Up @@ -99,6 +104,7 @@ jobs:
pull-requests: read
uses: ./.github/workflows/ai-work-item-resolver.yml
with:
runs-on: ${{ inputs['runs-on'] || 'ubuntu-latest' }}
work-scope: review
requested-pull-request-number: >-
${{ inputs['pull-request-number'] || '' }}
Expand All @@ -114,7 +120,7 @@ jobs:
github.event.workflow_run.event ==
'pull_request_review_comment' &&
github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
runs-on: ${{ inputs['runs-on'] || 'ubuntu-latest' }}
timeout-minutes: 10
permissions:
actions: read
Expand Down Expand Up @@ -225,6 +231,7 @@ jobs:
pull-requests: write
uses: ./.github/workflows/codex-issue-worker.yml
with:
runs-on: ${{ inputs['runs-on'] || 'ubuntu-latest' }}
issue-number: ${{ matrix.issue_number }}
pull-request-number: ${{ matrix.pull_request_number }}
address-only: ${{ matrix.address_only }}
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/ai-pr-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ on:
types: [created]
workflow_call:
inputs:
runs-on:
description: Runner label for every job in this workflow
required: false
type: string
default: ubuntu-latest
prompt-path:
description: Optional prompt file relative to the caller repository
required: false
Expand Down Expand Up @@ -69,7 +74,7 @@ jobs:
github.event_name == 'issue_comment' &&
github.event.issue.pull_request
)
runs-on: ubuntu-latest
runs-on: ${{ inputs['runs-on'] || 'ubuntu-latest' }}
permissions:
contents: write
pull-requests: write
Expand Down Expand Up @@ -100,7 +105,7 @@ jobs:
contains(github.event.comment.body, '/ai') &&
contains(github.event.comment.body, 'review')
)
runs-on: ubuntu-latest
runs-on: ${{ inputs['runs-on'] || 'ubuntu-latest' }}
permissions:
contents: read
pull-requests: read
Expand Down Expand Up @@ -144,6 +149,7 @@ jobs:
pull-requests: write
uses: ./.github/workflows/claude-review.yml
with:
runs-on: ${{ inputs['runs-on'] || 'ubuntu-latest' }}
pull-request-number: >-
${{ needs.resolve_review.outputs.pull-request-number }}
base-sha: ${{ needs.resolve_review.outputs.base-sha }}
Expand Down Expand Up @@ -171,6 +177,7 @@ jobs:
pull-requests: write
uses: ./.github/workflows/codex-review.yml
with:
runs-on: ${{ inputs['runs-on'] || 'ubuntu-latest' }}
pull-request-number: >-
${{ needs.resolve_review.outputs.pull-request-number }}
base-sha: ${{ needs.resolve_review.outputs.base-sha }}
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/ai-work-item-resolver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ name: AI Work Item Resolver
on:
workflow_call:
inputs:
runs-on:
description: Runner label for every job in this workflow
required: false
type: string
default: ubuntu-latest
work-scope:
description: Resolve issue implementation or PR review work
required: true
Expand Down Expand Up @@ -43,7 +48,7 @@ permissions: {}
jobs:
resolve:
name: Resolve authorized work
runs-on: ubuntu-latest
runs-on: ${{ inputs['runs-on'] || 'ubuntu-latest' }}
timeout-minutes: 10
permissions:
contents: read
Expand Down
23 changes: 8 additions & 15 deletions .github/workflows/claude-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ name: Claude PR Review
on:
workflow_call:
inputs:
runs-on:
description: Runner label for every job in this workflow
required: false
type: string
default: ubuntu-latest
pull-request-number:
description: Pull request number to review
required: true
Expand Down Expand Up @@ -62,7 +67,7 @@ concurrency:
jobs:
generate:
name: Generate Claude review
runs-on: ubuntu-latest
runs-on: ${{ inputs['runs-on'] || 'ubuntu-latest' }}
environment: >-
${{ inputs['environment-name'] || 'ai-pr-review-runtime' }}
timeout-minutes: 30
Expand Down Expand Up @@ -161,19 +166,7 @@ jobs:
} >> "$GITHUB_OUTPUT"

- name: Prepare unprivileged Claude user
run: |
bash .ai-review-toolkit/scripts/prepare_ai_review_user.sh claude-review

# The Claude CLI runs through sudo. Preserve only its Bedrock
# credentials and the action's subprocess-isolation controls.
sudo sh -c \
'printf "%s\n" \
"Defaults:runner env_keep += \"AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN AWS_REGION AWS_DEFAULT_REGION AWS_BEARER_TOKEN_BEDROCK\"" \
"Defaults:runner env_keep += \"ANTHROPIC_BEDROCK_BASE_URL CLAUDE_CODE_USE_BEDROCK CLAUDE_CODE_ENTRYPOINT CLAUDE_CODE_ACTION CLAUDE_CODE_ATTRIBUTION_HEADER\"" \
"Defaults:runner env_keep += \"CLAUDE_CODE_SUBPROCESS_ENV_SCRUB CLAUDE_CODE_SCRIPT_CAPS DETAILED_PERMISSION_MESSAGES\"" \
> /etc/sudoers.d/claude-review-env'
sudo chmod 440 /etc/sudoers.d/claude-review-env
sudo visudo -cf /etc/sudoers.d/claude-review-env
run: bash .ai-review-toolkit/scripts/prepare_ai_review_user.sh claude-review

- name: Configure AWS credentials for Claude
uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0
Expand Down Expand Up @@ -260,7 +253,7 @@ jobs:
post:
name: Post Claude review
needs: generate
runs-on: ubuntu-latest
runs-on: ${{ inputs['runs-on'] || 'ubuntu-latest' }}
timeout-minutes: 10
permissions:
contents: write
Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/codex-issue-worker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ name: Codex Issue Worker
on:
workflow_call:
inputs:
runs-on:
description: Runner label for every job in this workflow
required: false
type: string
default: ubuntu-latest
issue-number:
description: Issue number, or zero for PR-scoped review work
required: true
Expand Down Expand Up @@ -78,7 +83,7 @@ env:
jobs:
reconcile:
name: Reconcile ${{ inputs['work-key'] }}
runs-on: ubuntu-latest
runs-on: ${{ inputs['runs-on'] || 'ubuntu-latest' }}
environment: >-
${{ inputs['environment-name'] || 'ai-pr-review-runtime' }}
timeout-minutes: 140
Expand Down Expand Up @@ -499,12 +504,12 @@ jobs:

sudo install \
-m 600 \
-o runner \
-g runner \
-o "$(id -un)" \
-g "$(id -gn)" \
"$output_file" \
"${RUNNER_TEMP}/codex-implementation-result.json"

sudo chown -R runner:runner "$GITHUB_WORKSPACE"
sudo chown -R "$(id -un):$(id -gn)" "$GITHUB_WORKSPACE"
sudo chmod -R u+rwX,go-rwx "$GITHUB_WORKSPACE"

export AWS_CONTAINER_AUTHORIZATION_TOKEN="$credential_proxy_token"
Expand Down Expand Up @@ -546,7 +551,7 @@ jobs:
if: >-
always() &&
needs.reconcile.result != 'cancelled'
runs-on: ubuntu-latest
runs-on: ${{ inputs['runs-on'] || 'ubuntu-latest' }}
timeout-minutes: 20
permissions:
contents: write
Expand Down
50 changes: 29 additions & 21 deletions .github/workflows/codex-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ name: Codex PR Review
on:
workflow_call:
inputs:
runs-on:
description: Runner label for every job in this workflow
required: false
type: string
default: ubuntu-latest
pull-request-number:
description: Pull request number to review
required: true
Expand Down Expand Up @@ -62,7 +67,7 @@ concurrency:
jobs:
generate:
name: Generate Codex review
runs-on: ubuntu-latest
runs-on: ${{ inputs['runs-on'] || 'ubuntu-latest' }}
environment: >-
${{ inputs['environment-name'] || 'ai-pr-review-runtime' }}
timeout-minutes: 45
Expand Down Expand Up @@ -153,14 +158,6 @@ jobs:
run: |
bash .ai-review-toolkit/scripts/prepare_ai_review_user.sh codex-review

# Codex runs through sudo, so preserve its AWS SDK credential chain.
sudo sh -c \
'printf "%s\n" \
"Defaults:runner env_keep += \"AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN AWS_REGION AWS_DEFAULT_REGION\"" \
> /etc/sudoers.d/codex-review-env'
sudo chmod 440 /etc/sudoers.d/codex-review-env
sudo visudo -cf /etc/sudoers.d/codex-review-env

current_userns="$(
sysctl -n kernel.unprivileged_userns_clone 2>/dev/null || true
)"
Expand Down Expand Up @@ -233,24 +230,35 @@ jobs:
output_schema="${GITHUB_WORKSPACE}/.ai-review-toolkit/.github/prompts/ai-pr-review-schema.json"
trap 'sudo rm -rf "$output_dir"' EXIT

sudo -u codex-review -- sh -c '
: "${AWS_ACCESS_KEY_ID:?AWS_ACCESS_KEY_ID was not preserved by sudo}"
: "${AWS_SECRET_ACCESS_KEY:?AWS_SECRET_ACCESS_KEY was not preserved by sudo}"
: "${AWS_SESSION_TOKEN:?AWS_SESSION_TOKEN was not preserved by sudo}"
: "${AWS_REGION:?AWS_REGION was not preserved by sudo}"
'
for required in AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN AWS_REGION; do
: "${!required:?${required} is not set in the job environment}"
done

review_ready=false
for attempt in 1 2; do
sudo -u codex-review -- rm -f "$output_file"

# The model receives only this allowlist. `env -i` makes that true
# regardless of the runner image's sudo env_reset/env_keep policy.
# Keep enough of the job budget for a complete second attempt.
if sudo -u codex-review -- timeout \
if 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 \
env \
CODEX_HOME=/home/codex-review/.codex \
"$codex_bin" exec \
--skip-git-repo-check \
--cd "$GITHUB_WORKSPACE" \
Expand Down Expand Up @@ -295,8 +303,8 @@ jobs:

sudo install \
-m 600 \
-o runner \
-g runner \
-o "$(id -un)" \
-g "$(id -gn)" \
"$output_file" \
"${RUNNER_TEMP}/codex-review.json"

Expand All @@ -312,7 +320,7 @@ jobs:
post:
name: Post Codex review
needs: generate
runs-on: ubuntu-latest
runs-on: ${{ inputs['runs-on'] || 'ubuntu-latest' }}
timeout-minutes: 10
permissions:
contents: write
Expand Down
Loading
Loading