mergeresolve

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package mergeresolve provides AI-driven automatic resolution of git merge conflicts produced by the mergequeue when two parallel task branches both touch the same lines of a file.

The resolver implements the mergequeue.Resolver interface and is wired in from the orchestrator when worktree-parallel mode is enabled and a provider is available. When the merge queue encounters a conflict it hands the resolver the list of conflicted files (with conflict markers intact) and expects back the resolved content for each. The queue then writes the files, stages them, and finishes the merge commit — fully automating what would otherwise be a manual operation.

The resolver is intentionally conservative:

  • It only resolves files git reports as "both modified" (status code UU). "Add/add", "delete/modify", and rename conflicts are left for human attention because they involve structural decisions an LLM should not silently make.
  • It refuses to "resolve" a file if the AI's output still contains conflict markers (<<<<<<<, =======, >>>>>>>) — that's a sign the model gave up and we'd commit broken code.
  • Each file is bounded by MaxFileBytes so a single huge generated file can't blow up the prompt or the merge commit.
  • On any error the caller (mergequeue) falls back to `git merge --abort`, so the existing manual-resolution path is preserved.

Index

Constants

View Source
const DefaultTimeout = 90 * time.Second

DefaultTimeout is the per-file timeout for the provider call when the caller does not specify one explicitly. Each conflicted file is resolved in its own provider call so this bounds the slowest file, not the whole merge.

View Source
const MaxFileBytes = 64 * 1024

MaxFileBytes bounds the size of any single conflicted file the resolver will hand to the AI. Larger files are skipped (the merge is aborted as if no resolver were configured) because they would dominate the prompt and the LLM's chance of producing a correct unified resolution falls sharply.

Variables

This section is empty.

Functions

This section is empty.

Types

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

Resolver uses an AI provider to resolve git merge conflicts.

Construct with New(provider, model) and pass into mergequeue.Queue via SetResolver. Safe for concurrent calls.

func New

func New(p provider.Provider, model string, timeout time.Duration) *Resolver

New returns a Resolver that delegates to the given provider/model. model may be empty in which case the provider's DefaultModel is used by the callee. timeout may be zero in which case DefaultTimeout is used per file.

func (*Resolver) Resolve

Resolve handles a batch of conflicted files. For every file it returns a ResolvedFile whose Content is free of conflict markers. Implements the mergequeue.Resolver interface.

Files that exceed MaxFileBytes or that the AI cannot resolve cleanly are omitted from the result so the caller (mergequeue.Queue) sees a partial answer and falls back to `git merge --abort`. This conservative behaviour preserves the existing manual-resolution path whenever auto-resolve isn't confident.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL