Structural Code Intelligence.
Verified Lossless AST Diffing.
Treediff compares source code at the syntax-tree and symbol level using an arena-allocated CST, dual exact/alpha Merkle fingerprints, O(N log N) adaptive monolith alignment, cross-file move detection, and byte-for-byte verified edit scripts.
Why Existing Tools Hit a Wall
Line-based diffs fracture on moved functions and renames. Earlier structural tools either lack move/rename tracking (Difftastic Dijkstra alignment), fall back to line diffs on parse errors or >10k-line files (Diffmantic), or carry JVM startup and pointer-heavy AST memory overhead (GumTree).
1. Arena CST + Dual Merkle
Contiguous Vec<AstNode> with 32-bit indices, single-buffer string interning, exact_hash, alpha-renamed alpha_hash, and 64-bit sim_sketch.
2. 5-Phase Hybrid Matching
O(N) root/prefix pruning, height-ordered lazy Merkle top-down matching, context-scored duplicate disambiguation, LIS move detection, and O(N log N) LSH fallback for monoliths.
3. Error-Tolerant Recovery
Never abandons a file on syntax errors. Preserves healthy sibling ASTs while recovering multi-line Tree-sitter ERROR spans into structured statement/brace trees.
4. Cross-File Intelligence
Parallel directory and Git revision diffing via Rayon detects functions and classes relocated or renamed across files in a commit.
5. Verified Byte Reconstruction
Every diff emits non-overlapping TextEdit operations verified by apply(old, edits) == new byte-for-byte.
6. Uncertainty & Confidence
Reports honest match confidence scores and explicit AmbiguityRecord entries when duplicate subtrees tie in context.
Interactive Structural Output Explorer
Explore real Treediff outputs across refactoring, move, rename, error recovery, and JSON schema v1.0 modes.
Reproducible Competitive Benchmarks
Loading measured results from data/benchmarks.json...
| Workload | Size | Tool | Status | p50 (ms) | Peak RAM (MB) | Moves | Renames | Fallback |
|---|
CLI, Git & Programmatic APIs
Files & Directories
treediff old.rs new.rs treediff dir_a/ dir_b/ --format summary treediff a.py b.py --format side-by-side --verify
Git Revisions & Driver
treediff --git HEAD~1 HEAD GIT_EXTERNAL_DIFF=treediff git diff treediff --batch pairs.jsonl
Python FFI & JSON v1.0
from treediff_py import TreediffEngine res = TreediffEngine().diff(old, new, "rust") assert res["stats"]["reconstruction_verified"]
17 Native Languages + Structural Fallback
All Tree-sitter parsers are compiled statically into the binary; unsupported formats use the delimiter/indentation structural fallback parser.
Naming Note & Roadmap
Registry Naming Audit
Because treediff is already claimed on crates.io (Byron/treediff-rs) and npm, public registry release is prepared under collision-free treediff-engine / dendrodiff.
v0.2.0 Planned
3-way structural merge driver, C#/PHP/Kotlin/SQL Tree-sitter grammars, WebAssembly target, and HyperAST commit-DAG caching.
Security Guarantees
Never executes analyzed code. Bounded AST depth (1024), bounded file size (16 MiB), symlink-safe directory traversal, and binary NUL rejection.