diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/declined.go b/modules/mesh-delivery-pipeline/internal/pipeline/declined.go index e805063e2..384305bdf 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/declined.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/declined.go @@ -99,9 +99,7 @@ func (h *Hearer) putDeclined(key, old string, s seat.StepResult, a Asked, ev Ste break } } - if a.Run == "" { - unmarkAsk(h.Clock, old, h.logf) // one key per ask, gone once the ask is no longer open (H-A-506 addendum) - } + unmarkAsk(h.Clock, old, h.logf) // one key per ask, gone once the ask is no longer open (H-A-506 addendum, corrected) h.logf("%s: the %s step of %s was declined on %s (%s): asked again as %s, not on %s (H-A-445)", key, s.Step, strings.TrimSpace(s.Module+" "+s.Artifact), ev.Node, ev.Said, a.ID, strings.Join(s.NotOn, ", ")) return h.PutAgain(key, a) diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/drops.go b/modules/mesh-delivery-pipeline/internal/pipeline/drops.go index 9d240f488..7e4b8abf8 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/drops.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/drops.go @@ -47,9 +47,7 @@ func (h *Hearer) DropOpen(key string, steps []seat.StepResult, why string) { if sharedRun(st) != "" && st.Seat != wants.Seat { // A shared test run's ask is dropped only by its last reader's leave, never while another pipeline reads it // (H-A-506 corrected). - if dropped := h.leaveRun(key, st, why); dropped != "" { - h.logf("%s: the ask %s of %s's %s on %s is dropped with its test run, no reader left (H-A-506)", key, dropped, st.Module, st.Step, st.Seat) - } + h.leaveRun(key, st, why) continue } if !open(st) || st.Ask == "" || done[st.Ask] || !dropSeat(st.Seat) { @@ -109,8 +107,11 @@ func (s *Starter) dropEnded(p seat.Pipeline, prior []seat.StepResult, unput []As if s.Drop != nil && len(steps) > 0 { s.Drop(p.Pipeline, steps, "the pipeline "+p.Pipeline+" ended "+p.Outcome+": "+p.Why) } - // The end cleared these steps' asks, so their ask keys go here, not with the end's own (H-A-506 addendum). + // The end cleared these steps' asks, so their ask keys go here, not with the end's own (H-A-506 addendum); a shared + // test run's key goes with the run's end (H-A-506 corrected). for _, st := range steps { - unmarkAsk(s.Clock, st.Ask, s.logf) + if sharedRun(st) == "" { + unmarkAsk(s.Clock, st.Ask, s.logf) + } } } diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/repin_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/repin_test.go index f64a63717..3ac122550 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/repin_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/repin_test.go @@ -157,6 +157,49 @@ func TestASameSourceRepinKeepsTheMoverInItsPipeline(t *testing.T) { if p, _, _ := store.Get(key); !slices.Contains(p.Superseded, "app") { t.Errorf("the new source's revision left app in %s: %v", key, p.Superseded) } + t.Run("a holderless end drops the open asks of the movers it keeps", testARepinsHolderlessEndDropsTheOpenAsks) +} + +// design 47 H2 H-A-506: a re-pin whose placing ends the pipeline holderless drops, through each seat's drop, every ask still +// open of the movers it did not re-pin, and none of the re-pinned mover's new asks, never put. +func testARepinsHolderlessEndDropsTheOpenAsks(t *testing.T) { + reg, entries, repinned, read := repinFixture() + lib := catalog.CatalogEntry{Module: "lib", Path: "modules/lib", Fp: "src2:l1", Artifacts: []catalog.Artifact{{Ref: "lib:program", Language: "go"}}} + entries["lib"], repinned["lib"] = lib, lib + store := &MoverStore{Raw: newMemRaw()} + holders := []string{"mesh-build-go"} + var dropped []string + s := &Starter{Pipelines: store, Store: store, Steps: &stepAsks{}, Name: "the-runner", Now: ticking(), Revision: read, + Registration: func(m string) (catalog.Registration, bool) { return reg, m == "app" || m == "lib" }, + Say: func(string, any) error { return nil }, + Holders: func(string) ([]string, bool) { return holders, true }, + Ended: func(seat.Pipeline, []int) error { return nil }, + Drop: func(_ string, steps []seat.StepResult, _ string) { + for _, st := range steps { + dropped = append(dropped, st.Seat+" "+st.Ask) + } + }} + key := Key("main", 10) + if ok, err := s.Start(Begin{Branch: "main", Source: 41, Revision: 10, Entries: entries, Movers: []seat.Mover{ + {Module: "app", Commit: "c1", Fingerprint: "src2:aa", Repository: "o/app"}, + {Module: "lib", Commit: "c1", Fingerprint: "src2:l1", Repository: "o/lib"}}}); !ok || err != nil { + t.Fatalf("start = %v, %v", ok, err) + } + before, _, _ := store.Get(key) + var want []string + for _, st := range before.Steps { + if st.Module == "lib" && st.Ask != "" && open(st) { + want = append(want, st.Seat+" "+st.Ask) + } + } + holders = nil + if _, err := s.Revised(revisionEvent(11), read); err != nil { + t.Fatal(err) + } + p, _, _ := store.Get(key) + if p.Outcome != seat.PipelineOutcomeFailed || len(want) == 0 || fmt.Sprint(dropped) != fmt.Sprint(want) { + t.Errorf("the re-pin's holderless end = %s (%s), dropped %v; want failed and lib's open asks %v dropped", p.Outcome, p.Why, dropped, want) + } } // H-A-286: a kept mover not placed at its keep (its registration arrived later) is placed from the revision it is kept at diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/runends.go b/modules/mesh-delivery-pipeline/internal/pipeline/runends.go index 4b9a280c9..7a68b1e83 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/runends.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/runends.go @@ -540,7 +540,7 @@ const NoReaderLeft = "no reader is left" // leaveRun takes the step of pipeline key that read or asked a test run out of the run's readers (§726): a step superseded // or cancelled. When no reader is left the run ends `could not run`, naming that (A-469z), and its ask is dropped (§119); // while one is left the ask stays, so a superseded pipeline never takes away another's run. A step of no test run leaves -// nothing. It answers the ask it dropped, empty when it dropped none. +// nothing. It answers the ask whose drop it asked, empty when it asked none. func (h *Hearer) leaveRun(key string, s seat.StepResult, why string) string { run := sharedRun(s) if run == "" || h.TestRuns == nil { @@ -590,13 +590,19 @@ func (h *Hearer) leaveRun(key string, s seat.StepResult, why string) string { } unmarkAsk(h.Clock, r.Ask, h.logf) // the ask key goes with its run's end (H-A-506 addendum) } - if h.DropRun != nil { - if err := h.DropRun(r.Seat, r.Node, r.Ask, why); err != nil { - h.logf("the drop of ask %s of the test run %s, which no reader is left of, is not answered: %v", r.Ask, run, err) - } - return r.Ask + if h.DropRun == nil { + h.logf("%s: the ask %s of the test run %s, which no reader is left of, is not dropped: the runner has no drop", key, r.Ask, run) + return "" } - return "" + // Asked beside the leave, so a seat with no holder never holds it; one line says what happened (H-A-506). + h.aside(func() { + if err := h.DropRun(r.Seat, r.Node, r.Ask, why); err != nil { + h.logf("%s: the drop of the ask %s of the test run %s, which no reader is left of, is refused or not answered by %s: %v (H-A-506)", key, r.Ask, run, r.Seat, err) + return + } + h.logf("%s: the ask %s of the test run %s, which no reader is left of, is dropped on %s (H-A-506)", key, r.Ask, run, r.Seat) + }) + return r.Ask } } diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/steps.go b/modules/mesh-delivery-pipeline/internal/pipeline/steps.go index c32279218..d64333138 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/steps.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/steps.go @@ -520,9 +520,12 @@ func (h *Hearer) said(p seat.Pipeline, asked []int, ended bool) error { } h.Failures.Ended(p) h.Unfinished.Ended(p) - // Every ask key of its steps goes with the pipeline's end (H-A-506 addendum). + // Every ask key of its steps goes with the pipeline's end (H-A-506 addendum), but a shared test run's: another + // pipeline may still read the run, and its key goes with the run's end (H-A-500 addendum (1), H-A-506 corrected). for _, st := range p.Steps { - unmarkAsk(h.Clock, st.Ask, h.logf) + if sharedRun(st) == "" { + unmarkAsk(h.Clock, st.Ask, h.logf) + } } if h.RegistrationWaits != nil { h.RegistrationWaits() diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/steps_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/steps_test.go index 61dd483c5..2925bd337 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/steps_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/steps_test.go @@ -213,6 +213,34 @@ func TestStepEndedEndsThePipeline(t *testing.T) { t.Errorf("after the second decline: the step %+v, %d puts; want could not run, %q", lint, len(put), want) } }) + // H-A-506 addendum, corrected: a declined test-run step asked again keeps one ask key, its new ask's; the earlier + // ask's key is deleted as it is asked again, not at the run's end. + t.Run("declined test run", func(t *testing.T) { + h, store, _, _, _ := fixture() + h.Asker = nil + clock := &clockMem{runs: testRunsMem{}, bound: map[string]time.Duration{}} + h.Clock = clock + e := store[pkey] + e.p.Steps[0].Shared = []seat.Shared{{Run: "main.5.lint.d", Ask: "a1"}} + store[pkey] = e + _ = clock.MarkAsk("a1", AskMark{Pipeline: pkey, Module: "app", Step: "lint", Run: "main.5.lint.d"}) + h.NeedNodes = func([]string) ([]string, bool) { return []string{"n1", "n2"}, true } + h.AskDeclined = func(_ seat.Pipeline, s seat.StepResult, _ time.Time) (*Asked, error) { + return &Asked{Seat: s.Seat, ID: s.Ask + "x", Ask: nodebuildgo.StepAsk{ID: s.Ask + "x"}}, nil + } + h.PutAgain = func(string, Asked) error { return nil } + ev := ended("a1", "lint", nodebuildgo.StepEndedOutcomeDeclined) + ev.Node, ev.Needs, ev.Lacks, ev.Said = "n1", []string{"node-build-node"}, []string{"node-build-node"}, "this node lacks node-build-node" + if _, err := h.OnStepEnded(goSeat, goSeat.Prefix+"n1", ev); err != nil { + t.Fatal(err) + } + if lint := store[pkey].p.Steps[0]; lint.Ask != "a1x" { + t.Fatalf("the declined test-run step = %+v, want it asked again as a1x", lint) + } + if _, ok, _ := clock.AskOf("a1"); ok { + t.Error("the earlier ask's key of a declined test-run step outlives its ask") + } + }) } // The approval step is asked last, only when every other required step passed, and ended by its warrant (§26, §37). diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/supersede.go b/modules/mesh-delivery-pipeline/internal/pipeline/supersede.go index 03c4de5d3..284b478c8 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/supersede.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/supersede.go @@ -37,7 +37,9 @@ func (h *Hearer) Taken(ask, node string, at time.Time) (*time.Time, error) { return nil, nil } i := stepOfAsk(p, ask) - if i >= 0 && !open(p.Steps[i]) { + // A late ask-taken clears the finding only while the pipeline runs; after its end the finding stands (H-A-506 second + // addendum). + if i >= 0 && !open(p.Steps[i]) && p.Outcome == seat.PipelineOutcomeRunning { h.Asks.answeredLate(p.Steps[i], h.logf) } if i < 0 || !open(p.Steps[i]) { diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/testruns_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/testruns_test.go index 21a4f7bf0..008384478 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/testruns_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/testruns_test.go @@ -380,6 +380,19 @@ func TestATestRunsEndMovesEveryReaderAndIsCountedOnce(t *testing.T) { if r, _, _ := f.runs.Get(lint.Shared[0].Run); r.Ended != nil || len(r.Readers) != 2 || slices.Contains(f.drops, "node-build-go "+lint.Ask) || len(f.drops) == 0 { t.Fatalf("after a left the lint run = %+v, drops %v; want it running for b's two readers, its ask kept, a's own asks dropped", r, f.drops) } + // a's end keeps the run's ask key, which b still reads: b's holder's progress re-arms the run's clock (H-A-500 + // addendum (1), H-A-506 corrected). + run := lint.Shared[0].Run + if m, ok, _ := f.clock.AskOf(lint.Ask); !ok || m.Run != run { + t.Fatalf("after a's end the lint run's ask key = %+v, %v; want it kept for b", m, ok) + } + if err := f.h.RunTaken(lint.Ask, "ace"); err != nil { + t.Fatal(err) + } + delete(f.clock.bound, BoundPrefix+run) + if err := f.h.RunProgress(lint.Ask); err != nil || f.clock.bound[BoundPrefix+run] == 0 { + t.Fatalf("b's progress after a's end re-armed %v (%v), want the run's clock armed", f.clock.bound, err) + } n := len(f.drops) if _, err := v.Cancel("operator", seat.CancelInput{Pipeline: b.Pipeline, Why: "not needed"}); err != nil { t.Fatal(err)