fix: Prevent conflict resolution agent from destroying initiative branch

spawnConflictResolutionAgent was passing the initiative branch as branchName,
causing SimpleGitWorktreeManager.create() to force-reset it to the target
branch. Now spawns on a unique temp branch based off the initiative branch,
with the agent using git update-ref to advance the initiative branch after
resolving conflicts. Also fixes stale diff/commits cache after resolution.
This commit is contained in:
Lukas May
2026-03-06 11:40:22 +01:00
parent f428ec027e
commit 0c04a1d273
3 changed files with 20 additions and 8 deletions

View File

@@ -459,7 +459,10 @@ export function initiativeProcedures(publicProcedure: ProcedureBuilder) {
status: 'in_progress',
});
// Spawn agent
// Spawn agent on a unique temp branch based off the initiative branch.
// Using initiative.branch directly as branchName would cause SimpleGitWorktreeManager.create()
// to run `git branch -f <branch> <base>`, force-resetting the initiative branch.
const tempBranch = `${initiative.branch}-conflict-${Date.now()}`;
const prompt = buildConflictResolutionPrompt(initiative.branch, targetBranch, conflicts);
return agentManager.spawn({
name: `conflict-${Date.now()}`,
@@ -468,8 +471,8 @@ export function initiativeProcedures(publicProcedure: ProcedureBuilder) {
mode: 'execute',
provider: input.provider,
initiativeId: input.initiativeId,
baseBranch: targetBranch,
branchName: initiative.branch,
baseBranch: initiative.branch,
branchName: tempBranch,
});
}),
};