Skip to content

fix(ci): cap healer reruns globally via run_attempt check - #58

Merged
dizhaky merged 1 commit into
mainfrom
fix/ci-healer-global-retry-budget
Jun 30, 2026
Merged

fix(ci): cap healer reruns globally via run_attempt check#58
dizhaky merged 1 commit into
mainfrom
fix/ci-healer-global-retry-budget

Conversation

@dizhaky

@dizhaky dizhaky commented Jun 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds a gh api call inside the rerun loop to read the GitHub run_attempt counter for each failed workflow run before triggering a rerun
  • If run_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 indefinitely
  • Clarifies the existing per-invocation RERUN_COUNT comment to distinguish it from the global check

Background

Codex flagged this as P2 in its review of PR #50: the MAX_RERUNS=3 counter was local to each 30-minute healer invocation, so a deterministically failing job would be endlessly retried. The run_attempt field from the GitHub API reflects total attempts across all reruns and persists between invocations.

Test plan

  • Review the diff — gh api .../runs/$RUN_ID --jq .run_attempt is a read-only API call; on failure it falls back to 1, so the check degrades safely
  • Trigger a consistently failing workflow run, confirm the healer stops rerunning after 3 attempts across separate invocations
  • Confirm runs that are still within budget continue to be rerun normally

🤖 Generated with Claude Code

https://claude.ai/code/session_01KyAT56KirB4FysThAHPX4b


Generated by Claude Code

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.
@github-actions

Copy link
Copy Markdown

🔎 Lint report: fix/ci-healer-global-retry-budget vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 8653 on HEAD, 8653 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 4573 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@dizhaky
dizhaky marked this pull request as ready for review June 30, 2026 01:54
@dizhaky
dizhaky merged commit 1ecbbde into main Jun 30, 2026
22 checks passed
@dizhaky
dizhaky deleted the fix/ci-healer-global-retry-budget branch June 30, 2026 01:54

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant