fix(ci): cap healer reruns globally via run_attempt check - #58
Conversation
The MAX_RERUNS=3 counter was local to each healer invocation, so a deterministically failing workflow run would be rerun every 30 minutes indefinitely. Add a gh api call to read run_attempt before rerunning; skip any run that has already reached the retry ceiling across prior healer invocations. Addresses Codex PR #50 P2 finding.
🔎 Lint report:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9a25831f57
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # healer invocations. run_attempt==1 is the original run; each rerun | ||
| # increments it, so run_attempt==4 means 3 reruns have already been done. | ||
| ATTEMPT=$(gh api /repos/$REPO/actions/runs/$RUN_ID --jq '.run_attempt' 2>/dev/null || echo "1") | ||
| if [ "${ATTEMPT:-1}" -ge "$MAX_RERUNS" ] 2>/dev/null; then |
There was a problem hiding this comment.
Allow the third configured rerun
When a run has already failed after two healer-triggered reruns, GitHub reports run_attempt as 3 because the original run is attempt 1 (the new comment also notes attempt 4 means three reruns). This -ge "$MAX_RERUNS" check therefore skips the run at attempt 3, so MAX_RERUNS=3 and the later “after 3 reruns” messaging only ever allow two automatic reruns; compare against MAX_RERUNS + 1 or track actual rerun count instead.
Useful? React with 👍 / 👎.
Summary
gh apicall inside the rerun loop to read the GitHubrun_attemptcounter for each failed workflow run before triggering a rerunrun_attempt >= MAX_RERUNS(i.e. the run has already been retried as many times as the budget allows across all previous healer invocations), the run is skipped with a "needs manual review" message instead of being rerun again indefinitelyRERUN_COUNTcomment to distinguish it from the global checkBackground
Codex flagged this as P2 in its review of PR #50: the
MAX_RERUNS=3counter was local to each 30-minute healer invocation, so a deterministically failing job would be endlessly retried. Therun_attemptfield from the GitHub API reflects total attempts across all reruns and persists between invocations.Test plan
gh api .../runs/$RUN_ID --jq .run_attemptis a read-only API call; on failure it falls back to1, so the check degrades safely🤖 Generated with Claude Code
https://claude.ai/code/session_01KyAT56KirB4FysThAHPX4b
Generated by Claude Code