From fa886334279b33e059b1d3bc8d71362d8e68944b Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 1 Nov 2026 02:40:56 +0100 Subject: [PATCH] =?UTF-8?q?mesh-build-node=20tests=20decode=20their=20mani?= =?UTF-8?q?fest=20instead=20of=20judging=20it=20(ADR=200578=20=C2=A73)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Claude-Session: https://claude.ai/code/session_01NcbgfJ9Gum47zkFKWRaovL --- .../cmd/mesh-build-node/manifest_test.go | 23 +++++++++++-------- .../cmd/mesh-build-node/reads-outside | 3 +-- modules/mesh-build-node/go.mod | 2 +- modules/mesh-build-node/go.sum | 2 ++ 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/modules/mesh-build-node/cmd/mesh-build-node/manifest_test.go b/modules/mesh-build-node/cmd/mesh-build-node/manifest_test.go index 39860aa0..3da4725c 100644 --- a/modules/mesh-build-node/cmd/mesh-build-node/manifest_test.go +++ b/modules/mesh-build-node/cmd/mesh-build-node/manifest_test.go @@ -20,9 +20,13 @@ const ( func readManifest(t *testing.T) catalogue.Manifest { t.Helper() - m, err := catalogue.ReadTreeManifest(catalogueRoot, moduleDir) + raw, err := os.ReadFile(filepath.Join(moduleDir, "module.json")) if err != nil { - t.Fatalf("mesh-sdk's validator refuses module.json: %v", err) + t.Fatal(err) + } + m, err := catalogue.Decode(raw) // decoded and judged by nothing: the checker judges (ADR 0578 ยง2) + if err != nil { + t.Fatalf("module.json does not decode: %v", err) } return m } @@ -38,13 +42,10 @@ func resource(t *testing.T, m catalogue.Manifest, id string) map[string]any { return nil } -// 1488/AC1: mesh-sdk's validator accepts the module (alone on a shelf too), and it runs as mesh-build-node with its +// 1488/AC1: the module runs as mesh-build-node with its // home at mode 0700, requires user-namespaces and declares the four packages and carries toolchain/package-lock.json. -func TestManifestIsValidAndDeclaresTheAccountTheCapabilityAndThePackages(t *testing.T) { +func TestManifestDeclaresTheAccountTheCapabilityAndThePackages(t *testing.T) { m := readManifest(t) - if problems := catalogue.CatalogueProblems(catalogue.Shelf{m.Module: m}); len(problems) > 0 { - t.Errorf("the catalogue's rules refuse it: %v", problems) - } if m.Module != "mesh-build-node" || m.RunsAs != "mesh-build-node" { t.Errorf("module %q runs as %q, want mesh-build-node as itself", m.Module, m.RunsAs) } @@ -219,10 +220,12 @@ func TestTheModuleRequiresTheArtifactStoreAndIsToldItsAddress(t *testing.T) { if !slices.Contains(m.Requires, "artifact-store") { t.Errorf("requires %v lack artifact-store", m.Requires) } - // The validator reads the template (files/registry) into the resource's content. + // Decoding leaves the template (files/registry) unread in the resource, so its text is read here. r := resource(t, m, "registry") - if content, _ := r["content"].(string); r["type"] != "file" || r["path"] != "${dir:state}/registry" || !strings.Contains(content, "${seat:mesh-artifact-store:reach}") { - t.Errorf("the registry resource is %v", r) + content, err := os.ReadFile(filepath.Join(moduleDir, "files", "registry")) + if err != nil || r["type"] != "file" || r["path"] != "${dir:state}/registry" || r["template"] != "files/registry" || + !strings.Contains(string(content), "${seat:mesh-artifact-store:reach}") { + t.Errorf("the registry resource is %v (template %q, %v)", r, content, err) } } diff --git a/modules/mesh-build-node/cmd/mesh-build-node/reads-outside b/modules/mesh-build-node/cmd/mesh-build-node/reads-outside index 26937843..661a496f 100644 --- a/modules/mesh-build-node/cmd/mesh-build-node/reads-outside +++ b/modules/mesh-build-node/cmd/mesh-build-node/reads-outside @@ -1,5 +1,4 @@ # What these tests read outside their package, as paths from the repository's root (a glob, or a directory read whole; # ? before a path whose absence is read). mesh-build-go hashes them into the package's digest, so its verdict is kept # until one of them changes (issue 1936). An empty list, or a line matching nothing, keeps nothing. -# its manifest through mesh-sdk's validator, which reads the root's predefined keys. -predefined.json +# its manifest, decoded. diff --git a/modules/mesh-build-node/go.mod b/modules/mesh-build-node/go.mod index d22b9a4c..4f97ec62 100644 --- a/modules/mesh-build-node/go.mod +++ b/modules/mesh-build-node/go.mod @@ -3,7 +3,7 @@ module meshbuildnode go 1.26.0 require ( - git.novox.be/novox/mesh-sdk/go v0.1.14-0.20261030174137-a37181261c24 + git.novox.be/novox/mesh-sdk/go v0.1.14-0.20261101013805-4dfc11b42431 github.com/distribution/distribution/v3 v3.1.2 github.com/nats-io/nats.go v1.54.0 ) diff --git a/modules/mesh-build-node/go.sum b/modules/mesh-build-node/go.sum index 9f9ca2a0..8c8a0c0f 100644 --- a/modules/mesh-build-node/go.sum +++ b/modules/mesh-build-node/go.sum @@ -1,5 +1,7 @@ git.novox.be/novox/mesh-sdk/go v0.1.14-0.20261030174137-a37181261c24 h1:s0XXZtR7CFPBbnaDygWnE4/Q827iEFt0YfEzujk4Q9g= git.novox.be/novox/mesh-sdk/go v0.1.14-0.20261030174137-a37181261c24/go.mod h1:ouERNpZizzwZ0HLEtAypsY9FR20FyUgUYRni6J7kVCY= +git.novox.be/novox/mesh-sdk/go v0.1.14-0.20261101013805-4dfc11b42431 h1:3Yv1Jx+/g6xTIKGywYsp6ZWJB4w2oYG/qQSb5ARmmm8= +git.novox.be/novox/mesh-sdk/go v0.1.14-0.20261101013805-4dfc11b42431/go.mod h1:ouERNpZizzwZ0HLEtAypsY9FR20FyUgUYRni6J7kVCY= github.com/alicebob/miniredis/v2 v2.35.0 h1:QwLphYqCEAo1eu1TqPRN2jgVMPBweeQcR21jeqDCONI= github.com/alicebob/miniredis/v2 v2.35.0/go.mod h1:TcL7YfarKPGDAthEtl5NBeHZfeUQj6OXMm/+iu5cLMM= github.com/antithesishq/antithesis-sdk-go v0.7.0-default-no-op h1:Z/MZK75wC/NSrkgqeNIa7jexam9uWzhLmFTSCPI/kn0=