ADR 0593 §7: the composer with its refusals leaves mesh-sdk, so mesh-sdk carries no composition rule. The catalogue functions only the node-engine's composition reaches (Resolve, Resolution's Compose, Declaration, DataItems, LeftOut, Rules and the rest, the settings, placeholder and template refusals, the rendering helpers) are copied with their tests into internal/compose/resolution; a method of a mesh-sdk shape becomes a function taking it first. The composition calls its own copies, and the captured catalogue its tests read lives here now, shared by mesh-compose's tests. Claude-Session: https://claude.ai/code/session_01NcbgfJ9Gum47zkFKWRaovL
41 lines
1.8 KiB
Go
41 lines
1.8 KiB
Go
package resolution
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
mcat "git.novox.be/novox/mesh-sdk/go/catalogue"
|
|
)
|
|
|
|
// The artifact store's seat is one per mesh, read from the catalogue beside this checkout.
|
|
//
|
|
// **A second store anywhere is refused by name, not discovered as a consumer failure.** The seat
|
|
// was node-scoped, so a second `distribution` on another machine resolved cleanly there — and a
|
|
// node-scoped requirement with one candidate installs that candidate on the node, so anything that
|
|
// required the store's presence beside it would have raised a fresh, empty store on the wrong
|
|
// machine. Only afterwards did the mesh notice: `artifact-store` offered by two nodes, and every
|
|
// consumer elsewhere refusing to choose. The claim says it first, where the second store is
|
|
// assigned.
|
|
func TestASecondArtifactStoreAnywhereIsRefusedByName(t *testing.T) {
|
|
store := catalogueManifest(t, "distribution")
|
|
|
|
// The first store resolves as it always has.
|
|
if _, err := Resolve(shelf(store), []string{"distribution"}, workstation(), mcat.World{}); err != nil {
|
|
t.Fatalf("the store alone does not resolve: %v", err)
|
|
}
|
|
|
|
// A second one, on any other machine, is refused — and the refusal names the seat.
|
|
elsewhere := mcat.World{Held: []mcat.Held{{Claim: "mesh-artifact-store", Scope: mcat.ScopeMesh,
|
|
Node: "anchor", Module: "distribution"}}}
|
|
other := workstation()
|
|
other.Name = "laptop"
|
|
_, err := Resolve(shelf(store), []string{"distribution"}, other, elsewhere)
|
|
if err == nil {
|
|
t.Fatal("a second store was accepted on another machine; it would offer artifact-store a " +
|
|
"second time and every consumer elsewhere would refuse to choose")
|
|
}
|
|
if !strings.Contains(err.Error(), "mesh-artifact-store") || !strings.Contains(err.Error(), "one per mesh") {
|
|
t.Fatalf("refused without naming the seat: %v", err)
|
|
}
|
|
}
|