mesh-delivery-pipeline: a mover counts as moved only at a head newer than its pipeline's revision (fix-770 round 4, issue 1984)
H-A-770 (5): while the runner's view of the head is at the revision of the pipeline a mover's record names, or older, a head entry at another fingerprint counts for nothing: movedOn drops and unties nothing, so a lagging view never drops a key, and the mover is judged again when the view moves. movedOn, closedGroup, heldBack and HeldBehind now take the head's revision with its entries. Builds: design 47 H2 H-A-770 (5), H-A-594 (2)
This commit is contained in:
@@ -168,7 +168,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
}
|
||||
// The head's revision says which movers a newer revision moved: they tie nothing (design 47 H2 H-A-594 (2), H-A-761).
|
||||
head, _ := rv.Catalog.View(p.Branch)
|
||||
return pipeline.HeldBehind(p, module, half.Entries, head.Entries)
|
||||
return pipeline.HeldBehind(p, module, half.Entries, head)
|
||||
}}
|
||||
// Every ask but a test run's is bounded until its holder's first word (H-A-235, H-A-238), its bounds keys of the state
|
||||
// bounds. A step's ask is put as a kept call within the same bound (design 47 H2 §775).
|
||||
|
||||
@@ -164,10 +164,10 @@ func moduleNames(movers []seat.Mover) []string {
|
||||
}
|
||||
|
||||
// HeldBehind are the movers of p, sorted, that the failed mover module holds back: those whose own steps held and that await
|
||||
// it, directly or through others, or sit in the tier group of one that does (H-A-625 (2)). With head, the head's revision's
|
||||
// entries, a mover of p a newer revision moved, the head's entry holding another fingerprint, ties nothing and is held behind
|
||||
// nothing, as the carry reads it (design 47 H2 H-A-594 (2), H-A-761).
|
||||
func HeldBehind(p seat.Pipeline, module string, entries, head map[string]catalog.CatalogEntry) []string {
|
||||
// it, directly or through others, or sit in the tier group of one that does (H-A-625 (2)). With head, the head's revision, a
|
||||
// mover of p a newer revision moved, the head's entry holding another fingerprint, ties nothing and is held behind nothing, as the
|
||||
// carry reads it (design 47 H2 H-A-594 (2), H-A-761, H-A-770 (5)).
|
||||
func HeldBehind(p seat.Pipeline, module string, entries map[string]catalog.CatalogEntry, head Half) []string {
|
||||
failed := failedMovers(p)
|
||||
var left []string
|
||||
for _, m := range p.Movers {
|
||||
|
||||
@@ -167,7 +167,7 @@ func TestEachFailingMoverIsAFindingAndItsNextPassedPipelineClearsIt(t *testing.T
|
||||
Movers: []seat.Mover{{Module: "engine", Commit: "c1"}, {Module: "gitea"}},
|
||||
Steps: []seat.StepResult{{Module: "engine", Step: seat.StepResultStepLint, Status: seat.StepResultStatusRequired, Outcome: seat.StepResultOutcomeFailed},
|
||||
{Module: "gitea", Step: seat.StepResultStepLint, Status: seat.StepResultStatusRequired, Outcome: seat.StepResultOutcomeNotAsked}}}
|
||||
fl := &Failures{Findings: f, Observer: "runner", Behind: func(p seat.Pipeline, m string) []string { return HeldBehind(p, m, entries, nil) }}
|
||||
fl := &Failures{Findings: f, Observer: "runner", Behind: func(p seat.Pipeline, m string) []string { return HeldBehind(p, m, entries, Half{}) }}
|
||||
fl.StepEnded(nil, p, p.Steps[0])
|
||||
got := f.held["delivery.engine.main.pipeline-failed"]
|
||||
if !strings.Contains(got.Explanation, "gitea are held behind it") || !strings.Contains(got.Explanation, "runner_unfinished_place") {
|
||||
|
||||
@@ -54,7 +54,7 @@ func (v Verbs) Start(caller string, in seat.StartInput) (seat.StartAnswer, error
|
||||
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)
|
||||
older, movers, err := v.ownFailedPipelines(in.Branch, key, movers, half)
|
||||
if err != nil {
|
||||
return seat.StartAnswer{}, err
|
||||
}
|
||||
@@ -133,7 +133,7 @@ func (v Verbs) startAtHead(caller string, in seat.StartInput, half Half, key str
|
||||
case !Moves(head, m.Module):
|
||||
add = append(add, m)
|
||||
case len(failedSteps(head, m.Module)) > 0 || !allPassed(head, m.Module):
|
||||
g, by := v.closedGroup(head, m.Module, entries)
|
||||
g, by := v.closedGroup(head, m.Module, half)
|
||||
group = appendNew(group, g...)
|
||||
maps.Copy(passed, by)
|
||||
}
|
||||
@@ -171,7 +171,8 @@ func olderModules(o []ownPipeline) []string {
|
||||
|
||||
// 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) {
|
||||
func (v Verbs) ownFailedPipelines(branch, key string, movers []seat.Mover, half Half) ([]ownPipeline, []seat.Mover, error) {
|
||||
headEntries := half.Entries
|
||||
s := v.Starter
|
||||
pkeys, err := branchKeys(s.Store, branch)
|
||||
if err != nil {
|
||||
@@ -221,7 +222,7 @@ func (v Verbs) ownFailedPipelines(branch, key string, movers []seat.Mover, headE
|
||||
out = append(out, ownPipeline{from: best, entries: headEntries, passed: map[string]movedMover{}})
|
||||
at = len(out) - 1
|
||||
}
|
||||
g, by := v.closedGroup(best, m.Module, out[at].entries)
|
||||
g, by := v.closedGroup(best, m.Module, half)
|
||||
out[at].group = appendNew(out[at].group, g...)
|
||||
maps.Copy(out[at].passed, by)
|
||||
}
|
||||
@@ -254,11 +255,13 @@ func appendNew(into []string, add ...string) []string {
|
||||
|
||||
// closedGroup is the group of movers of p that go with module: closed under the tier edges and under every awaited edge from a
|
||||
// mover that left unfinished or failed, so a mover goes only with every mover it has an edge from (design 47 H2 H-A-594 (2),
|
||||
// H-A-646). A passed mover is never in it. entries are the head's revision's: a mover of p a newer revision moved, the head's
|
||||
// entry holding another fingerprint than p's, counts as carried by that revision's pipeline and is in no group (H-A-594 (2),
|
||||
// H-A-761); passed are those the group would hold otherwise, to be said and their keys dropped.
|
||||
func (v Verbs) closedGroup(p seat.Pipeline, module string, entries map[string]catalog.CatalogEntry) (group []string, passed map[string]movedMover) {
|
||||
moved := movedOn(p, entries)
|
||||
// H-A-646). A passed mover is never in it. It is read over head, the head's revision, whose edges are the newest (H-A-763 (3)): a
|
||||
// mover of p a newer revision moved, the head's entry holding another fingerprint than p's, counts as carried by that revision's
|
||||
// pipeline and is in no group (H-A-594 (2), H-A-761, H-A-770 (5)); passed are those the group would hold otherwise, to be said and
|
||||
// their keys dropped.
|
||||
func (v Verbs) closedGroup(p seat.Pipeline, module string, head Half) (group []string, passed map[string]movedMover) {
|
||||
entries := head.Entries
|
||||
moved := movedOn(p, head)
|
||||
delete(moved, module)
|
||||
universe := appendNew(slices.Clone(unfinishedOf(p)), failedMovers(p)...)
|
||||
passed = map[string]movedMover{}
|
||||
@@ -453,7 +456,7 @@ func (v Verbs) planUnfinished(key string) (handPlan, error) {
|
||||
return handPlan{}, fmt.Errorf("%s at fingerprint %s is read at the head's revision %d of %s, which has no source", module, e.Fingerprint, head.Revision, branch)
|
||||
}
|
||||
half := head
|
||||
group, passed := v.closedGroup(from, module, half.Entries)
|
||||
group, passed := v.closedGroup(from, module, half)
|
||||
from.Movers = slices.Clone(from.Movers)
|
||||
plan := handPlan{from: from, group: group, entries: half.Entries, passed: passed, head: half.Revision}
|
||||
for _, g := range group {
|
||||
|
||||
@@ -706,6 +706,25 @@ func testAPredecessorANewerRevisionMovedTiesNothing(t *testing.T) {
|
||||
t.Errorf("at main.5's end added %v, state %v, said %q: want gitea carried, stale not kept, engine and stale said", added, st, said)
|
||||
}
|
||||
})
|
||||
// H-A-770 (5): while the runner's view of the head is at main.5's revision or older, a head entry at another fingerprint counts
|
||||
// for nothing: gitea stays tied to engine, stale stays unfinished, nothing is said moved; they are judged again when it moves.
|
||||
t.Run("a lagging view drops and unties nothing", func(t *testing.T) {
|
||||
for _, rev := range []int64{5, 4} {
|
||||
var said, added []string
|
||||
st := memUnfinished{}
|
||||
u := &Unfinished{Store: st, Logf: func(f string, a ...any) { said = append(said, fmt.Sprintf(f, a...)) },
|
||||
Entries: func(string, int64) (map[string]catalog.CatalogEntry, bool) { return edges, true },
|
||||
Head: func(string) (Half, bool) { return Half{Revision: rev, Source: 9, Entries: moved}, true },
|
||||
Add: func(_ seat.Pipeline, group []seat.Mover) (string, bool) {
|
||||
added = append(added, moduleNames(group)...)
|
||||
return "main.7", true
|
||||
}}
|
||||
u.Ended(failed)
|
||||
if !slices.Equal(added, []string{"stale"}) || st["main.gitea"] == "" || st["main.stale"] == "" || strings.Contains(saidOf(said), "counts as carried") {
|
||||
t.Errorf("with the view at revision %d main.5's end added %v, state %v, said %q: want gitea tied and kept, stale kept and carried, nothing said moved", rev, added, st, said)
|
||||
}
|
||||
}
|
||||
})
|
||||
// The finding pipeline-failed's held-behind list (H-A-625 (2)) reads the head as the carry does: gitea awaits the failed engine's
|
||||
// package and mate awaits gitea's; a mover a newer revision moved is held behind nothing and holds nothing behind it.
|
||||
t.Run("the finding's held-behind list", func(t *testing.T) {
|
||||
@@ -716,13 +735,13 @@ func testAPredecessorANewerRevisionMovedTiesNothing(t *testing.T) {
|
||||
{Module: "mate", Step: seat.StepResultStepUnit, Status: seat.StepResultStatusRequired, Outcome: seat.StepResultOutcomeNotAsked}}}
|
||||
ties := maps.Clone(edges)
|
||||
edgeInto(ties, "mate", "gitea", 1)
|
||||
at := func(engine, gitea string) map[string]catalog.CatalogEntry {
|
||||
return map[string]catalog.CatalogEntry{"engine": {Fp: engine}, "gitea": {Fp: gitea}, "mate": {Fp: "f3"}}
|
||||
at := func(engine, gitea string) Half {
|
||||
return Half{Revision: 7, Entries: map[string]catalog.CatalogEntry{"engine": {Fp: engine}, "gitea": {Fp: gitea}, "mate": {Fp: "f3"}}}
|
||||
}
|
||||
for _, c := range []struct {
|
||||
head map[string]catalog.CatalogEntry
|
||||
head Half
|
||||
want []string
|
||||
}{{nil, []string{"gitea", "mate"}}, {at("f1", "f2"), []string{"gitea", "mate"}}, {at("f1b", "f2"), nil}, {at("f1", "f2b"), nil}} {
|
||||
}{{Half{}, []string{"gitea", "mate"}}, {at("f1", "f2"), []string{"gitea", "mate"}}, {at("f1b", "f2"), nil}, {at("f1", "f2b"), nil}} {
|
||||
if got := HeldBehind(p, "engine", ties, c.head); !slices.Equal(got, c.want) {
|
||||
t.Errorf("held behind engine with the head %v = %v, want %v", c.head, got, c.want)
|
||||
}
|
||||
|
||||
@@ -123,24 +123,25 @@ type Unfinished struct {
|
||||
// none).
|
||||
type movedMover struct{ At, Head string }
|
||||
|
||||
// movedOn are the movers of p it did not deliver, left unfinished or failed, whose module's entry in head, the head's revision's
|
||||
// entries, does not hold p's fingerprint of them: a predecessor a newer revision moved counts as carried by that revision's
|
||||
// pipeline, so it ties nothing and goes in no group (design 47 H2 H-A-594 (2)), and it goes on only at the fingerprint the head's
|
||||
// entry holds (H-A-761). None when head is nil.
|
||||
func movedOn(p seat.Pipeline, head map[string]catalog.CatalogEntry) map[string]movedMover {
|
||||
// movedOn are the movers of p it did not deliver, left unfinished or failed, whose module's entry at head, the head's revision,
|
||||
// does not hold p's fingerprint of them: a predecessor a newer revision moved counts as carried by that revision's pipeline, so it
|
||||
// ties nothing and goes in no group (design 47 H2 H-A-594 (2)), and it goes on only at the fingerprint the head's entry holds
|
||||
// (H-A-761). None when head holds no entries, or while it is p's revision or older: a lagging view drops and unties nothing, and
|
||||
// the mover is judged again when the view moves (H-A-770 (5)).
|
||||
func movedOn(p seat.Pipeline, head Half) map[string]movedMover {
|
||||
return movedAmong(p, appendNew(slices.Clone(unfinishedOf(p)), failedMovers(p)...), head)
|
||||
}
|
||||
|
||||
// movedAmong are the movers of p among names whose entry in head does not hold p's fingerprint of them (movedOn); none when head
|
||||
// is nil.
|
||||
func movedAmong(p seat.Pipeline, names []string, head map[string]catalog.CatalogEntry) map[string]movedMover {
|
||||
if head == nil {
|
||||
// movedAmong are the movers of p among names whose entry at head does not hold p's fingerprint of them (movedOn); none when head
|
||||
// holds no entries or is not newer than p's revision (H-A-770 (5)).
|
||||
func movedAmong(p seat.Pipeline, names []string, head Half) map[string]movedMover {
|
||||
if head.Entries == nil || head.Revision <= p.Revision {
|
||||
return nil
|
||||
}
|
||||
out := map[string]movedMover{}
|
||||
for _, name := range names {
|
||||
m, _ := MoverOf(p, name)
|
||||
if e := head[name]; !slices.Contains(p.Superseded, name) && e.Fp != m.Fingerprint {
|
||||
if e := head.Entries[name]; !slices.Contains(p.Superseded, name) && e.Fp != m.Fingerprint {
|
||||
out[name] = movedMover{At: m.Fingerprint, Head: e.Fp}
|
||||
}
|
||||
}
|
||||
@@ -294,7 +295,7 @@ func (u *Unfinished) Ended(p seat.Pipeline) {
|
||||
var head Half
|
||||
if len(left) > 0 && u.Head != nil {
|
||||
if h, ok := u.Head(p.Branch); ok {
|
||||
head, moved = h, movedOn(p, h.Entries)
|
||||
head, moved = h, movedOn(p, h)
|
||||
}
|
||||
}
|
||||
for _, m := range p.Movers {
|
||||
@@ -410,9 +411,9 @@ func (u *Unfinished) markCarried(branch string, modules []string, carrier string
|
||||
|
||||
// heldBack are the failed modules a mover's key is tied to: the failed movers of its pipeline that the mover awaits at that
|
||||
// pipeline's revision, directly or through others, and that are registered still (H-A-610, H-A-646). None when the hooks that
|
||||
// read them are not set. With head, the head's revision's entries, a mover of that pipeline a newer revision moved ties nothing
|
||||
// (design 47 H2 H-A-594 (2), H-A-761): the failed ones it passes for that are answered in passed, with the pipeline read.
|
||||
func (u *Unfinished) heldBack(branch, module string, e UnfinishedEntry, head map[string]catalog.CatalogEntry) (by []string, passed map[string]movedMover, from seat.Pipeline) {
|
||||
// read them are not set. With head, the head's revision, a mover of that pipeline a newer revision moved ties nothing (design 47
|
||||
// H2 H-A-594 (2), H-A-761, H-A-770 (5)): the failed ones it passes for that are answered in passed, with the pipeline read.
|
||||
func (u *Unfinished) heldBack(branch, module string, e UnfinishedEntry, head Half) (by []string, passed map[string]movedMover, from seat.Pipeline) {
|
||||
if u.Pipeline == nil || u.Entries == nil {
|
||||
return nil, nil, seat.Pipeline{}
|
||||
}
|
||||
@@ -495,7 +496,7 @@ func (u *Unfinished) Carry(branch string, revision int64, entries map[string]cat
|
||||
}
|
||||
// A failed predecessor a newer revision moved, the head's entry holding another fingerprint than its pipeline's, ties nothing,
|
||||
// said once (design 47 H2 H-A-594 (2), H-A-761).
|
||||
by, passed, from := u.heldBack(branch, module, e, entries)
|
||||
by, passed, from := u.heldBack(branch, module, e, Half{Revision: revision, Entries: entries})
|
||||
for _, f := range slices.Sorted(maps.Keys(passed)) {
|
||||
if w := movedWords(from, f, passed[f], revision); !slices.Contains(said, w) {
|
||||
said = append(said, w)
|
||||
|
||||
@@ -470,7 +470,7 @@ func (v Verbs) leaveMovedOn(p *seat.Pipeline, keep string) (moved map[string]mov
|
||||
if !ok {
|
||||
return nil, 0
|
||||
}
|
||||
moved = movedOn(*p, h.Entries)
|
||||
moved = movedOn(*p, h)
|
||||
delete(moved, keep)
|
||||
p.Movers = slices.DeleteFunc(slices.Clone(p.Movers), func(m seat.Mover) bool { _, ok := moved[m.Module]; return ok })
|
||||
return moved, h.Revision
|
||||
|
||||
Reference in New Issue
Block a user