From 05dcdf4bf55d391bb5e6729d8695a5037a823e35 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:17:53 +0100 Subject: [PATCH] W3 seed-reads-pages: the watchman's seed reads the runner's stands page by page, a failed page seeds nothing Builds: design 47 H2 H-A-709 (2), H-A-717 (DMC-20); row W3 --- .../integration_test.go | 40 ++++++++++++++++++- .../cmd/mesh-delivery-watchman/main.go | 30 +++++++++----- 2 files changed, 60 insertions(+), 10 deletions(-) diff --git a/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/integration_test.go b/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/integration_test.go index 038160818..7235f3721 100644 --- a/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/integration_test.go +++ b/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/integration_test.go @@ -3,8 +3,10 @@ package main import ( + "bytes" "context" "encoding/json" + "errors" "fmt" "io" "os" @@ -364,6 +366,26 @@ func TestWatchmanWhole(t *testing.T) { // 1135/AC8 return watch.FindingKey(watch.ScopeDelivery, watch.StepFindingID(seededPipeline+"/"+step+"/"), watch.KindPipelineStands) } until("the seeded composition step with no progress", func() bool { return finding(seeded("composition")) }) + // H-A-709 (2): the step of the stands' second page is seeded as the first page's is. + until("the seeded step of the second page", func() bool { + return finding(watch.FindingKey(watch.ScopeDelivery, watch.StepFindingID(seededPipeline+"/unit/web:program"), watch.KindPipelineStands)) + }) + // A page that fails seeds nothing and is said: the first page answers, the second does not. + { + out := &findingsOut{findings: map[string]bool{}} + w2 := watch.New(watchmanModule, out, time.Now) + var said []string + seedSteps(w2, func(key string, body any) (json.RawMessage, error) { + if in, ok := body.(meshpipelinerunner.StandsInput); ok && in.Next != "" { + return nil, errors.New("no responders") + } + raw, _ := json.Marshal(firstPage) + return raw, nil + }, func(f string, a ...any) { said = append(said, fmt.Sprintf(f, a...)) }) + if len(said) != 1 || !strings.Contains(said[0], "no step is seeded") || strings.Contains(said[0], "open steps the runner holds") { + t.Errorf("a failed second page: said %v; want one line saying no step is seeded", said) + } + } if finding(seeded("approval")) { t.Error("a step waiting on a person raised pipeline-stands") } @@ -695,6 +717,9 @@ const ( testWantsBucket = testAssigner + "_" + meshwants.StateWants ) +// firstPage is the first page of the stand-in runner's stands, which names the next. +var firstPage meshpipelinerunner.StandsAnswer + // seededPipeline is the pipeline the stand-in runner's stands names. const seededPipeline = "main.5.web" @@ -715,7 +740,20 @@ func serveCatalogHalf(t *testing.T, nc *nats.Conn) { stands := meshpipelinerunner.StandsAnswer{Stands: []meshpipelinerunner.Wait{ {Pipeline: seededPipeline, Step: "composition", Ask: "seeded-ask", Module: "web", Branch: "main", Since: time.Now().UTC(), V: 1}, {Pipeline: seededPipeline, Step: "approval", On: meshpipelinerunner.WaitOnPerson, Module: "web", Branch: "main", Since: time.Now().UTC(), V: 1}}} - for subject, handle := range map[string]nats.MsgHandler{"mesh.seat.mesh-pipeline-runner.call.stands": respond(stands), + // H-A-709 (2): the stands answer in two pages: the first names `next`, the second, asked with it, holds one more open step. + second := meshpipelinerunner.StandsAnswer{Stands: []meshpipelinerunner.Wait{ + {Pipeline: seededPipeline, Step: "unit", Artifact: "web:program", Ask: "seeded-ask-2", Module: "web", Branch: "main", Since: time.Now().UTC(), V: 1}}} + firstPage = stands + firstPage.Next = "page-2" + pages := func(m *nats.Msg) { + answer := firstPage + if bytes.Contains(m.Data, []byte(`"next":"page-2"`)) { + answer = second + } + raw, _ := json.Marshal(map[string]any{"result": answer, "node": "n0"}) + _ = m.Respond(raw) + } + for subject, handle := range map[string]nats.MsgHandler{"mesh.seat.mesh-pipeline-runner.call.stands": pages, "mesh.seat.mesh-catalog.call.revision": respond(revision), "mesh.seat.mesh-catalog.call.registrations": respond(registrations), "mesh.seat.mesh-delivery.call.source": respond(map[string]any{"branches": []string{"release"}})} { for _, s := range []string{subject, subject + ".>"} { diff --git a/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/main.go b/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/main.go index 29d258291..be8cc2fd5 100644 --- a/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/main.go +++ b/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/main.go @@ -542,19 +542,31 @@ func seedTakeIn(w *watch.Watchman, call func(key string, body any) (json.RawMess // standsVerb is the runner's seat verb that answers every step started and not ended (design 47 G §731, A-469p). const standsVerb = "seat:" + meshpipelinerunner.Seat + "." + meshpipelinerunner.VerbStands -// seedSteps asks the runner which steps stand now and keeps each, its clock begun at this start (Watchman.SeedSteps, design 47 G -// §731, §732). A runner that does not answer is said: the steps are then known from the events heard after. +// seedSteps asks the runner which steps stand now, page by page through `next`, and keeps each, its clock begun at this start +// (Watchman.SeedSteps, design 47 G §731, §732; H2 H-A-709 (2)). A page that fails seeds nothing and is said: the steps are then +// known from the events heard after. A runner built before reads one page, whose answer names no `next`. func seedSteps(w *watch.Watchman, call func(key string, body any) (json.RawMessage, error), logf func(string, ...any)) { - raw, err := call(standsVerb, map[string]any{}) - if err == nil { - var a meshpipelinerunner.StandsAnswer - if err = json.Unmarshal(raw, &a); err == nil { - w.SeedSteps(a.Stands) - logf("steps: %d open steps the runner holds are watched from this start (%s)", len(a.Stands), standsVerb) + var stands []meshpipelinerunner.Wait + next, pages := "", 0 + for { + raw, err := call(standsVerb, meshpipelinerunner.StandsInput{Next: next}) + if err != nil { + logf("steps: %s cannot be asked (%v) at its page %d, so no step is seeded and a step open before this start is timed only once an event of it is heard", standsVerb, err, pages+1) return } + var a meshpipelinerunner.StandsAnswer + if err := json.Unmarshal(raw, &a); err != nil { + logf("steps: %s answered what does not read (%v) at its page %d, so no step is seeded and a step open before this start is timed only once an event of it is heard", standsVerb, err, pages+1) + return + } + stands, pages = append(stands, a.Stands...), pages+1 + if a.Next == "" || a.Next == next { + break + } + next = a.Next } - logf("steps: %s cannot be asked (%v), so a step open before this start is timed only once an event of it is heard", standsVerb, err) + w.SeedSteps(stands) + logf("steps: %d open steps the runner holds are watched from this start, read in %d pages (%s)", len(stands), pages, standsVerb) } // takeInHeard hands one take-in event of the indexer to the watchman, by its name relative to the indexer, and acknowledges it;