feat(cli): add a read-only, fail-closed --predict-conflict command for safe parallel-branch integration (#226)#227
Merged
Conversation
…r safe parallel-branch integration (#226) Isolation (#41, #50) lets parallel agents work in separate worktrees, but nothing told an operator whether integrating a parallel agent's branch back would conflict before attempting it, risking a half-applied, hard-to-review merge. Add an opt-in --predict-conflict <source> [--conflict-target <target>] command that runs git merge-tree --write-tree (no working-tree mutation, no commit) to predict clean-vs-conflict and report a bounded, redacted list of conflicting paths. It fails closed on a dirty working tree, an unresolvable revision, or a merge-tree error, so a bad prediction can never lead to a silent bad merge.
Owner
Author
E2E verification
|
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.
Summary
Adds an opt-in (
--predict-conflict) read-only, fail-closed command that predicts whether integrating one revision into another would conflict, decomposed from roadmap #39 (isolated parallel agents).Isolation (#41, #50) lets parallel agents work in separate worktrees, but nothing told an operator whether integrating a parallel agent's branch back would conflict before attempting it — risking a half-applied, hard-to-review merge. This command predicts the outcome safely and read-only.
Design
src/conflict-prediction.ts:predictMergeConflict(workspace, source, target)runsgit merge-tree --write-tree --name-only(no working-tree mutation, no commit) and reports clean-vs-conflict plus a bounded (100), redacted (home collapsed) list of conflicting paths. It fails closed on a dirty working tree, an unresolvable revision, or a merge-tree error.src/index.ts: opt-in--predict-conflict <source>with--conflict-target <target>(defaultHEAD), wired as a read-only mode (JSON + text), exiting 0 on a successful prediction and 2 on a usage/state error.The prediction is strictly read-only (merge-tree computes the merge without touching the worktree or creating a commit) and never surfaces file contents.
Testing
tests/unit/conflict-prediction.test.ts(8 tests): clean vs. conflict classification against real temp repos, conflicting-path reporting, fail-closed on unresolvable revision / dirty tree / non-repo, no-mutation proof, and formatting.tests/integration/conflict-prediction.test.ts(5 tests): CLI predicts CONFLICT (JSON) for a divergent branch without mutating the repo, CLEAN (text) for a non-conflicting branch, default target HEAD, and exit 2 on unresolvable revision / dirty tree.Gates: typecheck, build, unit (1631), integration (447 + desktop), smoke (51) all pass.
Closes #226