diff --git a/modules/mesh-delivery-sdk/steprun/askrun.go b/modules/mesh-delivery-sdk/steprun/askrun.go index 01525731..74577abd 100644 --- a/modules/mesh-delivery-sdk/steprun/askrun.go +++ b/modules/mesh-delivery-sdk/steprun/askrun.go @@ -165,7 +165,9 @@ func (s AskSteps) fetch(ctx context.Context, fetch *sdkstep.Fetch) (json.RawMess // onToolchain is the toolchain this node builds with when the ask names one and this module reports its own, nil when // either is absent. A node on another toolchain than the ask names answers a Declining: it is not on the agreed one and -// sits out, for a node that is to take the ask (novox/hq ADR 0584 clause 2). +// sits out, for a node that is to take the ask (novox/hq ADR 0584 clause 2). The recipe is compared only when the ask names +// one: the runner names a step ask's language and version alone, the recipe and the node's digest being the seat's to report, +// not the runner's to know (design 47 G §416, A-104). func (s AskSteps) onToolchain(ctx context.Context, want *sdkstep.ToolchainUsed) (*sdkstep.ToolchainUsed, error) { if want == nil || s.Toolchain == nil { return nil, nil @@ -174,7 +176,7 @@ func (s AskSteps) onToolchain(ctx context.Context, want *sdkstep.ToolchainUsed) if err != nil { return nil, err } - if !sdkstep.SameToolchainVersion(tc.Version, want.Version) || tc.Recipe != want.Recipe { + if !sdkstep.SameToolchainVersion(tc.Version, want.Version) || (want.Recipe != "" && tc.Recipe != want.Recipe) { return nil, &Declining{Lacks: []string{fmt.Sprintf("the agreed toolchain %s (recipe %s)", sdkstep.LanguageVersion(want.Version), want.Recipe)}, Text: fmt.Sprintf("the ask is for %s (recipe %s) and this node builds with %s (recipe %s): it sits out, and the ask is left to a node on the agreed toolchain", sdkstep.LanguageVersion(want.Version), want.Recipe, sdkstep.LanguageVersion(tc.Version), tc.Recipe)} diff --git a/modules/mesh-delivery-sdk/steprun/askrun_test.go b/modules/mesh-delivery-sdk/steprun/askrun_test.go index 4fb03b81..f868984f 100644 --- a/modules/mesh-delivery-sdk/steprun/askrun_test.go +++ b/modules/mesh-delivery-sdk/steprun/askrun_test.go @@ -512,3 +512,27 @@ func TestRunAskRunsAPipelineStepAndSaysItsEnd(t *testing.T) { } } } + +// Design 47 G §416, A-104: the runner names a step ask's toolchain by language and version alone, so a node on that version +// takes it whatever its recipe; an ask that names a recipe still declines a node on another. +func TestAnAskNamingNoRecipeIsNotDeclinedForItsRecipe(t *testing.T) { + for _, c := range []struct { + name string + want sdkstep.ToolchainUsed + decline bool + }{ + {"version, no recipe", sdkstep.ToolchainUsed{Version: "go1.26"}, false}, + {"the same recipe", sdkstep.ToolchainUsed{Version: "go1.26", Recipe: "3"}, false}, + {"another recipe", sdkstep.ToolchainUsed{Version: "go1.26", Recipe: "4"}, true}, + {"another version, no recipe", sdkstep.ToolchainUsed{Version: "go1.27"}, true}, + } { + s := AskSteps{Toolchain: func(context.Context) (sdkstep.ToolchainUsed, error) { + return sdkstep.ToolchainUsed{Version: "go1.26.2", Recipe: "3"}, nil + }} + _, err := s.onToolchain(context.Background(), &c.want) + var dec *Declining + if errors.As(err, &dec) != c.decline || (err != nil && !c.decline) { + t.Errorf("%s: err %v, want declined %v", c.name, err, c.decline) + } + } +}