Skip to content

feat: implement semantic conflict detection in workspace merge #611

@Aureliolo

Description

@Aureliolo

Summary

Workspace merge only detects textual git conflicts (merge markers). Semantic conflicts (broken imports, type mismatches, logic errors from independently correct changes) are not detected.

Finding (from codebase audit)

  • src/synthorg/engine/workspace/git_worktree.py:549-550:
    # Git diff --diff-filter=U only detects textual conflicts;
    # semantic conflict detection is not yet implemented
  • Only ConflictType.TEXTUAL conflicts are created
  • The design spec (engine.md, section 9.3) requires: "Semantic conflicts: review agent evaluates merged result"

Impact

When two agents work on parallel workspace branches and their changes are merged:

  • Textual conflicts (merge markers) are caught correctly
  • But merged code can have correct syntax yet broken semantics (e.g., Agent A renames a function, Agent B adds a call to the old name - merge succeeds but code is broken)

Approach Options

  1. LLM-based review: After merge, pass the diff to an LLM agent asking "does this merged result have semantic conflicts?"
  2. AST-based analysis: Parse merged code, check for undefined references, type mismatches
  3. Test-based validation: Run the test suite on the merged result to detect regressions
  4. Hybrid: Quick AST check + targeted LLM review for suspicious patterns

Design Spec Reference

  • Engine design page, section 9.3 (Workspace Isolation, Strategy 1)

Files to Modify

  • src/synthorg/engine/workspace/git_worktree.py (add semantic analysis after merge)
  • Possibly new module src/synthorg/engine/workspace/semantic_analyzer.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope:medium1-3 days of workspec:agent-systemDESIGN_SPEC Section 3 - Agent Systemtype:featureNew feature implementationv0.5Minor version v0.5v0.5.3Patch release v0.5.3

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions