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:
2026-11-04 15:42:03 +01:00
parent e91a3923d0
commit 2bb0ccd3c6
6 changed files with 30 additions and 50 deletions
@@ -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)
}
+4 -7
View File
@@ -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;