feat(dolt): add peer-to-peer federation integration tests (bd-wkumz.9)

Add MergeAllowUnrelated for initial federation sync between
independently initialized towns.

Integration tests cover:
- Two-server push/pull operations
- Conflict resolution strategies
- Work handoff between towns
- Reputation tracking

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
emma
2026-01-20 23:14:58 -08:00
committed by Steve Yegge
parent fa14b9ee24
commit cff58c4639
2 changed files with 872 additions and 0 deletions

View File

@@ -455,6 +455,22 @@ func (s *DoltStore) Merge(ctx context.Context, branch string) ([]storage.Conflic
return nil, nil
}
// MergeAllowUnrelated merges the specified branch allowing unrelated histories.
// This is needed for initial federation sync between independently initialized towns.
// Returns any merge conflicts if present.
func (s *DoltStore) MergeAllowUnrelated(ctx context.Context, branch string) ([]storage.Conflict, error) {
_, err := s.db.ExecContext(ctx, "CALL DOLT_MERGE('--allow-unrelated-histories', ?)", branch)
if err != nil {
// Check if the error is due to conflicts
conflicts, conflictErr := s.GetConflicts(ctx)
if conflictErr == nil && len(conflicts) > 0 {
return conflicts, nil
}
return nil, fmt.Errorf("failed to merge branch %s: %w", branch, err)
}
return nil, nil
}
// CurrentBranch returns the current branch name
func (s *DoltStore) CurrentBranch(ctx context.Context) (string, error) {
var branch string