mesh-build-node tests decode their manifest instead of judging it (ADR 0578 §3)

Claude-Session: https://claude.ai/code/session_01NcbgfJ9Gum47zkFKWRaovL
This commit is contained in:
2026-11-01 02:40:56 +01:00
parent 762982dee7
commit fa88633427
4 changed files with 17 additions and 13 deletions
@@ -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)
}
}
@@ -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.