Problem
internal/application/service/ranking/ranking_utils.go imports codechunking/internal/application/dto to implement ApplyRRFRanks:
func ApplyRRFRanks(results []dto.SearchResultDTO) {
for i := range results {
score := CalculateRRFScore(i + 1)
results[i].EngineScore = score
results[i].SimilarityScore = score
}
}
This creates an upward dependency: a utility sub-package that should be purely mathematical reaches into the application DTO layer. It makes the ranking package untestable in isolation and couples it to the DTO schema.
Suggested Fix
Move ApplyRRFRanks (or an equivalent inline loop) into the service layer (search_service.go) where dto is already imported. Keep ranking package limited to CalculateRRFScore(rank int) float64 — a pure math function with no dependencies.
// ranking/ranking_utils.go — only this remains:
func CalculateRRFScore(rank int) float64 {
const k = 60.0
return 1.0 / (k + float64(rank))
}
// search_service.go — caller handles application:
for i := range results {
score := ranking.CalculateRRFScore(i + 1)
results[i].EngineScore = score
results[i].SimilarityScore = score
}
Files
internal/application/service/ranking/ranking_utils.go
internal/application/service/search_service.go
Problem
internal/application/service/ranking/ranking_utils.goimportscodechunking/internal/application/dtoto implementApplyRRFRanks:This creates an upward dependency: a utility sub-package that should be purely mathematical reaches into the application DTO layer. It makes the
rankingpackage untestable in isolation and couples it to the DTO schema.Suggested Fix
Move
ApplyRRFRanks(or an equivalent inline loop) into the service layer (search_service.go) wheredtois already imported. Keeprankingpackage limited toCalculateRRFScore(rank int) float64— a pure math function with no dependencies.Files
internal/application/service/ranking/ranking_utils.gointernal/application/service/search_service.go