feat(domain): add git rebase-on-main with agent-powered conflict resolution and sync-main#396
Merged
feat(domain): add git rebase-on-main with agent-powered conflict resolution and sync-main#396
Conversation
…-sync Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ents Address rejection feedback: conflict resolution should be automatic with agents instead of abort-and-report. Updated question 2 to use agent-powered resolution with iterative retry loop and abort fallback. Added new FRs for agent conflict resolution (FR-6 through FR-13), new NFR for cost control, new open question for max retries, and bumped size estimate to L.
…base-sync Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ebase-sync Populates research.yaml with 8 structured technology decisions covering conflict resolution architecture, agent invocation patterns, git operations layer, error handling strategy, sync main strategy, prompt design, worktree support, and retry strategy. Each decision includes context, options with pros/cons, chosen option, and rationale grounded in codebase patterns. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extend GitPrErrorCode with REBASE_CONFLICT and SYNC_FAILED codes for rebase conflict detection and sync failure classification. Add six new method signatures to IGitPrService: syncMain, rebaseOnMain, getConflictedFiles, stageFiles, rebaseContinue, rebaseAbort. Add stub implementations to GitPrService for compilation. Update interface tests to cover all 11 error codes and 26 methods. Update all test mocks that type-check against IGitPrService. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implement syncMain, rebaseOnMain, getConflictedFiles, stageFiles, rebaseContinue, and rebaseAbort methods on GitPrService. Extend parseGitError with REBASE_CONFLICT and SYNC_FAILED classification. Add comprehensive unit tests covering all methods and error paths. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…e and sync Add application layer for git rebase-on-main and sync-main operations: - ConflictResolutionService with iterative agent-powered conflict resolution loop (3 retries per commit, abort fallback) - RebaseFeatureOnMainUseCase with auto-sync, worktree support, and conflict resolution delegation - SyncRepositoryMainUseCase with repo resolution and default branch detection - DI container registrations with class and string-token aliases - Conflict resolution prompt builder following merge-prompts pattern - 29 unit tests covering all new code Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Integration tests for syncMain and rebaseOnMain against real temporary git repositories. Covers clean sync, diverged main, idempotent sync, clean rebase, conflict detection, dirty worktree, branch-not-found, conflict resolution helpers, and linear history verification. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…-rebase-sync Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ations Add server actions, action hooks, and UI buttons for rebase-on-main and sync-main operations in the web UI. Feature drawer overview tab shows a "Rebase on Main" button under GIT OPERATIONS. Repository drawer shows a "Sync Main" button. Both actions wire through existing use cases via DI. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…actions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ktrees syncMain now uses `git fetch origin <branch>` instead of `git fetch origin <branch>:<branch>` when on a different branch, avoiding the "refusing to fetch into branch checked out at..." error when main is checked out in another worktree. rebaseOnMain now targets `origin/<baseBranch>` instead of the local ref, ensuring the rebase always uses the freshly-fetched remote state. Also adds detection for the "Not possible to fast-forward" error message from git pull. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add `as unknown as` casts to IFeatureRepository and IWorktreeService mocks in rebase use case test to prevent type errors when the interfaces are extended by other branches during CI merge. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…tibility Add syncMain, rebaseOnMain, getConflictedFiles, stageFiles, rebaseContinue, rebaseAbort mocks to adopt-branch test and findByRemoteUrl, update mocks to sync-repository test to match extended interfaces after rebase onto main. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
e07e490 to
469cb84
Compare
Add a new git-rebase-sync feature flag (disabled by default) that controls visibility of the rebase on main and sync main ui operations. The flag is configurable from the settings page under feature flags. When disabled, the git operations sections are hidden from feature and repository drawers. Changes span all layers: typespec model, sqlite migration (042), settings mapper, defaults factory, feature-flags lib and context, settings page ui, drawer components, and all related tests and stories. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
the get-graph-data cache skipped computing behindCount when currentBranch === defaultBranch, always setting it to 0. this meant local main behind origin/main was never shown in the ui. remove the branch equality guard so rev-list runs for all branches including main itself. also remove the sha-based early return so behind count is recomputed on every ttl refresh even when head has not changed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…t version Port fixes from main to resolve E2E Docker test failure: the generated next.config.mjs was missing output:"standalone" causing Next.js server startup crash in production, and the next dependency is pinned to 16.1.6 to prevent unexpected breaking changes from minor updates. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add getBranchSyncStatus method to IGitPrService interface and GitPrService - Create GetBranchSyncStatusUseCase with remote sync before status check - Register use case in DI container with string-token alias - Create server action and storybook mock for get-branch-sync-status - Add rebase phase timing to RebaseFeatureOnMainUseCase (standalone agent run) - Add 'rebase' to NODE_TO_PHASE map in activity tab - Create useBranchSyncStatus hook with 30s TTL module-level cache - Create BranchSyncStatus component replacing FeatureGitOperations - Update overview-tab, feature-drawer-tabs, and feature-drawer-client - Auto-refresh sync status after successful rebase - Add unit tests for service, use case, and component Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ature Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
blackpc
pushed a commit
that referenced
this pull request
Mar 22, 2026
# [1.137.0](v1.136.1...v1.137.0) (2026-03-22) ### Features * **domain:** add git rebase-on-main with agent-powered conflict resolution and sync-main ([#396](#396)) ([d4cfb72](d4cfb72))
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
rebaseOnMain()toIGitPrServicethat rebases a feature branch ontoorigin/<baseBranch>with automatic agent-powered conflict resolution. Before rebasing, the system syncs the remote-tracking ref and verifies the worktree is clean. When conflicts are detected, an AI agent iteratively resolves them (up to 3 retries per commit), validates no conflict markers remain, stages resolved files, and continues the rebase. Falls back togit rebase --abortif the agent cannot resolve.syncMain()toIGitPrServicethat fetches the latest remote state. Works from any branch: usesgit fetch origin <baseBranch>when on a feature branch (updates onlyorigin/<baseBranch>, avoids touching the local branch ref), orgit pull --ff-onlywhen on the base branch. This design prevents the "refusing to fetch into branch checked out at..." error when main is checked out in another worktree.GitPrErrorCodeenum withREBASE_CONFLICTandSYNC_FAILEDfor precise programmatic error handling.RebaseFeatureOnMainUseCase(resolves feature, worktree path, invokes sync + rebase with conflict resolution) andSyncRepositoryMainUseCase(resolves repository, invokes sync).ConflictResolutionServiceorchestrates agentic resolution viaIAgentExecutorProvider: detects conflicted files, invokes AI agent with conflict context (file contents, branch info, markers), validates resolution, retries up to 3 times per commit, aborts on exhaustion.rebaseFeature,syncRepository), action hooks, and UI buttons. Feature drawer overview tab shows a "Rebase on Main" button under a BRANCH SYNC section. Repository drawer shows a "Sync Main" button under GIT OPERATIONS. Both actions delegate to existing use cases via DI.gitRebaseSyncfeature flag, configurable from the Settings page.Key Fix (Iteration 4)
The
syncMainmethod previously usedgit fetch origin main:mainwhich fails withfatal: refusing to fetch into branch 'refs/heads/main' checked out at '/path/to/repo'when the main branch is checked out in the primary worktree. Now usesgit fetch origin main(updates only the remote-tracking reforigin/main) andrebaseOnMaintargetsorigin/<baseBranch>directly. This correctly supports git worktree workflows where the main branch is checked out in the primary repo.Evidence
Feature Flag in Settings
Repository Drawer — Sync Main
Feature Drawer — Branch Sync Status & Rebase on Main
Overview Tab with Rebase Action
Loading State
Test Evidence
Test plan
GitPrService.rebaseOnMain: clean rebase, conflict detection, dirty worktree rejection, rebases ontoorigin/mainGitPrService.syncMain: fetch from feature branch (worktree-safe), pull from main, diverged rejection, error classificationConflictResolutionService: successful resolution, retry logic, abort on max retriesRebaseFeatureOnMainUseCase: happy path, feature not found, sync failure, conflict resolution flowSyncRepositoryMainUseCase: happy path, repo not found, sync failure propagation🤖 Generated with Claude Code