Revision 9cba252c24b22466028139cfe4b66893ce01ec4a

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

Refactor WriteCoordinator with comprehensive unit tests

Extract reusable components from WriteCoordinator:
- ClusterState: encapsulates cluster topology and quorum calculation
- TxnMetrics: centralized transaction telemetry recording
- Error types: PrepareConflictError, QuorumNotAchievedError,
CoordinatorNotParticipatedError, PartialCommitError

Add comprehensive unit test suite (142 tests + 5 benchmarks):
- Builder methods (validateStatements, buildPrepareRequest, buildCommitRequest)
- Prepare phase (runPreparePhase, executePreparePhase)
- Commit phase (sendRemoteCommits, waitForRemoteQuorum, commitLocalAfterRemoteQuorum)
- Integration tests for full transaction state machines
- Network partition and split-brain prevention tests
- Concurrency and race condition tests (10 dedicated tests)

Fix code quality issues:
- Race condition in TestWaitForCondition (use atomic.Int32)
- Unchecked errors in abort path (add explicit ignore with comment)
- Remove unused fields from test helpers
- Fix impossible len() < 0 condition
- Fix error comparison in classifyPrepareError (use type assertion)

All tests pass with -race flag.

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

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