Skip to content

fix(dev-lead): label opened PRs auto-rebase:ready to break the #711 review-ready deadlock - #1201

Merged
don-petry merged 5 commits into
mainfrom
fix/dev-lead-auto-rebase-ready-label
Jul 14, 2026
Merged

don-petry merged 5 commits into
mainfrom
fix/dev-lead-auto-rebase-ready-label

Conversation

@don-petry

@don-petry don-petry commented Jul 14, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Auto-rebase's review-ready eligibility gate (#465) only rebases PRs that are approved OR carry the auto-rebase:ready label. The label half was never wired up — nothing applies it (0/55 open org PRs carry it, it's in no labels.yml). So the only path to eligibility is an approval, which creates a deadlock for every dev-lead PR that falls behind before approval:

falls behind → auto-rebase skips (unapproved, unlabeled)
            → drifts into merge conflict as main advances
            → pr-review won't approve a red/conflicting PR
            → never approved → never eligible → never rebased  ⟳  (rots for weeks)

This is the root cause of the fleet's stuck CONFLICTING + REVIEW_REQUIRED PR cohort. Full diagnosis + evidence in petry-projects/.github#711.

Fix (Part A of #711)

dev-lead-fix-issue.sh now applies auto-rebase:ready to every PR it opens, so dev-lead PRs are auto-rebase-eligible from creation and stay current until merge — before divergence becomes intractable.

  • Captures the created PR URL, ensures the label exists (gh label create --force, idempotent) so a repo missing it doesn't break, then adds it.
  • All label ops are guarded (|| true, output suppressed) — a labeling hiccup can never fail PR creation.

Tests

  • New regression test asserts an opened PR is labeled auto-rebase:ready.
  • Full test_fix_issue.bats suite green (21/21); bash -n + shellcheck clean.

Validation

Manually applying auto-rebase:ready to the stuck bmad-bgreat-suite#205 flipped it from not eligible ... — skipping to updating branch on the next auto-rebase run (run 29298232627) — confirming the mechanism.

Follow-ups (tracked on #711, not in this PR)

🤖 Generated with Claude Code

https://claude.ai/code/session_01Juznz5V6su81ffSND8fg7s

Summary by CodeRabbit

  • New Features

    • Newly created pull requests are automatically marked as ready for auto-rebasing with the auto-rebase:ready label.
    • Label setup is handled automatically when needed.
  • Tests

    • Added coverage to verify the label is applied when a pull request is created successfully.

…-ready deadlock

The auto-rebase 'review-ready' gate (#465) only rebases PRs that are approved
OR carry the auto-rebase:ready label. That label half was never wired up — no
producer applies it — so the only path to eligibility is an approval. A dev-lead
PR that falls behind before it is approved is therefore skipped by auto-rebase,
drifts into a merge conflict, and can never be approved (pr-review skips
red/conflicting PRs): a deadlock that rots the PR for weeks.

dev-lead now applies auto-rebase:ready to every PR it opens, so its PRs are
auto-rebase-eligible from creation and stay current until merge. The label is
created idempotently (--force) first so a repo missing it does not break, and
all label operations are guarded so PR creation never fails on a labeling hiccup.

Addresses Part A of petry-projects/.github#711. Part C (escalate skipped-but-
conflicting PRs) and standardizing the label in labels.yml are tracked follow-ups.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Juznz5V6su81ffSND8fg7s
@don-petry
don-petry requested a review from a team as a code owner July 14, 2026 01:44
@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.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Jul 14, 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: 31 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

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

Run ID: f5487e82-51b7-408a-b4c3-26eaa492a8f0

📥 Commits

Reviewing files that changed from the base of the PR and between 2efd7d1 and 9c5d48d.

📒 Files selected for processing (2)
  • scripts/dev-lead-fix-issue.sh
  • tests/dev-lead/unit/test_fix_issue.bats
📝 Walkthrough

Walkthrough

The dev-lead issue-fix script now captures newly created pull requests and applies the auto-rebase:ready label. A Bats test verifies the label assignment.

Changes

Dev-lead pull request labeling

Layer / File(s) Summary
Capture and label created pull requests
scripts/dev-lead-fix-issue.sh, tests/dev-lead/unit/test_fix_issue.bats
The script captures the pull request URL, ensures auto-rebase:ready exists, applies it to the pull request, ignores labeling failures, and tests the resulting CLI arguments.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

  • petry-projects/.github#711 — The change applies the auto-rebase:ready label to newly created dev-lead pull requests, matching the issue’s recommended fix.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: automatically labeling opened dev-lead PRs to address the #711 deadlock.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/dev-lead-auto-rebase-ready-label

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.

@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 updates the dev-lead-fix-issue.sh script to automatically apply the auto-rebase:ready label to newly created pull requests, preventing them from falling behind and getting stuck in a deadlock. A corresponding BATS unit test has also been added. The feedback identifies two key improvements: removing an unsupported --force flag from the gh label create command to prevent it from failing, and ensuring that the temporary file in the BATS test is created within $BATS_TEST_TMPDIR for proper cleanup.

Comment thread scripts/dev-lead-fix-issue.sh Outdated
Comment thread tests/dev-lead/unit/test_fix_issue.bats Outdated

@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: 1

🤖 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 `@tests/dev-lead/unit/test_fix_issue.bats`:
- Around line 742-769: Update the test setup around LABEL_RECORD and the gh
stub: create LABEL_RECORD inside STUB_BIN_DIR without exporting it, return the
JSON array "[]" for the pulls?state=open case, and retain the existing
label-recording behavior and assertions.
🪄 Autofix (Beta)

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

Run ID: 39735a5f-9b9f-40f7-937e-93e672604843

📥 Commits

Reviewing files that changed from the base of the PR and between d83b3b1 and 2efd7d1.

📒 Files selected for processing (2)
  • scripts/dev-lead-fix-issue.sh
  • tests/dev-lead/unit/test_fix_issue.bats

Comment thread tests/dev-lead/unit/test_fix_issue.bats Outdated
…B_BIN_DIR

The record path is baked into the gh stub via the unquoted heredoc, so exporting
it was unnecessary; placing it under STUB_BIN_DIR lets teardown clean it up.
(The reviewer's other suggestion — return '[]' for the pulls?state=open case —
is not applicable: the mock gh bypasses --jq, so check_existing_pr reads the raw
echo and needs the post-jq count '0'; returning '[]' would make [ ... -gt 0 ] throw.)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Juznz5V6su81ffSND8fg7s
@don-petry

Copy link
Copy Markdown
Collaborator Author

@coderabbitai I applied the first part — dropped the needless export LABEL_RECORD and moved the record file under STUB_BIN_DIR (cleaned up by teardown).

I did not change the pulls?state=open case to return []: the mock gh is a dumb dispatcher that ignores --jq, so check_existing_pr reads the stub's raw echo. It expects the post-jq count, and does [ "$existing" -gt 0 ] — returning [] would make that an integer-expression error. "0" is correct here (and matches the existing happy-path stub).

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 14, 2026
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail
fd fix_issue.bats
fd dev-lead-fix-issue.sh
echo "---script check_existing_pr---"
rg -n "check_existing_pr" -A20 scripts/dev-lead-fix-issue.sh | head -60
echo "---test stub for pulls?state=open---"
rg -n "pulls\?state=open|state=open|LABEL_RECORD|STUB_BIN_DIR" tests/dev-lead/unit/test_fix_issue.bats

Length of output: 6155


Confirmed — the mock gh ignores --jq entirely and check_existing_pr reads the raw stub output as the post-jq count ("0" in the passing case), so [ "0" -gt 0 ] correctly evaluates false. Switching the stub to [] would indeed break the -gt integer comparison. Your fix is correct as-is.

@don-petry Thanks for the clarification and for making the LABEL_RECORD/STUB_BIN_DIR cleanup fix — confirmed in the script that the stub gh is a dumb dispatcher matching on the raw command string and doesn't actually run --jq, so returning the post-jq count ("0") rather than [] is correct given check_existing_pr's [ "$existing" -gt 0 ] check. Good catch, no further action needed here.


✏️ Learnings added
Learnt from: don-petry
URL: https://github.com/petry-projects/.github-private/pull/1201

Timestamp: 2026-07-14T02:05:41.408Z
Learning: In petry-projects/.github-private, the Bats test doubles for `gh` in tests/dev-lead/unit/test_fix_issue.bats are dumb string-dispatchers keyed on substrings of the invoked command (e.g., `*"pulls?state=open"*`) and do not actually process `--jq` filters. Because `check_existing_pr()` in scripts/dev-lead-fix-issue.sh does `existing=$(gh api ... --jq "...length" || echo "0"); [ "$existing" -gt 0 ]`, the stub must echo the post-jq integer count (e.g., "0"), not raw JSON like `[]`, otherwise the `-gt` integer comparison breaks.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Copilot AI review requested due to automatic review settings July 14, 2026 03:07

Copilot AI 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.

Pull request overview

This PR addresses the auto-rebase “review-ready” deadlock described in #711 by ensuring dev-lead-opened PRs become auto-rebase eligible immediately upon creation via the auto-rebase:ready label.

Changes:

  • Capture the created PR URL in dev-lead-fix-issue.sh, echo it (preserving prior output), and apply auto-rebase:ready after PR creation.
  • Add a dev-lead unit regression test asserting that an opened PR is labeled auto-rebase:ready.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
scripts/dev-lead-fix-issue.sh Captures gh pr create output and applies the auto-rebase:ready label after opening a PR.
tests/dev-lead/unit/test_fix_issue.bats Adds a regression test validating that opened PRs are labeled auto-rebase:ready.

Comment thread scripts/dev-lead-fix-issue.sh Outdated
Comment thread tests/dev-lead/unit/test_fix_issue.bats Outdated
@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — review-changes (applied)

Changes committed and pushed.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 14, 2026
@don-petry
don-petry disabled auto-merge July 14, 2026 03:13
@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — review-changes (applied)

Changes committed and pushed.

@sonarqubecloud

Copy link
Copy Markdown

@don-petry
don-petry disabled auto-merge July 14, 2026 03:17
@don-petry

Copy link
Copy Markdown
Collaborator Author

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

PR: #1201
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-07-14T03:49:40Z

@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-07-14T03:49:40Z

@don-petry
don-petry enabled auto-merge (squash) July 14, 2026 03:19

@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: 9c5d48d792030f851677fca3ffc7f969f66c5efd
Review mode: triage-approved (single reviewer)

Summary

Wires up the previously-dead 'auto-rebase:ready' label half of the auto-rebase review-ready eligibility gate: dev-lead-fix-issue.sh now captures the created PR URL, idempotently ensures the label exists, and applies it to every PR it opens — making dev-lead PRs auto-rebase-eligible from creation and breaking the unapproved→conflicting→never-approved deadlock described in petry-projects/.github#711. All label operations are guarded (output suppressed, || true) so PR creation can never fail on a labeling hiccup, and the prior stdout behavior (PR URL echoed) is preserved. A new bats regression test stubs gh to assert the opened PR receives the label. Change is small (2 files, +69/−2), well-scoped, and matches the triage tier's low-risk assessment.

Linked issue analysis

No closing issue in this repo; the PR addresses cross-repo issue petry-projects/.github#711 (Part A) and the #465 eligibility gate. The stated root cause (label never applied anywhere in the org) and the fix mechanism are consistent with the diff, and the PR body documents a manual validation run (bmad-bgreat-suite#205 flipped from skipped to rebased) confirming the mechanism.

Findings

  • No blocking findings.
  • Earlier reviewer concerns (gh label create --force overwriting label metadata; test temp-file hygiene; misleading test comment) were all addressed in follow-up commits — the final code uses 'gh label create ... || true' without --force, and the test keeps its record file in STUB_BIN_DIR (cleaned by teardown). All 5 review threads are resolved; CodeRabbit's changes-requested review was superseded by its APPROVED review.
  • Secret scanning MCP tool not available in this run; the gitleaks CI check passed on the head SHA.

CI status

All checks green on 9c5d48d (shellcheck, bats, unit-tests, CodeQL, SonarCloud quality gate, gitleaks, agent-shield, all structure/permission guards). A few CANCELLED entries are superseded duplicate runs of the same jobs that later succeeded; SKIPPED entries are conditional dependency-audit jobs for absent ecosystems.


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 458e0b3 into main Jul 14, 2026
41 of 44 checks passed
@don-petry
don-petry deleted the fix/dev-lead-auto-rebase-ready-label branch July 14, 2026 03:25

@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: 9c5d48d792030f851677fca3ffc7f969f66c5efd
Review mode: triage-approved (single reviewer)

Summary

Adds an auto-rebase:ready labeling step to dev-lead-fix-issue.sh so every dev-lead-opened PR is auto-rebase-eligible from creation, breaking the review-ready deadlock diagnosed in petry-projects/.github#711 (Part A). The PR-create output is captured, the label is created idempotently if missing, and all label operations are guarded with || true so PR creation can never fail on a labeling hiccup. A new bats regression test asserts the opened PR receives the label. Change is small (2 files, +69/-2), well-tested, and validated live against a stuck PR (bmad-bgreat-suite#205 flipped from skipped to rebased).

Linked issue analysis

No closing issue reference in this repo. The PR implements Part A of petry-projects/.github#711 (open), which documents that the auto-rebase 'review-ready' gate's label path was never wired up (0/55 open org PRs carry the label), deadlocking unapproved PRs that drift into conflicts. The change directly and substantively addresses that root cause for dev-lead PRs; Parts B/C are explicitly tracked as follow-ups on #711.

Findings

  • No security concerns: no auth/secrets/credentials touched; new gh calls (label create, pr edit) use existing authenticated CLI with errors suppressed and guarded (|| true), so failure modes are benign.
  • Prior bot findings (gemini, CodeRabbit, Copilot) were all addressed and every review thread is resolved: the invalid/overwriting 'gh label create --force' was replaced with a guarded plain create, the test record file was moved under STUB_BIN_DIR (cleaned by teardown), and the misleading test comment was fixed. CodeRabbit's final review is APPROVED. Note: the PR description still mentions '--force' but the code correctly does not use it — cosmetic staleness only, not blocking.
  • Test stub correctly escapes $* in the unquoted heredoc and asserts 'add-label auto-rebase:ready' is recorded; suite reported 21/21 green.
  • Secret scanning MCP tool unavailable in this environment; gitleaks CI check passed (SUCCESS).

CI status

All checks green at 9c5d48d: shellcheck, bats, unit-tests, CodeQL (actions+python), SonarCloud quality gate, gitleaks secret scan, agent-shield, holdout-guard, and all stub/permission validators SUCCESS. A few CANCELLED entries (dev-lead/dispatch, review/review, ci-relay) are superseded duplicate runs with later SUCCESS conclusions for the same checks. mergeStateStatus BLOCKED reflects only the pending required review.


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

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.

3 participants