Add PR merge optimizer tool (batch conflict-free merge planner)#514
Draft
tsainez wants to merge 1 commit into
Draft
Add PR merge optimizer tool (batch conflict-free merge planner)#514tsainez wants to merge 1 commit into
tsainez wants to merge 1 commit into
Conversation
Implements the "AI-Powered Batch Pull Request Merger" design as a standalone maintenance tool under scripts/pr_merge_optimizer/. The tool models a set of open pull requests as a conflict graph and computes the largest conflict-free batch via Maximum Independent Set (MIS); the remaining PRs are flagged for manual/agentic resolution. - models.py: PullRequest / MergePlan data models and file classification (binary assets, Git LFS, engine scene/prefab formats as hard conflicts). - mis.py: exact branch-and-bound Maximum Independent Set solver with isolated-vertex and max-degree reductions plus an upper-bound cutoff. - conflict_graph.py: file-overlap pre-filter + pluggable precise check. - git_simulator.py: side-effect-free `git merge-tree` pairwise check. - github_client.py: stdlib GitHub REST fetch with offline-testable parsing. - optimizer.py / cli.py: orchestration and a `python -m` command line. Tests (tests/test_pr_merge_optimizer.py) validate the MIS solver against a brute-force oracle over random graphs, conflict-graph construction, the game/RTS asset handling, and the CLI. Docs added and wired into mkdocs nav. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NJKckD5An9CHFUu8GHHTDT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Implements the AI-Powered Batch Pull Request Merger design as a standalone maintenance tool under
scripts/pr_merge_optimizer/.The tool analyzes a set of open pull requests, builds a pairwise conflict graph, and computes the largest set of PRs that can be merged together without conflicts by solving the Maximum Independent Set (MIS) on that graph. The remaining PRs are flagged for manual / agentic conflict resolution.
Pipeline (per the design doc):
git merge-treesimulation, or a conservative default.Module layout (
scripts/pr_merge_optimizer/):models.py—PullRequest/MergePlandata models and file classification.mis.py— exact branch-and-bound MIS solver (isolated-vertex + max-degree reductions, upper-bound cutoff).conflict_graph.py— file-overlap pre-filter + pluggable precise conflict check.git_simulator.py—git merge-treepairwise conflict tester (no working-tree side effects).github_client.py— stdlib-only GitHub REST fetch, with offline-testable payload parsing.optimizer.py/cli.py/__main__.py— orchestration and apython -m scripts.pr_merge_optimizerCLI.Game / RTS adaptation: overlaps on binary assets (
.png,.fbx,.wav, …), Git LFS tracked files, and engine scene/prefab formats (.unity,.prefab,.tscn,.uasset, …) are treated as hard, unmergeable conflicts, since the default git text driver corrupts them (the engine-scene rule is toggleable for repos with a smart merge driver configured).The tool lives under
scripts/(not thecommand_line_conflict/game package) because it operates on git/GitHub metadata rather than the engine.Example:
Type of change
Checklist:
Verification
All project gates pass locally (
./scripts/pre_commit.sh): Black, isort, Flake8, Pylint (9.83/10), Mypy, and pytest — 305 passed, 80.87% coverage.mkdocs build --strictsucceeds. The MIS solver is validated in tests against a brute-force oracle over 60 random graphs. Uses the Python standard library only — no new dependencies.🤖 Generated with Claude Code
https://claude.ai/code/session_01NJKckD5An9CHFUu8GHHTDT
Generated by Claude Code