diff --git a/modules/mesh-delivery-checker/internal/check/examiner_test.go b/modules/mesh-delivery-checker/internal/check/examiner_test.go index f93feda3..45a27d46 100644 --- a/modules/mesh-delivery-checker/internal/check/examiner_test.go +++ b/modules/mesh-delivery-checker/internal/check/examiner_test.go @@ -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: diff --git a/modules/mesh-delivery-checker/internal/check/manifests_judge.go b/modules/mesh-delivery-checker/internal/check/manifests_judge.go index 42bb640e..a2c88845 100644 --- a/modules/mesh-delivery-checker/internal/check/manifests_judge.go +++ b/modules/mesh-delivery-checker/internal/check/manifests_judge.go @@ -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()) diff --git a/modules/mesh-delivery-indexer/judge/busstate_test.go b/modules/mesh-delivery-indexer/judge/busstate_test.go index ad7d16b7..725a2ccc 100644 --- a/modules/mesh-delivery-indexer/judge/busstate_test.go +++ b/modules/mesh-delivery-indexer/judge/busstate_test.go @@ -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) } diff --git a/modules/mesh-delivery-indexer/judge/judge.go b/modules/mesh-delivery-indexer/judge/judge.go index 83b8bb90..6a688ab0 100644 --- a/modules/mesh-delivery-indexer/judge/judge.go +++ b/modules/mesh-delivery-indexer/judge/judge.go @@ -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) diff --git a/modules/mesh-delivery-indexer/judge/packages.go b/modules/mesh-delivery-indexer/judge/packages.go index 307c9133..cfacae8c 100644 --- a/modules/mesh-delivery-indexer/judge/packages.go +++ b/modules/mesh-delivery-indexer/judge/packages.go @@ -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; diff --git a/sdk/packagename/packagename.go b/sdk/packagename/packagename.go index 51b34986..86d8214b 100644 --- a/sdk/packagename/packagename.go +++ b/sdk/packagename/packagename.go @@ -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"` -}