Skip to content

feat(cli): add a read-only, fail-closed --predict-conflict command for safe parallel-branch integration (#226)#227

Merged
qwen-code-dev-bot merged 1 commit into
mainfrom
issue/226-conflict-prediction
Jul 22, 2026
Merged

feat(cli): add a read-only, fail-closed --predict-conflict command for safe parallel-branch integration (#226)#227
qwen-code-dev-bot merged 1 commit into
mainfrom
issue/226-conflict-prediction

Conversation

@qwen-code-dev-bot

Copy link
Copy Markdown
Owner

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

  • New src/conflict-prediction.ts: predictMergeConflict(workspace, source, target) runs git 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> (default HEAD), 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

…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.
@qwen-code-dev-bot

Copy link
Copy Markdown
Owner Author

E2E verification

  • Repository: qwen-code-dev-bot/oh-my-cli
  • Pull request: #227
  • Commit: 5b2130a9d59d001af68afdd02b566127c5b2ec47
  • Evidence mode: terminal
  • Result: PASS
Scenario Command Exit Duration
integration npm run test:integration 0 29.078s
smoke npm run smoke 0 3.268s

E2E evidence

Full immutable report

@qwen-code-dev-bot
qwen-code-dev-bot merged commit 6fe245b into main Jul 22, 2026
2 checks passed
@qwen-code-dev-bot
qwen-code-dev-bot deleted the issue/226-conflict-prediction branch July 22, 2026 23:00
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.

Parallel integration: predict whether a parallel agent's branch conflicts with the target before merging, redacted and fail-closed

1 participant