Revision a97fe285a6f90fff5f7daa1f7ce207ef2e9e4ea2

Committed on 15/12/2025 4:25 pm by Zohaib Sibte Hassan <zohaib@sibte.pk> [GitHub Diff]

Refactor: Extract ReplicationEngine to eliminate code duplication

LocalReplicator and ReplicationHandler had ~640 lines of duplicated
prepare/commit/abort logic. This refactoring:

- Extracts common replication logic into ReplicationEngine (477 lines)
- Reduces LocalReplicator from 414 → 84 lines (80% reduction)
- Reduces ReplicationHandler from 1104 → 635 lines (42% reduction)
- Adds comprehensive test coverage (775 lines, 13 tests)

Fixes included:
- DDL schema version tracking: Check for DDL before commit (transaction
removed after commit, breaking version increments on followers)
- GC race condition: Add closed checks in PebbleMetaStore cleanup methods
- Refactor monolithic Prepare() into focused private methods
- Remove broken error handling in WriteIntent (string-matching SQLite
errors when MetaStore is PebbleDB - dead code that never executed)

All tests passing. No behavioral changes to replication protocol.

???? Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>