From a8adda1a8c172ae78aed4f2e3acbc44777174505 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 18:09:07 +0100 Subject: [PATCH 1/3] mesh-delivery-pipeline: a build module's own inputs await not its toolchain edge MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A pipeline moving the Go build module with a package it imports (mesh-sdk, mesh-delivery-contracts) placed nothing: the package's build awaited the new build module's files, the build module awaited the package. What a build module's new version is built from is built by its running version. Builds: design 47 G §270, G-22 A-326, H §746, H-A-83 (2) --- .../internal/pipeline/order.go | 27 ++++++++++- .../internal/pipeline/order_test.go | 47 +++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/order.go b/modules/mesh-delivery-pipeline/internal/pipeline/order.go index cf0000b6..59838981 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/order.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/order.go @@ -137,7 +137,9 @@ func components(movers []seat.Mover, after map[string][]string) map[string]int { var buildKinds = []int64{3, 1} // awaited are the artifact references mover m's steps wait for in p (§746, H-A-51): the From of each edge of a build kind -// into m from another mover of p, toolchain edges first, each once. +// into m from another mover of p, toolchain edges first, each once. A toolchain edge (kind 3) from a build module whose +// own new version is built from m is not awaited: what a build module's new version is built from is built by its +// running version, never waited for (G §270, A-326), so the running build module builds m and the new one the rest. func awaited(p seat.Pipeline, m string, entries map[string]catalog.CatalogEntry) []catalog.Edge { var out []catalog.Edge for _, kind := range buildKinds { @@ -146,12 +148,35 @@ func awaited(p seat.Pipeline, m string, entries map[string]catalog.CatalogEntry) if x.Kind != kind || from == m || !Moves(p, from) || slices.ContainsFunc(out, func(e catalog.Edge) bool { return e.From == x.From }) { continue } + if kind == 3 && builtFrom(p, from, entries)[m] { + continue + } out = append(out, x) } } return out } +// builtFrom are the movers of p that module's new version is built from (G §270): the From mover of each edge of a build +// kind into it, and what those are built from in turn. +func builtFrom(p seat.Pipeline, module string, entries map[string]catalog.CatalogEntry) map[string]bool { + seen := map[string]bool{} + next := []string{module} + for len(next) > 0 { + cur := next[0] + next = next[1:] + for _, x := range entries[cur].Edges { + from := moduleOf(x.From) + if !slices.Contains(buildKinds, x.Kind) || from == cur || seen[from] || !Moves(p, from) { + continue + } + seen[from] = true + next = append(next, from) + } + } + return seen +} + // ready says whether mover m of p may be placed (§746, H-A-84): every artifact it awaits is in its From mover's published. // It answers the references still awaited, and the first From mover whose build ended without passing, so m never builds. func ready(p seat.Pipeline, m string, entries map[string]catalog.CatalogEntry) (bool, []string, string) { diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/order_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/order_test.go index a5dff3bb..d5cc86e0 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/order_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/order_test.go @@ -124,3 +124,50 @@ func TestAMoversBuildWaitsForItsDependenciesInThePipeline(t *testing.T) { } } } + +// Design 47 G §270, A-326 (H §746, H-A-83 (2)): what a build module's new version is built from is built by its running +// version, never waited for: a mover the moving build module imports, directly or through another mover, does not await +// that build module's toolchain edge, so a pipeline moving mesh-sdk or the contracts with the Go build module places them +// at once (main.28, main.30 of 2026-11-20 waited on each other forever); every other mover still awaits the new one. +func TestAToolchainEdgeIsNotAwaitedByTheBuildModulesOwnInputs(t *testing.T) { + e := func(from, to string, kind int64) catalog.Edge { return catalog.Edge{From: from, To: to, Kind: kind} } + entries := map[string]catalog.CatalogEntry{ + "mesh-sdk": {Edges: []catalog.Edge{e("mesh-build-go:files", "mesh-sdk:go", 3)}}, + "contracts": {Edges: []catalog.Edge{e("mesh-build-go:files", "contracts:go-a", 3), e("mesh-build-go:files", "contracts:go-b", 3)}}, + "delivery-sdk": {Edges: []catalog.Edge{e("mesh-build-go:files", "delivery-sdk:go", 3), e("mesh-sdk:go", "delivery-sdk:go", 1)}}, + "mesh-build-go": {Edges: []catalog.Edge{e("contracts:go-a", "mesh-build-go:tools", 1), e("delivery-sdk:go", "mesh-build-go:tools", 1), e("nats:tools", "mesh-build-go:files", 4)}}, + "zfs": {Edges: []catalog.Edge{e("mesh-build-go:files", "zfs:tools", 3), e("contracts:go-a", "zfs:tools", 1)}}, + "tool": {Edges: []catalog.Edge{e("builder:program", "tool:program", 3)}}, + "builder": {}, + } + pipe := func(modules ...string) seat.Pipeline { + var p seat.Pipeline + for _, m := range modules { + p.Movers = append(p.Movers, seat.Mover{Module: m}) + } + return p + } + all := pipe("mesh-sdk", "contracts", "delivery-sdk", "mesh-build-go", "zfs") + for _, c := range []struct { + name string + p seat.Pipeline + mover string + want []string + }{ + {"the build module's own package input awaits no toolchain edge", all, "contracts", nil}, + {"an input through another mover awaits no toolchain edge", all, "mesh-sdk", nil}, + {"an input that imports another input awaits only that package", all, "delivery-sdk", []string{"mesh-sdk:go"}}, + {"the build module awaits its inputs' packages", all, "mesh-build-go", []string{"contracts:go-a", "delivery-sdk:go"}}, + {"any other mover awaits the new build module first", all, "zfs", []string{"mesh-build-go:files", "contracts:go-a"}}, + {"a build module that is not built from the mover is awaited", pipe("tool", "builder"), "tool", []string{"builder:program"}}, + {"a build module that does not move is not awaited", pipe("tool"), "tool", nil}, + } { + var got []string + for _, x := range awaited(c.p, c.mover, entries) { + got = append(got, x.From) + } + if !slices.Equal(got, c.want) { + t.Errorf("%s: %s awaits %v, want %v", c.name, c.mover, got, c.want) + } + } +} From ef086e0b75628c4d344730837530e89e4c78fc05 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 18:12:04 +0100 Subject: [PATCH 2/3] mesh-delivery-pipeline: a cycle among unplaced movers ends the pipeline failed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A cycle the running build module does not break left a pipeline running with journal lines only, since validate is asked only for a placed mover. The placing now ends it failed, its why naming each artifact and edge kind. Builds: design 47 H H-A-175, G §270, G-22 A-326, H-A-101 (2) --- .../internal/pipeline/order_test.go | 63 +++++++++++++++++++ .../internal/pipeline/start.go | 45 +++++++++++++ 2 files changed, 108 insertions(+) diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/order_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/order_test.go index d5cc86e0..bd699591 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/order_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/order_test.go @@ -4,6 +4,7 @@ import ( "slices" "strings" "testing" + "time" 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" @@ -171,3 +172,65 @@ func TestAToolchainEdgeIsNotAwaitedByTheBuildModulesOwnInputs(t *testing.T) { } } } + +// Design 47 H H-A-175 (G §270, A-326; H-A-101 (2)): a cycle among a pipeline's movers without steps ends the pipeline failed +// at its placing, its why `cycle` naming each artifact and edge kind, each of their steps ended not asked; a cycle through +// a build module's own inputs is broken (G §270) and placed; a mover waiting on a placed mover only waits. +func TestACycleAmongUnplacedMoversEndsThePipelineFailed(t *testing.T) { + reg, base := placeFixture() + reg.Policy = catalog.Policy{Steps: catalog.StepStatuses{Lint: "bypass", Unit: "bypass", Integration: "bypass", Validate: "bypass", Composition: "bypass"}} + entry := func(m string, edges ...catalog.Edge) catalog.CatalogEntry { + return catalog.CatalogEntry{Module: m, Artifacts: []catalog.Artifact{{Ref: m + ":go", Language: "go"}}, Edges: edges} + } + e := func(from, to string, kind int64) catalog.Edge { return catalog.Edge{From: from, To: to, Kind: kind} } + for _, c := range []struct { + name string + entries []catalog.CatalogEntry + failed bool + placed []string + }{ + {"a cycle G §270 breaks is placed", []catalog.CatalogEntry{ + entry("mesh-sdk", e("mesh-build-go:files", "mesh-sdk:go", 3)), + entry("mesh-build-go", e("mesh-sdk:go", "mesh-build-go:go", 1))}, false, []string{"mesh-sdk"}}, + {"a cycle no rule breaks ends the pipeline failed naming it", []catalog.CatalogEntry{ + entry("a", e("b:go", "a:go", 1)), + entry("b", e("a:go", "b:go", 1)), + entry("c")}, true, []string{"a", "b", "c"}}, + {"a mover waiting on a placed mover waits", []catalog.CatalogEntry{ + entry("a", e("b:go", "a:go", 1)), + entry("b")}, false, []string{"b"}}, + } { + entries := map[string]catalog.CatalogEntry{"mesh-build-go": base["mesh-build-go"]} + p := seat.Pipeline{Pipeline: "main.4", Branch: "main", Source: 4, Outcome: seat.PipelineOutcomeRunning} + for _, en := range c.entries { + entries[en.Module] = en + p.Movers = append(p.Movers, seat.Mover{Module: en.Module, Commit: "c", Fingerprint: "src2:" + en.Module}) + } + s := &Starter{Name: "the-runner"} + asks, _, ended, _ := s.placeMovers(&p, func(string) (catalog.Registration, bool) { return reg, true }, entries, time.Unix(1, 0)) + var got []string + for _, m := range p.Movers { + if placed(p, m.Module) { + got = append(got, m.Module) + } + } + if !slices.Equal(got, c.placed) { + t.Errorf("%s: placed %v, want %v", c.name, got, c.placed) + } + if !c.failed { + if p.Outcome != seat.PipelineOutcomeRunning || len(ended) != 0 || len(asks) == 0 { + t.Errorf("%s: pipeline %s (%s), %d ended, %d asks; want running and asked", c.name, p.Outcome, p.Why, len(ended), len(asks)) + } + continue + } + if p.Outcome != seat.PipelineOutcomeFailed || !strings.HasPrefix(p.Why, "cycle: ") || !strings.Contains(p.Why, "a:go before b:go (kind 1)") || + !strings.Contains(p.Why, "b:go before a:go (kind 1)") || len(asks) != 0 || len(ended) == 0 { + t.Errorf("%s: pipeline %s why %q, %d asks, %d ended; want failed naming the cycle, nothing asked", c.name, p.Outcome, p.Why, len(asks), len(ended)) + } + for _, st := range p.Steps { + if st.Outcome != seat.StepResultOutcomeBypassed && (st.Outcome != seat.StepResultOutcomeNotAsked || st.Why != p.Why) { + t.Errorf("%s: %s's %s = %s (%s), want not asked naming the cycle", c.name, st.Module, st.Step, st.Outcome, st.Why) + } + } + } +} diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/start.go b/modules/mesh-delivery-pipeline/internal/pipeline/start.go index 27174963..d585cedb 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/start.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/start.go @@ -317,6 +317,7 @@ func (s *Starter) placeMovers(p *seat.Pipeline, reg func(module string) (catalog var asks []Asked var unregistered []string var notAsked []int + var waits []seat.Mover for _, m := range p.Movers { if placed(*p, m.Module) { continue @@ -331,6 +332,7 @@ func (s *Starter) placeMovers(p *seat.Pipeline, reg func(module string) (catalog due, waiting, failed := ready(*p, m.Module, entries) if !due && failed == "" { s.logf("%s: %s waits for %s before its build", p.Pipeline, m.Module, strings.Join(waiting, ", ")) + waits = append(waits, m) continue } steps, a := Place(*p, m, r, entries, now, s.Name) @@ -367,6 +369,9 @@ func (s *Starter) placeMovers(p *seat.Pipeline, reg func(module string) (catalog } } } + if ended := cycled(p, waits, unregistered, reg, entries, now, s.Name); len(ended) > 0 { + return nil, unregistered, ended, notAsked + } // A mover placed after the validate ended has its composition asked, or not asked, at once (§745). more, _ := releaseCompositions(p, now) asks = append(asks, more...) @@ -374,6 +379,46 @@ func (s *Starter) placeMovers(p *seat.Pipeline, reg func(module string) (catalog return asks, unregistered, ended, notAsked } +// cycled ends p failed at its placing when every mover still without steps waits only on movers without steps (H-A-175; +// G §270 and A-326 break a build module's own inputs before this): a cycle no build can start, its why `cycle` naming each +// artifact and edge kind on it. The waiting movers' steps are placed ended not asked (as H-A-101 (2) does), and every other +// step still open ends not asked, the way a holderless pipeline ends at once (A-470g). It answers the steps it ended, +// none when there is no such cycle. +func cycled(p *seat.Pipeline, waits []seat.Mover, unregistered []string, reg func(module string) (catalog.Registration, bool), entries map[string]catalog.CatalogEntry, now time.Time, name string) []int { + if len(waits) == 0 || len(unregistered) > 0 { + return nil + } + var on []string + for _, m := range waits { + for _, x := range awaited(*p, m.Module, entries) { + if placed(*p, moduleOf(x.From)) { + return nil + } + on = append(on, fmt.Sprintf("%s before %s (kind %d)", x.From, x.To, x.Kind)) + } + } + sort.Strings(on) + why := "cycle: " + strings.Join(on, "; ") + for _, m := range waits { + r, _ := reg(m.Module) + steps, _ := Place(*p, m, r, entries, now, name) + p.Steps = append(p.Steps, steps...) + } + var ended []int + for i := range p.Steps { + st := &p.Steps[i] + if st.Outcome == seat.StepResultOutcomeBypassed || (!open(*st) && st.Outcome != seat.StepResultOutcomeWaiting) { + continue + } + st.Outcome, st.Why, st.Ask, st.Shared, st.Ended = seat.StepResultOutcomeNotAsked, why, "", nil, &now + p.Unlogged = append(p.Unlogged, endEntry(p.Pipeline, *st, now)) + ended = append(ended, i) + } + p.Outcome, p.Why, p.Ended = seat.PipelineOutcomeFailed, why, &now + p.EndCount++ + return ended +} + // sayNotAsked says the step-ended of each step of p placed not asked because its mover's dependency did not build, naming // the dependency in its why, so no step ends silently (H-A-101 (2)). func (s *Starter) sayNotAsked(p seat.Pipeline, steps []int) { From a7b2fb0ffa8d4fa5d997cc264ca4bd52077ce497 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 18:15:47 +0100 Subject: [PATCH 3/3] mesh-delivery-pipeline: a cycle ends only its own steps; the end judgement ends the pipeline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A cycle ended every open step of the pipeline at once and named edges outside it. It now ends not asked only the steps of the movers without steps, names the edges inside a strongly connected group alone, and leaves the pipeline's end to the end judgement, so running steps run to their end. Builds: design 47 H H-A-176, H-A-175, H-A-163, G §270, G-22 A-326 --- .../internal/pipeline/order_test.go | 75 +++++++++--------- .../internal/pipeline/start.go | 76 +++++++++++++------ 2 files changed, 91 insertions(+), 60 deletions(-) diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/order_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/order_test.go index bd699591..0065aabd 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/order_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/order_test.go @@ -173,9 +173,10 @@ func TestAToolchainEdgeIsNotAwaitedByTheBuildModulesOwnInputs(t *testing.T) { } } -// Design 47 H H-A-175 (G §270, A-326; H-A-101 (2)): a cycle among a pipeline's movers without steps ends the pipeline failed -// at its placing, its why `cycle` naming each artifact and edge kind, each of their steps ended not asked; a cycle through -// a build module's own inputs is broken (G §270) and placed; a mover waiting on a placed mover only waits. +// Design 47 H H-A-175, H-A-176 (G §270, A-326; H-A-101 (2), H-A-163): when every mover without steps waits only on movers +// without steps, their steps are placed ended not asked, the why `cycle` naming the edges inside the cycle alone; a step +// of another mover is asked as ever, and the pipeline ends by the end judgement, at once when no required step is open; a +// cycle through a build module's own inputs is broken (G §270) and placed; a mover waiting on a placed mover only waits. func TestACycleAmongUnplacedMoversEndsThePipelineFailed(t *testing.T) { reg, base := placeFixture() reg.Policy = catalog.Policy{Steps: catalog.StepStatuses{Lint: "bypass", Unit: "bypass", Integration: "bypass", Validate: "bypass", Composition: "bypass"}} @@ -183,22 +184,22 @@ func TestACycleAmongUnplacedMoversEndsThePipelineFailed(t *testing.T) { return catalog.CatalogEntry{Module: m, Artifacts: []catalog.Artifact{{Ref: m + ":go", Language: "go"}}, Edges: edges} } e := func(from, to string, kind int64) catalog.Edge { return catalog.Edge{From: from, To: to, Kind: kind} } + cycle := []catalog.CatalogEntry{entry("a", e("b:go", "a:go", 1)), entry("b", e("a:go", "b:go", 1))} for _, c := range []struct { - name string - entries []catalog.CatalogEntry - failed bool - placed []string + name string + entries []catalog.CatalogEntry + outcome string + asked []string + notAsked []string }{ {"a cycle G §270 breaks is placed", []catalog.CatalogEntry{ entry("mesh-sdk", e("mesh-build-go:files", "mesh-sdk:go", 3)), - entry("mesh-build-go", e("mesh-sdk:go", "mesh-build-go:go", 1))}, false, []string{"mesh-sdk"}}, - {"a cycle no rule breaks ends the pipeline failed naming it", []catalog.CatalogEntry{ - entry("a", e("b:go", "a:go", 1)), - entry("b", e("a:go", "b:go", 1)), - entry("c")}, true, []string{"a", "b", "c"}}, + entry("mesh-build-go", e("mesh-sdk:go", "mesh-build-go:go", 1))}, seat.PipelineOutcomeRunning, []string{"mesh-sdk"}, nil}, + {"a cycle beside a free mover ends its own steps and the free one is asked", + append(slices.Clone(cycle), entry("c"), entry("d", e("a:go", "d:go", 1))), seat.PipelineOutcomeRunning, []string{"c"}, []string{"a", "b", "d"}}, + {"a cycle alone ends the pipeline failed at once", cycle, seat.PipelineOutcomeFailed, nil, []string{"a", "b"}}, {"a mover waiting on a placed mover waits", []catalog.CatalogEntry{ - entry("a", e("b:go", "a:go", 1)), - entry("b")}, false, []string{"b"}}, + entry("a", e("b:go", "a:go", 1)), entry("b")}, seat.PipelineOutcomeRunning, []string{"b"}, nil}, } { entries := map[string]catalog.CatalogEntry{"mesh-build-go": base["mesh-build-go"]} p := seat.Pipeline{Pipeline: "main.4", Branch: "main", Source: 4, Outcome: seat.PipelineOutcomeRunning} @@ -207,30 +208,32 @@ func TestACycleAmongUnplacedMoversEndsThePipelineFailed(t *testing.T) { p.Movers = append(p.Movers, seat.Mover{Module: en.Module, Commit: "c", Fingerprint: "src2:" + en.Module}) } s := &Starter{Name: "the-runner"} - asks, _, ended, _ := s.placeMovers(&p, func(string) (catalog.Registration, bool) { return reg, true }, entries, time.Unix(1, 0)) - var got []string - for _, m := range p.Movers { - if placed(p, m.Module) { - got = append(got, m.Module) + asks, _, ended, notAsked := s.placeMovers(&p, func(string) (catalog.Registration, bool) { return reg, true }, entries, time.Unix(1, 0)) + if p.Outcome != c.outcome || (c.outcome == seat.PipelineOutcomeFailed) != (len(ended) > 0) || (len(c.asked) > 0) != (len(asks) > 0) { + t.Errorf("%s: pipeline %s (%s), %d asks, %d ended; want %s", c.name, p.Outcome, p.Why, len(asks), len(ended), c.outcome) + } + said := map[int]bool{} + for _, i := range append(ended, notAsked...) { + said[i] = true + } + var asked, ends []string + for i, st := range p.Steps { + switch { + case st.Outcome == seat.StepResultOutcomeNotAsked && strings.HasPrefix(st.Why, "cycle: ") && said[i]: + if !slices.Contains(ends, st.Module) { + ends = append(ends, st.Module) + } + if st.Why != "cycle: a:go before b:go (kind 1); b:go before a:go (kind 1)" { + t.Errorf("%s: %s's %s why %q, want the cycle's two edges alone", c.name, st.Module, st.Step, st.Why) + } + case open(st) || st.Outcome == seat.StepResultOutcomeWaiting: + if !slices.Contains(asked, st.Module) { + asked = append(asked, st.Module) + } } } - if !slices.Equal(got, c.placed) { - t.Errorf("%s: placed %v, want %v", c.name, got, c.placed) - } - if !c.failed { - if p.Outcome != seat.PipelineOutcomeRunning || len(ended) != 0 || len(asks) == 0 { - t.Errorf("%s: pipeline %s (%s), %d ended, %d asks; want running and asked", c.name, p.Outcome, p.Why, len(ended), len(asks)) - } - continue - } - if p.Outcome != seat.PipelineOutcomeFailed || !strings.HasPrefix(p.Why, "cycle: ") || !strings.Contains(p.Why, "a:go before b:go (kind 1)") || - !strings.Contains(p.Why, "b:go before a:go (kind 1)") || len(asks) != 0 || len(ended) == 0 { - t.Errorf("%s: pipeline %s why %q, %d asks, %d ended; want failed naming the cycle, nothing asked", c.name, p.Outcome, p.Why, len(asks), len(ended)) - } - for _, st := range p.Steps { - if st.Outcome != seat.StepResultOutcomeBypassed && (st.Outcome != seat.StepResultOutcomeNotAsked || st.Why != p.Why) { - t.Errorf("%s: %s's %s = %s (%s), want not asked naming the cycle", c.name, st.Module, st.Step, st.Outcome, st.Why) - } + if !slices.Equal(asked, c.asked) || !slices.Equal(ends, c.notAsked) { + t.Errorf("%s: open %v, ended not asked %v; want %v and %v", c.name, asked, ends, c.asked, c.notAsked) } } } diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/start.go b/modules/mesh-delivery-pipeline/internal/pipeline/start.go index d585cedb..cfb8cc48 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/start.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/start.go @@ -369,8 +369,10 @@ func (s *Starter) placeMovers(p *seat.Pipeline, reg func(module string) (catalog } } } - if ended := cycled(p, waits, unregistered, reg, entries, now, s.Name); len(ended) > 0 { - return nil, unregistered, ended, notAsked + if steps, ended := cycled(p, waits, unregistered, reg, entries, now, s.Name); ended { + return nil, unregistered, steps, notAsked + } else { + notAsked = append(notAsked, steps...) } // A mover placed after the validate ended has its composition asked, or not asked, at once (§745). more, _ := releaseCompositions(p, now) @@ -379,44 +381,70 @@ func (s *Starter) placeMovers(p *seat.Pipeline, reg func(module string) (catalog return asks, unregistered, ended, notAsked } -// cycled ends p failed at its placing when every mover still without steps waits only on movers without steps (H-A-175; -// G §270 and A-326 break a build module's own inputs before this): a cycle no build can start, its why `cycle` naming each -// artifact and edge kind on it. The waiting movers' steps are placed ended not asked (as H-A-101 (2) does), and every other -// step still open ends not asked, the way a holderless pipeline ends at once (A-470g). It answers the steps it ended, -// none when there is no such cycle. -func cycled(p *seat.Pipeline, waits []seat.Mover, unregistered []string, reg func(module string) (catalog.Registration, bool), entries map[string]catalog.CatalogEntry, now time.Time, name string) []int { +// cycled ends not asked, at p's placing, the steps of every mover still without steps when each waits only on movers +// without steps (H-A-175, H-A-176; G §270 and A-326 break a build module's own inputs before this): a cycle no build can +// start, and the movers that wait only on it. Their steps are placed ended not asked (as H-A-101 (2) does), the why +// `cycle` naming each artifact and edge kind whose two movers share a strongly connected group; no step already asked is +// touched. The pipeline then ends by the end judgement of H-A-163 (endPipeline), failed once no required step is open, +// its running steps running to their own end. It answers the steps it ended not asked, or, when the pipeline ended, every +// step it ended, and whether the pipeline ended. +func cycled(p *seat.Pipeline, waits []seat.Mover, unregistered []string, reg func(module string) (catalog.Registration, bool), entries map[string]catalog.CatalogEntry, now time.Time, name string) ([]int, bool) { if len(waits) == 0 || len(unregistered) > 0 { - return nil + return nil, false } - var on []string + after := map[string][]string{} + edges := map[string][]catalog.Edge{} for _, m := range waits { for _, x := range awaited(*p, m.Module, entries) { - if placed(*p, moduleOf(x.From)) { - return nil + from := moduleOf(x.From) + if placed(*p, from) { + return nil, false + } + after[m.Module] = append(after[m.Module], from) + edges[m.Module] = append(edges[m.Module], x) + } + } + comp := components(waits, after) + var on []string + for _, m := range waits { + for _, x := range edges[m.Module] { + if comp[moduleOf(x.From)] == comp[m.Module] { + on = append(on, fmt.Sprintf("%s before %s (kind %d)", x.From, x.To, x.Kind)) } - on = append(on, fmt.Sprintf("%s before %s (kind %d)", x.From, x.To, x.Kind)) } } sort.Strings(on) why := "cycle: " + strings.Join(on, "; ") + var ended []int for _, m := range waits { r, _ := reg(m.Module) steps, _ := Place(*p, m, r, entries, now, name) + for k := range steps { + st := &steps[k] + if st.Outcome == seat.StepResultOutcomeBypassed { + continue + } + st.Outcome, st.Why, st.Ask, st.Shared, st.Ended = seat.StepResultOutcomeNotAsked, why, "", nil, &now + p.Unlogged = append(p.Unlogged, endEntry(p.Pipeline, *st, now)) + ended = append(ended, len(p.Steps)+k) + } p.Steps = append(p.Steps, steps...) } - var ended []int - for i := range p.Steps { - st := &p.Steps[i] - if st.Outcome == seat.StepResultOutcomeBypassed || (!open(*st) && st.Outcome != seat.StepResultOutcomeWaiting) { - continue + var approvals []int + for i, st := range p.Steps { + if st.Step == seat.StepResultStepApproval && st.Outcome == seat.StepResultOutcomeWaiting { + approvals = append(approvals, i) } - st.Outcome, st.Why, st.Ask, st.Shared, st.Ended = seat.StepResultOutcomeNotAsked, why, "", nil, &now - p.Unlogged = append(p.Unlogged, endEntry(p.Pipeline, *st, now)) - ended = append(ended, i) } - p.Outcome, p.Why, p.Ended = seat.PipelineOutcomeFailed, why, &now - p.EndCount++ - return ended + if !endPipeline(p, now, nil) { + return ended, false + } + for _, i := range approvals { + if p.Steps[i].Outcome == seat.StepResultOutcomeNotAsked { + ended = append(ended, i) + } + } + return ended, true } // sayNotAsked says the step-ended of each step of p placed not asked because its mover's dependency did not build, naming