feat(ml): fuse two embedding models and protect the ML service with a token

This commit is contained in:
shira committed 2026-10-11 14:40:52 +03:00
1 parent bc00d6901f
commit b24e5ff906
63 files changed
+2287 -276

No files matched your search

@@ -51,6 +51,34 @@ func (publisher *Publisher) EnsureDemoSemanticMatchingSection(ctx context.Contex
domain.DemoSemanticMatchingPolicy)
}
// EnsureDemoSemanticEnsembleSection makes the latest demonstration version
// carry the two-model semantic section
// (domain.DemoSemanticEnsembleMatchingPolicy). A version whose semantic
// section already names exactly the ensemble models, in order, is left
// alone. Otherwise it publishes the next version, a copy of the latest one
// whose matching section is replaced, so the single-model section stays as
// the previous version and a rollback needs no recomputed vectors.
func (publisher *Publisher) EnsureDemoSemanticEnsembleSection(ctx context.Context, author domain.PolicyAuthor) (MatchingResult, error) {
ensemble := domain.DemoMatchingSemanticsEnsemblePolicy()
return publisher.ensureMatching(ctx, author, "Publisher.EnsureDemoSemanticEnsembleSection",
func(current *domain.MatchingPolicy) bool {
return current != nil && current.Semantics != nil && sameMemberModels(current.Semantics.Members, ensemble.Members)
},
domain.DemoSemanticEnsembleMatchingPolicy)
}
func sameMemberModels(left, right []domain.MatchingSemanticMember) bool {
if len(left) != len(right) {
return false
}
for index := range left {
if left[index].Model != right[index].Model {
return false
}
}
return true
}
func (publisher *Publisher) ensureMatching(
ctx context.Context,
author domain.PolicyAuthor,