The delivery repository's contracts and SDK live under modules/ as mesh-delivery-contracts and mesh-delivery-sdk, their Go module paths renamed to match the folders (the TypeScript names already did), and every importer in mesh-delivery, mesh-catalog, mesh-host, mesh-tools and mesh-sdk follows in the same group: a design as it should be, one path per module, checked by the group's check building every importer. Builds: design 47 G §427, §88 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
44 lines
1.4 KiB
Go
44 lines
1.4 KiB
Go
package judge
|
|
|
|
import (
|
|
"fmt"
|
|
"slices"
|
|
"strings"
|
|
|
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
|
)
|
|
|
|
// PackageNameProblems refuses a revision in which two modules' entries carry the same package name in one ecosystem, naming
|
|
// both (design 47 G §491, §676): a name read as a module must name one. It judges the entries' package fields, which the
|
|
// indexer wrote at take-in from the revision's own files, and answers each owning module's problems, sorted.
|
|
func PackageNameProblems(entries []meshcatalog.CatalogEntry) map[string][]string {
|
|
owners := map[string][]string{} // ecosystem and name -> modules
|
|
for _, e := range entries {
|
|
for _, a := range e.Artifacts {
|
|
if a.Package == nil {
|
|
continue
|
|
}
|
|
key := a.Package.Ecosystem + " " + a.Package.Name
|
|
if !slices.Contains(owners[key], e.Module) {
|
|
owners[key] = append(owners[key], e.Module)
|
|
}
|
|
}
|
|
}
|
|
out := map[string][]string{}
|
|
for key, modules := range owners {
|
|
if len(modules) < 2 {
|
|
continue
|
|
}
|
|
slices.Sort(modules)
|
|
ecosystem, name, _ := strings.Cut(key, " ")
|
|
problem := fmt.Sprintf("the %s package name %s is carried by the artifacts of %s: a package's name belongs to one module (design 47 G section 491)", ecosystem, name, strings.Join(modules, " and "))
|
|
for _, m := range modules {
|
|
out[m] = append(out[m], problem)
|
|
}
|
|
}
|
|
for m := range out {
|
|
slices.Sort(out[m])
|
|
}
|
|
return out
|
|
}
|