The conflict resolution test was failing because when two nodes had the same
timestamp but different UUIDs/data, the system would just keep local data
instead of applying proper conflict resolution logic.
## 🔧 Fix Details
- Implement "oldest-node rule" for timestamp collisions in 2-node clusters
- When timestamps are equal, the node with the earliest joined_timestamp wins
- Add fallback to UUID comparison if membership info is unavailable
- Enhanced logging for conflict resolution debugging
## 🧪 Test Results
- All integration tests now pass (8/8)
- Conflict resolution test consistently converges to the same value
- Maintains data consistency across cluster nodes
This implements the sophisticated conflict resolution mentioned in the design
docs using majority vote with oldest-node tie-breaking, correctly handling
the 2-node cluster scenario used in integration tests.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Implemented fetchSingleKVFromPeer: HTTP client to fetch KV pairs from peers
- Implemented getLocalData: Badger DB access for local data retrieval
- Implemented deleteKVLocally: Local deletion with timestamp index cleanup
- Implemented storeReplicatedDataWithMetadata: Preserves original UUID/timestamp
- Implemented resolveConflict: Simple conflict resolution (newer timestamp wins)
- Implemented fetchAndStoreRange: Fetches KV ranges for Merkle sync
This fixes the critical data replication issue where sync was failing with
"not implemented" errors. Integration tests now pass for data replication.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Removed all duplicate Server methods from main.go (630 lines)
- Fixed import conflicts and unused imports
- main.go reduced from 3,298 to 340 lines (89% reduction)
- Clean modular structure with server package handling all server functionality
- Achieved clean build with no compilation errors
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Create cluster/merkle.go with Merkle tree operations
- Create cluster/gossip.go with gossip protocol implementation
- Create cluster/sync.go with data synchronization logic
- Create cluster/bootstrap.go with cluster joining functionality
Major clustering functionality now properly separated:
* MerkleService: Tree building, hashing, filtering
* GossipService: Member discovery, health checking, list merging
* SyncService: Merkle-based synchronization between nodes
* BootstrapService: Seed node joining and initial sync
Build tested and verified working. Ready for main.go integration.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>