From e137df7189d69f3fd4e9640d33eb6ea20e4d7438 Mon Sep 17 00:00:00 2001 From: jochen Date: Sat, 21 Nov 2026 20:43:02 +0100 Subject: [PATCH] H-A-311 (2): a step-progress or step-end heard late still places what its end unlocks A late progress or end moved nothing, so movers waiting on what the step's end gave stayed unplaced: main.137 placed nothing after its lint's late progress at 20:17:55. Builds: design 47 H H-A-311 (2), H-A-286, H-A-288 --- .../internal/pipeline/order_test.go | 17 ++++++++ .../internal/pipeline/runends.go | 39 ++++++++++++++++--- .../internal/pipeline/steps.go | 2 + .../internal/pipeline/testruns_test.go | 7 ++++ 4 files changed, 59 insertions(+), 6 deletions(-) diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/order_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/order_test.go index 95f5536a..4d4aeff0 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/order_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/order_test.go @@ -94,6 +94,23 @@ func TestAMoversBuildWaitsForItsDependenciesInThePipeline(t *testing.T) { return e } before := mem["main.7"] + // H-A-311 (2): the build's end written while its placing was cut (heard by a hearer that places nothing): the same end + // heard again, late, moves nothing of the build and still places tool, which that end unlocked. + cut := *h + cut.Release = nil + if _, err := cut.OnStepEnded(bs, bs.Prefix+"n1", end("passed")); err != nil { + t.Fatal(err) + } + if p, _, _ = mem.Get("main.7"); placed(p, "tool") { + t.Fatalf("the cut placing placed tool: %+v", stepsOf(p, "tool")) + } + if _, err := h.OnStepEnded(bs, bs.Prefix+"n1", end("passed")); err != nil { + t.Fatal(err) + } + if p, _, _ = mem.Get("main.7"); !placed(p, "tool") || stepsOf(p, "tool")[0].Outcome != seat.StepResultOutcomeRunning { + t.Errorf("after builder's build passed, heard late, tool's steps = %+v, want placed and asked", stepsOf(p, "tool")) + } + mem["main.7"] = before if _, err := h.OnStepEnded(bs, bs.Prefix+"n1", end("passed")); err != nil { t.Fatal(err) } diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/runends.go b/modules/mesh-delivery-pipeline/internal/pipeline/runends.go index c54faba5..ac1ad1dd 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/runends.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/runends.go @@ -75,12 +75,18 @@ func IsRunBound(key string) bool { // runOfAsk is the test run asked under ask: the run its asking step names in Shared, read from the state pipelines. func (h *Hearer) runOfAsk(ask string) (string, bool) { + run, _, ok := h.runAndPipelineOfAsk(ask) + return run, ok +} + +// runAndPipelineOfAsk is runOfAsk with the key of the pipeline whose step asked it. +func (h *Hearer) runAndPipelineOfAsk(ask string) (string, string, bool) { if h.TestRuns == nil || ask == "" { - return "", false + return "", "", false } pkeys, err := allKeys(h.Store) if err != nil { - return "", false + return "", "", false } for _, key := range pkeys { p, _, err := h.Store.Get(key) @@ -89,10 +95,26 @@ func (h *Hearer) runOfAsk(ask string) (string, bool) { } if i := stepOfAsk(p, ask); i >= 0 { run := sharedRun(p.Steps[i]) - return run, run != "" + return run, key, run != "" + } + } + return "", "", false +} + +// releaseLate places what the end of a step heard late unlocks (H-A-311 (2)): a step-progress or step-end that arrives +// after its ask ended moves nothing of the step itself, yet the movers waiting on what that end gave (the dependents' +// builds) are placed, in each pipeline named, as the end heard in time would have placed them (Release). +func (h *Hearer) releaseLate(pipelines ...string) { + if h.Release == nil { + return + } + seen := map[string]bool{} + for _, key := range pipelines { + if key != "" && !seen[key] { + seen[key] = true + h.Release(key) } } - return "", false } // RunTaken takes the ask-taken of a test run's ask (§725, A-470): the node that took it is kept on the run, its untaken @@ -158,13 +180,18 @@ func armBound(clock RunClock, runs TestRuns, key, run, ask string, ttl time.Dura // RunProgress takes a build seat's step-progress of a test run's ask (§725, A-466p): its clock begins again, so a run that // keeps saying its progress is never ended by it. An ask of no running, taken test run takes nothing. func (h *Hearer) RunProgress(ask string) error { - run, ok := h.runOfAsk(ask) + run, key, ok := h.runAndPipelineOfAsk(ask) if !ok { return nil } r, _, err := h.TestRuns.Get(run) if errors.Is(err, ErrNoRun) || (err == nil && (r.Ask != ask || r.Ended != nil)) { - h.logf("the step-progress of ask %s is late: the test run %s names ask %q (ended %v), so it moves nothing (A-470n)", ask, run, r.Ask, r.Ended != nil) + h.logf("the step-progress of ask %s is late: the test run %s names ask %q (ended %v), so it moves nothing of its own; what its end unlocks is placed (A-470n, H-A-311)", ask, run, r.Ask, r.Ended != nil) + late := []string{key} + for _, reader := range r.Readers { + late = append(late, reader.Pipeline) + } + h.releaseLate(late...) return nil } if err != nil { diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/steps.go b/modules/mesh-delivery-pipeline/internal/pipeline/steps.go index c492ce6f..3a629f1b 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/steps.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/steps.go @@ -273,6 +273,8 @@ func (h *Hearer) OnStepEndedPinned(bs StepSeat, subject string, ev StepEnded, sh ev.Module, ev.Commit, ev.Fingerprint, p.Steps[i].Step, p.Steps[i].Module, m.Commit, m.Fingerprint) case !open(p.Steps[i]): h.Asks.answeredLate(p.Steps[i], h.logf) + // An end heard late moves nothing of its step, and still places what that step's end unlocks (H-A-311 (2)). + defer h.releaseLate(ev.Pipeline) if run := sharedRun(p.Steps[i]); run != "" && h.TestRuns != nil { if r, _, err := h.TestRuns.Get(run); err == nil && r.Ended == nil && r.Ask == ev.ID { // The asking step's end was written and its run's was not (a write failed): the run ends now, heard again. diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/testruns_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/testruns_test.go index ba0712e4..07138de5 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/testruns_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/testruns_test.go @@ -2,6 +2,7 @@ package pipeline import ( "fmt" + "slices" "strings" "testing" "time" @@ -599,6 +600,8 @@ func TestNoWriteOfATestRunActsOnAReadBeforeItsLatestChange(t *testing.T) { run := unit.Shared[0].Run asked(f, run) delete(f.clock.bound, UntakenPrefix+run) + var released []string + f.h.Release = func(key string) { released = append(released, key) } _ = f.h.RunTaken(unit.Ask, "ace") _ = f.h.RunProgress(unit.Ask) late := 0 @@ -610,6 +613,10 @@ func TestNoWriteOfATestRunActsOnAReadBeforeItsLatestChange(t *testing.T) { if _, ok := f.clock.bound[BoundPrefix+run]; ok || late != 2 { t.Errorf("bounds %v, journal %q; want no clock and both late signals journaled", f.clock.bound, f.logged) } + // H-A-311 (2): the late step-progress still places what its step's end unlocks, in the pipeline that asked it. + if !slices.Contains(released, p.Pipeline) { + t.Errorf("the late step-progress placed in %v, want %s's waiting movers placed", released, p.Pipeline) + } }) // A run's end is written as its step-ended is heard, before the finding the step says (A-470o). t.Run("the run ends before the step's finding is written", func(t *testing.T) {