feat(matching): rank with semantic embeddings and explain matches by evidence

This commit is contained in:
shira committed 2026-10-11 10:39:46 +03:00
1 parent facc1789b1
commit 24b64d698a
215 files changed
+16951 -327

No files matched your search

@@ -219,6 +219,7 @@ func matchConfirmedCandidate(entry matching.Entry) api.MatchConfirmedCandidate {
ConfirmationStatus: api.MatchConfirmedCandidateConfirmationStatusConfirmed,
PublicContext: matchPublicContext(entry.PublicContext),
EvidenceSummary: matchEvidenceSummary(entry.EvidenceSummary),
SemanticEvidence: matchSemanticEvidence(entry.SemanticEvidence),
UnknownFlags: matchUnknownFlags(entry.UnknownFlags),
}
candidate.DeclaredGrade = matchDeclaredGrade(entry.DeclaredGrade)
@@ -251,6 +252,7 @@ func matchUnconfirmedCandidate(entry matching.Entry) api.MatchUnconfirmedCandida
DeclaredGrade: matchDeclaredGrade(entry.DeclaredGrade),
PublicContext: matchPublicContext(entry.PublicContext),
EvidenceSummary: matchEvidenceSummary(entry.EvidenceSummary),
SemanticEvidence: matchSemanticEvidence(entry.SemanticEvidence),
Components: api.MatchUnconfirmedComponents{Fit: entry.Components.Fit, Coverage: entry.Components.Coverage},
UnknownFlags: matchUnknownFlags(entry.UnknownFlags),
}
@@ -300,6 +302,24 @@ func matchEvidenceSummary(items []matching.EvidenceItem) api.MatchEvidenceSummar
return summary
}
// matchSemanticEvidence maps the computed explanation. The list is never
// null, so a client tells "nothing to explain" from a missing field.
func matchSemanticEvidence(items []matching.SemanticEvidence) api.MatchSemanticEvidenceList {
evidence := make(api.MatchSemanticEvidenceList, 0, len(items))
for _, item := range items {
title := api.NilString{Null: true}
if item.ProjectTitle != nil {
title = api.NewNilString(*item.ProjectTitle)
}
evidence = append(evidence, api.MatchSemanticEvidence{
RequirementKind: api.MatchRequirementKind(item.RequirementKind), RequirementText: item.RequirementText,
ItemKind: api.MatchSemanticItemKind(item.ItemKind), ProjectTitle: title,
RepositoryVerified: item.RepositoryVerified, Similarity: api.MatchSimilarityBand(item.Similarity),
})
}
return evidence
}
func matchUnknownFlags(flags []matching.UnknownFlag) api.MatchUnknownFlags {
response := make(api.MatchUnknownFlags, 0, len(flags))
for _, flag := range flags {