Skip to content

Entity-level semantic merge for worktree merges #255

@rs545837

Description

@rs545837

Problem

When multiple agents work in parallel on the same repo, each in its own worktree, they often touch the same files. Two agents editing different functions in the same file creates a merge conflict that shouldn't exist. Git's line-level merge doesn't understand code structure.

Right now, the merge path is:

  • workspace-worktree plugin creates isolated worktrees
  • Agents open PRs
  • scm.mergePR() squash-merges via GitHub API
  • If there are conflicts → the PR is "not mergeable" and the user has to resolve manually

This becomes a real bottleneck as the number of parallel agents grows. The auto-merge.yaml example workflow breaks down when two agents touch overlapping files.

Proposed solution

Weave is an entity-level semantic merge driver for Git. Instead of merging lines, it merges at the level of functions, classes, and methods using tree-sitter. On a 31-scenario benchmark, it resolves 100% cleanly vs git's 48%.

It could plug into Agent Orchestrator at two levels:

1. Git merge driver (zero code changes)

Weave installs as a git merge driver via .gitattributes. If the workspace-worktree plugin auto-configures this when creating worktrees, all local merges become entity-aware. Two agents editing different functions in the same file merge cleanly every time.

# .gitattributes (auto-configured per worktree)
*.ts merge=weave
*.py merge=weave
*.js merge=weave
*.go merge=weave
*.rs merge=weave

2. Pre-merge conflict detection (new plugin or reaction)

Weave ships as an MCP server with 14 tools. Relevant ones for AO:

  • weave_diff → entity-level diff (which functions changed, not which lines)
  • weave_potential_conflicts → detect when two branches modify the same entity
  • weave_impact_analysis → transitive blast radius of changes

This could power a new reaction or a pre-merge check:

  • Before an agent's PR is merged, check if it overlaps with other active sessions at the entity level
  • Suggest merge ordering: sessions touching high-dependent entities (foundations) merge first, leaf changes merge last
  • When conflicts do occur, classify them (signature change, body divergence, import conflict) so the agent gets structured context instead of raw diff hunks

3. Smarter ci-failed reaction

When CI fails after a merge, weave_impact_analysis can identify which entities were affected by the merge and narrow down the failure cause, giving the fixing agent a smaller search space.

Details

Weave supports TypeScript, JavaScript, Python, Go, Rust, Java, C, C++, Ruby, C# and more. Installs via Homebrew (brew install ataraxy-labs/tap/weave) or as a single binary.

Happy to help with integration or answer questions. The plugin architecture makes this a natural fit as either a workspace plugin enhancement or a new plugin slot.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions