feat(worker): add PlanningMergeOrchestrator.ContinueAsync to resume merge after conflict
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -125,6 +125,73 @@ public sealed class PlanningMergeOrchestratorTests : IDisposable
|
||||
return (parentId, subA, subB);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ContinueAsync_AfterConflict_ResumesRemainingMergesAndCompletes()
|
||||
{
|
||||
var db = NewDb();
|
||||
var repo = NewRepo();
|
||||
GitRepoFixture.RunGit(repo.RepoDir, "branch", "-m", "main");
|
||||
|
||||
var (parentId, subA, subB, subC) = await SeedPlanningThreeChildrenMiddleConflictsAsync(db, repo);
|
||||
|
||||
var (orch, spy) = BuildOrchestrator(db);
|
||||
await orch.StartAsync(parentId, "main", CancellationToken.None);
|
||||
|
||||
Assert.Contains(spy, c => c.Method == "PlanningSubtaskMerged" && (string)c.Args[1]! == subA);
|
||||
Assert.Contains(spy, c => c.Method == "PlanningMergeConflict" && (string)c.Args[1]! == subB);
|
||||
|
||||
File.WriteAllText(Path.Combine(repo.RepoDir, "README.md"), "resolved\n");
|
||||
|
||||
await orch.ContinueAsync(parentId, CancellationToken.None);
|
||||
|
||||
using var ctx = db.CreateContext();
|
||||
Assert.Equal(TaskStatus.Done, ctx.Tasks.Single(t => t.Id == parentId).Status);
|
||||
Assert.Equal(WorktreeState.Merged, ctx.Worktrees.Single(w => w.TaskId == subB).State);
|
||||
Assert.Equal(WorktreeState.Merged, ctx.Worktrees.Single(w => w.TaskId == subC).State);
|
||||
Assert.Contains(spy, c => c.Method == "PlanningSubtaskMerged" && (string)c.Args[1]! == subB);
|
||||
Assert.Contains(spy, c => c.Method == "PlanningSubtaskMerged" && (string)c.Args[1]! == subC);
|
||||
Assert.Contains(spy, c => c.Method == "PlanningCompleted");
|
||||
}
|
||||
|
||||
private async Task<(string parentId, string subA, string subB, string subC)> SeedPlanningThreeChildrenMiddleConflictsAsync(
|
||||
DbFixture db, GitRepoFixture repo)
|
||||
{
|
||||
File.WriteAllText(Path.Combine(repo.RepoDir, "README.md"), "# main change\n");
|
||||
GitRepoFixture.RunGit(repo.RepoDir, "commit", "-am", "main change README");
|
||||
|
||||
using var ctx = db.CreateContext();
|
||||
var listId = Guid.NewGuid().ToString();
|
||||
ctx.Lists.Add(new ListEntity
|
||||
{
|
||||
Id = listId, Name = "test", CreatedAt = DateTime.UtcNow, WorkingDir = repo.RepoDir,
|
||||
});
|
||||
var parentId = Guid.NewGuid().ToString();
|
||||
ctx.Tasks.Add(new TaskEntity
|
||||
{
|
||||
Id = parentId, ListId = listId, Title = "plan", CreatedAt = DateTime.UtcNow,
|
||||
Status = TaskStatus.Planned, SortOrder = 0,
|
||||
});
|
||||
var subA = Guid.NewGuid().ToString();
|
||||
var subB = Guid.NewGuid().ToString();
|
||||
var subC = Guid.NewGuid().ToString();
|
||||
ctx.Tasks.AddRange(
|
||||
new TaskEntity { Id = subA, ListId = listId, Title = "A", CreatedAt = DateTime.UtcNow, ParentTaskId = parentId, Status = TaskStatus.Done, SortOrder = 1 },
|
||||
new TaskEntity { Id = subB, ListId = listId, Title = "B", CreatedAt = DateTime.UtcNow, ParentTaskId = parentId, Status = TaskStatus.Done, SortOrder = 2 },
|
||||
new TaskEntity { Id = subC, ListId = listId, Title = "C", CreatedAt = DateTime.UtcNow, ParentTaskId = parentId, Status = TaskStatus.Done, SortOrder = 3 }
|
||||
);
|
||||
await ctx.SaveChangesAsync();
|
||||
|
||||
SeedWorktreeWithFile(ctx, repo, subA, "fileA.txt", "A\n");
|
||||
SeedWorktreeWithFile(ctx, repo, subB, "README.md", "branch change\n");
|
||||
SeedWorktreeWithFile(ctx, repo, subC, "fileC.txt", "C\n");
|
||||
await ctx.SaveChangesAsync();
|
||||
|
||||
return (parentId, subA, subB, subC);
|
||||
}
|
||||
|
||||
private void SeedWorktreeWithFile(ClaudeDoDbContext ctx, GitRepoFixture repo, string taskId, string filename, string content)
|
||||
=> SeedWorktree(ctx, repo, taskId, filename, content);
|
||||
|
||||
private void SeedWorktree(ClaudeDoDbContext ctx, GitRepoFixture repo, string taskId, string filename, string content)
|
||||
{
|
||||
var wtPath = Path.Combine(Path.GetTempPath(), $"wt_{Guid.NewGuid():N}");
|
||||
|
||||
Reference in New Issue
Block a user