Merge feat/47-H2-corrections-e into feat/47-H2-corrections-b

The whole test TestAMoverLeftUnfinishedIsPutInTheNextPipelineAndWanted holds both sides' steps: one fake answers e1's revision 99 (nothing), engine/gitea/free entries from revision 4 and the builds seat's published answer, and b8's holders and grants answers and Base per revision. b8's AC-P6b steps are renumbered from revisions/pipelines 4,5 to 11,12 (main.11, main.12; the build seat's holder moves at revision 12, lib l12), after e1's 4 to 10; they use app's fingerprint src2:a9 as the fake holds it from revision 9.

Builds: design 47 H2 H-A-595, H-A-594, H-A-608, H-A-623, H-A-643
This commit is contained in:
2026-11-25 19:53:26 +01:00
8 changed files with 558 additions and 84 deletions
@@ -289,6 +289,13 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
return half.Entries, err == nil
}
unfinished.Pipeline = func(key string) (seat.Pipeline, bool) { p, _, err := store.Get(key); return p, err == nil }
unfinished.Kept = func(key string) map[string]int64 {
kept, err := store.KeptRevisions(key)
if err != nil {
logger.Printf("the kept-revisions of %s are not read, so its movers' entries are read at the revision its key names: %v", key, err)
}
return kept
}
unfinished.Registered = func(module string) bool { _, ok := rv.Registrations.Registration(module); return ok }
unfinished.Add = func(from seat.Pipeline, group []seat.Mover) (string, bool) {
half, ok := rv.Catalog.View(from.Branch)
@@ -12,6 +12,7 @@ import (
"slices"
"strings"
"sync"
"sync/atomic"
"testing"
"time"
@@ -102,7 +103,21 @@ func testTheQueueRunsPipelinesInTurn(t *testing.T) {
}
}
answer("mesh.seat.mesh-catalog.call.registrations.*", catalog.RegistrationsAnswer{Registrations: regs})
answer("mesh.seat.mesh-catalog.call.revision.*", catalog.RevisionAnswer{Revision: &catalog.CatalogRevision{Revision: 100, Kind: "trunk", Branch: "main", Source: 2}, Entries: entries})
// The view holds the revision of the newest take-in (the head, H-A-594 (1), H-A-759); take says each revision before its take-in.
var newest atomic.Int64
newest.Store(1)
if _, err := nc.Subscribe("mesh.seat.mesh-catalog.call.revision.*", func(m *nats.Msg) {
var q catalog.RevisionInput
_ = json.Unmarshal(m.Data, &q)
n := q.Revision
if n == 0 {
n = newest.Load()
}
raw, _ := json.Marshal(map[string]any{"result": catalog.RevisionAnswer{Revision: &catalog.CatalogRevision{Revision: n, Kind: "trunk", Branch: "main", Source: n}, Entries: entries}})
_ = m.Respond(raw)
}); err != nil {
t.Fatal(err)
}
answer("mesh.seat.mesh-hand-acts.call.hand-act.*", map[string]any{})
// The router of the operator's asks holds the seat operator-channel; its record of each ask is in its state asks.
const router = "operator-router"
@@ -227,6 +242,11 @@ func testTheQueueRunsPipelinesInTurn(t *testing.T) {
for _, m := range movers {
ev.Entries = append(ev.Entries, catalog.TakeInEntry{Module: m, Commit: "c1", Fingerprint: "src2:" + m})
}
newest.Store(source)
rev, _ := json.Marshal(catalog.CatalogRevisionEvent{V: 1, Revision: source, Kind: "trunk", Branch: "main", Source: source, CallKind: catalog.CatalogRevisionEventCallKindTakeIn})
if _, err := js.Publish(ctx, catalog.SubjectCatalogRevision("main"), rev); err != nil {
t.Fatal(err)
}
body, _ := json.Marshal(ev)
if _, err := js.Publish(ctx, "mesh.mod.mesh-delivery-indexer.event.take-in.taken", body); err != nil {
t.Fatal(err)
@@ -429,8 +449,10 @@ func testTheQueueRunsPipelinesInTurn(t *testing.T) {
if s.Outcome != seat.StepResultOutcomeCouldNotRun || s.Why != pipeline.UntakenWhy(builds.Seat) || s.Ended == nil || s.Ended.Sub(*build.Started) < time.Second {
t.Fatalf("main.10's build = %+v, want could not run, its ask not taken, at its bound of 1s", s)
}
if strings.Contains(logs.String(), "asked once more") {
t.Fatal("the untaken build's ask was asked once more for its bound")
for _, line := range strings.Split(logs.String(), "\n") { // the catalog view's own retries, as its revision moves, are no ask of a build
if strings.Contains(line, "asked once more") && !strings.Contains(line, catalog.VerbRevision) {
t.Fatalf("the untaken build's ask was asked once more for its bound: %s", line)
}
}
waitFor(t, ctx, logs, func() bool {
e, err := findings.Get(ctx, "call."+build.Ask+".call-unanswered")
@@ -33,7 +33,10 @@ func TestAMoverLeftUnfinishedIsPutInTheNextPipelineAndWanted(t *testing.T) {
steps := catalog.StepStatuses{Lint: "bypass", Unit: "required", Integration: "bypass", Validate: "required", Composition: "required",
Review: "bypass", Approval: "bypass"}
regs := []catalog.Registration{{Module: "app", Branches: []string{"main"}, Origin: "o/app", Policy: catalog.Policy{Steps: steps}},
{Module: "lib", Branches: []string{"main"}, Origin: "o/lib", Policy: catalog.Policy{Steps: steps}}}
{Module: "lib", Branches: []string{"main"}, Origin: "o/lib", Policy: catalog.Policy{Steps: steps}},
{Module: "engine", Branches: []string{"main"}, Origin: "o/engine", Policy: catalog.Policy{Steps: steps}},
{Module: "gitea", Branches: []string{"main"}, Origin: "o/gitea", Policy: catalog.Policy{Steps: steps}},
{Module: "free", Branches: []string{"main"}, Origin: "o/free", Policy: catalog.Policy{Steps: steps}}}
var newest atomic.Int64
newest.Store(1)
w := startWhole(t, ctx, regs, func(in []byte) catalog.RevisionAnswer {
@@ -43,17 +46,42 @@ func TestAMoverLeftUnfinishedIsPutInTheNextPipelineAndWanted(t *testing.T) {
if n == 0 {
n = newest.Load()
}
lib, goFp, base := "l1", "src2:go", n-1
if n == 99 { // a revision the catalog keeps no more
return catalog.RevisionAnswer{}
}
lib, goFp := "l1", "src2:go"
if n == 2 {
lib = "l2"
}
if n == 5 { // the build seat's holder moves with revision 5 (AC-P6b)
lib, goFp = "l5", "src2:go2"
if n == 12 { // the build seat's holder moves with revision 12 (AC-P6b)
lib, goFp = "l12", "src2:go2"
}
return catalog.RevisionAnswer{Revision: &catalog.CatalogRevision{Revision: n, Kind: "trunk", Branch: "main", Source: n + 2, Base: base},
Entries: []catalog.CatalogEntry{{Module: "app", Commit: "c1", Fp: "src2:aa"},
{Module: "lib", Commit: lib, Fp: "src2:" + lib, Artifacts: []catalog.Artifact{{Ref: "lib:lib", Language: "go", Kind: "program"}}},
{Module: "mesh-build-go", Commit: "c0", Fp: goFp, Acts: []catalog.ActingRule{{Step: "build", On: "go", Seat: nodebuildgo.Seat}}}}}
entries := []catalog.CatalogEntry{{Module: "app", Commit: "c1", Fp: "src2:aa"},
{Module: "lib", Commit: lib, Fp: "src2:" + lib, Artifacts: []catalog.Artifact{{Ref: "lib:lib", Language: "go", Kind: "program"}}},
{Module: "mesh-build-go", Commit: "c0", Fp: goFp, Acts: []catalog.ActingRule{{Step: "build", On: "go", Seat: nodebuildgo.Seat}}}}
if n >= 4 {
// engine, the module gitea's build waits for (an edge of kind 3): its fingerprint is e1 at 4 and 5, e2 at 6, e3 from 7.
engine, gitea, free := "e1", "g1", "f1"
switch {
case n >= 7:
engine, gitea = "e3", "g2"
case n == 6:
engine = "e2"
}
if n >= 8 {
free = "f2"
}
app := catalog.CatalogEntry{Module: "app", Commit: "c1", Fp: "src2:aa"}
if n >= 9 {
app.Fp = "src2:a9"
}
entries[0] = app
entries = append(entries,
catalog.CatalogEntry{Module: "engine", Commit: engine, Fp: "src2:" + engine, Artifacts: []catalog.Artifact{{Ref: "engine:engine", Language: "go", Kind: "program"}}},
catalog.CatalogEntry{Module: "gitea", Commit: gitea, Fp: "src2:" + gitea, Edges: []catalog.Edge{{From: catalog.ArtifactRef("engine:engine"), Kind: 3}}},
catalog.CatalogEntry{Module: "free", Commit: free, Fp: "src2:" + free})
}
return catalog.RevisionAnswer{Revision: &catalog.CatalogRevision{Revision: n, Kind: "trunk", Branch: "main", Source: n + 2, Base: n - 1}, Entries: entries}
})
// The seat holders and the grants part answer, so a widening is named only for what a revision alters against its base: the
// build seat's holder is the module mesh-build-go, every other seat's a module the catalog holds no entry of.
@@ -66,7 +94,10 @@ func TestAMoverLeftUnfinishedIsPutInTheNextPipelineAndWanted(t *testing.T) {
held = append(held, map[string]any{"seat": name, "holders": []any{map[string]any{"module": holder}}})
}
for subject, body := range map[string]any{"mesh.seat." + seatlist.HolderSeat + ".call." + seatlist.HolderVerb + ".*": map[string]any{"seats": held},
"mesh.seat." + meshgrants.Seat + ".call." + meshgrants.VerbGrantsFor + ".*": meshgrants.GrantsFor{}} {
"mesh.seat." + meshgrants.Seat + ".call." + meshgrants.VerbGrantsFor + ".*": meshgrants.GrantsFor{},
// The builds seat's published answers that nothing is published: gitea's wait on engine (an edge of kind 3) is met by
// engine's build step passing, as the runner hears it.
"mesh.seat." + builds.Seat + ".call." + builds.VerbPublished + ".*": builds.PublishedAnswer{}} {
raw, _ := json.Marshal(map[string]any{"result": body})
if _, err := w.nc.Subscribe(subject, func(m *nats.Msg) { _ = m.Respond(raw) }); err != nil {
t.Fatal(err)
@@ -93,6 +124,7 @@ func TestAMoverLeftUnfinishedIsPutInTheNextPipelineAndWanted(t *testing.T) {
}
// answer ends every running step of key once, as its seat's holder says it: lib's unit fails when fail says so.
answered := map[string]bool{}
failing, failStep := "lib", seat.StepResultStepUnit // the step that fails where answer is told to fail
answer := func(key string, fail bool) func() bool {
return func() bool {
var p seat.Pipeline
@@ -107,7 +139,7 @@ func TestAMoverLeftUnfinishedIsPutInTheNextPipelineAndWanted(t *testing.T) {
answered[s.Ask+s.Module] = true
m, _ := pipeline.MoverOf(p, s.Module)
outcome := "passed"
if fail && s.Module == "lib" && s.Step == seat.StepResultStepUnit {
if fail && s.Module == failing && s.Step == failStep {
outcome = "failed"
}
body := map[string]any{"v": 1, "id": s.Ask, "pipeline": key, "step": s.Step, "module": s.Module, "commit": m.Commit,
@@ -142,6 +174,12 @@ func TestAMoverLeftUnfinishedIsPutInTheNextPipelineAndWanted(t *testing.T) {
t.Fatalf("the state unfinished holds no main.app: %v", err)
}
// design 47 H2 H-A-607 (2), H-A-619 (AC-P4): with no pipeline running, nothing starts to carry app; main.2 is started by the next
// take-in alone.
var none seat.Pipeline
if readPipeline(ctx, w.pipelines, "main.2", &none) {
t.Fatalf("main.2 was started with no take-in: the runner starts nothing to carry a mover\n%s", w.logs.String())
}
// The next take-in moves lib alone, at a new fingerprint: its pipeline carries app, whose composition is asked and passes.
newest.Store(2)
rev, _ := json.Marshal(catalog.CatalogRevisionEvent{V: 1, Revision: 2, Kind: "trunk", Branch: "main", Source: 4, CallKind: catalog.CatalogRevisionEventCallKindTakeIn})
@@ -206,35 +244,223 @@ func TestAMoverLeftUnfinishedIsPutInTheNextPipelineAndWanted(t *testing.T) {
t.Errorf("main.3 ended %d times and %d ends wait, want its second end and no third", third.EndCount, len(ended))
}
// design 47 H2 H-A-595 (AC-P6b), whole: lib fails in main.4 against a base that alters nothing for app, so app's first widens are
// empty and kept so in its key; main.5 carries app while the build seat's holder moves, and says app's widens as the first
// pipeline did, empty, while lib's own name the serving part.
newest.Store(4)
rev, _ = json.Marshal(catalog.CatalogRevisionEvent{V: 1, Revision: 4, Kind: "trunk", Branch: "main", Source: 6, CallKind: catalog.CatalogRevisionEventCallKindTakeIn})
if _, err := w.js.Publish(ctx, catalog.SubjectCatalogRevision("main"), rev); err != nil {
// reach makes revision n the one the view holds, as the indexer's catalog-revision says it, then takes in its entries.
reach := func(n int64, entries ...catalog.TakeInEntry) {
newest.Store(n)
rev, _ := json.Marshal(catalog.CatalogRevisionEvent{V: 1, Revision: n, Kind: "trunk", Branch: "main", Source: n + 2, CallKind: catalog.CatalogRevisionEventCallKindTakeIn})
if _, err := w.js.Publish(ctx, catalog.SubjectCatalogRevision("main"), rev); err != nil {
t.Fatal(err)
}
takeIn(n+2, n, entries...)
}
unfinishedEntry := func(key string) (pipeline.UnfinishedEntry, bool) {
var e pipeline.UnfinishedEntry
raw, err := unfinished.Get(ctx, key)
if err != nil || json.Unmarshal(raw.Value(), &e) != nil {
return e, false
}
return e, true
}
moves := func(key string, modules ...string) bool {
var p seat.Pipeline
if !readPipeline(ctx, w.pipelines, key, &p) {
return false
}
for _, m := range modules {
if !pipeline.Moves(p, m) {
return false
}
}
return true
}
// design 47 H2 H-A-594 (2), H-A-646, H-A-610 (AC-P3), whole: engine fails in main.4 and gitea, whose build waits for engine's
// build step (an edge of kind 3), passes its steps; gitea is left unfinished and tied to engine. A take-in that moves free alone
// carries nothing: main.5 moves free, gitea stays in unfinished.
failing = "engine"
reach(4, catalog.TakeInEntry{Module: "engine", Commit: "e1", Fingerprint: "src2:e1"}, catalog.TakeInEntry{Module: "gitea", Commit: "g1", Fingerprint: "src2:g1"})
waitFor(t, ctx, w.logs, answer("main.4", true))
if pe := endOf(); pe.Pipeline != "main.4" || pe.Outcome != seat.PipelineEndedOutcomeFailed || !slices.Equal(pe.Unfinished, []string{"gitea"}) {
t.Fatalf("pipeline-ended = %s %s unfinished %v, want main.4 failed leaving gitea unfinished\n%s", pe.Pipeline, pe.Outcome, pe.Unfinished, w.logs.String())
}
reach(5, catalog.TakeInEntry{Module: "free", Commit: "f1", Fingerprint: "src2:f1"})
waitFor(t, ctx, w.logs, answer("main.5", false))
if e, ok := unfinishedEntry("main.gitea"); !ok || e.Pipeline != "main.4" || e.CarriedBy != "" || !moves("main.5", "free") || moves("main.5", "gitea") {
t.Fatalf("main.gitea = %+v (held %t), main.5 moves gitea %t: want gitea tied to engine, kept in unfinished and not carried by main.5\n%s", e, ok, moves("main.5", "gitea"), w.logs.String())
}
if pe := endOf(); pe.Pipeline != "main.5" || pe.Outcome != seat.PipelineEndedOutcomePassed {
t.Fatalf("main.5 ended %s %s, want passed\n%s", pe.Pipeline, pe.Outcome, w.logs.String())
}
// AC-P3: once engine passes, in the pipeline of its newer fingerprint, gitea is carried with it and wanted; its key goes.
failing = ""
reach(6, catalog.TakeInEntry{Module: "engine", Commit: "e2", Fingerprint: "src2:e2"})
waitFor(t, ctx, w.logs, answer("main.6", false))
if pe := endOf(); pe.Pipeline != "main.6" || pe.Outcome != seat.PipelineEndedOutcomePassed || !moves("main.6", "engine", "gitea") {
t.Fatalf("main.6 ended %s %s, moving gitea %t: want engine passed and gitea carried with it\n%s", pe.Pipeline, pe.Outcome, moves("main.6", "gitea"), w.logs.String())
}
if _, ok := unfinishedEntry("main.gitea"); ok {
t.Error("main.gitea is still unfinished after main.6 passed")
}
// design 47 H2 H-A-623 (AC-P5b), whole: engine fails again in main.7, leaving gitea tied to it; place-unfinished of gitea's key
// reopens main.7 for gitea with its failed engine, whose step fails again: main.7 ends failed a second time, leaving gitea.
placeKey := func(key string) seat.PlaceUnfinishedAnswer {
var placed seat.PlaceUnfinishedAnswer
waitFor(t, ctx, w.logs, func() bool {
raw, _ := json.Marshal(seat.PlaceUnfinishedInput{Key: key, Why: "the whole test"})
m, err := w.nc.Request("mesh.seat."+seat.Seat+".call.place-unfinished.agent~dev", raw, 15*time.Second)
var reply struct {
Result json.RawMessage `json:"result"`
Error string `json:"error"`
}
if err != nil || json.Unmarshal(m.Data, &reply) != nil || strings.Contains(reply.Error, "not yet read") {
return false
}
if reply.Error != "" {
t.Fatalf("place-unfinished %s: %s", key, reply.Error)
}
return json.Unmarshal(reply.Result, &placed) == nil
})
return placed
}
failing, failStep = "engine", seat.StepResultStepBuild // a build step is asked again by a plain ask; a test step joins a run of its own
reach(7, catalog.TakeInEntry{Module: "engine", Commit: "e3", Fingerprint: "src2:e3"}, catalog.TakeInEntry{Module: "gitea", Commit: "g2", Fingerprint: "src2:g2"})
waitFor(t, ctx, w.logs, answer("main.7", true))
if pe := endOf(); pe.Pipeline != "main.7" || pe.Outcome != seat.PipelineEndedOutcomeFailed || !slices.Equal(pe.Unfinished, []string{"gitea"}) {
t.Fatalf("pipeline-ended = %s %s unfinished %v, want main.7 failed leaving gitea unfinished\n%s", pe.Pipeline, pe.Outcome, pe.Unfinished, w.logs.String())
}
if placed := placeKey("main.gitea"); len(placed.Placed) != 1 || placed.Placed[0].Pipeline != "main.7" {
t.Fatalf("place-unfinished of main.gitea = %+v, want it placed in main.7", placed)
}
waitFor(t, ctx, w.logs, answer("main.7", true))
var seventh seat.Pipeline
if pe := endOf(); pe.Pipeline != "main.7" || pe.Outcome != seat.PipelineEndedOutcomeFailed || !slices.Equal(pe.Unfinished, []string{"gitea"}) ||
!readPipeline(ctx, w.pipelines, "main.7", &seventh) || seventh.EndCount != 2 || !pipeline.Moves(seventh, "engine") {
t.Fatalf("main.7 ended again %s unfinished %v after %d ends, want failed with engine in its group, leaving gitea\n%s", pe.Outcome, pe.Unfinished, seventh.EndCount, w.logs.String())
}
// AC-P3, the tie's end: engine leaves the registrations (its registration-changed heard, the first view asked again); the next
// take-in's pipeline, main.8, carries gitea although engine failed and is not moved by it.
regs[2] = regs[4] // engine, the third registration, is replaced by a copy of free's: the answer no longer names it
gone, _ := json.Marshal(catalog.RegistrationChangedEvent{V: 1, Module: "engine", Version: 9, Moved: []string{}, Warrant: "the whole test"})
if _, err := w.js.Publish(ctx, "mesh.seat.mesh-catalog.event.registration-changed.engine", gone); err != nil {
t.Fatal(err)
}
takeIn(6, 4, catalog.TakeInEntry{Module: "app", Commit: "c1", Fingerprint: "src2:aa"}, catalog.TakeInEntry{Module: "lib", Commit: "l1", Fingerprint: "src2:l1"})
waitFor(t, ctx, w.logs, answer("main.4", true))
if pe := endOf(); pe.Pipeline != "main.4" || !slices.Equal(pe.Unfinished, []string{"app"}) {
t.Fatalf("pipeline-ended = %s unfinished %v, want main.4 leaving app unfinished\n%s", pe.Pipeline, pe.Unfinished, w.logs.String())
waitFor(t, ctx, w.logs, func() bool { // the registrations' picture holds four keys once the first view is asked again
kv, err := w.js.KeyValue(ctx, "mesh-delivery-pipeline_first-views")
if err != nil {
return false
}
e, err := kv.Get(ctx, "mesh-catalog.registrations")
var view struct {
Keys int `json:"keys"`
}
return err == nil && json.Unmarshal(e.Value(), &view) == nil && view.Keys == len(regs)-1
})
failing, failStep = "", ""
reach(8, catalog.TakeInEntry{Module: "free", Commit: "f2", Fingerprint: "src2:f2"})
waitFor(t, ctx, w.logs, answer("main.8", false))
if pe := endOf(); pe.Pipeline != "main.8" || pe.Outcome != seat.PipelineEndedOutcomePassed || !moves("main.8", "free", "gitea") {
t.Fatalf("main.8 ended %s %s, moving gitea %t: want gitea carried although engine failed and left the registrations\n%s", pe.Pipeline, pe.Outcome, moves("main.8", "gitea"), w.logs.String())
}
if _, ok := unfinishedEntry("main.gitea"); ok {
t.Error("main.gitea is still unfinished after main.8 passed")
}
// design 47 H2 H-A-608 (AC-P4), whole: free's key names revision 99, which the catalog keeps no more; the take-in of revision 9
// reads it at the head's revision, where free holds the key's fingerprint, and carries it; ghost's fingerprint is held at neither
// revision, so its key is dropped and the journal names the fingerprint and the revisions looked at.
for key, entry := range map[string]string{
"main.free": `{"fingerprint":"src2:f2","revision":99,"pipeline":"main.99","outcome":"failed"}`,
"main.ghost": `{"fingerprint":"src2:zz","revision":99,"pipeline":"main.99","outcome":"failed"}`,
} {
if _, err := unfinished.Put(ctx, key, []byte(entry)); err != nil {
t.Fatal(err)
}
}
reach(9, catalog.TakeInEntry{Module: "app", Commit: "c1", Fingerprint: "src2:a9"})
waitFor(t, ctx, w.logs, answer("main.9", false))
if pe := endOf(); pe.Pipeline != "main.9" || pe.Outcome != seat.PipelineEndedOutcomePassed || !moves("main.9", "app", "free") {
t.Fatalf("main.9 ended %s %s, moving free %t: want free read at the head's revision and carried\n%s", pe.Pipeline, pe.Outcome, moves("main.9", "free"), w.logs.String())
}
if _, ok := unfinishedEntry("main.ghost"); ok || !strings.Contains(w.logs.String(), "ghost is no longer unfinished at fingerprint src2:zz: its kept revision 99 is gone, the head's revision 9 of main holds it at") {
t.Errorf("main.ghost is kept, or the journal does not name its fingerprint and the revisions looked at:\n%s", w.logs.String())
}
// design 47 H2 H-A-571, H-A-643 (AC-P5c), whole: while the head's pipeline main.10 runs, start of free and lib, which it does not
// carry, adds both to it, each said by mover-added with the caller; no `.again.<n>` pipeline is keyed.
added := make(chan seat.MoverAdded, 4)
if _, err := w.nc.Subscribe("mesh.seat.mesh-pipeline-runner.event.mover-added.>", func(m *nats.Msg) {
var ev seat.MoverAdded
if json.Unmarshal(m.Data, &ev) == nil {
added <- ev
}
}); err != nil {
t.Fatal(err)
}
reach(10, catalog.TakeInEntry{Module: "app", Commit: "c1", Fingerprint: "src2:a9"})
waitFor(t, ctx, w.logs, func() bool { // its steps are placed once the view holds revision 10, the head start reads
return strings.Contains(w.logs.String(), "main.10 app build asked")
})
var started seat.StartAnswer
waitFor(t, ctx, w.logs, func() bool {
raw, _ := json.Marshal(seat.StartInput{Branch: "main", Modules: []string{"free", "lib"}, Why: "the whole test"})
m, err := w.nc.Request("mesh.seat."+seat.Seat+".call.start.agent~dev", raw, 15*time.Second)
var reply struct {
Result json.RawMessage `json:"result"`
Error string `json:"error"`
}
if err != nil || json.Unmarshal(m.Data, &reply) != nil || strings.Contains(reply.Error, "not yet") {
return false
}
if reply.Error != "" {
t.Fatalf("start: %s", reply.Error)
}
return json.Unmarshal(reply.Result, &started) == nil
})
if started.Pipeline != "main.10" || !moves("main.10", "app", "free", "lib") || len(added) != 2 {
t.Fatalf("start = %+v, main.10 moves free and lib %t, %d mover-added said, want both added to main.10 and said\n%s", started, moves("main.10", "free", "lib"), len(added), w.logs.String())
}
for range 2 {
if ev := <-added; ev.Pipeline != "main.10" || ev.Caller == "" || ev.From != "" {
t.Errorf("mover-added = %+v, want main.10 with the caller of start", ev)
}
}
keysOf, err := w.pipelines.Keys(ctx)
if err != nil {
t.Fatal(err)
}
for _, k := range keysOf {
if strings.Contains(k, ".again.") {
t.Errorf("start keyed the pipeline %s", k)
}
}
waitFor(t, ctx, w.logs, answer("main.10", false))
if pe := endOf(); pe.Pipeline != "main.10" || pe.Outcome != seat.PipelineEndedOutcomePassed {
t.Errorf("main.10 ended %s %s, want passed with its added movers\n%s", pe.Pipeline, pe.Outcome, w.logs.String())
}
// design 47 H2 H-A-595 (AC-P6b), whole: lib fails in main.11 against a base that alters nothing for app, so app's first widens are
// empty and kept so in its key; main.12 carries app while the build seat's holder moves, and says app's widens as the first
// pipeline did, empty, while lib's own name the serving part.
failing, failStep = "lib", seat.StepResultStepUnit
reach(11, catalog.TakeInEntry{Module: "app", Commit: "c1", Fingerprint: "src2:a9"}, catalog.TakeInEntry{Module: "lib", Commit: "l1", Fingerprint: "src2:l1"})
waitFor(t, ctx, w.logs, answer("main.11", true))
if pe := endOf(); pe.Pipeline != "main.11" || !slices.Equal(pe.Unfinished, []string{"app"}) {
t.Fatalf("pipeline-ended = %s unfinished %v, want main.11 leaving app unfinished\n%s", pe.Pipeline, pe.Unfinished, w.logs.String())
}
if e, err := unfinished.Get(ctx, "main.app"); err != nil || strings.Contains(string(e.Value()), `"widens"`) {
t.Fatalf("main.app's first widens are kept as %s (%v), want none named", e.Value(), err)
}
newest.Store(5)
rev, _ = json.Marshal(catalog.CatalogRevisionEvent{V: 1, Revision: 5, Kind: "trunk", Branch: "main", Source: 7, CallKind: catalog.CatalogRevisionEventCallKindTakeIn})
if _, err := w.js.Publish(ctx, catalog.SubjectCatalogRevision("main"), rev); err != nil {
t.Fatal(err)
}
takeIn(7, 5, catalog.TakeInEntry{Module: "lib", Commit: "l5", Fingerprint: "src2:l5"})
waitFor(t, ctx, w.logs, answer("main.5", false))
reach(12, catalog.TakeInEntry{Module: "lib", Commit: "l12", Fingerprint: "src2:l12"})
waitFor(t, ctx, w.logs, answer("main.12", false))
last := endOf()
widens := map[string][]seat.Widening{}
for _, m := range last.Movers {
widens[m.Module] = m.Widens
}
if last.Pipeline != "main.5" || len(widens["app"]) != 0 || len(widens["lib"]) != 1 || widens["lib"][0].Name != "mesh-build-go" {
if last.Pipeline != "main.12" || len(widens["app"]) != 0 || len(widens["lib"]) != 1 || widens["lib"][0].Name != "mesh-build-go" {
t.Fatalf("%s ended with the widens %+v, want the carried app's empty as its first pipeline's and lib's naming the serving part mesh-build-go\n%s", last.Pipeline, widens, w.logs.String())
}
}
@@ -8,7 +8,6 @@ import (
runnerclient "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshpipelinerunnerclient"
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"
)
// AddedFrom says where a mover added to a pipeline came from; exactly one field is set (design 47 H2 H-A-645).
@@ -96,35 +95,43 @@ func (f AddedFrom) describe() string {
return fmt.Sprintf("a take-in of source %d", f.TakeIn)
}
// head is the key of the newest pipeline of branch, by its catalog revision, and the pipeline: the head's pipeline (H-A-594 (1)).
func (s *Starter) head(branch string) (seat.Pipeline, bool) {
pkeys, err := s.Store.Keys(keys.EscapeName(branch) + ".*")
if err != nil {
return seat.Pipeline{}, false
}
var best seat.Pipeline
found := false
for _, k := range pkeys {
p, _, err := s.Store.Get(k)
if err != nil || p.Run != "" || p.Branch != branch {
continue
}
if !found || p.Revision > best.Revision {
best, found = p, true
}
}
return best, found
// headKey is the key of the head's pipeline of branch, whose catalog view holds half: the head's revision is the newest one the runner's catalog
// view holds, one head for the carry and for start alike (design 47 H2 H-A-594 (1), H-A-759).
func headKey(branch string, half Half) string {
return Key(branch, keyRevision(Begin{Revision: half.Revision, Source: half.Source}))
}
// CarryToHead adds the closed group of movers pipeline from left to the head's pipeline of its branch when that waits or runs,
// head reads the head's pipeline of half's branch by its key: held is false when the head's revision has no pipeline (a
// revision whose take-in is not handled yet, or that moved nothing); an older open pipeline of the branch is never the head.
func (s *Starter) head(key string) (p seat.Pipeline, held bool, err error) {
keys, err := s.Store.Keys(key)
if err != nil || len(keys) == 0 {
return seat.Pipeline{}, false, err
}
p, _, err = s.Store.Get(key)
return p, err == nil, err
}
// CarryToHead adds the closed group of movers pipeline from left to the head's pipeline of its branch (view's newest revision) when that waits or runs,
// and takes the movers out of from's movers, so none of its later ends names them (H-A-594 (3), (4), H-A-607 (2)). It
// answers the head's key, false when nothing was added: the head is from itself or has ended.
func (s *Starter) CarryToHead(from seat.Pipeline, group []seat.Mover, entries map[string]catalog.CatalogEntry, view func(branch string) (Half, bool)) (string, bool) {
if s.Store == nil {
return "", false
}
head, ok := s.head(from.Branch)
if !ok || head.Pipeline == from.Pipeline || head.Revision < from.Revision || !openPipeline(head) {
if view == nil {
return "", false
}
half, ok := view(from.Branch)
if !ok {
return "", false
}
head, held, err := s.head(headKey(from.Branch, half))
if err != nil {
s.logf("the head's pipeline of %s is not read, so the movers %v of %s are not carried to it: %v", from.Branch, moduleNames(group), from.Pipeline, err)
return "", false
}
if !held || head.Pipeline == from.Pipeline || head.Revision < from.Revision || !openPipeline(head) {
return "", false
}
if _, err := s.AddMovers(head.Pipeline, group, entries, AddedFrom{From: from.Pipeline}, view); err != nil {
@@ -50,21 +50,45 @@ func (v Verbs) Start(caller string, in seat.StartInput) (seat.StartAnswer, error
if len(absent) > 0 {
return seat.StartAnswer{}, fmt.Errorf("the head of %s (revision %d) holds no entry of %s: nothing was started", in.Branch, half.Revision, strings.Join(absent, ", "))
}
key := Key(in.Branch, keyRevision(Begin{Revision: half.Revision, Source: half.Source}))
held, err := s.Store.Keys(key)
key := headKey(in.Branch, half)
// A module whose own step failed in a pipeline older than the head reopens that pipeline as rerun does, never joins the head's
// (design 47 H2 H-A-643, H-A-594 (3)); the call is one hand act.
older, movers, err := v.ownFailedPipelines(in.Branch, key, movers, half.Entries)
if err != nil {
return seat.StartAnswer{}, fmt.Errorf("the pipeline %s is not looked for: nothing was started: %w", key, err)
return seat.StartAnswer{}, err
}
var head seat.Pipeline
if len(held) > 0 {
if head, _, err = s.Store.Get(key); err != nil {
return seat.StartAnswer{}, fmt.Errorf("the pipeline %s is not read: nothing was started: %w", key, err)
if len(older) > 0 {
if err := v.record(seat.VerbStart, fmt.Sprintf("started %s at the head of %s by hand", strings.Join(append(moduleNames(movers), olderModules(older)...), ", "), in.Branch), in.Why); err != nil {
return seat.StartAnswer{}, err
}
for _, o := range older {
if err := v.reopenGroup(caller, o.from, o.group, nil, o.entries, in.Why); err != nil {
return seat.StartAnswer{}, err
}
s.markCarriedKeys(o.from, o.group, o.from.Pipeline)
}
w := v
w.noRecord = true
if len(movers) == 0 {
return seat.StartAnswer{Pipeline: older[0].from.Pipeline}, nil
}
return w.startAtHead(caller, in, half, key, movers)
}
return v.startAtHead(caller, in, half, key, movers)
}
// startAtHead is Start's rule for the modules no older pipeline of its own takes: the head's pipeline `key` joins them while it
// waits or runs, or is started with them, or is reopened once it has ended.
func (v Verbs) startAtHead(caller string, in seat.StartInput, half Half, key string, movers []seat.Mover) (seat.StartAnswer, error) {
s := v.Starter
head, held, err := s.head(key)
if err != nil {
return seat.StartAnswer{}, fmt.Errorf("the pipeline %s is not read: nothing was started: %w", key, err)
}
names := moduleNames(movers)
what := fmt.Sprintf("started %s at the head of %s by hand", strings.Join(names, ", "), in.Branch)
switch {
case len(held) == 0:
case !held:
if err := v.record(seat.VerbStart, what, in.Why); err != nil {
return seat.StartAnswer{}, err
}
@@ -122,6 +146,74 @@ func (v Verbs) Start(caller string, in seat.StartInput) (seat.StartAnswer, error
return seat.StartAnswer{Pipeline: key}, nil
}
// ownPipeline is an older pipeline a started module's own step failed in, and the group its reopening puts.
type ownPipeline struct {
from seat.Pipeline
group []string
entries map[string]catalog.CatalogEntry
}
func olderModules(o []ownPipeline) []string {
var out []string
for _, p := range o {
out = appendNew(out, p.group...)
}
return out
}
// ownFailedPipelines splits movers: those whose own required step failed in the newest pipeline of the branch other than the
// head's `key` that moves them, which ended (design 47 H2 H-A-643), with the closed group each such pipeline reopens for, and the movers left.
func (v Verbs) ownFailedPipelines(branch, key string, movers []seat.Mover, headEntries map[string]catalog.CatalogEntry) ([]ownPipeline, []seat.Mover, error) {
s := v.Starter
pkeys, err := branchKeys(s.Store, branch)
if err != nil {
return nil, nil, fmt.Errorf("the pipelines of %s are not listed: nothing was started: %w", branch, err)
}
head, held, err := s.head(key)
if err != nil {
return nil, nil, fmt.Errorf("the pipeline %s is not read: nothing was started: %w", key, err)
}
var out []ownPipeline
var rest []seat.Mover
for _, m := range movers {
var best seat.Pipeline
found := false
if !held || !Moves(head, m.Module) {
for _, k := range pkeys {
if k == key {
continue
}
p, _, err := s.Store.Get(k)
if err != nil || p.Run != "" || p.Branch != branch || !Moves(p, m.Module) || slices.Contains(p.Superseded, m.Module) {
continue
}
if !found || p.Revision > best.Revision {
best, found = p, true
}
}
// Only the newest pipeline that moves the module counts: a newer one that passed it leaves the failure behind.
found = found && best.Ended != nil && len(failedSteps(best, m.Module)) > 0
}
if !found {
rest = append(rest, m)
continue
}
at := slices.IndexFunc(out, func(o ownPipeline) bool { return o.from.Pipeline == best.Pipeline })
if at < 0 {
entries := headEntries
if s.Revision != nil {
if h, err := s.Revision(branch, best.Revision); err == nil && h.Entries != nil {
entries = h.Entries
}
}
out = append(out, ownPipeline{from: best, entries: entries})
at = len(out) - 1
}
out[at].group = appendNew(out[at].group, v.closedGroup(best, m.Module, out[at].entries)...)
}
return out, rest, nil
}
// allPassed says whether module has required steps in p and every one passed, was carried or had nothing to run: the pipeline
// delivered it.
func allPassed(p seat.Pipeline, module string) bool {
@@ -295,22 +387,40 @@ func (v Verbs) planUnfinished(key string) (handPlan, error) {
if err != nil || !Moves(from, module) {
return handPlan{}, fmt.Errorf("its pipeline %s is not read or moves %s no more", e.Pipeline, module)
}
var half Half
switch {
case s.Revision != nil:
if half, err = s.Revision(branch, e.Revision); err != nil {
return handPlan{}, fmt.Errorf("the revision %d of %s is not read: %w", e.Revision, branch, err)
}
case v.View != nil:
var ok bool
if half, ok = v.View(branch); !ok || half.Revision != e.Revision {
return handPlan{}, fmt.Errorf("the revision %d of %s is not held", e.Revision, branch)
}
default:
if s.Revision == nil && v.View == nil {
return handPlan{}, errors.New("the runner reads no catalog revision")
}
if entry, ok := half.Entries[module]; !ok || entry.Fp != e.Fingerprint || half.Source <= 0 {
return handPlan{}, fmt.Errorf("the revision %d of %s holds %s at %q, not its unfinished fingerprint %s", e.Revision, branch, module, entry.Fp, e.Fingerprint)
// The entry is read at its kept revision, else at the head's when the entry there has the same fingerprint (design 47 H2 H-A-608).
readAt := func(rev int64) (Half, error) {
if s.Revision != nil {
h, err := s.Revision(branch, rev)
if err != nil {
return Half{}, fmt.Errorf("the revision %d of %s is not read: %w", rev, branch, err)
}
return h, nil
}
if h, ok := v.View(branch); ok && h.Revision == rev {
return h, nil
}
return Half{}, fmt.Errorf("the revision %d of %s is not held", rev, branch)
}
kept := s.Unfinished.keptRevision(e, module)
half, rerr := readAt(kept)
entry, has := half.Entries[module]
if rerr != nil || !has || entry.Fp != e.Fingerprint || half.Source <= 0 {
looked := fmt.Sprintf("its kept revision %d holds it at %q", kept, entry.Fp)
if rerr != nil {
looked = rerr.Error()
}
head, hok := Half{}, false
if v.View != nil {
head, hok = v.View(branch)
}
he, hhas := head.Entries[module]
if !hok || !hhas || he.Fp != e.Fingerprint || head.Source <= 0 {
return handPlan{}, fmt.Errorf("%s at fingerprint %s is read at neither revision: %s; the head's revision %d of %s holds it at %q", module, e.Fingerprint, looked, head.Revision, branch, he.Fp)
}
half = head
}
group := v.closedGroup(from, module, half.Entries)
plan := handPlan{from: from, group: group, entries: half.Entries}
@@ -534,6 +534,36 @@ func TestTakenInStartsOnlyItsEntries(t *testing.T) {
if p, _, _ := mem.Get("main.14"); p.Outcome != seat.PipelineOutcomeRunning || p.Ended != nil {
t.Errorf("main.14 is %s ended %v, want the cancelled pipeline reopened", p.Outcome, p.Ended)
}
// design 47 H2 H-A-608 (AC-P4): a key whose kept revision is gone is read at the head's revision when the fingerprint is the same,
// by the hand verb as by the carry; a key whose kept revision is still read is read there, beyond the take-in's revision.
c, rev, _ = mem.Get("main.14")
c.Outcome, c.Ended = seat.PipelineOutcomeFailed, &end
if _, err := mem.Update("main.14", c, rev); err != nil {
t.Fatal(err)
}
u["main.batched"] = `{"fingerprint":"src2:bb","revision":9,"pipeline":"main.14","outcome":"failed"}`
if a, err = v.PlaceUnfinished("agent.dev", seat.PlaceUnfinishedInput{Key: "main.batched", Why: "kept revision gone"}); err != nil || len(a.Placed) != 1 {
t.Fatalf("place-unfinished of a key whose kept revision 9 is gone = %+v (%v), want it read at the head's revision and placed", a, err)
}
u["main.batched"] = `{"fingerprint":"src2:zz","revision":9,"pipeline":"main.14","outcome":"failed"}`
if _, err = v.PlaceUnfinished("agent.dev", seat.PlaceUnfinishedInput{Key: "main.batched", Why: "neither"}); err == nil || !strings.Contains(err.Error(), "src2:zz") || !strings.Contains(err.Error(), "revision 9") || !strings.Contains(err.Error(), "revision 14") {
t.Errorf("place-unfinished of a key found at neither revision = %v, want it naming the fingerprint and both revisions", err)
}
var said []string
held := map[int64]map[string]catalog.CatalogEntry{3: {"old": {Commit: "c3", Fp: "src2:o1"}}}
cu := &Unfinished{Store: memUnfinished{
"main.old": `{"fingerprint":"src2:o1","revision":3}`,
"main.far": `{"fingerprint":"src2:f1","revision":2}`,
"main.back": `{"fingerprint":"src2:b1","revision":2}`,
}, Logf: func(f string, a ...any) { said = append(said, fmt.Sprintf(f, a...)) },
Entries: func(_ string, r int64) (map[string]catalog.CatalogEntry, bool) { e, ok := held[r]; return e, ok }}
got := cu.Carry("main", 20, map[string]catalog.CatalogEntry{"back": {Commit: "c20", Fp: "src2:b1"}}, nil)
if len(got) != 2 || got[0].Module != "back" || got[0].Commit != "c20" || got[1].Module != "old" || got[1].Commit != "c3" {
t.Errorf("the carry = %+v, want back read at the head's revision (its kept revision 2 gone) and old at its kept revision 3, which the head does not hold", got)
}
if j := strings.Join(said, "\n"); !strings.Contains(j, "far is no longer unfinished at fingerprint src2:f1") || !strings.Contains(j, "kept revision 2 is gone") || !strings.Contains(j, "head's revision 20") {
t.Errorf("the journal says %q, want each drop naming its fingerprint and the revisions looked at", said)
}
}
// R16/AC1 (design 47 H §765, H-A-58, H-A-98): a take-in.taken of the old form, with no call (or no branch or source), is
@@ -614,10 +644,19 @@ func TestAPublishIsTakenIntoThePipelineOfItsRevision(t *testing.T) {
return nil
}}
st := memUnfinished{}
// design 47 H2 H-A-594 (1), H-A-759 (AC-P5 head): the head is the newest revision the view holds, its pipeline read by its
// key; with revision 7 in the view and no pipeline at main.7, the older open main.6 is never taken as the head and nothing
// is carried.
viewAt := func(rev int64) func(string) (Half, bool) {
return func(string) (Half, bool) { return Half{Revision: rev, Source: 9, Entries: entries}, true }
}
if c, ok := s.CarryToHead(failed, []seat.Mover{{Module: "free", Fingerprint: "f3"}}, entries, viewAt(7)); ok || c != "" || len(out) != 0 {
t.Fatalf("a carry with revision 7 in the view and no pipeline at main.7 = %q %t (said %d), want none: main.6 is not the head", c, ok, len(out))
}
u := &Unfinished{Store: st,
Entries: func(string, int64) (map[string]catalog.CatalogEntry, bool) { return entries, true },
Add: func(from seat.Pipeline, group []seat.Mover) (string, bool) {
return s.CarryToHead(from, group, entries, nil)
return s.CarryToHead(from, group, entries, viewAt(6))
}}
u.Ended(failed)
if len(out) != 1 || out[0].ev.Module != "free" || out[0].ev.From != "main.5" || out[0].ev.Pipeline != "main.6" || !strings.HasSuffix(out[0].subject, ".main.6") {
@@ -110,6 +110,9 @@ type Unfinished struct {
Pipeline func(key string) (seat.Pipeline, bool)
Registered func(module string) bool
Add func(from seat.Pipeline, group []seat.Mover) (string, bool)
// Kept reads a pipeline's kept-revisions, the revision each re-pinned mover's entry comes from (H-A-285); nil, or a pipeline
// that keeps none, says the revision the key names (H-A-608).
Kept func(pipeline string) map[string]int64
}
func (u *Unfinished) logf(format string, args ...any) {
@@ -417,13 +420,13 @@ func (u *Unfinished) Carry(branch string, revision int64, entries map[string]cat
}
if i := slices.IndexFunc(movers, func(m seat.Mover) bool { return m.Module == module }); i >= 0 {
if movers[i].Fingerprint != e.Fingerprint {
u.dropMoved(key, module, fmt.Sprintf("revision %d of %s moves it at %s", revision, branch, movers[i].Fingerprint))
u.dropMoved(key, module, e.Fingerprint, fmt.Sprintf("revision %d of %s, the revision looked at, moves it at %s", revision, branch, movers[i].Fingerprint))
}
continue
}
entry, ok := entries[module]
if !ok || entry.Fp != e.Fingerprint {
u.dropMoved(key, module, fmt.Sprintf("revision %d of %s holds it at %q", revision, branch, entry.Fp))
entry, why, ok := u.entryOf(branch, revision, entries, module, e)
if !ok {
u.dropMoved(key, module, e.Fingerprint, why)
continue
}
if by := u.heldBack(branch, module, e); len(by) > 0 && !slices.ContainsFunc(by, func(f string) bool {
@@ -438,13 +441,47 @@ func (u *Unfinished) Carry(branch string, revision int64, entries map[string]cat
return movers
}
// dropMoved deletes the key of an unfinished mover a newer fingerprint moves (§786).
func (u *Unfinished) dropMoved(key, module, why string) {
// keptRevision is the revision the entry of module's key comes from: its kept revision in the pipeline the key names (H-A-285),
// else the revision the key names (design 47 H2 H-A-608).
func (u *Unfinished) keptRevision(e UnfinishedEntry, module string) int64 {
if u.Kept != nil {
if r := u.Kept(e.Pipeline)[module]; r > 0 {
return r
}
}
return e.Revision
}
// entryOf reads module's entry for the carry (design 47 H2 H-A-608): at its kept revision when that is still read and holds it
// at the key's fingerprint, else at the head's revision (entries) when the entry there has the same fingerprint. Neither says why,
// naming the fingerprint and each revision looked at.
func (u *Unfinished) entryOf(branch string, head int64, entries map[string]catalog.CatalogEntry, module string, e UnfinishedEntry) (catalog.CatalogEntry, string, bool) {
var looked []string
if kept := u.keptRevision(e, module); kept > 0 && kept != head && u.Entries != nil {
if kents, ok := u.Entries(branch, kept); !ok {
looked = append(looked, fmt.Sprintf("its kept revision %d is gone", kept))
} else if entry, ok := kents[module]; ok && entry.Fp == e.Fingerprint {
return entry, "", true
} else {
looked = append(looked, fmt.Sprintf("its kept revision %d holds it at %q", kept, entry.Fp))
}
}
entry, ok := entries[module]
if ok && entry.Fp == e.Fingerprint {
return entry, "", true
}
looked = append(looked, fmt.Sprintf("the head's revision %d of %s holds it at %q", head, branch, entry.Fp))
return catalog.CatalogEntry{}, strings.Join(looked, ", ") + ", so a newer revision moved it or its entry is gone", false
}
// dropMoved deletes the key of an unfinished mover a newer fingerprint moves, or whose entry no revision looked at holds at its
// fingerprint (§786, H-A-608): one journal line names the fingerprint and the revisions looked at.
func (u *Unfinished) dropMoved(key, module, fingerprint, why string) {
if err := u.Store.Delete(key); err != nil {
u.logf("the unfinished entry of %s is not deleted: %v", module, err)
return
}
u.logf("%s is no longer unfinished: %s", module, why)
u.logf("%s is no longer unfinished at fingerprint %s: %s", module, fingerprint, why)
}
// Entry is one key's entry; false when the state holds none.
@@ -604,12 +604,38 @@ func TestStartWithModulesJoinsTheHeadsPipelineOrReopensIt(t *testing.T) {
if got, _, _ := store.Get(pkey); got.Outcome != seat.PipelineOutcomeRunning || got.Ended != nil || len(asks.asks) == asked {
t.Errorf("%s is %s ended %v, %d asks since: want reopened and its failed step asked again", pkey, got.Outcome, got.Ended, len(asks.asks)-asked)
}
// H-A-643 (Q-a): a module whose own step failed in a pipeline older than the head reopens that pipeline and is never added to
// the head: with revision 10 in the view and main.9 no longer moving app, start of app reopens the pipeline whose lint failed
// again, and keys no pipeline at main.10.
nine := store["main.9"]
nine.p.Movers = slices.DeleteFunc(slices.Clone(nine.p.Movers), func(m seat.Mover) bool { return m.Module == "app" })
nine.p.Outcome, nine.p.Ended = seat.PipelineOutcomePassed, &end
store["main.9"] = nine
p5 = store[pkey].p
for i := range p5.Steps {
if p5.Steps[i].Step == seat.StepResultStepLint {
p5.Steps[i].Outcome, p5.Steps[i].Ended = seat.StepResultOutcomeFailed, &end
}
}
p5.Outcome, p5.Ended = seat.PipelineOutcomeFailed, &end
store[pkey] = struct {
p seat.Pipeline
rev uint64
}{p5, 3}
revision = 10
asked = len(asks.asks)
if a, err = v.Start("operator", seat.StartInput{Branch: "main", Modules: []string{"app"}, Why: "its lint failed again"}); err != nil || a.Pipeline != pkey {
t.Fatalf("start of app whose step failed in the older %s = %+v, %v; want %s reopened", pkey, a, err, pkey)
}
if got, _, _ := store.Get(pkey); got.Outcome != seat.PipelineOutcomeRunning || len(asks.asks) == asked || made["main.10"] != nil {
t.Errorf("%s is %s, %d asks since, main.10 written %t: want the older pipeline reopened and nothing keyed at the head", pkey, got.Outcome, len(asks.asks)-asked, made["main.10"] != nil)
}
for k := range made {
if strings.Contains(k, ".again.") {
t.Errorf("a start keyed %s", k)
}
}
if len(*acts) != 5 {
if len(*acts) != 6 {
t.Errorf("hand acts %v, want the five starts that did something recorded", *acts)
}
if !IsStepsKey(StepsKey("main.9.again.1", "app")) {