Skip to content

feat: review sweep auto-updates a cleanly-behind PR branch via GitHub's update-branch API - #630

Merged
getappz merged 2 commits into
masterfrom
task/review-sweep-update-branch
Aug 28, 2026
Merged

getappz merged 2 commits into
masterfrom
task/review-sweep-update-branch

Conversation

@getappz

@getappz getappz commented Aug 28, 2026 •

Copy link
Copy Markdown
Owner

Summary

PRs #621, #623, and #627 all hit mergeStateStatus: BEHIND this session and needed a manual git merge origin/master in the item's worktree before they could merge — nothing was watching for or fixing this automatically, even though run_review_sweep already polls every in-review item's PR status every tick.

Changes

  • PrCiStatus gains a Behind { number } variant, checked in pr_ci_status_impl right after the merged check and before check-runs are ever fetched — GitHub's own mergeable_state == "behind" already means "mergeable, no conflict, just missing base-branch commits," so there's no point fetching CI for checks the branch update is about to invalidate anyway.
  • New worktree::update_stale_branch calls the new github::pulls::update_branch, which is PUT /pulls/{number}/update-branch — the same server-side operation the PR page's own "Update branch" button triggers. Entirely server-side: no local worktree/git state touched, so it can't race a concurrently-dispatched job still pushing to the same branch the way a local git merge would.
  • run_review_sweep gets a Behind match arm calling this, counted in a new ReviewSweepResult.updated field (distinct from promoted/self_repaired since neither the item's state nor CI outcome changed).

Test plan

  • New test: update_branch_puts_to_the_update_branch_endpoint — confirms the right HTTP verb/path
  • New test: pr_ci_status_reports_behind_before_ever_fetching_check_runs — confirms Behind short-circuits before the check-runs API call
  • cargo test --bin agentflare -- worktree:: supervisor:: github::pulls:: — 85 passed, 0 failed
  • cargo build --bin agentflare, cargo fmt --all -- --check, cargo clippy --bin agentflare all clean on touched files

Summary by CodeRabbit

  • New Features

    • Automatically updates mergeable pull request branches when they fall behind the base branch.
    • Review sweeps now track successfully updated branches separately from promoted, repaired, and waiting items.
  • Bug Fixes

    • Improved handling of stale branches during review processing.
    • Review logs now clearly report when branches were updated, including the total count.

…'s update-branch API

Follow-up to the review-sweep BEHIND friction hit repeatedly this
session (PRs #621, #623, #627 all needed a manual git merge
origin/master before they could merge). run_review_sweep now checks
PrCiStatus::Behind (GitHub's own mergeable_state == "behind" -- mergeable,
no conflict, just missing base-branch commits) before ever fetching CI
check runs for that PR, and calls pulls::update_branch (the same
server-side operation the PR page's own "Update branch" button
triggers) to bring it current, letting CI re-run naturally.

Entirely server-side: no local worktree/git state touched, so it can't
race a concurrently-dispatched job still pushing to the same branch the
way a local git merge would.

Agentflare-Agent: claude-code
Agentflare-Branch: task/review-sweep-update-branch
Agentflare-Session: e77fc32e-33d0-4884-ab55-fdda48fe45fd
@coderabbitai

coderabbitai Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1881bb09-72a1-440b-8a26-caf334b90d0f

📥 Commits

Reviewing files that changed from the base of the PR and between 11445e3 and 506d5bf.

📒 Files selected for processing (4)
  • src/dashboard/server.rs
  • src/github/pulls.rs
  • src/supervisor.rs
  • src/worktree.rs

Included review availability: 0 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.


📝 Walkthrough

Walkthrough

The review sweep now detects pull requests behind the base branch, updates stale branches through GitHub, tracks successful updates, and reports the updated count in dashboard logs.

Changes

Stale branch update flow

Layer / File(s) Summary
Behind status and GitHub update API
src/worktree.rs, src/github/pulls.rs
PrCiStatus::Behind represents mergeable pull requests with stale branches. The worktree calls the GitHub update-branch endpoint. Tests verify status detection and the PUT request.
Review sweep update handling
src/supervisor.rs, src/worktree.rs
The review sweep updates behind branches, counts successful updates in updated, and counts failed updates as skipped.
Review sweep result reporting
src/dashboard/server.rs
Dashboard logging includes sweeps with updates and reports the updated count.

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

Merge Risk: ⚪ Minimal · up to 506d5

This change automatically updates cleanly-behind pull request branches through GitHub without altering local worktrees. No actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 76.92% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: automatic updates for cleanly behind pull request branches through GitHub's update-branch API.
Description check ✅ Passed The description explains the problem, implementation, behavior, and test results. It includes Summary and Test plan sections. The optional Notes for reviewers section is missing, but the description i…
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.
Full details: Description check

Explanation

The description explains the problem, implementation, behavior, and test results. It includes Summary and Test plan sections. The optional Notes for reviewers section is missing, but the description is otherwise complete.

  • Fix all pre-merge checks with AI
✨ 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 task/review-sweep-update-branch

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

@getappz
getappz merged commit ebeb2cd into master Aug 28, 2026
17 checks passed
@getappz
getappz deleted the task/review-sweep-update-branch branch August 28, 2026 09:35
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