Skip to content

backport: prepare shared modules and source-change planning - #81

Open
sarthakaggarwal97 wants to merge 2 commits into
valkey-io:mainfrom
sarthakaggarwal97:backport-split/1-prep
Open

backport: prepare shared modules and source-change planning#81
sarthakaggarwal97 wants to merge 2 commits into
valkey-io:mainfrom
sarthakaggarwal97:backport-split/1-prep

Conversation

@sarthakaggarwal97

Copy link
Copy Markdown
Collaborator

This is prep work for sharing one backport engine between the manual and scheduled flows.

It moves the shared Git helpers and missing-test adaptation into their own modules, removes the unused source-PR diff fetch, and consolidates the result parser used by the sweep paths.

It also adds source-change planning. This identifies the single commit representing a merged PR for merge, squash, and single-commit cases. Multi-commit rebase merges stop with a clear manual-backport message because GitHub’s merge SHA contains only the final rewritten commit.

…ules

Mechanical preparation for unifying the manual and sweep apply engines:

- git_commands.py: run_git (was main._run_git), has_staged_changes,
  index_stage_exists, read_index_stage (were sweep_apply) moved verbatim.
  Breaks the sweep_apply -> main import edge.
- missing_test_adaptation.py: the test-adaptation half of sweep_apply.py
  moved verbatim (sandbox, snapshots, prompt, import/restore machinery).
- extract_agent_result_text: two near-identical copies (sweep_apply,
  sweep_validation) deduplicated into scripts/ai/runtime.py, which owns
  the stream-JSON result format.
- Dead code removed: the source PR diff fetch in main.py and the
  BackportPRContext.source_pr_diff field it fed (nothing ever read it),
  and diff_comments.list_marked_source_prs (only tests called it).

No behavior change.

Signed-off-by: Sarthak Aggarwal <sarthagg@amazon.com>
Classify how a merged PR landed (merge / squash / single) and pin the one
authoritative commit that carries its complete change. Rebase merges fail
closed: their merge SHA is only the final rewritten commit, and replaying
a rebased series is unsupported, so those PRs must be backported manually.

Squash-vs-rebase discrimination compares exact patch identities
(git patch-id --verbatim over a binary --full-index diff) between the
merge SHA and the source series. Ambiguous or disconnected histories are
refused rather than guessed at. Incomplete commit listings (the API pages
out on very large PRs) fall back to fetching the authoritative PR head.

Real-Git contract tests cover every classification and refusal path.
Nothing consumes the module yet; the apply engines switch over next.

Signed-off-by: Sarthak Aggarwal <sarthagg@amazon.com>
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Warning

Review limit reached

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

Next review available in: 34 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: CHILL

Plan: Pro Plus

Run ID: c1a96d44-c2e5-441f-b486-d9af6e30f078

📥 Commits

Reviewing files that changed from the base of the PR and between cab64ac and 958c985.

📒 Files selected for processing (16)
  • scripts/ai/runtime.py
  • scripts/backport/diff_comments.py
  • scripts/backport/git_commands.py
  • scripts/backport/main.py
  • scripts/backport/missing_test_adaptation.py
  • scripts/backport/models.py
  • scripts/backport/revert_commit.py
  • scripts/backport/source_plan.py
  • scripts/backport/sweep_apply.py
  • scripts/backport/sweep_git.py
  • scripts/backport/sweep_validation.py
  • tests/test_backport_pr_creator.py
  • tests/test_backport_source_plan.py
  • tests/test_backport_sweep.py
  • tests/test_claude_conflict_resolver.py
  • tests/test_diff_comments.py

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.

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