You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 35cb910
Browse filesBrowse the repository at this point in the historyBrowse files
Merge pull request #255 from LibraVault/fix/agent-pipeline-workflow-drift-oidc
Reviewed as principal dev lead: this is dev-agent's own correctly-scoped fix for #254, consistent across all three pipeline workflows, CI green. The classify-risk step never labeled this PR (separate minor bug, not investigating further right now) — merging directly since it's a sensitive path anyway.
if ! git diff --quiet origin/dev -- .github/workflows/dev-agent.yml; then
262
+
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
263
+
echo "drift=true" >> "$GITHUB_OUTPUT"
264
+
else
265
+
echo "drift=false" >> "$GITHUB_OUTPUT"
266
+
fi
267
+
241
268
- name: Mint pipeline App token
242
269
# Moved ahead of "Run dev agent" (rather than only after it, as
243
270
# qa-agent.yml/principal-review.yml do) — the agent itself needs
# Deliberately the default GITHUB_TOKEN as the primary $GH_TOKEN,
@@ -423,6 +450,19 @@ jobs:
423
450
# the agent creates one).
424
451
PR_NUMBER="${{ steps.guard.outputs.pr_number }}"
425
452
453
+
# Workflow-file drift (see the "Check for workflow-file drift"
454
+
# step above) — the agent step was skipped outright, so there's
455
+
# nothing to trust either way. Same reasoning as the crash
456
+
# check right below: route to a human instead of leaving this
457
+
# stuck on status:in-progress forever with no actionable signal.
458
+
if [ "${{ steps.workflow-drift.outputs.drift }}" = "true" ]; then
459
+
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 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."
463
+
exit 0
464
+
fi
465
+
426
466
# The agent step itself failed/crashed (max-turns exhausted,
427
467
# error) — don't advance a PR we can't trust is actually fixed
428
468
# into QA. Route to a human instead of silently proceeding, and
- name: Check for workflow-file drift (GitHub OIDC self-check)
142
+
# GitHub refuses to mint the OIDC token claude-code-action needs
143
+
# (this job requests id-token: write) when a pull_request-triggered
144
+
# workflow's own file on the PR branch doesn't byte-match the copy
145
+
# on the base branch — its own anti-tampering check, to stop a PR
146
+
# from modifying the very workflow that's about to run with that
147
+
# trust. "Run principal review agent" below still reports success
148
+
# when this happens (the token exchange fails inside the action,
149
+
# not the step), so without this check the run silently does
150
+
# nothing and the PR is left stuck on status:needs-review with no
151
+
# actionable signal. See issue #254 for the full diagnosis (a live
152
+
# hit on PR #234, 14 commits behind dev, this exact pattern hitting
153
+
# qa-agent.yml).
154
+
id: workflow-drift
142
155
if: steps.guard.outputs.skip != 'true'
156
+
run: |
157
+
set -euo pipefail
158
+
git fetch origin dev
159
+
if ! git diff --quiet origin/dev -- .github/workflows/principal-review.yml; then
160
+
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
# Workflow-file drift (see the "Check for workflow-file drift"
256
+
# step above) — the agent step was skipped outright, so there's
257
+
# no principal-verdict.txt to look for. Same reasoning as the
258
+
# crash branch below: this is a pipeline/tooling failure, not a
259
+
# review verdict, so route to a human directly.
260
+
if [ "${{ steps.workflow-drift.outputs.drift }}" = "true" ]; then
261
+
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 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."
267
+
echo "verdict=drift" >> "$GITHUB_OUTPUT"
268
+
exit 0
269
+
fi
270
+
230
271
# A genuine crash (max-turns exhausted, tool error) is a pipeline
231
272
# failure, not a review verdict — there's no principal-verdict.txt
232
273
# to trust either way, so route straight to a human instead of
- name: Check for workflow-file drift (GitHub OIDC self-check)
120
+
# GitHub refuses to mint the OIDC token claude-code-action needs
121
+
# (this job requests id-token: write) when a pull_request-triggered
122
+
# workflow's own file on the PR branch doesn't byte-match the copy
123
+
# on the base branch — its own anti-tampering check, to stop a PR
124
+
# from modifying the very workflow that's about to run with that
125
+
# trust. "Run QA agent" below still reports success when this
126
+
# happens (the token exchange fails inside the action, not the
127
+
# step), so without this check the run silently does nothing and
128
+
# falls through to the generic "produced neither a verdict file nor
129
+
# a verdict comment line" message below — misleading, since QA
130
+
# never actually ran. See issue #254 for the full diagnosis (a live
131
+
# hit on PR #234, 14 commits behind dev, this exact file among the
132
+
# 7 that had diverged).
133
+
id: workflow-drift
134
+
if: steps.guard.outputs.skip != 'true'
135
+
run: |
136
+
set -euo pipefail
137
+
git fetch origin dev
138
+
if ! git diff --quiet origin/dev -- .github/workflows/qa-agent.yml; then
139
+
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
140
+
echo "drift=true" >> "$GITHUB_OUTPUT"
141
+
else
142
+
echo "drift=false" >> "$GITHUB_OUTPUT"
143
+
fi
144
+
119
145
- name: Record run start time
120
146
# Timestamp boundary for the comment-verdict fallback below — lets
121
147
# "Advance PR" tell this run's own PR comment apart from a stale one
# Workflow-file drift (see the "Check for workflow-file drift"
263
+
# step above) — the agent step was skipped outright, so there's
264
+
# no verdict of any kind to look for. Same reasoning as the crash
265
+
# branch below: this is a pipeline/tooling failure, not a QA
266
+
# finding, so route to a human without burning dev-agent's
267
+
# automated retry budget.
268
+
if [ "${{ steps.workflow-drift.outputs.drift }}" = "true" ]; then
269
+
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 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."
273
+
exit 0
274
+
fi
275
+
236
276
# A genuine crash (max-turns exhausted, tool error) is a pipeline
237
277
# failure, not a QA finding — there's nothing for dev-agent's
238
278
# automated retry to act on, so route straight to a human instead
0 commit comments