mesh/delivery merged: source.main moved to novox/mesh-delivery@68581bed7e36
mesh/check failed: mesh-build-go: the change's manifests cannot be judged: the seat list is not read (the seat list is … | 2e9f23f34828 on 68581bed7e36
The review of 0f5c186b: counting each record's packages made 94 sub-package
paths, commands among them, known names, which design 32 forbids; the seven
names refused live are each their record's module (issue 1966).
Claude-Session: https://claude.ai/code/session_01NcbgfFfQ4Z9UE5jK32PmE5
70 lines
3.1 KiB
Go
70 lines
3.1 KiB
Go
package judge
|
|
|
|
import (
|
|
"fmt"
|
|
"maps"
|
|
"slices"
|
|
"strings"
|
|
|
|
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
|
)
|
|
|
|
// KnownPackages are the names of the packages the mesh knows, each by its name in its own ecosystem (design 32: a Go
|
|
// package's go.mod module path, a TypeScript package's package.json name): the names the indexer's packages state holds
|
|
// (its series keys, index.SeriesPackage's Name), read at each trunk merge, and, at the merge check, the names a member
|
|
// of the change's delivery group names at its head for a package new in the group, and the Go module path of each
|
|
// per-module record the state holds: a Go module the trunk holds a record of is known while no build module builds Go
|
|
// package artifacts (issue 1966), never a package inside it. Both read a name with mesh-delivery's
|
|
// sdk/packagename. Nil is no list at hand: the names are then not judged, only their series.
|
|
type KnownPackages map[string]bool
|
|
|
|
// knownOf is the known packages a request names (composer.Request.Packages); nil when it names none (no list, not an
|
|
// empty one).
|
|
func knownOf(names []string) KnownPackages {
|
|
if names == nil {
|
|
return nil
|
|
}
|
|
known := KnownPackages{}
|
|
for _, name := range names {
|
|
known[name] = true
|
|
}
|
|
return known
|
|
}
|
|
|
|
// PackagesCatalogueProblems are the rules of a manifest's `packages` no single manifest can be judged against (DLV-I14;
|
|
// ADR 0606 §4, design 32 *A package, its series, and the series its users accept*): each name is a known package's name in
|
|
// its own ecosystem (known; not judged when nil), and each series is `<major>.<minor>`.
|
|
func PackagesCatalogueProblems(shelf catalogue.Shelf, known KnownPackages) []string {
|
|
var problems []string
|
|
for _, module := range shelfOrder(shelf) {
|
|
accepts := shelf[module].Packages
|
|
problems = append(problems, UnknownPackageNames(module, shelf[module], known)...)
|
|
for _, name := range slices.Sorted(maps.Keys(accepts)) {
|
|
if s := strings.TrimSpace(accepts[name]); !seriesForm.MatchString(s) {
|
|
problems = append(problems, fmt.Sprintf("%s's packages accept %q in the series %q, which is no <major>.<minor> "+
|
|
"such as 0.1 (design 32)", module, name, accepts[name]))
|
|
}
|
|
}
|
|
}
|
|
return problems
|
|
}
|
|
|
|
// UnknownPackageNames are the problems of module's manifest m whose `packages` name a package known does not (DLV-I14,
|
|
// design 32), one per name, sorted; none when known is nil. PackagesCatalogueProblems says them among the rest; the indexer
|
|
// asks them of a manifest a merge takes in, whose candidate was judged without them (the checker judges a pull request's
|
|
// names, knowing its delivery group).
|
|
func UnknownPackageNames(module string, m catalogue.Manifest, known KnownPackages) []string {
|
|
if known == nil {
|
|
return nil
|
|
}
|
|
var problems []string
|
|
for _, name := range slices.Sorted(maps.Keys(m.Packages)) {
|
|
if !known[name] {
|
|
problems = append(problems, fmt.Sprintf("%s's packages name %q, which no package of the mesh is named "+
|
|
"(a package is named in its own language: a Go package by its go.mod's module path, a TypeScript "+
|
|
"package by its package.json's name; design 32)", module, name))
|
|
}
|
|
}
|
|
return problems
|
|
}
|