Design 47 H1 (5b): a release, take-in again or recompute revision starts one pipeline, read by its number

A re-pin on a module's release, a take-in again and a recompute that moves a
fingerprint each keep a catalog revision of their own. The runner hears a trunk
catalog-revision of those kinds, reads that revision by its number through the catalog
seat's revision verb, and starts one pipeline keyed <branch>.<revision> with the
revision's movers. A package-published no longer starts per-artifact pipelines: it
only places the movers waiting for it. A branch's newest pipeline for a mover is the
one of the highest revision number.

Builds: design 47 H H-A-212, H-A-213 (2) and (4), H-A-217
This commit is contained in:
2026-11-21 00:07:55 +01:00
parent 189d75ad40
commit 91b5e8d086
11 changed files with 205 additions and 113 deletions
@@ -71,3 +71,28 @@ func TestPlaceLostRunsReadsEachCandidateNewest(t *testing.T) {
t.Errorf("asked %+v, want the candidate's group alone", asked[1])
}
}
// H-A-213 (2), (4): a catalog-revision heard is handed whole to the start of a revision's pipeline; a start that fails is
// an error, so the bus delivers the event again, and a body that is no event is ended.
func TestARevisionHeardIsHandedToItsStart(t *testing.T) {
var got []catalog.CatalogRevisionEvent
fail := false
hear := revisedHear(func(ev catalog.CatalogRevisionEvent) (int, error) {
got = append(got, ev)
if fail {
return 0, errors.New("not read")
}
return 1, nil
}, func(string, ...any) {})
data := []byte(`{"v":1,"kind":"trunk","branch":"main","revision":10,"source":41,"call-kind":"release","call":"release of mesh-sdk 0.1.17"}`)
if err := hear(t.Context(), data); err != nil || len(got) != 1 || got[0].Revision != 10 || got[0].CallKind != "release" || got[0].Source != 41 {
t.Fatalf("heard %+v (%v), want the release revision 10", got, err)
}
fail = true
if err := hear(t.Context(), data); err == nil {
t.Error("a start that failed is not an error, so the event is never heard again")
}
if err := hear(t.Context(), []byte("no event")); err != nil {
t.Errorf("a body that is no event = %v, want it ended", err)
}
}
@@ -98,6 +98,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
var advancer atomic.Pointer[func(string)]
var placer atomic.Pointer[func(catalog.CatalogRevisionEvent) error]
var registrar atomic.Pointer[func(catalog.Registration)]
var reviser atomic.Pointer[func(catalog.CatalogRevisionEvent) (int, error)]
rv, err := startViews(ctx, js, conn, cred, hub, calls.State("findings"), calls.Call, func(branch string) {
if f := resumer.Load(); f != nil {
(*f)(branch)
@@ -115,6 +116,11 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
if f := registrar.Load(); f != nil {
(*f)(reg)
}
}, func(ev catalog.CatalogRevisionEvent) (int, error) {
if f := reviser.Load(); f != nil {
return (*f)(ev)
}
return 0, fmt.Errorf("the revision %d of %s is heard before the runner can start its pipeline", ev.Revision, ev.Branch)
}, logger.Printf)
if err != nil {
return err
@@ -203,6 +209,10 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
}
}
registrar.Store(&register)
// A release's, a take-in again's or a recompute's revision starts one pipeline, its revision read by its number
// (H-A-213 (2), (4)).
revise := func(ev catalog.CatalogRevisionEvent) (int, error) { return starter.Revised(ev, widener.Revision) }
reviser.Store(&revise)
starter.Store = store
// The queue (design 47 H §748): at most pipelines-at-once pipelines have their steps asked, the others wait in order in
// the state queue, placed at the start from it and on every end.
@@ -1,6 +1,7 @@
package main
import (
"context"
"encoding/json"
"github.com/nats-io/nats.go/jetstream"
@@ -11,10 +12,10 @@ import (
"mesh-delivery-pipeline/internal/pipeline"
)
// hearPublished hears each package-published (design 47 H §746, §747): in its source's running pipeline, or starting one
// pipeline of the package's kind-1 dependents that pipeline does not move. The message is acknowledged once that is
// written, on a goroutine of its own, so a slow write holds no other event; the durable consumer delivers a publish heard
// after a stop.
// hearPublished hears each package-published (design 47 H §746, §747): in the running pipeline of the revision that
// published it, the movers waiting for it are placed; it starts no pipeline (a release's revision does, H-A-213 (2)). The
// message is acknowledged once that is written, on a goroutine of its own, so a slow write holds no other event; the
// durable consumer delivers a publish heard after a stop.
func hearPublished(hub handlers, starter *pipeline.Starter, v *pipeline.Views, logf func(string, ...any)) error {
return hub.Handle(builds.SubjectPackagePublished, func(m jetstream.Msg) {
var ev builds.PackagePublished
@@ -24,18 +25,38 @@ func hearPublished(hub handlers, starter *pipeline.Starter, v *pipeline.Views, l
return
}
go func() {
n, err := starter.Published(ev, v.View)
if err != nil {
logf("the publish of %s %s on %s: %d pipelines started, then %v; heard again", ev.Artifact, ev.Version, ev.Branch, n, err)
if err := starter.Published(ev, v.View); err != nil {
logf("the publish of %s %s on %s: %v; heard again", ev.Artifact, ev.Version, ev.Branch, err)
_ = m.Nak()
return
}
logf("the publish of %s %s on %s started %d pipelines", ev.Artifact, ev.Version, ev.Branch, n)
logf("the publish of %s %s on %s is heard", ev.Artifact, ev.Version, ev.Branch)
_ = m.Ack()
}()
})
}
// revisedHear is the handler of catalog-revision that starts the pipeline of a revision whose call kind is not a
// take-in's (design 47 H-A-212, H-A-213 (2), H-A-217): every other revision is left to the views that hear it. An error
// has the event heard again; a second start of its key writes nothing.
func revisedHear(revised func(ev catalog.CatalogRevisionEvent) (int, error), logf func(string, ...any)) func(context.Context, []byte) error {
return func(_ context.Context, data []byte) error {
var ev catalog.CatalogRevisionEvent
if err := json.Unmarshal(data, &ev); err != nil {
logf("a catalog-revision is not read: %v", err)
return nil
}
n, err := revised(ev)
if err != nil {
return err
}
if n > 0 {
logf("the revision %d of %s (%s, %s) started %d pipeline", ev.Revision, ev.Branch, ev.CallKind, ev.Call, n)
}
return nil
}
}
// hearTakenIn starts the pipeline of each take-in.taken heard (design 47 H §746): one per take-in, the message acknowledged
// once it is written, and heard again when a write failed, so the key already written starts nothing twice.
func hearTakenIn(hub handlers, starter *pipeline.Starter, v *pipeline.Views, logf func(string, ...any)) error {
@@ -98,7 +98,7 @@ func (h *holderView) Holders(seatName string) ([]string, bool) {
// after, then start hub once.
func startViews(ctx context.Context, js jetstream.JetStream, conn *nats.Conn, cred process.Account, hub *process.EventHub, findingsState process.State,
call meshcatalogclient.Call, onReady, onAdvance func(branch string), candidate func(ctx context.Context, ev catalog.CatalogRevisionEvent) error,
registered func(reg catalog.Registration), logf func(string, ...any)) (*runnerViews, error) {
registered func(reg catalog.Registration), revised func(ev catalog.CatalogRevisionEvent) (int, error), logf func(string, ...any)) (*runnerViews, error) {
findings, err := findingWriter(ctx, cred, conn, js, findingsState, logf)
if err != nil {
return nil, err
@@ -153,6 +153,11 @@ func startViews(ctx context.Context, js jetstream.JetStream, conn *nats.Conn, cr
if err := meshcatalogclient.WireCandidatesProcess(reader, candidate); err != nil {
return nil, err
}
// A trunk revision of a release, a take-in again or a recompute starts one pipeline of its own, read by its number
// (H-A-212, H-A-213 (2), H-A-217), heard on the same event's one subscription.
if err := reader.AdoptEvent(catalog.Seat, catalog.EventCatalogRevision, revisedHear(revised, logf)); err != nil {
return nil, err
}
reader.Start(ctx, js, cred, status)
return &runnerViews{Registrations: regs, Catalog: cv, Findings: findings, Holders: &holderView{reader: reader, catalog: cv, logf: logf}}, nil
}
@@ -166,7 +166,8 @@ func catalogRevision(call func(string, any) (json.RawMessage, error), kept *revi
if h, ok := kept.get(branch, a.Revision.Revision); ok {
return h, nil
}
half = pipeline.Half{Revision: a.Revision.Revision, Source: a.Revision.Source, Entries: map[string]catalog.CatalogEntry{}}
half = pipeline.Half{Revision: a.Revision.Revision, Source: a.Revision.Source, Entries: map[string]catalog.CatalogEntry{},
Call: a.Revision.Call, Movers: a.Revision.Movers}
in.Revision = a.Revision.Revision // the pages of one revision, though a newer one is said between them
}
for _, e := range a.Entries {
@@ -231,11 +231,11 @@ func (a *Ager) newest(p seat.Pipeline) (bool, error) {
if err != nil {
return false, fmt.Errorf("the pipelines of %s are not listed: %w", p.Branch, err)
}
// Newest for one of its movers: no later pipeline of the branch moves it.
// Newest for one of its movers: no pipeline of a later revision of the branch moves it (H-A-213 (4)).
for _, m := range p.Movers {
newer := false
for _, k := range pkeys {
if q, _, err := a.Pipelines.Get(k); err == nil && q.Source > p.Source && Moves(q, m.Module) {
if q, _, err := a.Pipelines.Get(k); err == nil && keyRevision(Begin{Revision: q.Revision, Source: q.Source}) > keyRevision(Begin{Revision: p.Revision, Source: p.Source}) && Moves(q, m.Module) {
newer = true
break
}
@@ -142,3 +142,23 @@ func TestOneStepEndAgesAtMostTwentyEntries(t *testing.T) {
t.Fatalf("%d outputs deleted, sequence %d; want 20 and 20", len(f.outputs), f.aged["7d"])
}
}
// H-A-213 (4): a branch's newest pipeline for a mover is the one of the highest revision number, never of the highest source:
// a release revision of the same source is newer than its take-in's.
func TestTheNewestPipelineIsOfTheHighestRevision(t *testing.T) {
f := newAgedFixture()
for key, p := range map[string]seat.Pipeline{
"main.41": {Pipeline: "main.41", Branch: "main", Source: 41, Revision: 41, Movers: []seat.Mover{{Module: "app"}}},
"main.42": {Pipeline: "main.42", Branch: "main", Source: 41, Revision: 42, Movers: []seat.Mover{{Module: "app"}}},
} {
f.pipes.memStore[key] = struct {
p seat.Pipeline
rev uint64
}{p, 1}
}
for key, want := range map[string]bool{"main.41": false, "main.42": true} {
if got, err := f.ager.newest(f.pipes.memStore[key].p); got != want || err != nil {
t.Errorf("%s newest = %v (%v), want %v", key, got, err, want)
}
}
}
@@ -74,8 +74,8 @@ func TestAMoversBuildWaitsForItsDependenciesInThePipeline(t *testing.T) {
if !placed(p, "mesh-sdk") || !placed(p, "builder") || placed(p, "app") || placed(p, "tool") {
t.Fatalf("placed at the start: %+v, want mesh-sdk and builder only", p.Steps)
}
if n, err := s.Published(builds.PackagePublished{Artifact: "mesh-sdk:go", Module: "mesh-sdk", Branch: "main", Source: 4, Version: "0.2.0"}, view); n != 0 || err != nil {
t.Fatalf("the publish started %d (%v), want none", n, err)
if err := s.Published(builds.PackagePublished{Artifact: "mesh-sdk:go", Module: "mesh-sdk", Branch: "main", Source: 4, Version: "0.2.0"}, view); err != nil {
t.Fatalf("the publish is not heard: %v", err)
}
p, _, _ = mem.Get("main.7")
if sdk, _ := MoverOf(p, "mesh-sdk"); !placed(p, "app") || placed(p, "tool") || len(mem) != 1 || !slices.Contains(sdk.Published, "mesh-sdk:go") {
@@ -99,6 +99,10 @@ type Half struct {
Revision int64
Source int64
Entries map[string]catalog.CatalogEntry
// Call and Movers are the revision's own, as the revision verb answers them (H-A-213): what made it and its movers;
// a view's half names none.
Call string
Movers []catalog.TakeInEntry
}
// Views is the runner's views of the catalog half, one per watched branch the registrations name (design 47 G §21,
@@ -4,7 +4,6 @@ import (
"encoding/json"
"errors"
"fmt"
"maps"
"slices"
"sort"
"strconv"
@@ -39,9 +38,7 @@ type Begin struct {
Movers []seat.Mover
// Entries are the catalog half's entries of the pipeline's branch: the steps' artifacts and build seats are read from them.
Entries map[string]catalog.CatalogEntry
// Published is the package's publish that started the pipeline, nil for any other start (§747).
Published *seat.Published
// Key is the pipeline's key when it is not <branch>.<revision> (a publish's, §747); empty for a take-in's.
// Key is the pipeline's key when it is not <branch>.<revision>; empty for every start the runner makes.
Key string
// unheld says the branch's catalog half is not held yet: the pipeline starts with no steps, placed once it is (A-336).
unheld bool
@@ -63,14 +60,8 @@ func keyRevision(b Begin) int64 {
return b.Source
}
// PublishedKey is the key of a pipeline a package's publish starts, `<branch>.<source>.published.<package>.<version>`,
// each part escaped as a key's name is (design 47 H §747).
func PublishedKey(branch string, source int64, pkg, version string) string {
return seat.PipelinesByBranchSourcePublishedPackageVersionKey(keys.EscapeName(branch), strconv.FormatInt(source, 10),
keys.EscapeName(pkg), keys.EscapeName(version))
}
// keyForms are the filters of every key form of the state pipelines: a take-in's, a run's and a publish's.
// keyForms are the filters of every key form of the state pipelines: a revision's, a run's, and a publish's kept from before
// a release revision started one pipeline (H-A-213 (2)).
var keyForms = []string{"*.*", "*." + runToken + ".*", "*.*.published.*.*"}
// AllKeys are every pipeline's key, of each key form (§746, §747; H-A-83).
@@ -292,7 +283,7 @@ func (s *Starter) sayStarted(key string, asks []Asked) {
func newPipeline(b Begin, key string, now time.Time) seat.Pipeline {
movers := append([]seat.Mover(nil), b.Movers...)
return seat.Pipeline{V: 1, Pipeline: key, Branch: b.Branch, Source: b.Source, Call: b.Call, Revision: b.Revision, Movers: movers,
Outcome: seat.PipelineOutcomeRunning, Started: &now, Steps: []seat.StepResult{}, Published: b.Published}
Outcome: seat.PipelineOutcomeRunning, Started: &now, Steps: []seat.StepResult{}}
}
func (s *Starter) create(key string, p seat.Pipeline) error {
@@ -957,49 +948,60 @@ func (s *Starter) sourcePipeline(branch string, source int64) (string, bool) {
return found, found != ""
}
// publishedKind is the edge a dependent builds on a published package by: B published before A builds, a package A
// imports (§53).
const publishedKind = 1
// Published hears a package-published (design 47 H §747, H-A-52): in the running pipeline of the source revision that
// published it, a mover that builds on it waits for it there (§746) and nothing starts; every module the catalog half
// holds a kind-1 edge from the package into that this pipeline does not move (a publish again of an older build, a
// dependent it does not move) is a mover of one pipeline keyed `<branch>.<source>.published.<package>.<version>`, at the
// publishing source's catalog revision. The dependents come from the edges the runner holds, never from a comparison.
func (s *Starter) Published(ev builds.PackagePublished, view func(branch string) (Half, bool)) (int, error) {
// Published hears a package-published (design 47 H §746, H-A-52): in the running pipeline of the revision that published
// it, a mover that builds on it waits for it there and is placed once it is heard. It starts no pipeline: a re-pin on a
// module's release is a catalog revision of its own, whose pipeline Revised starts (H-A-212, H-A-213 (2)).
func (s *Starter) Published(ev builds.PackagePublished, view func(branch string) (Half, bool)) error {
if ev.Artifact == "" || ev.Branch == "" || ev.Source <= 0 {
return 0, fmt.Errorf("a package-published names its artifact, watched branch and source revision: %+v", ev)
return fmt.Errorf("a package-published names its artifact, watched branch and source revision: %+v", ev)
}
publishing, held, err := s.heardPublished(ev, view)
if err != nil {
return 0, err
}
half, ok := view(ev.Branch)
if !ok {
return 0, fmt.Errorf("the catalog half of %s is not held yet: the publish of %s %s is heard again once it is", ev.Branch, ev.Artifact, ev.Version)
}
var movers []seat.Mover
for _, module := range slices.Sorted(maps.Keys(half.Entries)) {
e := half.Entries[module]
if module == ev.Module || Moves(publishing, module) || !slices.ContainsFunc(e.Edges, func(x catalog.Edge) bool {
return x.Kind == publishedKind && x.From == ev.Artifact
}) {
continue
}
movers = append(movers, seat.Mover{Module: module, Commit: e.Commit, Fingerprint: e.Fp, Repository: e.Repository})
}
if len(movers) == 0 {
_, _, err := s.heardPublished(ev, view)
return err
}
// revisedKinds are the call kinds of a catalog revision whose pipeline Revised starts: every kind but a take-in's, whose
// pipeline its take-in.taken starts (H-A-213 (2), H-A-217).
var revisedKinds = []string{catalog.CatalogRevisionEventCallKindRelease, catalog.CatalogRevisionEventCallKindTakeInAgain,
catalog.CatalogRevisionEventCallKindRecompute}
// Revised starts, on a catalog-revision of the trunk kind whose call kind is release, take-in again or recompute, ONE
// pipeline keyed <branch>.<revision> by compare-and-set on its absence (design 47 H §746, H-A-212, H-A-213 (2) and (4),
// H-A-217): the revision is read by its number through the catalog seat's revision verb, never the newest half, and its
// movers are the revision's movers, its steps placed from the revision's entries. A revision of another kind, or one with
// no mover, starts nothing; a second hearing writes nothing.
func (s *Starter) Revised(ev catalog.CatalogRevisionEvent, read func(branch string, revision int64) (Half, error)) (int, error) {
if ev.Kind != "trunk" || !slices.Contains(revisedKinds, ev.CallKind) {
return 0, nil
}
revision := half.Revision
if held && publishing.Revision > 0 {
revision = publishing.Revision
branch, err := keys.UnescapeName(ev.Branch)
if err != nil || branch == "" || ev.Revision <= 0 {
return 0, fmt.Errorf("a catalog-revision names its watched branch and revision: branch %q revision %d", ev.Branch, ev.Revision)
}
if read == nil {
return 0, fmt.Errorf("the revision %d of %s cannot be read: the runner holds no revision reader", ev.Revision, branch)
}
half, err := read(branch, ev.Revision)
if err != nil {
return 0, fmt.Errorf("the revision %d of %s is not read, so its pipeline is not started: %w", ev.Revision, branch, err)
}
if half.Revision != ev.Revision {
return 0, fmt.Errorf("the revision verb answered revision %d of %s for %d", half.Revision, branch, ev.Revision)
}
if len(half.Movers) == 0 {
s.logf("the revision %d of %s (%s) names no mover: it starts no pipeline", ev.Revision, branch, ev.Call)
return 0, nil
}
movers := make([]seat.Mover, 0, len(half.Movers))
for _, e := range half.Movers {
movers = append(movers, seat.Mover{Module: e.Module, Commit: e.Commit, Fingerprint: e.Fingerprint, Repository: e.Repository})
}
movers = Tiers(movers, half.Entries, s.logf)
started, err := s.Start(Begin{Branch: ev.Branch, Source: ev.Source, Call: publishing.Call, Revision: revision, Movers: movers,
Entries: half.Entries, Published: &seat.Published{Artifact: ev.Artifact, Version: ev.Version},
Key: PublishedKey(ev.Branch, ev.Source, ev.Artifact, ev.Version)})
if started {
call := half.Call
if call == "" {
call = ev.Call
}
ok, err := s.Start(Begin{Branch: branch, Source: half.Source, Call: call, Revision: half.Revision, Movers: movers, Entries: half.Entries})
if ok {
return 1, err
}
return 0, err
@@ -11,6 +11,7 @@ import (
builds "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
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"
)
type created map[string][]byte
@@ -55,12 +56,11 @@ func TestStarts(t *testing.T) {
}
}
// R10/AC1 and AC2 (design 47 H §747, H-A-52): a package-published of a mover of its source's running pipeline whose
// dependent that pipeline moves starts nothing: the dependent waits there. A publish again of an older build starts one
// pipeline keyed <branch>.<source>.published.<package>.<version>, its movers the package's kind-1 dependents from the
// edges the runner holds, at the publishing source's revision, and says pipeline-started with the publish; an ordering
// edge starts nothing; heard twice, the second writes nothing.
func TestAPublishStartsOnlyWhatItsPipelineDoesNotMove(t *testing.T) {
// H-A-212, H-A-213 (2) and (4), H-A-217: a package-published starts no pipeline, the movers waiting for it in its
// pipeline placed there; a trunk catalog-revision of a release, a take-in again or a recompute starts ONE pipeline keyed
// <branch>.<revision>, the revision read by its number, its movers the revision's, its source and call the revision's;
// heard twice the second writes nothing; a take-in's revision, a candidate's and one with no mover start nothing.
func TestARevisionOfAReleaseStartsOnePipeline(t *testing.T) {
mem := memStore{}
var said []seat.PipelineStarted
s := &Starter{Pipelines: memCreated{mem}, Store: mem, Say: func(_ string, body any) error {
@@ -70,37 +70,60 @@ func TestAPublishStartsOnlyWhatItsPipelineDoesNotMove(t *testing.T) {
return nil
}}
edges := []catalog.Edge{{From: "mesh-sdk:go", To: "x", Kind: 1}}
view := func(string) (Half, bool) {
return Half{Revision: 9, Entries: map[string]catalog.CatalogEntry{
"mesh-sdk": {Module: "mesh-sdk"},
"app": {Module: "app", Commit: "c1", Fp: "src2:aa", Repository: "o/app", Edges: edges},
"tool": {Module: "tool", Commit: "c2", Fp: "src2:bb", Edges: edges},
"ordered": {Module: "ordered", Edges: []catalog.Edge{{From: "mesh-sdk:go", To: "x", Kind: 4}}}}}, true
entries := map[string]catalog.CatalogEntry{
"mesh-sdk": {Module: "mesh-sdk"},
"app": {Module: "app", Commit: "c1", Fp: "src2:aa", Repository: "o/app", Edges: edges},
"tool": {Module: "tool", Commit: "c2", Fp: "src2:bb", Edges: edges}}
view := func(string) (Half, bool) { return Half{Revision: 9, Entries: entries}, true }
ev := builds.PackagePublished{Artifact: "mesh-sdk:go", Branch: "main", Source: 30, Module: "mesh-sdk", Version: "0.1.9"}
if err := s.Published(ev, view); err != nil || len(mem) != 0 {
t.Fatalf("a publish of an older build wrote %d pipelines (%v), want none", len(mem), err)
}
mem[Key("main", 41)] = struct {
p seat.Pipeline
rev uint64
}{seat.Pipeline{Pipeline: "main.41", Branch: "main", Source: 41, Revision: 8, Outcome: seat.PipelineOutcomeRunning,
Movers: []seat.Mover{{Module: "mesh-sdk"}, {Module: "app"}, {Module: "tool"}}}, 1}
ev := builds.PackagePublished{Artifact: "mesh-sdk:go", Branch: "main", Source: 41, Module: "mesh-sdk", Version: "0.1.16"}
if n, err := s.Published(ev, view); n != 0 || err != nil || len(mem) != 1 {
t.Fatalf("a publish in a pipeline moving its dependents started %d (%v), %d pipelines", n, err, len(mem))
var asked []int64
movers := []catalog.TakeInEntry{{Module: "app", Commit: "c1", Fingerprint: "src2:ab", Repository: "o/app"}, {Module: "tool", Commit: "c2", Fingerprint: "src2:bc"}}
read := func(branch string, revision int64) (Half, error) {
asked = append(asked, revision)
if branch != "release.1" {
return Half{}, fmt.Errorf("branch %q", branch)
}
r := Half{Revision: revision, Source: 41, Entries: entries, Call: "release of mesh-sdk 0.1.17"}
if revision != 12 {
r.Movers = movers
}
return r, nil
}
// A publish again of an older build, at source 30: its pipeline is gone, so every kind-1 dependent is a mover.
ev.Source, ev.Version = 30, "0.1.9"
release := catalog.CatalogRevisionEvent{Kind: "trunk", Branch: keys.EscapeName("release.1"), Revision: 10, Source: 41, CallKind: "release", Call: "release of mesh-sdk 0.1.17"}
for i := range 2 {
if n, err := s.Published(ev, view); n != 1-i || err != nil {
if n, err := s.Revised(release, read); n != 1-i || err != nil {
t.Fatalf("hearing %d started %d (%v)", i+1, n, err)
}
}
key := PublishedKey("main", 30, "mesh-sdk:go", "0.1.9")
p, _, err := mem.Get(key)
if err != nil || len(p.Movers) != 2 || !Moves(p, "app") || !Moves(p, "tool") || Moves(p, "ordered") || p.Revision != 9 ||
p.Published == nil || p.Published.Version != "0.1.9" || len(said) != 1 || said[0].Published == nil {
t.Fatalf("the pipeline %s = %+v (%v), said %+v", key, p, err, said)
p, _, err := mem.Get(Key("release.1", 10))
if err != nil || len(mem) != 1 || len(p.Movers) != 2 || p.Revision != 10 || p.Source != 41 || p.Call != "release of mesh-sdk 0.1.17" ||
len(said) != 1 || len(asked) != 2 || asked[0] != 10 {
t.Fatalf("the pipeline %s = %+v (%v), %d written, said %d, read %v", Key("release.1", 10), p, err, len(mem), len(said), asked)
}
if app, _ := MoverOf(p, "app"); app.Commit != "c1" || app.Fingerprint != "src2:aa" || app.Repository != "o/app" {
t.Errorf("the mover app = %+v", app)
if app, _ := MoverOf(p, "app"); app.Fingerprint != "src2:ab" || app.Repository != "o/app" || app.Tier != 1 {
t.Errorf("the mover app = %+v, want the revision's", app)
}
for _, c := range []struct {
name string
ev catalog.CatalogRevisionEvent
want int
}{
{"take-in again", catalog.CatalogRevisionEvent{Kind: "trunk", Branch: release.Branch, Revision: 11, CallKind: "take-in-again"}, 1},
{"recompute with no mover", catalog.CatalogRevisionEvent{Kind: "trunk", Branch: release.Branch, Revision: 12, CallKind: "recompute"}, 0},
{"recompute", catalog.CatalogRevisionEvent{Kind: "trunk", Branch: release.Branch, Revision: 13, CallKind: "recompute"}, 1},
{"take-in", catalog.CatalogRevisionEvent{Kind: "trunk", Branch: release.Branch, Revision: 14, CallKind: "take-in"}, 0},
{"candidate", catalog.CatalogRevisionEvent{Kind: "candidate", Branch: release.Branch, Revision: 15, CallKind: "release"}, 0},
} {
if n, err := s.Revised(c.ev, read); n != c.want || err != nil {
t.Errorf("%s: started %d (%v), want %d", c.name, n, err, c.want)
}
}
if _, err := s.Revised(catalog.CatalogRevisionEvent{Kind: "trunk", Branch: release.Branch, Revision: 16, CallKind: "release"},
func(string, int64) (Half, error) { return Half{}, errors.New("no answer") }); err == nil {
t.Error("a revision that cannot be read is not an error, so it is never heard again")
}
}
@@ -243,25 +266,6 @@ func TestAPipelineStartedBeforeItsRegistrationIsPlacedWhenItArrives(t *testing.T
if n != 1 || err != nil || len(p.Steps) == 0 {
t.Errorf("the half of next placed %d (%v): %d steps, want the take-in's pipeline placed", n, err, len(p.Steps))
}
// A-336: a package published heard before its branch's half is held starts nothing, heard again once it is: its
// dependents are the half's edges (§747).
held = false
app := entries["app"]
app.Edges = []catalog.Edge{{From: "mesh-sdk:go", To: "app:program", Kind: 1}}
entries["app"] = app
published := builds.PackagePublished{Artifact: "mesh-sdk:go", Branch: "next", Source: 7, Module: "mesh-sdk", Version: "0.1.17"}
if n, err := s.Published(published, late); n != 0 || err == nil {
t.Fatalf("the publish before the half started %d (%v), want none and an error, heard again", n, err)
}
held = true
if n, err := s.Published(published, late); n != 1 || err != nil {
t.Fatalf("the publish with the half held started %d (%v)", n, err)
}
p, _, _ = store.Get(PublishedKey("next", 7, "mesh-sdk:go", "0.1.17"))
if len(p.Steps) == 0 {
t.Errorf("the publish's pipeline placed %d steps, want its steps", len(p.Steps))
}
// A-446: a pipeline an earlier runner left set aside for its new version (the record keeps a `held` field, outcome running,
// no step placed) is placed and asked as a newly started one when the half is held; no hold is read any more.
var old seat.Pipeline