1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//! # merge-engine
//!
//! A non-LLM merge conflict resolver that uses program analysis techniques
//! from recent academic research to automatically resolve git merge conflicts.
//!
//! ## Approach
//!
//! The engine applies a pipeline of increasingly sophisticated strategies:
//!
//! 1. **Pattern-based DSL rules** — Matches common conflict patterns
//! (whitespace-only, identical changes, import unions, adjacent edits)
//! and resolves them instantly with high confidence.
//! *Based on: Svyatkovskiy et al., "Can Program Synthesis be Used to Learn
//! Merge Conflict Resolutions?", ICSE 2021*
//!
//! 2. **Structured merge via tree-sitter CSTs** — Parses code into concrete
//! syntax trees and performs three-way tree amalgamation, eliminating false
//! conflicts that arise from formatting changes or reordering.
//! *Based on: Duarte, Borba, Cavalcanti, "LASTMERGE — A Language-Agnostic
//! Structured Tool for Code Integration", arXiv 2025;
//! Neto & Borba, "On the Methodology of Three-Way Structured Merge", JSA 2023*
//!
//! 3. **Version Space Algebra (VSA)** — For remaining conflicts, builds a
//! compact representation of all possible resolutions by combining edits
//! from both sides, then enumerates and ranks candidates.
//! *Based on: Zhu & He, "Conflict Resolution for Structured Merge via
//! Version Space Algebra", OOPSLA 2018 / AutoMerge*
//!
//! 4. **Search-based resolution with parent similarity** — Uses evolutionary
//! search (genetic algorithm) over candidate resolutions, scored by a
//! fitness function that measures token-level similarity to both parents.
//! *Based on: Campos Junior et al., "Towards a Feasible Evaluation Function
//! for Search-Based Merge Conflict Resolution", ACM TOSEM, July 2025*
//!
//! ## Supported Languages
//!
//! Tree-sitter-based structured merge supports: Rust, JavaScript, TypeScript,
//! Python, Java, Go, C, C++. Pattern-based and search-based strategies work
//! on any text content.
//!
//! ## Example
//!
//! ```rust
//! use merge_engine::{Resolver, ResolverConfig, Language};
//!
//! let config = ResolverConfig {
//! language: Some(Language::Rust),
//! ..Default::default()
//! };
//! let resolver = Resolver::new(config);
//!
//! let result = resolver.resolve_file(
//! "fn main() { println!(\"hello\"); }",
//! "fn main() { println!(\"hello world\"); }",
//! "fn main() { println!(\"hello\"); eprintln!(\"debug\"); }",
//! );
//!
//! println!("All resolved: {}", result.all_resolved);
//! println!("Merged:\n{}", result.merged_content);
//! ```
// Re-export primary public API
pub use ;
pub use ;