From 9ffdaca898b5c2696d9b748288c6cedf76393bff Mon Sep 17 00:00:00 2001 From: jochen Date: Thu, 5 Nov 2026 16:33:43 +0100 Subject: [PATCH] =?UTF-8?q?Join:=20one=20buildstep=20Toolchain=20(the=20se?= =?UTF-8?q?ats'=20value)=20under=20the=20agreement=20rule;=20the=20package?= =?UTF-8?q?s=20key=20is=20the=20seat's=20key=20form=20(ADR=200634=20=C2=A7?= =?UTF-8?q?2;=20issue=201966)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../internal/index/packages_values.go | 2 +- .../mesh-delivery-view/internal/view/names.go | 3 ++- modules/mesh-delivery-view/manifest_test.go | 12 ++++++++++++ sdk/buildstep/toolchains.go | 16 ++++++---------- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/modules/mesh-delivery-indexer/internal/index/packages_values.go b/modules/mesh-delivery-indexer/internal/index/packages_values.go index c4b6b870..31932492 100644 --- a/modules/mesh-delivery-indexer/internal/index/packages_values.go +++ b/modules/mesh-delivery-indexer/internal/index/packages_values.go @@ -22,7 +22,7 @@ func PackagesKey(module string) (string, error) { if _, _, ok := trunk.PackageRepository(module); !ok { return "", fmt.Errorf("index: %q is no mesh Go module's path (it starts with %s)", module, trunk.ForgeModulePrefix) } - return keys.EscapeName(module), nil + return meshcatalog.PackagesByModuleKey(keys.EscapeName(module)), nil } func checkPublished(p meshcatalog.PackagesByModuleValue) error { diff --git a/modules/mesh-delivery-view/internal/view/names.go b/modules/mesh-delivery-view/internal/view/names.go index d4b29075..6b0ee441 100644 --- a/modules/mesh-delivery-view/internal/view/names.go +++ b/modules/mesh-delivery-view/internal/view/names.go @@ -4,6 +4,7 @@ import ( "fmt" "git.novox.be/novox/mesh-delivery/contracts/go/clients/meshcatalogclient" + "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog" "git.novox.be/novox/mesh-delivery/sdk/trunk" "git.novox.be/novox/mesh-sdk/go/keys" ) @@ -84,5 +85,5 @@ func PackagesKey(module string) (string, error) { if _, _, ok := trunk.PackageRepository(module); !ok { return "", fmt.Errorf("view: %q is no mesh Go module's path", module) } - return keys.EscapeName(module), nil + return meshcatalog.PackagesByModuleKey(keys.EscapeName(module)), nil } diff --git a/modules/mesh-delivery-view/manifest_test.go b/modules/mesh-delivery-view/manifest_test.go index a493ff4e..29894aaf 100644 --- a/modules/mesh-delivery-view/manifest_test.go +++ b/modules/mesh-delivery-view/manifest_test.go @@ -13,7 +13,9 @@ import ( "strings" "testing" + "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-view/viewstate" + "git.novox.be/novox/mesh-sdk/go/keys" ) // The controller's manifest reader is mesh-controller internal/catalogue (ParseManifest), an internal package of another @@ -179,6 +181,16 @@ func TestManifestIsTakenAndReadsOnly(t *testing.T) { // 1134/AC7 if viewstate.ViewModule != m.Module || viewstate.ViewAnswersBucket != m.Module+"_answers" || viewstate.ReachBucket != m.Module+"_reach" { t.Errorf("the view names itself %s (%s, %s), its manifest %s", viewstate.ViewModule, viewstate.ViewAnswersBucket, viewstate.ReachBucket, m.Module) } + // The packages key is the seat's key of its state packages for a module (), as the indexer writes it: the + // escaped path, with no dot, so a reader never takes it for a . key. + const path = "git.novox.be/novox/mesh-sdk/go" + key, err := view.PackagesKey(path) + if want := meshcatalog.PackagesByModuleKey(keys.EscapeName(path)); err != nil || key != want || strings.Contains(key, ".") { + t.Errorf("the packages key of %s is %q (%v), the seat's is %q", path, key, err, want) + } + if module, ok := meshcatalog.ParsePackagesByModuleKey(key); !ok || module != keys.EscapeName(path) { + t.Errorf("the seat does not read %q as a module key: %q %v", key, module, ok) + } }) for _, a := range m.Build.Artifacts { // A bundle compiled to a binary is one executable: what the runtime loads is that binary's name, or the controller's diff --git a/sdk/buildstep/toolchains.go b/sdk/buildstep/toolchains.go index 6dc878f7..ea88ffc2 100644 --- a/sdk/buildstep/toolchains.go +++ b/sdk/buildstep/toolchains.go @@ -13,13 +13,9 @@ import ( // ToolchainNoReport is the reason AgreedToolchain gives when no node has reported a language's toolchain. const ToolchainNoReport = "toolchain not yet reported" -// Toolchain is what a toolchain is identified by: the language, the installed version and the build module's recipe -// version. It has the fields of the mesh-catalog client's Toolchain2, which a caller converts it to. -type Toolchain struct { - Language string - Version string - Recipe string -} +// toolchainID is what a toolchain is identified by: the language, the installed version and the build module's recipe +// version (a Toolchain's other fields, its layout version and its time, do not tell two toolchains apart). +type toolchainID struct{ Language, Version, Recipe string } // NodeToolchain is one node's entry of a language, as read from a build seat's state toolchains. type NodeToolchain struct { @@ -52,14 +48,14 @@ func ToolchainAgreement(entries []NodeToolchain) Agreement { if len(entries) == 0 { return Agreement{Wait: ToolchainNoReport} } - groups := map[Toolchain][]string{} + groups := map[toolchainID][]string{} for _, e := range entries { - k := Toolchain{Language: e.Language, Version: e.Version, Recipe: e.Recipe} + k := toolchainID{Language: e.Language, Version: e.Version, Recipe: e.Recipe} groups[k] = append(groups[k], e.Node) } for k, nodes := range groups { if 2*len(nodes) > len(entries) { - a := Agreement{Toolchain: k} + a := Agreement{Toolchain: Toolchain{Language: k.Language, Version: k.Version, Recipe: k.Recipe}} for _, e := range entries { if e.Version != k.Version || e.Recipe != k.Recipe { a.SittingOut = append(a.SittingOut, SittingOut{Node: e.Node, Version: e.Version, Recipe: e.Recipe})