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

@@ -26,19 +26,28 @@ var (
type Dependencies struct {
Transactor outbound.Transactor
Clock func() time.Time
// Semantic schedules the card vector refresh after a publication change;
// nil schedules nothing.
Semantic SemanticTrigger
}
// SemanticTrigger schedules the refresh of a candidate's card vectors.
type SemanticTrigger interface {
CandidateChanged(ctx context.Context, unit outbound.UnitOfWork, candidateID uuid.UUID, at time.Time) error
}
// Service applies candidate-owned privacy settings in one transaction.
type Service struct {
transactor outbound.Transactor
clock func() time.Time
semantic SemanticTrigger
}
func NewService(deps Dependencies) (*Service, error) {
if deps.Transactor == nil || deps.Clock == nil {
return nil, fmt.Errorf("candidateprivacy.NewService - dependencies are missing: %w", ErrPrivacyServiceUnavailable)
}
return &Service{transactor: deps.Transactor, clock: deps.Clock}, nil
return &Service{transactor: deps.Transactor, clock: deps.Clock, semantic: deps.Semantic}, nil
}
func (service *Service) GetMyPrivacySettings(ctx context.Context, userID uuid.UUID) (outbound.CandidatePrivacySettings, error) {
@@ -110,7 +119,17 @@ func (service *Service) SetMyPublication(
if !change.Changed {
return nil
}
return persistPublicationChange(ctx, unit, repository, userID, expectedVersion, change, at, location)
if err := persistPublicationChange(ctx, unit, repository, userID, expectedVersion, change, at, location); err != nil {
return err
}
// The published fields are the text of the card vectors: a closed card
// drops them, and another field set renders another text.
if service.semantic != nil {
if err := service.semantic.CandidateChanged(ctx, unit, userID, at); err != nil {
return fmt.Errorf("%s - schedule vector refresh: %w", location, err)
}
}
return nil
})
if err != nil {
return domain.Publication{}, fmt.Errorf("%s - run transaction: %w", location, err)