Add merge gate and AI-assisted merge pick to fork merge-pick#27
Open
plebioda wants to merge 2 commits into
Open
Add merge gate and AI-assisted merge pick to fork merge-pick#27plebioda wants to merge 2 commits into
fork merge-pick#27plebioda wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a deterministic “merge gate” (decides when to merge) and an optional AI-assisted “merge pick” flow (decides which upstream commit boundary to merge to) to the mergai fork merge-pick command set, and surfaces the gate decision in fork status.
Changes:
- Add
fork.merge_gateandfork.ai_pickconfig sections and implement a pureevaluate_merge_gate()+GateDecision. - Extend
fork merge-pickwith--plan(token-free JSON decision) and--ai(agent pick within a capped candidate window, with validation and fallback). - Add prompts and tests covering the gate logic, window capping, deterministic resolution, and AI-pick validation/fallback behavior.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_merge_pick_ai.py | Command-level tests for merge-pick --plan and --ai flows (including JSON output and fallback cases). |
| tests/test_merge_gate.py | Unit tests for gate evaluation, window capping, deterministic/window sha resolution, and config parsing. |
| src/mergai/utils/git_utils.py | Adds ForkStatus.unmerged_oldest_age_days and surfaces it in JSON divergence output. |
| src/mergai/prompts/system_prompt_merge_pick.md | New system prompt instructing the agent how to choose a merge boundary and output JSON. |
| src/mergai/prompts/init.py | Adds loader for the merge-pick system prompt. |
| src/mergai/prompt_builder.py | Adds build_merge_pick_prompt() to assemble system prompt + optional project rules + candidates JSON. |
| src/mergai/merge_pick_strategies/gate.py | Implements the pure deterministic merge gate and GateDecision. |
| src/mergai/config.py | Adds MergeGateConfig and AiPickConfig and wires them into ForkConfig. |
| src/mergai/commands/fork.py | Implements candidate-window capping, gate computation, merge-pick --plan, and merge-pick --ai (with validation/fallback), and surfaces gate decision in fork status. |
| README.md | Documents new config sections and CLI flags (--plan, --ai). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9147620 to
414c9b1
Compare
A deterministic gate (count + age + force-strategy override, capped by a max batch size) decides whether to merge now; the deterministic pick chooses where to cut within the candidate window. No AI tokens, safe for an unprivileged periodic phase. - config: `MergeGateConfig` (min_commits / max_age_days / max_commits / force_strategies, with string-or-list and enum validation) and `AiPickConfig` (consumed here by `--plan` to report the mode) on `ForkConfig`. - `ForkStatus.unmerged_oldest_age_days`, surfaced in `to_dict()`. - gate: pure `evaluate_merge_gate()` + `GateDecision`. - fork.py: candidate-window restriction, `compute_gate`, the banded `resolve_deterministic_sha` (forced-below-min, else first in-band match, else window tip), `merge-pick --plan` (token-free JSON decision) and `merge-pick --gate` (gate-respecting deterministic pick), and the gate decision surfaced in `fork status`. - docs + tests for the gate, window capping, deterministic resolution, and config parsing.
Builds on the deterministic gate/pick: when fork.ai_pick is enabled, an AI
agent chooses the merge boundary within the candidate window instead of the
deterministic resolver.
- config: `AiPickConfig.fallback` is validated against {deterministic, error}.
- prompts: `system_prompt_merge_pick.md` + loader + `build_merge_pick_prompt`
(system prompt + optional project rules + candidate JSON).
- fork.py: `merge-pick --ai [--next] [--force] [--json]` (agent pick within
the window, sha + reasoning validation, deterministic/error fallback, clean
stdout in capture modes), the candidate-window input builder, and the
agent-sha resolver.
- docs + tests for the AI pick output, validation, and fallback.
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.
A deterministic gate decides when to merge; the pick (deterministic or AI) decides which upstream commit to merge to.
MergeGateConfig(min_commits/max_age_days/max_commits/ force_strategies) andAiPickConfig(enabled/agent/rules_file/fallback) onForkConfig.ForkStatus.unmerged_oldest_age_days: age of the oldest unmerged commit (distinct fromdays_behind), surfaced into_dict().evaluate_merge_gate()+GateDecisionover fork status and prioritized commits, no AI tokens.merge-pick --plan: token-free JSON decision (wait / merge + mode + sha), deterministic sha capped to the candidate window.merge-pick --ai [--next] [--force] [--json]: gate re-check, agent pick within the window, sha validation, deterministic/error fallback. Styled human output plus--jsonfor downstream processing.fork status.