J7 (2): the checker hands the judge the known packages in composer.Request.Packages, not in Input
Input is the composition's input; the judge's names now have their own field (mesh-sdk), so packagename.Input and the judge's inputOf are gone and mesh-judge reads Packages. Claude-Session: https://claude.ai/code/session_01JG73KJNrH5EgFXMKKYSrig
This commit is contained in:
@@ -21,7 +21,6 @@ import (
|
||||
gobuild "git.novox.be/novox/mesh-catalog/modules/mesh-build-go/buildstep"
|
||||
"git.novox.be/novox/mesh-contracts/go/seats/meshconfig"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/buildrun"
|
||||
"git.novox.be/novox/mesh-delivery/sdk/packagename"
|
||||
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
||||
"git.novox.be/novox/mesh-sdk/go/composer"
|
||||
"git.novox.be/novox/mesh-sdk/go/delivery"
|
||||
@@ -1181,9 +1180,9 @@ func TestTheIndexersJudgeJudgesTheChangesManifests(t *testing.T) {
|
||||
req.Cases[0].Manifests["mail"].Digest != strings.Repeat("a", 64) {
|
||||
t.Fatalf("%s: the request %+v: %v", row.name, req, err)
|
||||
}
|
||||
if in := (packagename.Input{}); row.known != nil && (json.Unmarshal(req.Input, &in) != nil || !reflect.DeepEqual(in.Packages, row.known)) ||
|
||||
row.known == nil && len(req.Input) != 0 && string(req.Input) != "null" {
|
||||
t.Errorf("%s: the judge's input %s, want the known packages %v", row.name, req.Input, row.known)
|
||||
if !reflect.DeepEqual(req.Packages, row.known) || len(req.Input) != 0 && string(req.Input) != "null" {
|
||||
t.Errorf("%s: the judge's known packages %v and input %s, want the known packages %v and no input", row.name,
|
||||
req.Packages, req.Input, row.known)
|
||||
}
|
||||
switch {
|
||||
case row.fails == "" && v.State != delivery.VerdictPass:
|
||||
|
||||
@@ -123,13 +123,7 @@ func (st *state) judgeManifests(ctx context.Context) *delivery.Verdict {
|
||||
req.Predefined = list
|
||||
st.c.note("the manifests are judged against the predefined keys of " + from)
|
||||
}
|
||||
if known := st.knownPackages(ctx); known != nil {
|
||||
input, err := json.Marshal(packagename.Input{Packages: known})
|
||||
if err != nil {
|
||||
return fail(goModule, err.Error())
|
||||
}
|
||||
req.Input = input
|
||||
}
|
||||
req.Packages = st.knownPackages(ctx)
|
||||
raw, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
return fail(goModule, err.Error())
|
||||
|
||||
@@ -128,12 +128,13 @@ func TestBusStateIsJudgedOnce(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// judgedByRequest is every refusal the judge's request (mesh-judge's) answers of shelf's manifests, its Input naming known.
|
||||
// judgedByRequest is every refusal the judge's request (mesh-judge's) answers of shelf's manifests, its Packages naming known,
|
||||
// after the request went over the wire as the checker sends it.
|
||||
func judgedByRequest(t *testing.T, shelf catalogue.Shelf, known KnownPackages) string {
|
||||
t.Helper()
|
||||
input, err := json.Marshal(Input{Packages: slices.Sorted(maps.Keys(known))})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
var names []string
|
||||
if known != nil {
|
||||
names = append([]string{}, slices.Sorted(maps.Keys(known))...)
|
||||
}
|
||||
c := composer.Case{Name: "change", Manifests: map[string]composer.Manifest{}}
|
||||
for name, m := range shelf {
|
||||
@@ -143,7 +144,15 @@ func judgedByRequest(t *testing.T, shelf catalogue.Shelf, known KnownPackages) s
|
||||
}
|
||||
c.Manifests[name] = composer.Manifest{Raw: raw}
|
||||
}
|
||||
v, err := Request(composer.Request{V: composer.Version, Input: input, Cases: []composer.Case{c}})
|
||||
wire, err := json.Marshal(composer.Request{V: composer.Version, Packages: names, Cases: []composer.Case{c}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
r, err := composer.Decode(wire)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
v, err := Request(r)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -205,17 +205,14 @@ const Unnamed = "(between manifests)"
|
||||
|
||||
// Request judges every case of a composer request (mesh-sdk composer.Request), what cmd/mesh-judge answers the checker:
|
||||
// each case's manifests as one catalogue (Shelf), every manifest accepted or refused with its problems, one per line; the
|
||||
// problems no module's removal ends under Between. The request's Input is the judge's (Input): the known packages every
|
||||
// case's `packages` are judged against. The verdict's SDK names this judge (Identity). A manifest left as a digest, a case
|
||||
// named twice, or an Input not of its shape is a request it cannot run.
|
||||
// problems no module's removal ends under Between. The request's Packages are the known packages every case's `packages`
|
||||
// are judged against (nil judges no name). The verdict's SDK names this judge (Identity). A manifest left as a digest, or
|
||||
// a case named twice, is a request it cannot run.
|
||||
func Request(r composer.Request) (composer.Verdict, error) {
|
||||
v := composer.Verdict{V: composer.Version, SDK: Identity()}
|
||||
seen := map[string]bool{}
|
||||
counts := trunkOldSections(r)
|
||||
known, err := inputOf(r.Input)
|
||||
if err != nil {
|
||||
return composer.Verdict{}, err
|
||||
}
|
||||
known := knownOf(r.Packages)
|
||||
for _, c := range r.Cases {
|
||||
if seen[c.Name] {
|
||||
return composer.Verdict{}, fmt.Errorf("the case %q is named twice", c.Name)
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
package judge
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"maps"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
||||
|
||||
"git.novox.be/novox/mesh-delivery/sdk/packagename"
|
||||
)
|
||||
|
||||
// KnownPackages are the names of the packages the mesh knows, each by its name in its own ecosystem (design 32: a Go
|
||||
@@ -19,26 +16,17 @@ import (
|
||||
// sdk/packagename. Nil is no list at hand: the names are then not judged, only their series.
|
||||
type KnownPackages map[string]bool
|
||||
|
||||
// Input is the judge's own input in a judge request (mesh-delivery's sdk/packagename.Input, which the checker hands it).
|
||||
type Input = packagename.Input
|
||||
|
||||
// inputOf reads the known packages a request's Input names; nil when it names none (no list, not an empty one).
|
||||
func inputOf(raw json.RawMessage) (KnownPackages, error) {
|
||||
if len(raw) == 0 || string(raw) == "null" {
|
||||
return nil, nil
|
||||
}
|
||||
var in Input
|
||||
if err := json.Unmarshal(raw, &in); err != nil {
|
||||
return nil, fmt.Errorf("the judge's input is not JSON of its shape: %w", err)
|
||||
}
|
||||
if in.Packages == nil {
|
||||
return nil, nil
|
||||
// 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 in.Packages {
|
||||
for _, name := range names {
|
||||
known[name] = true
|
||||
}
|
||||
return known, nil
|
||||
return known
|
||||
}
|
||||
|
||||
// PackagesCatalogueProblems are the rules of a manifest's `packages` no single manifest can be judged against (DLV-I14;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// own language): a Go package by the module line of its go.mod, a TypeScript package by the name in its package.json, read
|
||||
// at a commit of the repository that builds it. The indexer reads it so at each trunk merge (its packages state's series
|
||||
// keys), and the checker so at a delivery group member's head for a package new in the group, so the judge is handed one
|
||||
// name for each package whoever reads it.
|
||||
// name for each package whoever reads it (mesh-sdk composer.Request.Packages).
|
||||
package packagename
|
||||
|
||||
import (
|
||||
@@ -67,10 +67,3 @@ func Of(ctx context.Context, read ReadFile, repository, commit, dir string, a ca
|
||||
}
|
||||
return "", fmt.Errorf("no %s under %v", file, roots)
|
||||
}
|
||||
|
||||
// Input is the indexer's judge's own input in a judge request (mesh-sdk composer.Request's Input, which the composer reads
|
||||
// as the composition's input and the judge as this), as the checker hands it: the known packages, each by its name in its
|
||||
// own ecosystem, that a manifest's `packages` may name (DLV-I14). A request without one judges no name.
|
||||
type Input struct {
|
||||
Packages []string `json:"packages"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user