Skip to content

feat: implement issue #1407 — [Phase 4] Demote dev-lead-retry from normal-path driver to a true backstop — resume blocked states event-first - #1489

Merged
don-petry merged 4 commits into
mainfrom
dev-lead/issue-1407-20260808-2059
Aug 8, 2026
Merged

feat: implement issue #1407 — [Phase 4] Demote dev-lead-retry from normal-path driver to a true backstop — resume blocked states event-first#1489
don-petry merged 4 commits into
mainfrom
dev-lead/issue-1407-20260808-2059

Conversation

@don-petry

@don-petry don-petry commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

User description

Closes #1407

Implemented by dev-lead agent. Please review.


CodeAnt-AI Description

Resume blocked dev-lead runs immediately after clearing events

What Changed

  • Rate-limited dev-lead runs now resume immediately after a successful check or submitted review instead of waiting for the two-hour scheduled retry.
  • The scheduled retry remains as a fallback for recovery events that produce no follow-up activity.
  • Both resume paths stop when a PR needs human review or has reached its automation budget, preventing repeated retries.
  • Added coverage for event-driven resumes, missing PRs, human gates, exhausted budgets, and normal retry behavior.

Impact

✅ Faster recovery after successful checks
✅ Fewer unnecessary two-hour retry delays
✅ Fewer automated retry loops on human-gated or exhausted PRs

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

Summary by CodeRabbit

  • New Features

    • Added event-driven resumption for eligible rate-limited automation after pull-request reviews or successful checks.
    • Added safeguards to stop automation when human review is required or the automation budget is exhausted.
    • Added a timer-based fallback to resume eligible work when event triggers are unavailable.
  • Bug Fixes

    • Prevented retries from bypassing exhausted automation budgets.
  • Tests

    • Added coverage for resume eligibility, suppression rules, budget limits, and clean exit conditions.

…rmal-path driver to a true backstop — resume blocked states event-first
@don-petry
don-petry requested a review from a team as a code owner August 8, 2026 21:19
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@codeant-ai

codeant-ai Bot commented Aug 8, 2026

Copy link
Copy Markdown

🤖 CodeAnt AI — Review Status

Status Commit Started (UTC) Finished (UTC)
✅ Reviewed your PR 53c7078 Aug 08, 2026 · 21:20 21:22

@codeant-ai

codeant-ai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because your trial has ended. Ask your workspace admin to add credits to resume reviews. Manage billing

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@don-petry, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 32 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a0fa5e7a-b0c2-4b25-b70e-9bf40603b82e

📥 Commits

Reviewing files that changed from the base of the PR and between 53c7078 and 491e5b9.

📒 Files selected for processing (5)
  • scripts/dev-lead-retry.sh
  • scripts/lib/pr-automation-budget.sh
  • tests/dev-lead/unit/test_dev_lead_resume.bats
  • tests/dev-lead/unit/test_dev_lead_retry_pr_escalation.bats
  • tests/test_pr_automation_budget.bats
📝 Walkthrough

Walkthrough

The PR adds event-driven resume handling for rate-limited dev-lead work. It adds shared suppression checks for human review and automation budgets, retains the cron as a safety net, updates the interaction contract, and adds Bats coverage.

Changes

Dev-lead resume flow

Layer / File(s) Summary
Shared resume suppression and retry gating
scripts/lib/pr-automation-budget.sh, scripts/dev-lead-retry.sh, tests/test_pr_automation_budget.bats, tests/dev-lead/unit/test_dev_lead_retry_pr_escalation.bats
Retry dispatch now uses pr_resume_suppressed to enforce human-review and automation-budget stop conditions.
Event-driven resume wiring
.github/workflows/dev-lead-reusable.yml, scripts/dev-lead-resume.sh, .github/workflows/dev-lead-retry.yml, interaction-contracts/dev-lead.yml
Review and successful check-run events resolve eligible pull requests and invoke the resume bridge. The cron is documented as a safety-net path.
Resume behavior validation
tests/dev-lead/unit/test_dev_lead_resume.bats
Tests cover eligible dispatch, suppression markers, exhausted budgets, missing rate-limit markers, and empty PR numbers.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the implementation and impact but omits the required Interaction contract and Checklist sections, including shellcheck and documentation confirmations. Add the template's Interaction contract and Checklist sections, then mark the applicable items and document required validation.
Linked Issues check ⚠️ Warning The implementation covers review and check-run resumes, suppression gates, the safety-net timer, and the contract, but it does not show support for resolved-thread events required by #1407. Add and test an event path for resolved discussion threads, or document why the repository cannot receive that clearing event.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies issue #1407 and the event-first resume change that demotes the retry workflow to a safety net.
Out of Scope Changes check ✅ Passed All reported code, contract, workflow, and test changes directly support the event-first resume and safety-net objectives in #1407.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev-lead/issue-1407-20260808-2059

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codeant-ai codeant-ai Bot added the size:L This PR changes 100-499 lines, ignoring generated files label Aug 8, 2026
@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — waiting on PR blockers (intent: review-changes)

PR: #1489
No changes were committed, but the PR still has blocking checks or reviews (failing or cancelled checks, or changes-requested reviews). The retry cron will re-attempt automatically. Next attempt after: 2026-08-08T21:51:02Z

@don-petry

Copy link
Copy Markdown
Collaborator Author

Note

@don-petry I reviewed this PR and no code changes were needed, but it still has blocking checks or reviews (failing or cancelled checks, or changes-requested reviews), so I cannot mark it done yet. I'll re-check automatically.
Next attempt after: 2026-08-08T21:51:02Z

@don-petry
don-petry enabled auto-merge (squash) August 8, 2026 21:21

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces an event-first resume mechanism (scripts/dev-lead-resume.sh) to immediately wake blocked or rate-limited dev-lead states upon receiving clearing events, such as review submissions or successful check runs. It unifies the stop-condition logic under a single pr_resume_suppressed gate shared by both the resume script and the safety-net cron, ensuring that both paths respect human-gated labels and per-PR automation budgets. The feedback recommends utilizing $BATS_TEST_TMPDIR in the new BATS unit tests instead of manually creating and cleaning up temporary directories with mktemp -d and rm -rf to leverage automatic per-test isolation and cleanup.

Comment thread tests/dev-lead/unit/test_dev_lead_resume.bats
Comment thread tests/dev-lead/unit/test_dev_lead_resume.bats
@don-petry
don-petry disabled auto-merge August 8, 2026 21:22
Comment thread scripts/dev-lead-resume.sh
Comment thread scripts/dev-lead-retry.sh
Comment thread scripts/lib/pr-automation-budget.sh
coderabbitai[bot]
coderabbitai Bot previously requested changes Aug 8, 2026

@coderabbitai coderabbitai 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.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/dev-lead-reusable.yml:
- Around line 566-571: Update the environment configuration for the resume step
invoking dev-lead-resume.sh: remove the github.token fallback from GH_TOKEN and
retain only secrets.GH_PAT_DON_PETRY || secrets.GH_PAT_WORKFLOWS. Add a pre-run
validation that fails when both PAT secrets are empty, before the script
executes, while preserving GH_PAT_WORKFLOWS as the migration fallback.

In `@scripts/dev-lead-retry.sh`:
- Around line 230-239: After fetching the PR object, validate its `.state`
before evaluating labels or dispatch conditions: continue only when it is
`"open"` and return 0 for every other state, including closed or missing state.
Update the relevant retry function around the fetched `pr_obj`, and add a
regression test proving closed PRs cannot reach `dispatch_ci_retry` or
`dispatch_reviews_retry`.

In `@scripts/lib/pr-automation-budget.sh`:
- Around line 111-126: Update the automation-event retrieval flow around
gather_pr_automation_events so API failures are distinguishable from a valid
empty event list; when comments, commits, or reviews retrieval fails, propagate
that failure and return 0 to suppress resumption rather than evaluating the
budget as available. Add regression coverage for each failed retrieval path.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 02ff095a-349c-4d4d-b088-84620fce11a9

📥 Commits

Reviewing files that changed from the base of the PR and between 353c9b2 and 53c7078.

📒 Files selected for processing (9)
  • .github/workflows/dev-lead-retry.yml
  • .github/workflows/dev-lead-reusable.yml
  • interaction-contracts/dev-lead.yml
  • scripts/dev-lead-resume.sh
  • scripts/dev-lead-retry.sh
  • scripts/lib/pr-automation-budget.sh
  • tests/dev-lead/unit/test_dev_lead_resume.bats
  • tests/dev-lead/unit/test_dev_lead_retry_pr_escalation.bats
  • tests/test_pr_automation_budget.bats

Comment thread .github/workflows/dev-lead-reusable.yml
Comment thread scripts/dev-lead-retry.sh
Comment thread scripts/lib/pr-automation-budget.sh
@don-petry

Copy link
Copy Markdown
Collaborator Author

@coderabbitai resolve

@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — fix-reviews (applied)

Changes committed and pushed.

@don-petry
don-petry enabled auto-merge (squash) August 8, 2026 21:23
coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 8, 2026
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
✅ Action performed

Comments resolved and changes approved.

@don-petry
don-petry disabled auto-merge August 8, 2026 21:24
@donpetry-bot

Copy link
Copy Markdown
Contributor

CI checks on this PR are still running. Once they complete, re-mention @donpetry-bot to trigger a fresh review.

Posted by the donpetry-bot PR-review cascade.

@donpetry-bot
donpetry-bot dismissed coderabbitai[bot]’s stale review August 8, 2026 21:28

Auto-dismissed (#617): coderabbitai[bot] CHANGES_REQUESTED on a superseded commit. The bot re-reviews the new head automatically — a valid concern will return as a fresh review.

@donpetry-bot

Copy link
Copy Markdown
Contributor

CI checks on this PR are still running. Once they complete, re-mention @donpetry-bot to trigger a fresh review.

Posted by the donpetry-bot PR-review cascade.

1 similar comment
@donpetry-bot

Copy link
Copy Markdown
Contributor

CI checks on this PR are still running. Once they complete, re-mention @donpetry-bot to trigger a fresh review.

Posted by the donpetry-bot PR-review cascade.

@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — review-changes (applied)

Changes committed and pushed.

@don-petry
don-petry disabled auto-merge August 8, 2026 21:42
@don-petry
don-petry enabled auto-merge (squash) August 8, 2026 21:44
@don-petry
don-petry disabled auto-merge August 8, 2026 21:45
@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — fix-bot-comment (applied)

Changes committed and pushed.

@don-petry
don-petry enabled auto-merge (squash) August 8, 2026 21:47
@don-petry
don-petry disabled auto-merge August 8, 2026 21:47
@sonarqubecloud

sonarqubecloud Bot commented Aug 8, 2026

Copy link
Copy Markdown

@don-petry
don-petry enabled auto-merge (squash) August 8, 2026 21:50
@don-petry
don-petry disabled auto-merge August 8, 2026 21:51
@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — fix-bot-comment (no-changes)

Agent reasoning
### Review Threads Status
- **codeant-ai:** 3/3 resolved ✓
- **coderabbitai:** 3/3 resolved ✓  
- **gemini-code-assist:** 2/2 resolved ✓
### CI Status
- **Success:** 51 checks ✓
- **Skipped:** 9 checks (expected)
- **Cancelled:** 10 checks (expected)
- **Failures:** 0
The PR is ready — all code review feedback has been validated and addressed through replies to each thread, with all threads now marked resolved.

@don-petry
don-petry enabled auto-merge (squash) August 8, 2026 21:53
@donpetry-bot

Copy link
Copy Markdown
Contributor

Advisory bots were rate-limited; auto-approval is withheld until they recover. pr-review-sweep will re-review this PR after 2026-08-08T22:53:15Z.

@donpetry-bot donpetry-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated review — APPROVED ✓

Risk: MEDIUM
Reviewed commit: 491e5b99c7acfdfa717842f856bac92e2cf3a779
Review mode: triage-approved (single reviewer)

Summary

Phase 4 of #1407: demotes the dev-lead-retry 2h cron from normal-path convergence driver to a genuine safety-net backstop, and adds an event-first resume path. A new resume job in dev-lead-reusable.yml fires on a review-submitted or check_run-success clearing event and runs scripts/dev-lead-resume.sh, which reuses scan_pr_for_rate_limits so its dispatch and stop-condition are identical to the cron. Both paths now route through a single shared pr_resume_suppressed gate (human-gate label + per-PR automation budget). Adds a best-effort dispatch-dedup guard and makes budget-event collection fail-closed on API error. Well covered by new/expanded bats tests.

Linked issue analysis

Closes #1407 (Phase 4). The diff substantively implements the stated ACs: event fast-path added and the interaction-contract LEAK closed (event_fast_path populated, timer role -> safety-net); AC#3 (single shared stop-condition across timer + event paths) realized via pr_resume_suppressed; AC#5 (frozen ring-0 caller stub untouched) upheld — new triggers ride existing forwarded events and caller-stub-freeze is green.

Findings

No blocking findings.

  • Security: new resume job follows the established Bridge A pattern used by ci-relay — SHA-pinned actions/checkout (v7.0.1), minimal perms (contents:write, pull-requests:read, issues:read), persist-credentials:false, sparse-checkout limited to scripts/. PAT (secrets.GH_PAT_*) is required because GITHUB_TOKEN cannot fire the downstream repository_dispatch; no hardcoded secrets. The if: guard excludes 'dev-lead / ' check-runs to prevent self-trigger recursion.
  • Robustness: gather_pr_automation_events now returns non-zero on any gh API failure and pr_resume_suppressed suppresses fail-closed on that — sound anti-runaway behavior during outages.
  • Minor (non-blocking): the dispatch-dedup guard (post-before-dispatch) is inherently best-effort and has a TOCTOU window under true concurrency; acknowledged in-code and harmless since any duplicate dispatch is still budget-gated.
  • Secret-scanning MCP tool (run_secret_scanning) not available in this environment; gitleaks CI check passed.

CI status

All required checks green (shellcheck, bats, actionlint, caller-stub-freeze, validate-interaction-contracts, validate-caller-inputs, caller-permissions, CodeQL, Secret scan gitleaks, SonarCloud, agent-shield, etc.). CANCELLED entries are superseded dev-lead dispatch/ci-relay concurrency cancellations, not failures. CodeRabbit APPROVED with threads resolved; no unanswered human-reviewer questions.


Reviewed automatically by the PR-review agent (single-reviewer mode: fable 5). Reply if you need a human review.

@don-petry
don-petry merged commit d0ab87b into main Aug 8, 2026
69 of 85 checks passed
@don-petry
don-petry deleted the dev-lead/issue-1407-20260808-2059 branch August 8, 2026 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Phase 4] Demote dev-lead-retry from normal-path driver to a true backstop — resume blocked states event-first

2 participants