From 0f167db73dff05fee3e771823e44c57bcca5fe85 Mon Sep 17 00:00:00 2001 From: jochen Date: Sat, 21 Nov 2026 11:10:01 +0100 Subject: [PATCH] Rerun of validate or composition asks the shared ask (H-A-236) The rerun verb looked a step's ask up by the mover's id, but the validate ask is one per pipeline and names no mover, so every validate rerun, and a composition rerun, was refused "placed no ask now". Builds: design 47 H H-A-236 --- .../internal/pipeline/verbs.go | 16 +++++++ .../internal/pipeline/verbs_test.go | 42 +++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/verbs.go b/modules/mesh-delivery-pipeline/internal/pipeline/verbs.go index d86cec3b..6ccd0f0b 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/verbs.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/verbs.go @@ -509,6 +509,22 @@ func (v Verbs) askOf(p seat.Pipeline, s seat.StepResult, caller string, now time if !ok { return nil, fmt.Errorf("%s moves no module %q", p.Pipeline, s.Module) } + // The validate ask is the pipeline's one, naming no mover (H-A-51): its rerun asks that one ask again; a composition's + // rerun builds the mover's composition ask directly, never looked up among the placed steps (H-A-236). + switch s.Step { + case seat.StepResultStepValidate, seat.StepResultStepComposition: + if s.Seat == wants.Seat { + id, step := AskID(now, p.Pipeline, "", "", seat.StepResultStepValidate), wants.StepRunStepValidate + if s.Step == seat.StepResultStepComposition { + id, step = AskID(now, p.Pipeline, m.Module, "", seat.StepResultStepComposition), wants.StepRunStepComposition + } + a := wantsAsk(p, m, id, step) + b := a.Ask.(wants.StepRun) + b.Rerun, b.By = true, caller + a.Ask = b + return &a, nil + } + } reg, ok := v.Starter.Registration(m.Module) if !ok { return nil, fmt.Errorf("%s has no registration", m.Module) diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/verbs_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/verbs_test.go index a2c8adae..ed9a67c3 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/verbs_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/verbs_test.go @@ -8,6 +8,7 @@ import ( catalog "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner" + wants "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants" nodebuildgo "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/nodebuildgo" "git.novox.be/novox/mesh-sdk/go/views" ) @@ -252,6 +253,47 @@ func TestRerunOfARunAsksWithItsCandidatesHalf(t *testing.T) { } } +// H-A-236: a rerun of a failed pipeline's validate step asks the pipeline's one validate ask again (H-A-51), naming no +// mover in its id; a rerun of a composition step builds the mover's composition ask directly. Neither is refused "placed no +// ask now". +func TestRerunOfValidateOrCompositionAsksTheSharedAsk(t *testing.T) { + v, store, _, asks, _, _ := verbsFixture() + reg, entries := placeFixture() + reg.Policy.Steps.Validate, reg.Policy.Steps.Composition = "required", "required" + v.Starter.Registration = func(string) (catalog.Registration, bool) { return reg, true } + p, rev, _ := store.Get(pkey) + p.Steps, _ = Place(p, p.Movers[0], reg, entries, time.Unix(1, 0), "the-runner") + for i := range p.Steps { + switch p.Steps[i].Step { + case seat.StepResultStepValidate: + p.Steps[i].Outcome = seat.StepResultOutcomeFailed + case seat.StepResultStepComposition: + p.Steps[i].Outcome = seat.StepResultOutcomeNotAsked + } + } + p.Outcome = seat.PipelineOutcomeFailed + store.Update(pkey, p, rev) + now := v.now() + for _, c := range []struct{ step, module string }{{seat.StepResultStepValidate, ""}, {seat.StepResultStepComposition, "app"}} { + n := len(asks.asks) + r, err := v.Rerun("operator", seat.RerunInput{Pipeline: pkey, Module: "app", Step: c.step, Why: "the holder restarted"}) + want := AskID(now, pkey, c.module, "", c.step) + if err != nil || r.Result == nil || r.Result.Ask != want || r.Result.Outcome != seat.StepResultOutcomeRunning { + t.Fatalf("a rerun of %s = %+v, %v, want running under %s", c.step, r.Result, err, want) + } + if len(asks.asks) != n+1 || asks.ids[n] != want { + t.Fatalf("a rerun of %s asked %v, want one ask under %s", c.step, asks.ids[n:], want) + } + b, ok := asks.asks[n].(wants.StepRun) + if !ok || b.Step != c.step || b.Module != "app" || b.Pipeline != pkey || !b.Rerun || b.By != "operator" || b.Asker != seat.Seat { + t.Errorf("the %s ask = %+v", c.step, asks.asks[n]) + } + p, rev, _ = store.Get(pkey) + p.Steps[stepIndex(p, c.step, "")].Outcome = seat.StepResultOutcomeFailed + store.Update(pkey, p, rev) + } +} + func stepIndex(p seat.Pipeline, step, artifact string) int { for i, s := range p.Steps { if s.Step == step && s.Artifact == artifact {