Skip to content

t1048: Fix auto-rebase: handle AI-completed rebase and increase max attempts#1477

Merged
marcusquinn merged 1 commit intomainfrom
bugfix/t1048
Feb 14, 2026
Merged

t1048: Fix auto-rebase: handle AI-completed rebase and increase max attempts#1477
marcusquinn merged 1 commit intomainfrom
bugfix/t1048

Conversation

@marcusquinn
Copy link
Owner

@marcusquinn marcusquinn commented Feb 14, 2026

Summary

  • Fix rebase_sibling_pr() failing when the AI conflict resolver already completes the rebase — check for rebase state dirs before calling --continue
  • Increase max_rebase_attempts from 2 to 5 to handle cascading rebases across 10+ sibling PRs

Root Cause

resolve_rebase_conflicts() spawns a full AI agent session (opencode run) that resolves conflict markers, runs git add, and often also runs git rebase --continue itself. When the shell script then calls git rebase --continue, it gets fatal: no rebase in progress — which was treated as failure, blocking the task.

17 of 20 open PRs were stuck in CONFLICTING/DIRTY state because of this.

Fix

After AI resolution succeeds, check if rebase-merge or rebase-apply directories still exist (using git rev-parse --git-dir which works correctly for both worktrees and main repos). If the rebase is already done, log success and proceed to force-push.

Also increased max_rebase_attempts from 2 to 5 — with many sibling PRs merging sequentially, a branch can fall behind multiple times before all siblings are processed.

Testing

  • bash -n syntax check: pass
  • shellcheck -S warning -x: no new warnings (3 pre-existing SC2034 for unused read vars)
  • Logic verified against supervisor log patterns showing the exact failure sequence

Summary by CodeRabbit

  • Chores
    • Enhanced auto-rebase retry mechanism to improve deployment reliability and handle edge cases in merge conflict resolution more robustly
    • Refined continuous integration rebase handling logic for better error detection and recovery during automated deployment processes

@gemini-code-assist
Copy link

Summary of Changes

Hello @marcusquinn, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the robustness of the automated rebase mechanism by addressing a critical failure point where the system would incorrectly attempt to continue a rebase that an AI agent had already completed. Additionally, it improves the system's resilience to frequent rebase requirements by allowing more attempts, which is crucial for environments with many interdependent pull requests.

Highlights

  • Auto-rebase fix: Resolved an issue where the rebase_sibling_pr() function would fail if an AI conflict resolver had already completed the rebase process, by checking for rebase state directories before attempting to continue the rebase.
  • Increased rebase attempts: Increased the max_rebase_attempts from 2 to 5 to better handle scenarios with multiple cascading rebases across numerous sibling pull requests.
Changelog
  • .agents/scripts/supervisor/deploy.sh
    • Increased the max_rebase_attempts variable from 2 to 5 to accommodate cascading rebases across multiple sibling PRs.
    • Introduced a check for rebase-merge or rebase-apply directories after AI conflict resolution to prevent git rebase --continue from failing if the AI agent already completed the rebase.
    • Updated the logic to log success if the AI agent already completed the rebase, avoiding unnecessary git rebase --continue calls and improving error handling.
Activity
  • No activity (comments, reviews, etc.) was provided in the context.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 14, 2026

Warning

Rate limit exceeded

@marcusquinn has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 25 minutes and 45 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Walkthrough

This change enhances the deploy.sh script's rebase conflict resolution logic by increasing auto-rebase retry attempts from 2 to 5 and adding state detection to determine whether a rebase remains in progress after AI-assisted conflict resolution, conditionally continuing or treating the operation as complete based on git state.

Changes

Cohort / File(s) Summary
Rebase Retry and Conflict Resolution
.agents/scripts/supervisor/deploy.sh
Increased max_rebase_attempts from 2 to 5 for BEHIND/DIRTY PR handling. Added post-AI-resolution checks in rebase_sibling_pr (two locations) to inspect git state (rebase-merge or rebase-apply directories), conditionally continuing the rebase with git rebase --continue if in progress, or treating as success if AI already completed. Includes abort-and-return logic on resolution failures.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related issues

Possibly related PRs

Poem

🌿 A rebase spring with greener paths,
Five attempts now dance through git's math,
AI resolves, the state we check—
No spurious continues wreck the deck! 🚀
Clean conflicts in the DevOps sun.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and specifically addresses the main changes: fixing auto-rebase to handle AI-completed rebase scenarios and increasing max attempts from 2 to 5.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix/t1048

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 and usage tips.

@github-actions
Copy link

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 5 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Sat Feb 14 14:52:52 UTC 2026: Code review monitoring started
Sat Feb 14 14:52:52 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 5

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 5
  • VULNERABILITIES: 0

Generated on: Sat Feb 14 14:52:55 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

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 effectively addresses a race condition where an AI conflict resolver completes a rebase before the script attempts to continue it. The logic to check for an in-progress rebase is sound, and increasing the maximum rebase attempts is a sensible adjustment for handling complex, cascading merges. I've included two medium-severity comments: one regarding a style guide violation for missing explicit return statements, and another suggesting a refactor to reduce significant code duplication, which would improve maintainability.

Comment on lines 2184 to 2201
# t1048: Check if rebase is still in progress — the AI agent
# may have already run `git rebase --continue` itself, leaving
# no rebase in progress for us to continue.
local git_state_dir
git_state_dir="$(git -C "$git_dir" rev-parse --git-dir 2>/dev/null)"
if [[ -d "$git_state_dir/rebase-merge" || -d "$git_state_dir/rebase-apply" ]]; then
log_info "rebase_sibling_pr: AI resolved conflicts for $task_id — continuing rebase"
if git -C "$git_dir" rebase --continue 2>>"$SUPERVISOR_LOG"; then
log_success "rebase_sibling_pr: rebase completed after AI resolution for $task_id"
else
log_warn "rebase_sibling_pr: rebase --continue failed after AI resolution for $task_id"
git -C "$git_dir" rebase --abort 2>>"$SUPERVISOR_LOG" || true
return 1
fi
else
log_warn "rebase_sibling_pr: rebase --continue failed after AI resolution for $task_id"
git -C "$git_dir" rebase --abort 2>>"$SUPERVISOR_LOG" || true
return 1
# AI agent already completed the rebase — treat as success
log_success "rebase_sibling_pr: rebase completed (AI resolved and continued) for $task_id"
fi

Choose a reason for hiding this comment

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

medium

This block of logic for handling the post-AI-resolution rebase is nearly identical to the block at lines 2223-2240. This duplication can make future maintenance more difficult and error-prone. To improve maintainability, consider refactoring this repeated logic into a helper function.

The main difference between the blocks is the error handling when git rebase --continue fails (one path checks out the original branch, the other doesn't). The helper function could be designed to accommodate this difference, for example by accepting a parameter or returning a specific status code.

Comment on lines 2226 to 2240
if [[ -d "$git_state_dir/rebase-merge" || -d "$git_state_dir/rebase-apply" ]]; then
log_info "rebase_sibling_pr: AI resolved conflicts for $task_id — continuing rebase"
if git -C "$git_dir" rebase --continue 2>>"$SUPERVISOR_LOG"; then
log_success "rebase_sibling_pr: rebase completed after AI resolution for $task_id"
else
log_warn "rebase_sibling_pr: rebase --continue failed after AI resolution for $task_id"
git -C "$git_dir" rebase --abort 2>>"$SUPERVISOR_LOG" || true
# Return to original branch
git -C "$git_dir" checkout "${current_branch:-main}" 2>>"$SUPERVISOR_LOG" || true
return 1
fi
else
log_warn "rebase_sibling_pr: rebase --continue failed after AI resolution for $task_id"
git -C "$git_dir" rebase --abort 2>>"$SUPERVISOR_LOG" || true
# Return to original branch
git -C "$git_dir" checkout "${current_branch:-main}" 2>>"$SUPERVISOR_LOG" || true
return 1
# AI agent already completed the rebase — treat as success
log_success "rebase_sibling_pr: rebase completed (AI resolved and continued) for $task_id"
fi

Choose a reason for hiding this comment

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

medium

The repository style guide requires all functions to have explicit return statements. The success paths in this block (lines 2229 and 2239) are missing return 0;. A similar issue exists in the duplicated block at lines 2189-2201. Please add return 0 to all successful exit points in this function to adhere to the style guide.

Suggested change
if [[ -d "$git_state_dir/rebase-merge" || -d "$git_state_dir/rebase-apply" ]]; then
log_info "rebase_sibling_pr: AI resolved conflicts for $task_id — continuing rebase"
if git -C "$git_dir" rebase --continue 2>>"$SUPERVISOR_LOG"; then
log_success "rebase_sibling_pr: rebase completed after AI resolution for $task_id"
else
log_warn "rebase_sibling_pr: rebase --continue failed after AI resolution for $task_id"
git -C "$git_dir" rebase --abort 2>>"$SUPERVISOR_LOG" || true
# Return to original branch
git -C "$git_dir" checkout "${current_branch:-main}" 2>>"$SUPERVISOR_LOG" || true
return 1
fi
else
log_warn "rebase_sibling_pr: rebase --continue failed after AI resolution for $task_id"
git -C "$git_dir" rebase --abort 2>>"$SUPERVISOR_LOG" || true
# Return to original branch
git -C "$git_dir" checkout "${current_branch:-main}" 2>>"$SUPERVISOR_LOG" || true
return 1
# AI agent already completed the rebase — treat as success
log_success "rebase_sibling_pr: rebase completed (AI resolved and continued) for $task_id"
fi
if [[ -d "$git_state_dir/rebase-merge" || -d "$git_state_dir/rebase-apply" ]]; then
log_info "rebase_sibling_pr: AI resolved conflicts for $task_id — continuing rebase"
if git -C "$git_dir" rebase --continue 2>>"$SUPERVISOR_LOG"; then
log_success "rebase_sibling_pr: rebase completed after AI resolution for $task_id"
return 0
else
log_warn "rebase_sibling_pr: rebase --continue failed after AI resolution for $task_id"
git -C "$git_dir" rebase --abort 2>>"$SUPERVISOR_LOG" || true
# Return to original branch
git -C "$git_dir" checkout "${current_branch:-main}" 2>>"$SUPERVISOR_LOG" || true
return 1
fi
else
# AI agent already completed the rebase — treat as success
log_success "rebase_sibling_pr: rebase completed (AI resolved and continued) for $task_id"
return 0
fi
References
  1. All functions must have explicit return statements. (link)

rebase_sibling_pr() failed when resolve_rebase_conflicts() spawned an AI
agent that completed the rebase itself. The shell script then called
`git rebase --continue` which got `fatal: no rebase in progress`,
treating it as failure and blocking the task.

Fix: after AI resolution succeeds, check if rebase state dirs still exist
before calling --continue. If the AI already finished the rebase, treat
it as success.

Also increase max_rebase_attempts from 2 to 5 — with 10+ sibling PRs
merging sequentially, branches fall behind multiple times.

Unblocks 17 PRs stuck in CONFLICTING/DIRTY state.
@github-actions
Copy link

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 5 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Sat Feb 14 14:57:05 UTC 2026: Code review monitoring started
Sat Feb 14 14:57:06 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 5

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 5
  • VULNERABILITIES: 0

Generated on: Sat Feb 14 14:57:08 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link

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