A mesh carries its whole licence, not only its name
CI / test (push) Failing after 6m25s

GLBs carried the licence's name, URL and notice in asset.extras.license.
A pipeline that sorts assets by licence needs what a machine matches on:
the id, whether commercial use is allowed, the regions it excludes, the
revenue cap and the attribution. The whole licence is written, as
/v1/models gives it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5.5 committed 2026-10-14 01:12:47 +02:00
1 parent cfc636e328
commit 2eb2a6d8fe
2 files changed
+40 -5

No files matched your search

+9 -5
View File
@@ -221,12 +221,16 @@ func glbWithLicense(glb []byte, lic catalog.License) ([]byte, error) {
if extras == nil {
extras = map[string]any{}
}
l := map[string]any{"name": lic.Name}
if lic.URL != "" {
l["url"] = lic.URL
// The whole licence, as /v1/models gives it: its id, whether it allows
// commercial use and where it grants nothing are what a pipeline that
// sorts assets by licence reads, and the name alone is for people.
var l map[string]any
b, err := json.Marshal(lic)
if err != nil {
return nil, err
}
if lic.Notice != "" {
l["notice"] = lic.Notice
if err := json.Unmarshal(b, &l); err != nil {
return nil, err
}
extras["license"] = l
asset["extras"] = extras
+31
View File
@@ -401,3 +401,34 @@ func TestAModelAsleepUntilAskedIsListedAndSaidAsleep(t *testing.T) {
t.Error("a model serving is not said loaded")
}
}
func TestAMeshCarriesItsWholeLicence(t *testing.T) {
// The name alone was written: a pipeline that sorts assets by licence
// reads the id, whether commercial use is allowed and where it is not.
glb, err := objToGLB([]byte("v 0 0 0\nv 1 0 0\nv 1 1 0\nf 1 2 3\n"))
if err != nil {
t.Fatal(err)
}
yes := true
out, err := glbWithLicense(glb, catalog.License{ID: "stability-community", Name: "Stability AI Community License",
Commercial: &yes, RevenueCapUSD: 1000000, Attribution: "Powered by Stability AI", ExcludedRegions: []string{"XX"}})
if err != nil {
t.Fatal(err)
}
n := binary.LittleEndian.Uint32(out[12:])
var doc struct {
Asset struct {
Extras struct {
License map[string]any `json:"license"`
} `json:"extras"`
} `json:"asset"`
}
if err := json.Unmarshal(out[20:20+n], &doc); err != nil {
t.Fatal(err)
}
l := doc.Asset.Extras.License
if l["id"] != "stability-community" || l["commercial"] != true || l["revenue_cap_usd"] != 1000000.0 ||
l["attribution"] != "Powered by Stability AI" || l["name"] == nil {
t.Errorf("licence %v", l)
}
}