Skip to content

Commit c8f12ef

Browse files
authored
fix(ci): resume sign-off verifier when it stops without a verdict (#5209)
* fix(ci): resume sign-off verifier when it stops without a verdict - Resume the same Claude session once if it ends without writing the verdict file - Log the agent's stop reason, final message, and permission denials - Fail the Check sign-off job when no verdict is produced * fix(ci): disable workflow commands while printing verifier summary - Agent output can be steered by PR text, so wrap it in ::stop-commands:: with a random token
1 parent df6b5fa commit c8f12ef

1 file changed

Lines changed: 82 additions & 7 deletions

File tree

‎.github/workflows/codeowner-signoff-verify.yml‎

Lines changed: 82 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,19 @@ jobs:
120120
checks: read # Read check-runs on PR commits.
121121
outputs:
122122
verification-succeeded: ${{ steps.outcome.outputs.succeeded }}
123+
env:
124+
VERDICT_PATH: /tmp/codeowner-signoff-verdict.md
125+
VERIFIER_CLAUDE_ARGS: |
126+
--model 'claude-opus-5-5'
127+
--allowedTools "Read,Write,Glob,Grep,WebFetch,mcp__github_ci__*,Bash(gh pr view:*),Bash(gh pr diff:*),Bash(gh api:*),Bash(gh run view:*),Bash(gh run list:*),Bash(gh run download:*),Bash(git log:*),Bash(git show:*),Bash(docker manifest inspect:*),Bash(uv run --project inferencex-e2e --locked python -m infx.workflows.pareto_coverage:*),Bash(uv run --project inferencex-e2e --locked python -m infx.workflows.signoff_facts:*),Bash(uv run --project inferencex-e2e --locked python -m infx.workflows.signoff_validate:*)"
128+
--disallowedTools "Read(//proc/**),Write(//proc/**)"
129+
# claude-code-action hides the transcript, so log only why the agent stopped and what it was denied.
130+
CLAUDE_RUN_SUMMARY_JQ: |
131+
.[] | select(.type == "result")
132+
| "Stop: \(.subtype) after \(.num_turns) turns",
133+
"Final message:", (.result // "(none)"),
134+
"Permission denials (\(.permission_denials | length)):",
135+
(.permission_denials[]? | "- \(.tool_name): \(.tool_input.command // .tool_input.file_path // .tool_input.url // (.tool_input | tostring))")
123136
steps:
124137
- name: Checkout trusted workflow code
125138
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@@ -185,35 +198,97 @@ jobs:
185198
settings: |
186199
{"fastMode": true}
187200
188-
claude_args: |
189-
--model 'claude-opus-5-5'
190-
--allowedTools "Read,Write,Glob,Grep,WebFetch,mcp__github_ci__*,Bash(gh pr view:*),Bash(gh pr diff:*),Bash(gh api:*),Bash(gh run view:*),Bash(gh run list:*),Bash(gh run download:*),Bash(git log:*),Bash(git show:*),Bash(docker manifest inspect:*),Bash(uv run --project inferencex-e2e --locked python -m infx.workflows.pareto_coverage:*),Bash(uv run --project inferencex-e2e --locked python -m infx.workflows.signoff_facts:*),Bash(uv run --project inferencex-e2e --locked python -m infx.workflows.signoff_validate:*)"
191-
--disallowedTools "Read(//proc/**),Write(//proc/**)"
201+
claude_args: ${{ env.VERIFIER_CLAUDE_ARGS }}
192202
prompt: |
193203
Read the file /tmp/codeowner-signoff-verify-prompt.md and follow the
194204
instructions in it exactly — it is your complete task specification,
195205
already rendered with this run's PR number, head SHA, and sign-off
196206
metadata.
197207
208+
- name: Summarize Claude run
209+
if: always() && steps.claude.outputs.execution_file != ''
210+
continue-on-error: true
211+
env:
212+
EXECUTION_FILE: ${{ steps.claude.outputs.execution_file }}
213+
# Agent text can be steered by the PR, so print it with workflow commands disabled.
214+
run: |
215+
token="$(openssl rand -hex 16)"
216+
echo "::stop-commands::$token"
217+
trap 'echo "::$token::"' EXIT
218+
jq -r "$CLAUDE_RUN_SUMMARY_JQ" "$EXECUTION_FILE"
219+
220+
- name: Check for verdict
221+
id: verdict
222+
if: steps.claude.outcome == 'success'
223+
run: |
224+
if [[ -f "$VERDICT_PATH" ]]; then
225+
echo "written=true" >> "$GITHUB_OUTPUT"
226+
fi
227+
228+
# The agent sometimes ends its turn before writing the verdict; resuming keeps its findings.
229+
- name: Resume Claude to write the verdict
230+
id: claude_resume
231+
if: steps.claude.outcome == 'success' && steps.verdict.outputs.written != 'true' && steps.claude.outputs.session_id != ''
232+
uses: anthropics/claude-code-action@9171db3e57d6a3140a37ddc2ba92788584e0ead6 # v1.0.234
233+
env:
234+
GH_TOKEN: ${{ github.token }}
235+
GITHUB_TOKEN: ${{ github.token }}
236+
BASH_DEFAULT_TIMEOUT_MS: "1800000"
237+
BASH_MAX_TIMEOUT_MS: "3600000"
238+
with:
239+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} # zizmor: ignore[secrets-outside-env]
240+
github_token: ${{ github.token }}
241+
path_to_claude_code_executable: ${{ steps.claude_cli.outputs.path }}
242+
track_progress: false
243+
allowed_bots: ''
244+
additional_permissions: |
245+
actions: read
246+
settings: |
247+
{"fastMode": true}
248+
249+
claude_args: |
250+
${{ env.VERIFIER_CLAUDE_ARGS }}
251+
--resume ${{ steps.claude.outputs.session_id }}
252+
prompt: |
253+
You ended your turn without writing /tmp/codeowner-signoff-verdict.md, so no
254+
verdict was published. Finish any checks from
255+
/tmp/codeowner-signoff-verify-prompt.md that you have not completed, then write
256+
the verdict file and run signoff_validate on it as that file's "Verdict and
257+
output" section requires. Do not stop until the file exists and validates.
258+
259+
- name: Summarize resumed Claude run
260+
if: always() && steps.claude_resume.outputs.execution_file != ''
261+
continue-on-error: true
262+
env:
263+
EXECUTION_FILE: ${{ steps.claude_resume.outputs.execution_file }}
264+
run: |
265+
token="$(openssl rand -hex 16)"
266+
echo "::stop-commands::$token"
267+
trap 'echo "::$token::"' EXIT
268+
jq -r "$CLAUDE_RUN_SUMMARY_JQ" "$EXECUTION_FILE"
269+
198270
- name: Record verification outcome
199271
id: outcome
200272
if: always()
201273
env:
202-
CLAUDE_SUCCEEDED: ${{ steps.claude.outcome == 'success' }}
203-
VERDICT_PATH: /tmp/codeowner-signoff-verdict.md
274+
CLAUDE_SUCCEEDED: ${{ steps.claude.outcome == 'success' && steps.claude_resume.outcome != 'failure' }}
204275
run: |
205276
succeeded=false
206277
if [[ "$CLAUDE_SUCCEEDED" == true && -f "$VERDICT_PATH" ]]; then
207278
succeeded=true
208279
fi
209280
echo "succeeded=$succeeded" >> "$GITHUB_OUTPUT"
281+
if [[ "$succeeded" != true ]]; then
282+
echo "::error::Verifier did not write $VERDICT_PATH"
283+
exit 1
284+
fi
210285
211286
- name: Upload verdict
212287
if: always() && steps.outcome.outputs.succeeded == 'true'
213288
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
214289
with:
215290
name: codeowner-signoff-verdict
216-
path: /tmp/codeowner-signoff-verdict.md
291+
path: ${{ env.VERDICT_PATH }}
217292
if-no-files-found: error
218293
retention-days: 7
219294

0 commit comments

Comments
 (0)