feat(cli): add a governed, fail-closed --integrate command for reviewable parallel-branch integration (#228)#229
Merged
Conversation
…able parallel-branch integration (#228) Conflict prediction (#226) and isolation (#41, #50) let parallel agents work safely and foresee conflicts, but nothing performed the integration of a parallel agent's branch back into the target in a governed, reviewable way. Add an opt-in --integrate <source> [--integrate-dry-run] command that reuses conflict prediction to refuse a conflicting merge, shows a bounded/redacted preview (changed paths + commit list), and otherwise performs a non-fast-forward merge preserving the source's commit identity. It fails closed on a detached HEAD, dirty tree, unresolvable revision, predicted conflict, or failed merge, and never discards changes or auto-resolves conflicts.
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 (
--integrate) governed, fail-closed command that reviewably integrates a parallel agent's branch into the current branch, decomposed from roadmap #39 (isolated parallel agents).Conflict prediction (#226) and isolation (#41, #50) let parallel agents work safely and foresee conflicts, but nothing performed the integration of a parallel agent's branch back into the target in a governed, reviewable way. This command does, preserving commit identity and failing closed.
Design
src/selective-integration.ts:integrateBranch(workspace, source, { dryRun })reusespredictMergeConflict(Parallel integration: predict whether a parallel agent's branch conflicts with the target before merging, redacted and fail-closed #226) to refuse a conflicting merge, builds a bounded (100 paths / 50 commits), redacted preview (changed paths + commit list), and otherwise performs a non-fast-forward merge (git merge --no-ff) that preserves the source's commit identity. It fails closed on a detached HEAD, a dirty tree, an unresolvable revision, a predicted conflict, or a failed merge.src/index.ts: opt-in--integrate <source>with--integrate-dry-run(preview without merging), wired as a mode (JSON + text), exiting 0 on success and 2 on a usage/state error.The integration never discards changes or auto-resolves conflicts, and the preview surfaces no file contents.
Testing
tests/unit/selective-integration.test.ts(8 tests): clean non-fast-forward integration with commit-identity preservation (two-parent merge commit, feature commit remains an ancestor), conflict refusal, fail-closed on dirty tree / unresolvable revision / detached HEAD, dry-run preview without merge, nothing-to-integrate, and formatting.tests/integration/selective-integration.test.ts(4 tests): CLI integrates a clean branch (JSON) creating a merge commit, refuses a conflicting branch (exit 2, no merge), dry-run preview without merge (text), and exit 2 on unresolvable revision.Gates: typecheck, build, unit (1639), integration (451 + desktop), smoke (51) all pass.
Closes #228