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
42 changes: 41 additions & 1 deletion .github/workflows/dev-agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,33 @@ jobs:
gh pr checkout "${{ steps.guard.outputs.pr_number }}"
rm -f dev-agent-pr-number.txt

- name: Check for workflow-file drift (GitHub OIDC self-check, revise mode only)
# GitHub refuses to mint the OIDC token claude-code-action needs
# (this job requests id-token: write) when a pull_request-triggered
# workflow's own file on the PR branch doesn't byte-match the copy
# on the base branch — its own anti-tampering check, to stop a PR
# from modifying the very workflow that's about to run with that
# trust. "Run dev agent" below still reports success when this
# happens (the token exchange fails inside the action, not the
# step), so without this check a revise-mode run silently does
# nothing and the PR is left stuck on status:in-progress with no
# actionable signal. Triage mode doesn't need this: it checks out
# the default branch itself (no PR branch yet), so its own copy of
# this file is always dev's own. See issue #254 for the full
# diagnosis (a live hit on PR #234, 14 commits behind dev, with
# this exact file among the 7 that had diverged).
id: workflow-drift
if: steps.guard.outputs.skip != 'true' && steps.guard.outputs.mode == 'revise'
run: |
set -euo pipefail
git fetch origin dev
if ! git diff --quiet origin/dev -- .github/workflows/dev-agent.yml; then
echo "This workflow's own file (.github/workflows/dev-agent.yml) differs between this PR branch and dev — the OIDC token exchange below would be refused. Skipping the agent step." >&2
echo "drift=true" >> "$GITHUB_OUTPUT"
else
echo "drift=false" >> "$GITHUB_OUTPUT"
fi

- name: Mint pipeline App token
# Moved ahead of "Run dev agent" (rather than only after it, as
# qa-agent.yml/principal-review.yml do) — the agent itself needs
Expand All @@ -257,7 +284,7 @@ jobs:
private-key: ${{ secrets.PIPELINE_APP_PRIVATE_KEY }}

- name: Run dev agent
if: steps.guard.outputs.skip != 'true'
if: steps.guard.outputs.skip != 'true' && steps.workflow-drift.outputs.drift != 'true'
id: agent
env:
# Deliberately the default GITHUB_TOKEN as the primary $GH_TOKEN,
Expand Down Expand Up @@ -423,6 +450,19 @@ jobs:
# the agent creates one).
PR_NUMBER="${{ steps.guard.outputs.pr_number }}"

# Workflow-file drift (see the "Check for workflow-file drift"
# step above) — the agent step was skipped outright, so there's
# nothing to trust either way. Same reasoning as the crash
# check right below: route to a human instead of leaving this
# stuck on status:in-progress forever with no actionable signal.
if [ "${{ steps.workflow-drift.outputs.drift }}" = "true" ]; then
echo "PR #$PR_NUMBER's branch has workflow-file drift from dev — GitHub's OIDC anti-tampering check would have silently no-opped the dev agent step, so it was skipped instead. Routing to a human." >&2
gh pr edit "$PR_NUMBER" --remove-label status:in-progress || true
gh pr edit "$PR_NUMBER" --add-label status:needs-info
gh pr comment "$PR_NUMBER" --body "This PR's branch is stale relative to \`dev\` — specifically, \`.github/workflows/dev-agent.yml\` differs between this branch and \`dev\`. GitHub Actions refuses to mint the OIDC token \`claude-code-action\` needs when a \`pull_request\`-triggered, \`id-token: write\` workflow's own file doesn't byte-match the base branch (its own anti-tampering check), so the dev agent step was skipped rather than silently no-opping (see issue #254 for the full diagnosis). Rebase/merge \`dev\` into this branch and re-add \`status:in-progress\` to retry."
exit 0
fi

# The agent step itself failed/crashed (max-turns exhausted,
# error) — don't advance a PR we can't trust is actually fixed
# into QA. Route to a human instead of silently proceeding, and
Expand Down
43 changes: 42 additions & 1 deletion .github/workflows/principal-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,33 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr checkout "${{ steps.guard.outputs.pr_number }}"

- name: Run principal review agent
- name: Check for workflow-file drift (GitHub OIDC self-check)
# GitHub refuses to mint the OIDC token claude-code-action needs
# (this job requests id-token: write) when a pull_request-triggered
# workflow's own file on the PR branch doesn't byte-match the copy
# on the base branch — its own anti-tampering check, to stop a PR
# from modifying the very workflow that's about to run with that
# trust. "Run principal review agent" below still reports success
# when this happens (the token exchange fails inside the action,
# not the step), so without this check the run silently does
# nothing and the PR is left stuck on status:needs-review with no
# actionable signal. See issue #254 for the full diagnosis (a live
# hit on PR #234, 14 commits behind dev, this exact pattern hitting
# qa-agent.yml).
id: workflow-drift
if: steps.guard.outputs.skip != 'true'
run: |
set -euo pipefail
git fetch origin dev
if ! git diff --quiet origin/dev -- .github/workflows/principal-review.yml; then
echo "This workflow's own file (.github/workflows/principal-review.yml) differs between this PR branch and dev — the OIDC token exchange below would be refused. Skipping the agent step." >&2
echo "drift=true" >> "$GITHUB_OUTPUT"
else
echo "drift=false" >> "$GITHUB_OUTPUT"
fi

- name: Run principal review agent
if: steps.guard.outputs.skip != 'true' && steps.workflow-drift.outputs.drift != 'true'
id: agent
# Without this, a crash here (e.g. exhausting --max-turns) fails
# the whole job and skips every step after it, including "Advance
Expand Down Expand Up @@ -227,6 +252,22 @@ jobs:
PR_NUMBER="${{ steps.guard.outputs.pr_number }}"
RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"

# Workflow-file drift (see the "Check for workflow-file drift"
# step above) — the agent step was skipped outright, so there's
# no principal-verdict.txt to look for. Same reasoning as the
# crash branch below: this is a pipeline/tooling failure, not a
# review verdict, so route to a human directly.
if [ "${{ steps.workflow-drift.outputs.drift }}" = "true" ]; then
echo "PR #$PR_NUMBER's branch has workflow-file drift from dev — GitHub's OIDC anti-tampering check would have silently no-opped the principal review agent step, so it was skipped instead. Routing to a human." >&2
gh pr edit "$PR_NUMBER" --remove-label status:needs-review || true
gh pr edit "$PR_NUMBER" --remove-label status:approved-auto-merge || true
gh pr edit "$PR_NUMBER" --remove-label status:needs-human-merge || true
gh pr edit "$PR_NUMBER" --add-label status:needs-info
gh pr comment "$PR_NUMBER" --body "This PR's branch is stale relative to \`dev\` — specifically, \`.github/workflows/principal-review.yml\` differs between this branch and \`dev\`. GitHub Actions refuses to mint the OIDC token \`claude-code-action\` needs when a \`pull_request\`-triggered, \`id-token: write\` workflow's own file doesn't byte-match the base branch (its own anti-tampering check), so the principal review agent step was skipped rather than silently no-opping (see issue #254 for the full diagnosis). Rebase/merge \`dev\` into this branch and re-add \`status:needs-review\` to retry."
echo "verdict=drift" >> "$GITHUB_OUTPUT"
exit 0
fi

# A genuine crash (max-turns exhausted, tool error) is a pipeline
# failure, not a review verdict — there's no principal-verdict.txt
# to trust either way, so route straight to a human instead of
Expand Down
42 changes: 41 additions & 1 deletion .github/workflows/qa-agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,32 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr checkout "${{ steps.guard.outputs.pr_number }}"

- name: Check for workflow-file drift (GitHub OIDC self-check)
# GitHub refuses to mint the OIDC token claude-code-action needs
# (this job requests id-token: write) when a pull_request-triggered
# workflow's own file on the PR branch doesn't byte-match the copy
# on the base branch — its own anti-tampering check, to stop a PR
# from modifying the very workflow that's about to run with that
# trust. "Run QA agent" below still reports success when this
# happens (the token exchange fails inside the action, not the
# step), so without this check the run silently does nothing and
# falls through to the generic "produced neither a verdict file nor
# a verdict comment line" message below — misleading, since QA
# never actually ran. See issue #254 for the full diagnosis (a live
# hit on PR #234, 14 commits behind dev, this exact file among the
# 7 that had diverged).
id: workflow-drift
if: steps.guard.outputs.skip != 'true'
run: |
set -euo pipefail
git fetch origin dev
if ! git diff --quiet origin/dev -- .github/workflows/qa-agent.yml; then
echo "This workflow's own file (.github/workflows/qa-agent.yml) differs between this PR branch and dev — the OIDC token exchange below would be refused. Skipping the agent step." >&2
echo "drift=true" >> "$GITHUB_OUTPUT"
else
echo "drift=false" >> "$GITHUB_OUTPUT"
fi

- name: Record run start time
# Timestamp boundary for the comment-verdict fallback below — lets
# "Advance PR" tell this run's own PR comment apart from a stale one
Expand All @@ -125,7 +151,7 @@ jobs:
run: echo "started_at=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$GITHUB_OUTPUT"

- name: Run QA agent
if: steps.guard.outputs.skip != 'true'
if: steps.guard.outputs.skip != 'true' && steps.workflow-drift.outputs.drift != 'true'
id: agent
# Without this, a hard crash (max-turns exhausted, tool error) skips
# every step below by GitHub Actions' default job-status semantics —
Expand Down Expand Up @@ -233,6 +259,20 @@ jobs:
PR_NUMBER="${{ steps.guard.outputs.pr_number }}"
RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"

# Workflow-file drift (see the "Check for workflow-file drift"
# step above) — the agent step was skipped outright, so there's
# no verdict of any kind to look for. Same reasoning as the crash
# branch below: this is a pipeline/tooling failure, not a QA
# finding, so route to a human without burning dev-agent's
# automated retry budget.
if [ "${{ steps.workflow-drift.outputs.drift }}" = "true" ]; then
echo "PR #$PR_NUMBER's branch has workflow-file drift from dev — GitHub's OIDC anti-tampering check would have silently no-opped the QA agent step, so it was skipped instead. Routing to a human." >&2
gh pr edit "$PR_NUMBER" --remove-label status:needs-qa || true
GH_TOKEN="$APP_GH_TOKEN" gh pr edit "$PR_NUMBER" --add-label status:needs-info
gh pr comment "$PR_NUMBER" --body "This PR's branch is stale relative to \`dev\` — specifically, \`.github/workflows/qa-agent.yml\` differs between this branch and \`dev\`. GitHub Actions refuses to mint the OIDC token \`claude-code-action\` needs when a \`pull_request\`-triggered, \`id-token: write\` workflow's own file doesn't byte-match the base branch (its own anti-tampering check), so the QA agent step was skipped rather than silently no-opping (see issue #254 for the full diagnosis). Rebase/merge \`dev\` into this branch and re-add \`status:needs-qa\` to retry."
exit 0
fi

# A genuine crash (max-turns exhausted, tool error) is a pipeline
# failure, not a QA finding — there's nothing for dev-agent's
# automated retry to act on, so route straight to a human instead
Expand Down
Loading