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

@@ -81,3 +81,34 @@ func TestEnsureDemoMatchingSectionDoesNotRetryAfterAConcurrentPublication(t *tes
t.Fatalf("versions = %d, want only the concurrent publication stored and no built-on-stale version", len(store.versions))
}
}
func TestEnsureDemoSemanticEnsembleSectionKeepsTheSingleModelVersionBeforeIt(t *testing.T) {
store := &memoryPolicies{}
seedVersion(t, store, domain.PolicyKindDemo, domain.DemoProductPolicyV5())
publisher := NewPublisher(store, testClock)
result, err := publisher.EnsureDemoSemanticEnsembleSection(context.Background(), "operator:night")
if err != nil || !result.Created || result.Version.Version() != 2 {
t.Fatalf("EnsureDemoSemanticEnsembleSection() = %+v, %v, want version 2 created", result, err)
}
semantics := result.Version.Policy().Matching.Semantics
if semantics == nil || len(semantics.Members) != 2 ||
semantics.Members[0].Model.ID != domain.GigaEmbeddingsModelID || semantics.Members[1].Model.ID != domain.Qwen3EmbeddingModelID {
t.Fatalf("semantic members = %+v, want Giga first and Qwen3 second", semantics)
}
if previous := store.versions[0].Policy().Matching.Semantics; len(previous.Members) != 1 {
t.Fatalf("previous version members = %d, want the single-model version kept", len(previous.Members))
}
if result.Version.Policy().Assessment.Signals == nil || result.Version.Policy().Support == nil {
t.Fatal("the ensemble version dropped an earlier section")
}
again, err := publisher.EnsureDemoSemanticEnsembleSection(context.Background(), "operator:night")
if err != nil || again.Created || len(store.versions) != 2 {
t.Fatalf("second call = %+v, %v with %d versions, want no new version", again, err, len(store.versions))
}
single, err := publisher.EnsureDemoSemanticMatchingSection(context.Background(), "operator:night")
if err != nil || single.Created {
t.Fatalf("the single-model command after the ensemble = %+v, %v, want it to leave the ensemble alone", single, err)
}
}