Runner: a version written after a pipeline's end says pipeline-ended again

The seat mesh-wants' holder skips a passed mover with no version yet; the
version-released arrives late, so the end it took named none and no want was
written. Saying the same pipeline-ended again, naming the version, lets the
holder take the mover it skipped.

Builds: design 47 H H-A-270 (2)
This commit is contained in:
2026-11-21 15:34:34 +01:00
parent 599bf62d23
commit e927bb8971
2 changed files with 30 additions and 4 deletions
@@ -3,6 +3,7 @@ package pipeline
import (
"strings"
"testing"
"time"
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"
@@ -108,8 +109,11 @@ func TestThePipelinePassesOnNothingToRunAndFailsOnOneMover(t *testing.T) {
// R8 (design 47 H §746, H-A-52, H-A-62): a version-released writes its version into the mover of that module in the pipeline
// of the source revision built, on the branch it was released for, so pipeline-ended names it; another branch's pipeline,
// and a version heard again, write nothing.
//
// H-A-270 (2): a version written into a pipeline whose end was already said says its pipeline-ended again, naming the
// version; a pipeline still running says nothing.
func TestAReleasedVersionIsTheMoversVersion(t *testing.T) {
h, store, _, _ := twoMovers(t)
h, store, bodies, order := twoMovers(t)
other := store[pkey]
other.p.Pipeline, other.p.Branch, other.p.Movers = "beta.5", "beta", append([]seat.Mover(nil), other.p.Movers...)
store["beta.5"] = other
@@ -120,6 +124,10 @@ func TestAReleasedVersionIsTheMoversVersion(t *testing.T) {
again.p.Pipeline, again.p.Source, again.p.Movers = key, source, append([]seat.Mover(nil), again.p.Movers...)
store[key] = again
}
done := store[pkey]
at := time.Unix(1, 0)
done.p.Ended, done.p.Outcome = &at, seat.PipelineOutcomePassed
store[pkey] = done
ev := catalog.VersionReleasedEvent{Module: "app", Version: "0.4.1", Source: 5}
if n, err := h.Released(ev, "main"); n != 2 || err != nil {
t.Fatalf("released wrote %d (%v), want app's mover of main.5 and main.8", n, err)
@@ -133,8 +141,15 @@ func TestAReleasedVersionIsTheMoversVersion(t *testing.T) {
if m, _ := MoverOf(store["beta.5"].p, "app"); m.Version != "" {
t.Errorf("beta's mover = %+v, want no version: released for main", m)
}
if n, _ := h.Released(ev, "main"); n != 0 {
t.Errorf("the version heard again wrote %d", n)
pe, ok := bodies["pipeline-ended.main.5"].(seat.PipelineEnded)
if !ok || len(pe.Movers) != 2 || pe.Movers[1].Module != "app" || pe.Movers[1].Version != "0.4.1" {
t.Errorf("pipeline-ended.main.5 = %+v, want said again naming app at 0.4.1 (said %v)", bodies["pipeline-ended.main.5"], *order)
}
if len(*order) != 1 {
t.Errorf("said %v, want only main.5's end again: main.8 has not ended", *order)
}
if n, _ := h.Released(ev, "main"); n != 0 || len(*order) != 1 {
t.Errorf("the version heard again wrote %d and said %v", n, *order)
}
if got := pipelineEnded(store[pkey].p).Movers[1]; got.Module != "app" || got.Version != "0.4.1" {
t.Errorf("pipeline-ended names %+v, want app at 0.4.1", got)
@@ -5,13 +5,15 @@ import (
"fmt"
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"
"git.novox.be/novox/mesh-sdk/go/keys"
)
// Released writes a version-released's version into the entry of the mover it names (design 47 H §746, H-A-52): the mover of
// that module in each pipeline of the source revision built, a run's aside, so its pipeline-ended names the released version.
// branch, when not empty, is the one watched branch the version was released for (H-A-62); empty matches every branch's
// pipeline of that source. It says how many movers it wrote.
// pipeline of that source. A pipeline whose end was said already says it again, naming the version (H-A-270 (2)). It says how
// many movers it wrote.
func (h *Hearer) Released(ev catalog.VersionReleasedEvent, branch string) (int, error) {
if ev.Module == "" || ev.Version == "" || ev.Source <= 0 {
return 0, fmt.Errorf("a version-released names its module, version and source revision: %+v", ev)
@@ -56,6 +58,15 @@ func (h *Hearer) Released(ev catalog.VersionReleasedEvent, branch string) (int,
return wrote, fmt.Errorf("the pipeline %s cannot be written: %w", key, err)
}
wrote++
// A version written after the pipeline's end was said says that end again (H-A-270 (2)): the same pipeline-ended,
// now naming the version, so the seat mesh-wants' holder takes the mover it skipped; taking a mover again is a no-op.
if p.Ended != nil {
if err := h.say(seat.EventPipelineEnded, p, nil); err != nil {
return wrote, fmt.Errorf("the version %s of %s is written into the ended pipeline %s but its %s is not said again: %w",
ev.Version, ev.Module, key, seat.EventPipelineEnded, err)
}
h.logf("%s: the version %s of %s is written after its end: %s said again", key, ev.Version, ev.Module, seat.EventPipelineEnded)
}
break
}
}