From 81387d0f3bde5bbf43162098f0f0608ea4601dbe Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 10:56:14 +0100 Subject: [PATCH 1/5] Pipelines page: one pipeline by tier and stage, and its delivery on each node The operator read every step of main.417 as passed and took it for delivered while it had failed on one step and no want was written: the page listed a pipeline's steps flat, with no tier, no stage and no delivery. One pipeline now shows a header (outcome, first failure's why, how many movers run their build on every node they are placed on), then a block per tier with a row per mover, a cell per stage (the worst outcome over its artifacts, waited, ran and why on hover) and a cell per node its module is placed on (no want written, wanted, applying, running the pipeline's build, held with why), in the web page and the terminal view. The page reloads on the runner's events and on the wants', haves' and assignments' changes the view already hears. Builds: design 47 H2 H-A-531, H-A-531 addendum (hq 7dc6592b, f870d24b) --- .../cmd/mesh-delivery-cli/main.go | 5 +- .../cmd/mesh-delivery-cli/main_test.go | 6 +- .../mesh-delivery-view/integration_test.go | 2 +- .../internal/view/pipelines.go | 23 +- .../internal/view/pipelines_test.go | 125 +++++- .../internal/view/pipelinespage.go | 93 ++++- .../internal/view/pipelineview.go | 359 ++++++++++++++++++ .../mesh-delivery-view/internal/view/serve.go | 19 +- .../mesh-delivery-view/internal/view/view.go | 4 + 9 files changed, 598 insertions(+), 38 deletions(-) create mode 100644 modules/mesh-delivery-view/internal/view/pipelineview.go diff --git a/modules/mesh-delivery-view/cmd/mesh-delivery-cli/main.go b/modules/mesh-delivery-view/cmd/mesh-delivery-cli/main.go index 51404efa5..c5db6c24b 100644 --- a/modules/mesh-delivery-view/cmd/mesh-delivery-cli/main.go +++ b/modules/mesh-delivery-view/cmd/mesh-delivery-cli/main.go @@ -17,7 +17,6 @@ import ( "text/tabwriter" "time" - seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner" "mesh-delivery-view/internal/view" ) @@ -148,8 +147,8 @@ func pipelines(socket string, args []string, next string, limit int, follow, asJ return 0 } -// seatShow is the seat's answer of show, as the view hands it on. -type seatShow = seat.ShowAnswer +// seatShow is the view's answer of one pipeline: show's, with the pipeline's page by tier and stage naming no mover. +type seatShow = view.PipelineAnswer // holds prints every hold: module, fingerprint, node, since, answer, words. func holds(socket string, asJSON bool, out, errOut io.Writer) int { diff --git a/modules/mesh-delivery-view/cmd/mesh-delivery-cli/main_test.go b/modules/mesh-delivery-view/cmd/mesh-delivery-cli/main_test.go index 4d4f61386..d1039d53c 100644 --- a/modules/mesh-delivery-view/cmd/mesh-delivery-cli/main_test.go +++ b/modules/mesh-delivery-view/cmd/mesh-delivery-cli/main_test.go @@ -306,7 +306,8 @@ func rawAsk(t *testing.T, a oc.Ask) json.RawMessage { const testView = "acme-view" -// Design 47 H2 H-A-467: the terminal view's pipelines page: a branch's newest pipelines, and one pipeline's mover rows. +// Design 47 H2 H-A-467, H-A-531: the terminal view's pipelines page: a branch's newest pipelines, and one pipeline by tier and +// stage. func TestThePipelinesCommands(t *testing.T) { m := view.New(testView) call := func(key string, body any) (json.RawMessage, error) { @@ -346,7 +347,8 @@ func TestThePipelinesCommands(t *testing.T) { {[]string{"pipelines", "next"}, "next.3 3 2 passed 1 4 0 0 0 0 0 0 0"}, {[]string{"pipelines", "next"}, "next.2"}, // the newest 20 by default {[]string{"-limit", "1", "pipelines", "next"}, "next.3"}, - {[]string{"pipeline", "next.3"}, "alpha src2:aa 0.2.1 passed"}, + {[]string{"pipeline", "next.3"}, "TIER 1 MOVER OUTCOME BUILD LINT UNIT INTEGRATION VALIDATE COMPOSITION CODE REVIEW APPROVAL alpha passed - - - - - - - -"}, + {[]string{"pipeline", "next.3"}, "PIPELINE next.3: passed; 0 of 1 movers run their build on every node they are placed on; 1 is placed on none"}, {[]string{"-json", "pipeline", "next.3"}, `"fingerprint": "src2:aa"`}, } { var out, errOut bytes.Buffer diff --git a/modules/mesh-delivery-view/cmd/mesh-delivery-view/integration_test.go b/modules/mesh-delivery-view/cmd/mesh-delivery-view/integration_test.go index 55532c3a7..722a418ed 100644 --- a/modules/mesh-delivery-view/cmd/mesh-delivery-view/integration_test.go +++ b/modules/mesh-delivery-view/cmd/mesh-delivery-view/integration_test.go @@ -896,7 +896,7 @@ func TestProcessWholeSaysTheSourceRevisionIsDelivered(t *testing.T) { pipelines.set(pseat.PipelineRow{Pipeline: "release.9", Source: rev, Revision: 9, Outcome: "passed", MoverCount: 1}, pseat.PipelineRow{Pipeline: "release.8", Source: rev, Revision: 8, Outcome: "superseded", MoverCount: 1}) var seen [][]string - err = view.AskPipelines(env["MESH_DELIVERY_SOCKET"], catalogBranch, 0, "", "", "", true, func(page view.PipelinesPage, _ *pseat.ShowAnswer) bool { + err = view.AskPipelines(env["MESH_DELIVERY_SOCKET"], catalogBranch, 0, "", "", "", true, func(page view.PipelinesPage, _ *view.PipelineAnswer) bool { var keys []string for _, r := range page.Rows { keys = append(keys, r.Pipeline) diff --git a/modules/mesh-delivery-view/internal/view/pipelines.go b/modules/mesh-delivery-view/internal/view/pipelines.go index 0428d126f..cc1cfe901 100644 --- a/modules/mesh-delivery-view/internal/view/pipelines.go +++ b/modules/mesh-delivery-view/internal/view/pipelines.go @@ -104,6 +104,11 @@ func (p *Pipelines) List(branch string, limit int) ([]seat.PipelineRow, error) { // (design 47 H2 H-A-467 (2)); next is the cursor of a page show answered. func (p *Pipelines) Show(pipeline, mover, next string) (seat.ShowAnswer, error) { raw, err := p.call(PipelinesShowVerb, seat.ShowInput{Pipeline: pipeline, Mover: mover, Next: next}) + return showAnswer(raw, err, pipeline) +} + +// showAnswer reads an answer of show. +func showAnswer(raw json.RawMessage, err error, pipeline string) (seat.ShowAnswer, error) { if err != nil { return seat.ShowAnswer{}, fmt.Errorf("%s of %s: %w", PipelinesShowVerb, pipeline, err) } @@ -211,6 +216,14 @@ func (p *Pipelines) Hear(data []byte) error { return nil } +// deliveryKey is what heard keeps the last change of the delivery under: a want, a have or an assignment the view heard, +// which every pipeline's page shows (design 47 H2 H-A-531). No pipeline's key holds a NUL. +const deliveryKey = "\x00delivery" + +// Delivered tells every pipeline's page that the delivery changed: a want, a have or an assignment the view heard, on the +// events it already hears for "What each node runs" (design 47 H2 H-A-531), never a timer. The lists are not read again. +func (p *Pipelines) Delivered() { p.notify(deliveryKey) } + // owe has Run read the lists again. func (p *Pipelines) owe() { select { @@ -266,7 +279,7 @@ func (p *Pipelines) Version() uint64 { func (p *Pipelines) Changed(ctx context.Context, what string, since uint64) bool { ch := make(chan string, 1) p.mu.Lock() - if p.heard[what] > since { + if p.changedSince(what, since) { p.mu.Unlock() return true } @@ -283,7 +296,7 @@ func (p *Pipelines) Changed(ctx context.Context, what string, since uint64) bool return false case <-ch: // any change: a note dropped while one waited is read from heard, never lost p.mu.Lock() - changed := p.heard[what] > since + changed := p.changedSince(what, since) p.mu.Unlock() if changed { return true @@ -291,3 +304,9 @@ func (p *Pipelines) Changed(ctx context.Context, what string, since uint64) bool } } } + +// changedSince says whether what changed after since: a pipeline's page changes with the delivery too (design 47 H2 +// H-A-531), the lists do not. The caller holds p.mu. +func (p *Pipelines) changedSince(what string, since uint64) bool { + return p.heard[what] > since || (what != "" && p.heard[deliveryKey] > since) +} diff --git a/modules/mesh-delivery-view/internal/view/pipelines_test.go b/modules/mesh-delivery-view/internal/view/pipelines_test.go index eeba6991b..c41077c6b 100644 --- a/modules/mesh-delivery-view/internal/view/pipelines_test.go +++ b/modules/mesh-delivery-view/internal/view/pipelines_test.go @@ -13,6 +13,9 @@ import ( "testing" "time" + "git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient" + "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshwantsclient" seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner" ) @@ -22,6 +25,7 @@ type fakeRunner struct { mu sync.Mutex rows map[string][]seat.PipelineRow // by branch shows map[string]seat.ShowAnswer // by pipeline, or pipeline/mover + steps map[string][]seat.StepResult // by pipeline, every mover's steps, which show filtered by a step answers two a page lists int } @@ -39,6 +43,22 @@ func (f *fakeRunner) call(key string, body any) (json.RawMessage, error) { return json.Marshal(seat.ListAnswer{Rows: rows[:min(int(in.Limit), len(rows))]}) case PipelinesShowVerb: in := body.(seat.ShowInput) + if in.Step != "" { + a := f.shows[in.Pipeline] + var held []seat.StepResult + for _, s := range f.steps[in.Pipeline] { + if s.Step == in.Step { + held = append(held, s) + } + } + from := 0 + fmt.Sscan(in.Next, &from) + a.Pipeline.Steps = held[min(from, len(held)):min(from+2, len(held))] + if a.Next = ""; from+2 < len(held) { + a.Next = fmt.Sprint(from + 2) + } + return json.Marshal(a) + } k := in.Pipeline if in.Mover != "" { k += "/" + in.Mover @@ -58,6 +78,13 @@ func (f *fakeRunner) setRows(branch string, rows ...seat.PipelineRow) { f.rows[branch] = rows } +// The builds of the pipeline's movers, in the new form a want names. +var ( + fpA = "src2:" + strings.Repeat("a", 64) + fpB = "src2:" + strings.Repeat("b", 64) + fpB0 = "src2:" + strings.Repeat("0", 64) +) + // changedWithin is p.Changed bounded, so a change never said fails the test instead of hanging it. func changedWithin(ctx context.Context, p *Pipelines, what string, since uint64) bool { ctx, cancel := context.WithTimeout(ctx, 30*time.Second) @@ -65,20 +92,26 @@ func changedWithin(ctx context.Context, p *Pipelines, what string, since uint64) return p.Changed(ctx, what, since) } -// Design 47 H2 H-A-467: the pipelines page reads the runner's list and show, refreshes on its events, never on a timer, -// and links each delivery to its pipeline by its source revision. +// Design 47 H2 H-A-467, H-A-531: the pipelines page reads the runner's list and show, refreshes on its events and on the wants' +// and haves', never on a timer, shows one pipeline by tier and stage with its nodes, and links each delivery to its pipeline. func TestThePipelinesPage(t *testing.T) { started, ended := t0, t0.Add(3*60e9) taken := t0.Add(160e9) // a build node took the step 2m40s after its ask, and it ran 20s (design 47 H2 H-A-516) runner := &fakeRunner{rows: map[string][]seat.PipelineRow{}, shows: map[string]seat.ShowAnswer{ "main.12": {Pipeline: seat.Pipeline{Pipeline: "main.12", Branch: "main", Source: 9, Revision: 12, Outcome: seat.PipelineOutcomeFailed, - Started: &started, Ended: &ended, Movers: []seat.Mover{{Module: "alpha", Fingerprint: "src2:aa", Version: "0.1.4"}, {Module: "beta", Fingerprint: "src2:bb"}}}, + Started: &started, Ended: &ended, Movers: []seat.Mover{{Module: "alpha", Fingerprint: fpA, Version: "0.1.4", Tier: 1}, + {Module: "beta", Fingerprint: fpB, Tier: 2}, {Module: "gamma", Fingerprint: fpNew, Tier: 2}, {Module: "delta", Fingerprint: fpOld}}}, Movers: []seat.MoverRow{{Module: "alpha", Outcome: seat.MoverRowOutcomePassed}, - {Module: "beta", Outcome: seat.MoverRowOutcomeFailed, Failed: &seat.FailedStep{Step: "unit", Artifact: "beta:program", Outcome: "could not run", Why: "no build node"}}}}, + {Module: "beta", Outcome: seat.MoverRowOutcomeFailed, Failed: &seat.FailedStep{Step: "unit", Artifact: "beta:program", Outcome: "could not run", Why: "no build node"}}, + {Module: "gamma", Outcome: seat.MoverRowOutcomePassed}, {Module: "delta", Outcome: seat.MoverRowOutcomePassed}}}, "main.12/beta": {Pipeline: seat.Pipeline{Pipeline: "main.12", Branch: "main", Source: 9, Revision: 12, Outcome: seat.PipelineOutcomeFailed, Steps: []seat.StepResult{{Module: "beta", Step: "unit", Artifact: "beta:program", Seat: "node-build-go", Node: "n1", Outcome: "could not run", AskedAt: &started, Started: &started, TakenAt: &taken, Ended: &ended, Why: "no build node"}, {Module: "beta", Step: "lint", Artifact: "beta:program", Seat: "node-build-go", Outcome: "could not run", AskedAt: &started, Ended: &ended}}}}, - }} + }, steps: map[string][]seat.StepResult{"main.12": { + {Module: "alpha", Step: "build", Artifact: "alpha:program", Outcome: "passed"}, {Module: "alpha", Step: "build", Artifact: "alpha:image", Outcome: "carried"}, + {Module: "alpha", Step: "build", Artifact: "alpha:tool", Outcome: "passed"}, {Module: "alpha", Step: "review", Outcome: "passed"}, + {Module: "beta", Step: "unit", Artifact: "beta:program", Node: "n1", Outcome: "could not run", AskedAt: &started, TakenAt: &taken, Ended: &ended, Why: "no build node"}, + {Module: "beta", Step: "unit", Artifact: "beta:tool", Outcome: "passed"}, {Module: "beta", Step: "approval", Outcome: "waiting", Why: "a person"}}}} runner.setRows("main", seat.PipelineRow{Pipeline: "main.12", Source: 9, Revision: 12, Started: &started, Outcome: seat.PipelineOutcomeFailed, MoverCount: 2, Steps: map[string]int64{"passed": 5, "failed": 1, "could not run": 1, "waiting for a build node": 2}}) runner.setRows(testBranch, seat.PipelineRow{Pipeline: "release.8", Source: 4, Revision: 8, Outcome: seat.PipelineOutcomePassed}, @@ -86,6 +119,15 @@ func TestThePipelinesPage(t *testing.T) { p := NewPipelines(runner.call, func() []string { return []string{testBranch} }, 0, nil) m := New(testView) fill(m, sourceE(t, 4)) + // alpha runs its build on both its nodes; beta is wanted on n1, applying on n2 and has no want on n3; gamma's build failed + // its health on n1 and the assigner holds it; delta is placed on no node (design 47 H2 H-A-531 and its addendum). + applying, _ := nodeengineclient.EncodeHave(nodeengine.HaveByNodeModuleValue{Fp: fpB0, Phase: nodeengineclient.PhaseApplying, Health: nodeengineclient.HealthWaits}) + sick, _ := nodeengineclient.EncodeHave(nodeengine.HaveByNodeModuleValue{Fp: fpNew, Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthFailed, Detail: "connection refused"}) + delivery := []Entry{place(t, "n1", "alpha", "beta", "gamma"), place(t, "n2", "alpha", "beta", "gamma"), place(t, "n3", "beta"), + haveFP(t, "n1", "alpha", fpA, nodeengineclient.HealthOK), haveFP(t, "n2", "alpha", fpA, nodeengineclient.HealthOK), + wantE(t, "n1", "beta", meshwantsclient.Want{Fp: fpB}), wantE(t, "n2", "beta", meshwantsclient.Want{Fp: fpB}), haveE(t, "n2", "beta", applying, t0), + wantE(t, "n1", "gamma", meshwantsclient.Want{Fp: fpNew}), haveE(t, "n1", "gamma", sick, t0), heldE(t, "gamma", fpNew, "n1", "health failed on n1")} + fill(m, delivery...) m.SetPipelines(p) ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -117,9 +159,29 @@ func TestThePipelinesPage(t *testing.T) { "main.12 12 9 2026-10-18", "failed 2 5 1 1 0 0 2 0 0"}}, {"the web list links each pipeline and reloads on the view's changes, never a timer", func() string { return web("/pipelines") }, []string{ `main.12`, `new EventSource("/pipelines/changes?since=`}}, - {"a pipeline's page is its mover rows, each linking its steps", func() string { return web("/pipelines/show?pipeline=main.12") }, []string{ - `alphasrc2:aa0.1.4passed`, - "unit beta:program: could not run: no build node", `changes?pipeline=main.12\u0026since=`}}, + {"a pipeline's page is its header, then a block per tier, a row per mover with a cell per stage and per node", func() string { + return web("/pipelines/show?pipeline=main.12") + }, []string{ + "failed; first failure: unit beta:program: could not run: no build node; 1 of 4 movers run their build on every node they are placed on; 1 is placed on none", + "

TIER 1

", "MOVEROUTCOMEBUILDLINTUNITINTEGRATIONVALIDATECOMPOSITIONCODE REVIEWAPPROVALn1n2n3", + `alphapassedpassed 2/3", `running the pipeline's buildrunning the pipeline's build`, + `could not run 1/2", + `waiting`, + `wantedapplyingno want written`, + `held: connection refusedheld: health failed on n1`, + "

TIER 2

", `changes?pipeline=main.12\u0026since=`}}, + {"a stage's worst outcome follows the runner's step words, an unknown one counting as failed", func() string { + at := func(o ...string) string { + var ss []seat.StepResult + for _, x := range o { + ss = append(ss, seat.StepResult{Step: "unit", Outcome: x}) + } + return stageCell(ss, t0).Text() + } + return strings.Join([]string{at("passed", "running", "waiting for a build node", "not asked", "running"), at("cancelled", "could not run"), + at("frobbed", "passed"), at("running", "running"), at("nothing to run"), at()}, "|") + }, []string{"not asked 1/5|could not run 1/2|frobbed 1/2|running 2/2|nothing to run|"}}, {"a mover's page is its steps, each asked, taken and ended, how long it waited and how long it ran", func() string { return web("/pipelines/show?pipeline=main.12&mover=beta") }, []string{"ASKEDTAKENENDEDWAITEDRAN", @@ -130,7 +192,7 @@ func TestThePipelinesPage(t *testing.T) { if err != nil { return err.Error() } - return text(func(b *bytes.Buffer) { PipelineTable(b, a, "beta") }) + return text(func(b *bytes.Buffer) { PipelineTable(b, PipelineAnswer{ShowAnswer: a}, "beta") }) }, []string{"STEPS OF beta", "OUTCOME ASKED TAKEN ENDED WAITED RAN WHY", "could not run " + since(started) + " " + since(taken) + " " + since(ended) + " 2m40s 20s no build node"}}, {"a step still waiting counts its wait to now, one running its run", func() string { now := t0.Add(400e9) @@ -139,13 +201,21 @@ func TestThePipelinesPage(t *testing.T) { w3, r3 := waitedRan(seat.StepResult{Ended: &ended}, now) return fmt.Sprintf("waiting %s/%s; running %s/%s; never asked %q/%q", w1, r1, w2, r2, w3, r3) }, []string{`waiting 6m40s/; running 2m40s/4m0s; never asked ""/""`}}, - {"the terminal view's pipeline names each mover's fingerprint, version and failed step", func() string { - a, err := p.Show("main.12", "", "") - if err != nil { + {"the terminal view's pipeline is its header and a block per tier, as the page's", func() string { + path, sm := served(t) + fill(sm, delivery...) + sm.SetPipelines(p) + var got *PipelineAnswer + if err := AskPipelines(path, "", 0, "main.12", "", "", false, func(_ PipelinesPage, a *PipelineAnswer) bool { got = a; return true }); err != nil { return err.Error() } - return text(func(b *bytes.Buffer) { PipelineTable(b, a, "") }) - }, []string{"PIPELINE main.12: failed, source 9, revision 12", "alpha src2:aa 0.1.4 passed", "beta src2:bb failed unit beta:program: could not run: no build node"}}, + return text(func(b *bytes.Buffer) { PipelineTable(b, *got, "") }) + }, []string{"PIPELINE main.12: failed; first failure: unit beta:program: could not run: no build node; 1 of 4 movers", + "TIER 1 MOVER OUTCOME BUILD LINT UNIT INTEGRATION VALIDATE COMPOSITION CODE REVIEW APPROVAL N1 N2 N3", + "alpha passed passed 2/3 - - - - - passed - running the pipeline's build running the pipeline's build -", + "delta passed - - - - - - - - - - -", "TIER 2", + "beta failed - - could not run 1/2 - - - - waiting wanted applying no want written", + "gamma passed - - - - - - - - held: connection refused held: health failed on n1 -"}}, {"the web list asks the newest limit of a branch", func() string { return web("/pipelines?branch=" + testBranch + "&limit=1") }, []string{ "release.8", `name="limit" value="1"`}}, {"the web list is the newest 20 by default", func() string { return web("/pipelines?branch=" + testBranch) }, []string{ @@ -224,12 +294,29 @@ func TestThePipelinesPage(t *testing.T) { } }) + t.Run("a want or a have heard tells every pipeline's page, never the lists", func(t *testing.T) { + v := p.Version() + fill(m, haveFP(t, "n2", "gamma", fpNew, nodeengineclient.HealthOK)) + if !changedWithin(ctx, p, "main.12", v) { + t.Fatal("the page of main.12 is not told of the have") + } + p.mu.Lock() + lists := p.changedSince("", v) + p.mu.Unlock() + if lists { + t.Error("a have tells the lists") + } + if got := web("/pipelines/show?pipeline=main.12"); !strings.Contains(got, `held: connection refusedrunning the pipeline's build`) { + t.Errorf("the page does not show gamma running on n2: %s", got) + } + }) + t.Run("the terminal view follows the list on the socket, again at each event", func(t *testing.T) { path, sm := served(t) sm.SetPipelines(p) var seen []string heard := false - err := AskPipelines(path, "", 0, "", "", "", true, func(page PipelinesPage, _ *seat.ShowAnswer) bool { + err := AskPipelines(path, "", 0, "", "", "", true, func(page PipelinesPage, _ *PipelineAnswer) bool { seen = append(seen, page.Rows[0].Pipeline) if !heard { heard = true @@ -244,14 +331,14 @@ func TestThePipelinesPage(t *testing.T) { if err != nil || seen[len(seen)-1] != "main.14" { t.Fatalf("followed %v, %v", seen, err) } - var show *seat.ShowAnswer - if err := AskPipelines(path, "", 0, "main.12", "beta", "", false, func(_ PipelinesPage, a *seat.ShowAnswer) bool { show = a; return true }); err != nil { + var show *PipelineAnswer + if err := AskPipelines(path, "", 0, "main.12", "beta", "", false, func(_ PipelinesPage, a *PipelineAnswer) bool { show = a; return true }); err != nil { t.Fatal(err) } if len(show.Pipeline.Steps) != 2 || show.Pipeline.Steps[0].Node != "n1" { t.Fatalf("the mover's steps on the socket = %+v", show) } - if err := AskPipelines(path, "", 0, "main.99", "", "", false, func(PipelinesPage, *seat.ShowAnswer) bool { return true }); err == nil || !strings.Contains(err.Error(), "no pipeline main.99") { + if err := AskPipelines(path, "", 0, "main.99", "", "", false, func(PipelinesPage, *PipelineAnswer) bool { return true }); err == nil || !strings.Contains(err.Error(), "no pipeline main.99") { t.Fatalf("a pipeline the runner does not hold = %v", err) } }) @@ -293,7 +380,7 @@ func TestThePipelinesPage(t *testing.T) { path, sm := served(t) sm.SetPipelines(up) var seen []PipelinesPage - err := AskPipelines(path, "", 0, "", "", "", true, func(page PipelinesPage, _ *seat.ShowAnswer) bool { + err := AskPipelines(path, "", 0, "", "", "", true, func(page PipelinesPage, _ *PipelineAnswer) bool { seen = append(seen, page) if len(seen) == 1 { mu.Lock() diff --git a/modules/mesh-delivery-view/internal/view/pipelinespage.go b/modules/mesh-delivery-view/internal/view/pipelinespage.go index 1b90e4a16..54297b82d 100644 --- a/modules/mesh-delivery-view/internal/view/pipelinespage.go +++ b/modules/mesh-delivery-view/internal/view/pipelinespage.go @@ -153,25 +153,61 @@ func PipelinesTable(w io.Writer, p PipelinesPage) { table(w, PipelinesHead, rows) } -// PipelineTable prints one pipeline as show answered it for mover: its mover rows, or that mover's steps. -func PipelineTable(w io.Writer, a seat.ShowAnswer, mover string) { +// PipelineAnswer is one pipeline as the socket answers it: show's answer, and naming no mover the pipeline's page by tier +// and stage with its nodes (design 47 H2 H-A-531). +type PipelineAnswer struct { + seat.ShowAnswer + View *PipelineView `json:"view,omitempty"` +} + +// PipelineTable prints one pipeline for mover: naming none, its page by tier and stage with its nodes (design 47 H2 +// H-A-531); naming one, that mover's steps. +func PipelineTable(w io.Writer, a PipelineAnswer, mover string) { p := a.Pipeline + if mover == "" && a.View != nil { + ViewTable(w, *a.View) + return + } fmt.Fprintf(w, "PIPELINE %s: %s, source %d, revision %d, started %s, ended %s\n", p.Pipeline, p.Outcome, p.Source, p.Revision, timeOf(p.Started), timeOf(p.Ended)) if p.Why != "" { fmt.Fprintf(w, "why: %s\n", p.Why) } if mover == "" { - table(w, MoversHead, MoverRowsText(a)) + table(w, MoversHead, MoverRowsText(a.ShowAnswer)) } else { fmt.Fprintf(w, "STEPS OF %s\n", mover) - table(w, StepsHead, StepsText(a)) + table(w, StepsHead, StepsText(a.ShowAnswer)) } if a.Next != "" { fmt.Fprintf(w, "more: -next %s\n", a.Next) } } -const pipelinesStyle = `` +// ViewTable prints one pipeline's page: its header, then one block per tier, in tier order (design 47 H2 H-A-531). +func ViewTable(w io.Writer, v PipelineView) { + fmt.Fprintf(w, "PIPELINE %s: %s\n", v.Pipeline, v.Header()) + for _, u := range v.Unread { + fmt.Fprintf(w, "unreadable: %s\n", u) + } + for _, t := range v.Tiers { + fmt.Fprintf(w, "TIER %d\n", t.Tier) + var rows [][]string + for _, r := range t.Movers { + cells := r.Cells() + for i, c := range cells { + if c == "" { + cells[i] = "-" + } + } + rows = append(rows, cells) + } + table(w, upper(v.TierHead()), rows) + } +} + +const pipelinesStyle = `` // changesScript reloads the page when the view says its part changed, on the runner's events (design 47 H2 H-A-467): never // on a timer. @@ -185,6 +221,38 @@ var pipelinesPage = template.Must(template.New("pl").Parse(`{{index .Cells 0}}{{range slice .Cells 1}}{{.}}{{end}}{{end}}{{end}} ` + changesScript + ``)) +// pipelineViewPage is one pipeline's page (design 47 H2 H-A-531): its header, then a block per tier, a row per mover, a +// cell per stage (each artifact's waited, ran and why on hover) and a cell per node its module is placed on. +var pipelineViewPage = template.Must(template.New("pv").Funcs(template.FuncMap{"word": cellWord, "moverLink": PipelineLink}).Parse(` +Pipeline {{.Pipeline}}` + pipelinesStyle + ` +

What each node runs · Pipelines of {{.Branch}}

+

PIPELINE {{.Pipeline}}

+{{if .Error}}

unreadable: {{.Error}}

{{else}}{{with .View}}

{{.Header}}

+{{range .Unread}}

unreadable: {{.}}

{{end}}{{$v := .}}{{range .Tiers}}

TIER {{.Tier}}

+{{range $v.TierHead}}{{end}} +{{range .Movers}}{{range .Stages}}{{end}}{{range .Nodes}}{{end}} +{{end}}
{{.}}
{{.Module}}{{.Outcome}}{{.Text}}{{.Text}}
{{end}}{{end}}{{end}} +` + changesScript + ``)) + +// cellWord is a cell's class: the runner's step word of an outcome (H-A-531 addendum (2)), or a node's state's. +func cellWord(s string) string { + switch s { + case "": + return "none" + case NodeRuns, seat.MoverRowOutcomePassed: + return "passed" + case NodeHeld: + return "held" + case NodeApplies: + return "applying" + case NodeWanted: + return "wanted" + case NodeNoWant: + return "not-run" + } + return [...]string{"passed", "running", "waiting", "not-run", "failed"}[stepRank(s)] +} + var pipelinePage = template.Must(template.New("p1").Parse(` Pipeline {{.Pipeline}}` + pipelinesStyle + `

What each node runs · Pipelines of {{.Branch}}{{if .Mover}} · Pipeline {{.Pipeline}}{{end}}

@@ -238,6 +306,21 @@ func webPipelines(m *Model, w http.ResponseWriter, r *http.Request) { v := p.Version() a, err := p.Show(key, mover, q.Get("next")) data := map[string]any{"Pipeline": key, "Mover": mover, "Changes": changesLink(key, v), "Up": PipelineLink(key, "")} + if mover == "" && q.Get("next") == "" { + if err == nil { + pv, verr := m.PipelineView(p, a) + data["View"], err = pv, verr + } + if err != nil { + data["Error"] = err.Error() + } else { + data["Branch"] = a.Pipeline.Branch + data["Back"] = "/pipelines?" + url.Values{"branch": {a.Pipeline.Branch}}.Encode() + } + w.Header().Set("Content-Type", "text/html; charset=utf-8") + pipelineViewPage.Execute(w, data) + return + } if err != nil { data["Error"] = err.Error() } else { diff --git a/modules/mesh-delivery-view/internal/view/pipelineview.go b/modules/mesh-delivery-view/internal/view/pipelineview.go new file mode 100644 index 000000000..1dbe8e8fc --- /dev/null +++ b/modules/mesh-delivery-view/internal/view/pipelineview.go @@ -0,0 +1,359 @@ +package view + +import ( + "fmt" + "maps" + "slices" + "strings" + "time" + + "git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshwantsclient" + seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner" +) + +// One pipeline as its page shows it (design 47 H2 H-A-531 and its addendum): a header with its outcome, its first failure's +// why and how many of its movers run on every node they are placed on; then one block per tier, in tier order, one row per +// mover, a cell per stage and a cell per node the mover's module is placed on. The stages are read through the runner's verb +// show, the nodes from what the view already reads for "What each node runs" (the seat's assignments, the wants and the +// haves); nothing is kept. + +// Stage is one stage a mover passes, by its name on the page and the step kind the runner names it by. +type Stage struct { + Name string + Step string +} + +// Stages are the stages in the order a mover passes them (design 47 H2 H-A-531). +var Stages = []Stage{{"build", seat.StepResultStepBuild}, {"lint", seat.StepResultStepLint}, {"unit", seat.StepResultStepUnit}, + {"integration", seat.StepResultStepIntegration}, {"validate", seat.StepResultStepValidate}, + {"composition", seat.StepResultStepComposition}, {"code review", seat.StepResultStepReview}, {"approval", seat.StepResultStepApproval}} + +// The states of a mover's module on a node it is placed on (design 47 H2 H-A-531). +const ( + NodeNoWant = "no want written" + NodeWanted = "wanted" + NodeApplies = "applying" + NodeRuns = "running the pipeline's build" + NodeHeld = "held" +) + +// PipelineView is one pipeline's page: its header, its tiers and the nodes its movers' modules are placed on, by name. +type PipelineView struct { + Pipeline string `json:"pipeline"` + Branch string `json:"branch"` + Outcome string `json:"outcome"` + Failed *seat.FailedStep `json:"failed,omitempty"` + Why string `json:"why,omitempty"` + Movers int `json:"movers"` + // Running is how many movers run the pipeline's build on every node they are placed on, Unplaced how many are placed on + // none: those never count as running (H-A-531 addendum (4)). + Running int `json:"running"` + Unplaced int `json:"unplaced"` + Nodes []string `json:"nodes"` + Tiers []PipelineTier `json:"tiers"` + // Unread says each stage show could not read: its cells are then empty, never shown passed. + Unread []string `json:"unread,omitempty"` +} + +// PipelineTier is one tier of the pipeline's delivery order, its movers by module. +type PipelineTier struct { + Tier int64 `json:"tier"` + Movers []MoverStage `json:"movers"` +} + +// MoverStage is one mover's row: its stages' cells in Stages' order and its cells on the nodes in the view's Nodes' order. +type MoverStage struct { + Module string `json:"module"` + Fingerprint string `json:"fingerprint"` + Version string `json:"version,omitempty"` + Outcome string `json:"outcome"` + Stages []StageCell `json:"stages"` + Nodes []NodeCell `json:"nodes"` +} + +// StageCell is one stage of one mover: the worst outcome over its artifacts, how many hold it of how many, and each +// artifact's waited, ran and why, shown on hover. +type StageCell struct { + Outcome string `json:"outcome,omitempty"` + Count int `json:"count,omitempty"` + Of int `json:"of,omitempty"` + Steps []string `json:"steps,omitempty"` +} + +// Text is the cell's outcome, with the count where the stage has several artifacts (H-A-531 addendum (3)). +func (c StageCell) Text() string { + if c.Of > 1 { + return fmt.Sprintf("%s %d/%d", c.Outcome, c.Count, c.Of) + } + return c.Outcome +} + +// Hover is each artifact's line, one per line. +func (c StageCell) Hover() string { return strings.Join(c.Steps, "\n") } + +// NodeCell is the mover's module on one node: empty when it is not placed there. +type NodeCell struct { + Placed bool `json:"placed,omitempty"` + State string `json:"state,omitempty"` + Why string `json:"why,omitempty"` +} + +// Text is the cell's state, with its why. +func (c NodeCell) Text() string { + if c.Why != "" { + return c.State + ": " + c.Why + } + return c.State +} + +// stepRank is how bad a step's outcome is, by the runner's own step words (H-A-531 addendum (2)): failed, then not run, then +// waiting, then running, then passed; an outcome it does not know counts as failed. +func stepRank(outcome string) int { + switch outcome { + case seat.StepResultOutcomePassed, seat.StepResultOutcomeCarried, seat.StepResultOutcomeAccepted, + seat.StepResultOutcomeBypassed, seat.StepResultOutcomeNothingToRun: + return 0 + case seat.StepResultOutcomeRunning: + return 1 + case seat.StepResultOutcomeWaiting, seat.StepResultOutcomeWaitingForABuildNode: + return 2 + case seat.StepResultOutcomeNotAsked, seat.StepResultOutcomeDeclined, seat.StepResultOutcomeSuperseded, seat.StepResultOutcomeCancelled: + return 3 + } + return 4 +} + +// stageCell is the cell of one mover's steps of one stage. +func stageCell(steps []seat.StepResult, now time.Time) StageCell { + var c StageCell + worst := -1 + for _, s := range steps { + c.Of++ + switch r := stepRank(s.Outcome); { + case r > worst: + worst, c.Outcome, c.Count = r, s.Outcome, 1 + case s.Outcome == c.Outcome: + c.Count++ + } + waited, ran := waitedRan(s, now) + line := s.Step + if s.Artifact != "" { + line = s.Artifact + } + line += ": " + s.Outcome + if waited != "" { + line += ", waited " + waited + } + if ran != "" { + line += ", ran " + ran + } + if s.Node != "" { + line += " on " + s.Node + } + if s.Why != "" { + line += ": " + s.Why + } + c.Steps = append(c.Steps, line) + } + return c +} + +// stageSteps reads every step of one stage through show, page by page. +func (p *Pipelines) stageSteps(pipeline, step string) ([]seat.StepResult, error) { + var out []seat.StepResult + next := "" + for { + raw, err := p.call(PipelinesShowVerb, seat.ShowInput{Pipeline: pipeline, Step: step, Next: next}) + a, err := showAnswer(raw, err, pipeline) + if err != nil { + return nil, err + } + out = append(out, a.Pipeline.Steps...) + if a.Next == "" || a.Next == next { + return out, nil + } + next = a.Next + } +} + +// moverRows reads every mover's row through show, page by page, starting from the answer of the first page. +func (p *Pipelines) moverRows(a seat.ShowAnswer) ([]seat.MoverRow, error) { + rows := slices.Clone(a.Movers) + next := a.Next + for next != "" { + b, err := p.Show(a.Pipeline.Pipeline, "", next) + if err != nil { + return nil, err + } + rows = append(rows, b.Movers...) + if b.Next == next { + break + } + next = b.Next + } + return rows, nil +} + +// nodeCell is module's state on node for the pipeline's build fp, from the wants, the haves and the holds the view reads. +// The caller holds m.mu. +func (m *Model) nodeCell(node, module, fp string) NodeCell { + c := NodeCell{Placed: true, State: NodeNoWant} + hk, err := nodeengineclient.HaveKey(node, module) + if err != nil { + return c + } + h, has := m.haves[hk] + has = has && h.err == "" + w, wanted := m.wants[hk] + wanted = wanted && w.err == "" && !w.value.Removed && w.value.Fp == fp + ours := has && h.have.Fp == fp + switch { + case ours && (h.have.Phase == nodeengineclient.PhaseFailed || h.have.Health == nodeengineclient.HealthFailed): + // A build that failed, or whose health failed, is held, never running (H-A-531 addendum (1)). + c.State, c.Why = NodeHeld, h.have.Detail + if c.Why == "" { + c.Why = "health " + string(h.have.Health) + ", phase " + string(h.have.Phase) + } + case ours && h.have.Phase == nodeengineclient.PhaseRunning: + c.State = NodeRuns + case has && (wanted || ours) && (h.have.Phase == nodeengineclient.PhaseHeld || h.have.Phase == nodeengineclient.PhaseWaitingYes): + c.State, c.Why = NodeHeld, h.have.Detail + if h.have.Wait != nil && h.have.Wait.Words != "" { + c.Why = h.have.Wait.Words + } + case ours: + c.State = NodeApplies + case wanted && has && (h.have.Phase == nodeengineclient.PhaseApplying || h.have.Phase == nodeengineclient.PhaseBackingUp || + h.have.Phase == nodeengineclient.PhaseChecking): + c.State = NodeApplies + case wanted: + c.State = NodeWanted + default: + if key, err := meshwantsclient.HeldKey(module, fp); err == nil { + if held, ok := m.holds[key]; ok && held.err == "" { + c.State, c.Why = NodeHeld, held.value.Words + } + } + } + return c +} + +// PipelineView is one pipeline's page from show's answer naming no mover (its movers' rows): its stages read through show +// per stage, its nodes from the view's own reading of the assignments, the wants and the haves (design 47 H2 H-A-531). +func (m *Model) PipelineView(p *Pipelines, a seat.ShowAnswer) (PipelineView, error) { + rows, err := p.moverRows(a) + if err != nil { + return PipelineView{}, err + } + pl := a.Pipeline + v := PipelineView{Pipeline: pl.Pipeline, Branch: pl.Branch, Outcome: pl.Outcome, Why: pl.Why, Movers: len(pl.Movers), Nodes: []string{}, Tiers: []PipelineTier{}} + outcome := map[string]string{} + for _, r := range rows { + outcome[r.Module] = r.Outcome + if v.Failed == nil && r.Failed != nil { // the first failure, in the runner's movers' order + v.Failed = r.Failed + } + } + steps := map[string]map[string][]seat.StepResult{} // by stage step, then module + for _, s := range Stages { + got, err := p.stageSteps(pl.Pipeline, s.Step) + if err != nil { + v.Unread = append(v.Unread, s.Name+": "+err.Error()) + continue + } + steps[s.Step] = map[string][]seat.StepResult{} + for _, r := range got { + steps[s.Step][r.Module] = append(steps[s.Step][r.Module], r) + } + } + m.mu.Lock() + defer m.mu.Unlock() + byNode := m.placed.ByNode() + placedOn := map[string][]string{} + for node, modules := range byNode { + for _, mod := range modules { + placedOn[mod] = append(placedOn[mod], node) + } + } + nodes := map[string]bool{} + for _, mv := range pl.Movers { + for _, n := range placedOn[mv.Module] { + nodes[n] = true + } + } + v.Nodes = slices.Sorted(maps.Keys(nodes)) + now := time.Now() + tiers := map[int64][]MoverStage{} + for _, mv := range pl.Movers { + row := MoverStage{Module: mv.Module, Fingerprint: mv.Fingerprint, Version: mv.Version, Outcome: outcome[mv.Module]} + for _, s := range Stages { + row.Stages = append(row.Stages, stageCell(steps[s.Step][mv.Module], now)) + } + runs := len(placedOn[mv.Module]) > 0 + for _, n := range v.Nodes { + if !slices.Contains(placedOn[mv.Module], n) { + row.Nodes = append(row.Nodes, NodeCell{}) + continue + } + c := m.nodeCell(n, mv.Module, mv.Fingerprint) + runs = runs && c.State == NodeRuns + row.Nodes = append(row.Nodes, c) + } + switch { + case len(placedOn[mv.Module]) == 0: + v.Unplaced++ + case runs: + v.Running++ + } + tier := max(mv.Tier, 1) + tiers[tier] = append(tiers[tier], row) + } + for _, t := range slices.Sorted(maps.Keys(tiers)) { + ms := tiers[t] + slices.SortFunc(ms, func(a, b MoverStage) int { return strings.Compare(a.Module, b.Module) }) + v.Tiers = append(v.Tiers, PipelineTier{Tier: t, Movers: ms}) + } + return v, nil +} + +// Header is the page's header line: the outcome, the first failure's why, and how many movers run on every node they are +// placed on, those placed on none said apart (H-A-531 addendum (4)). +func (v PipelineView) Header() string { + s := v.Outcome + switch { + case v.Failed != nil: + s += "; first failure: " + failedText(v.Failed) + case v.Why != "": + s += "; why: " + v.Why + } + s += fmt.Sprintf("; %d of %d movers run their build on every node they are placed on", v.Running, v.Movers) + switch { + case v.Unplaced == 1: + s += "; 1 is placed on none" + case v.Unplaced > 1: + s += fmt.Sprintf("; %d are placed on none", v.Unplaced) + } + return s +} + +// TierHead is a tier block's head: the mover, its outcome, a column per stage, a column per node. +func (v PipelineView) TierHead() []string { + out := []string{"MOVER", "OUTCOME"} + for _, s := range Stages { + out = append(out, strings.ToUpper(s.Name)) + } + return append(out, v.Nodes...) +} + +// Cells is a mover row's cells in TierHead's order. +func (r MoverStage) Cells() []string { + out := []string{r.Module, r.Outcome} + for _, c := range r.Stages { + out = append(out, c.Text()) + } + for _, c := range r.Nodes { + out = append(out, c.Text()) + } + return out +} diff --git a/modules/mesh-delivery-view/internal/view/serve.go b/modules/mesh-delivery-view/internal/view/serve.go index 612b20ef9..661f6cde2 100644 --- a/modules/mesh-delivery-view/internal/view/serve.go +++ b/modules/mesh-delivery-view/internal/view/serve.go @@ -15,8 +15,6 @@ import ( "strings" "text/tabwriter" "time" - - seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner" ) // ListenSocket listens on the unix socket at path, in a directory of mode 0755, with mode 0666 on the socket: the @@ -576,7 +574,16 @@ func answerPipelines(c net.Conn, m *Model, a ask) { } else if sa, serr := p.Show(a.Pipeline, a.Mover, a.Next); serr != nil { err = enc.Encode(pipelinesRefusal{Refused: serr.Error()}) } else { - err = enc.Encode(sa) + pa := PipelineAnswer{ShowAnswer: sa} + if a.Mover == "" && a.Next == "" { // the pipeline's page by tier and stage (design 47 H2 H-A-531) + pv, verr := m.PipelineView(p, sa) + if verr != nil { + enc.Encode(pipelinesRefusal{Refused: verr.Error()}) + return + } + pa.View = &pv + } + err = enc.Encode(pa) } if err != nil || !a.Follow || !p.Changed(ctx, what, v) { return @@ -594,7 +601,7 @@ type pipelinesRefusal struct { // AskPipelines asks the socket at path for one branch's newest limit pipelines (the default's below one), or with pipeline // set for that pipeline (of mover when named); with follow, each answers again at each change, handed to each until it // answers false or the view leaves. -func AskPipelines(path, branch string, limit int, pipeline, mover, next string, follow bool, each func(PipelinesPage, *seat.ShowAnswer) bool) error { +func AskPipelines(path, branch string, limit int, pipeline, mover, next string, follow bool, each func(PipelinesPage, *PipelineAnswer) bool) error { c, err := net.DialTimeout("unix", path, 5*time.Second) if err != nil { return fmt.Errorf("cannot reach the view at %s: %w", path, err) @@ -625,9 +632,9 @@ func AskPipelines(path, branch string, limit int, pipeline, mover, next string, return errors.New(refused.Refused) } var page PipelinesPage - var show *seat.ShowAnswer + var show *PipelineAnswer if pipeline != "" { - show = &seat.ShowAnswer{} + show = &PipelineAnswer{} if err := json.Unmarshal(raw, show); err != nil { return fmt.Errorf("the view's answer is not a pipeline: %w", err) } diff --git a/modules/mesh-delivery-view/internal/view/view.go b/modules/mesh-delivery-view/internal/view/view.go index a7a29114f..203f9194e 100644 --- a/modules/mesh-delivery-view/internal/view/view.go +++ b/modules/mesh-delivery-view/internal/view/view.go @@ -392,6 +392,7 @@ func (m *Model) Apply(e Entry) { } writes, reached := m.reachNow() say, put := m.deliveredEvent, m.reachPut + pipes := m.pipelines sayMotion := m.motionEvent left, w := m.left, m.writer m.left = nil @@ -404,6 +405,9 @@ func (m *Model) Apply(e Entry) { } m.sendReach(put, say, writes, reached) m.sayMotion(sayMotion, motion) + if pipes != nil && !e.History && (e.Bucket == WantsBucket || e.Bucket == HaveBucket || e.Bucket == AssignmentsBucket) { + pipes.Delivered() // a pipeline's page shows each mover's nodes (design 47 H2 H-A-531) + } } // deleteAnswers deletes the view's answers to the asks that left asks, after the model's lock is released; one not deleted is From 9bba3000f3f1497663e52082c3a459b803177982 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 10:57:26 +0100 Subject: [PATCH 2/5] Pipelines page: a stage's count is of the worst outcome's group Passed, carried and passed read "passed 2/3", as if one did not pass: the cell counts the artifacts in the group of its worst outcome (failed, not run, waiting, running, passed) and shows the count only where fewer than all are in it, so a cell never reads worse or better than it is. Builds: design 47 H2 H-A-531 addendum (3), as read in hq d7e7d204 --- .../mesh-delivery-view/internal/view/pipelines_test.go | 8 ++++---- .../mesh-delivery-view/internal/view/pipelineview.go | 10 ++++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/modules/mesh-delivery-view/internal/view/pipelines_test.go b/modules/mesh-delivery-view/internal/view/pipelines_test.go index c41077c6b..f640a91f4 100644 --- a/modules/mesh-delivery-view/internal/view/pipelines_test.go +++ b/modules/mesh-delivery-view/internal/view/pipelines_test.go @@ -165,7 +165,7 @@ func TestThePipelinesPage(t *testing.T) { "failed; first failure: unit beta:program: could not run: no build node; 1 of 4 movers run their build on every node they are placed on; 1 is placed on none", "

TIER 1

", "MOVEROUTCOMEBUILDLINTUNITINTEGRATIONVALIDATECOMPOSITIONCODE REVIEWAPPROVALn1n2n3", `alphapassedpassed 2/3", `running the pipeline's buildrunning the pipeline's build`, + `alpha:tool: passed">passed`, `running the pipeline's buildrunning the pipeline's build`, `could not run 1/2", `waiting`, `wantedapplyingno want written`, @@ -180,8 +180,8 @@ func TestThePipelinesPage(t *testing.T) { return stageCell(ss, t0).Text() } return strings.Join([]string{at("passed", "running", "waiting for a build node", "not asked", "running"), at("cancelled", "could not run"), - at("frobbed", "passed"), at("running", "running"), at("nothing to run"), at()}, "|") - }, []string{"not asked 1/5|could not run 1/2|frobbed 1/2|running 2/2|nothing to run|"}}, + at("frobbed", "passed"), at("running", "running"), at("nothing to run"), at("failed", "passed", "carried"), at()}, "|") + }, []string{"not asked 1/5|could not run 1/2|frobbed 1/2|running|nothing to run|failed 1/3|"}}, {"a mover's page is its steps, each asked, taken and ended, how long it waited and how long it ran", func() string { return web("/pipelines/show?pipeline=main.12&mover=beta") }, []string{"ASKEDTAKENENDEDWAITEDRAN", @@ -212,7 +212,7 @@ func TestThePipelinesPage(t *testing.T) { return text(func(b *bytes.Buffer) { PipelineTable(b, *got, "") }) }, []string{"PIPELINE main.12: failed; first failure: unit beta:program: could not run: no build node; 1 of 4 movers", "TIER 1 MOVER OUTCOME BUILD LINT UNIT INTEGRATION VALIDATE COMPOSITION CODE REVIEW APPROVAL N1 N2 N3", - "alpha passed passed 2/3 - - - - - passed - running the pipeline's build running the pipeline's build -", + "alpha passed passed - - - - - passed - running the pipeline's build running the pipeline's build -", "delta passed - - - - - - - - - - -", "TIER 2", "beta failed - - could not run 1/2 - - - - waiting wanted applying no want written", "gamma passed - - - - - - - - held: connection refused held: health failed on n1 -"}}, diff --git a/modules/mesh-delivery-view/internal/view/pipelineview.go b/modules/mesh-delivery-view/internal/view/pipelineview.go index 1dbe8e8fc..c193bde01 100644 --- a/modules/mesh-delivery-view/internal/view/pipelineview.go +++ b/modules/mesh-delivery-view/internal/view/pipelineview.go @@ -72,7 +72,8 @@ type MoverStage struct { Nodes []NodeCell `json:"nodes"` } -// StageCell is one stage of one mover: the worst outcome over its artifacts, how many hold it of how many, and each +// StageCell is one stage of one mover: the worst outcome over its artifacts, how many are in its group (failed, not run, +// waiting, running, passed) of how many, and each // artifact's waited, ran and why, shown on hover. type StageCell struct { Outcome string `json:"outcome,omitempty"` @@ -81,9 +82,10 @@ type StageCell struct { Steps []string `json:"steps,omitempty"` } -// Text is the cell's outcome, with the count where the stage has several artifacts (H-A-531 addendum (3)). +// Text is the cell's outcome, with how many artifacts are in its group where fewer than all are (H-A-531 addendum (3), as read +// in hq d7e7d204): passed, carried and passed read "passed"; failed, passed and passed "failed 1/3". func (c StageCell) Text() string { - if c.Of > 1 { + if c.Count < c.Of { return fmt.Sprintf("%s %d/%d", c.Outcome, c.Count, c.Of) } return c.Outcome @@ -133,7 +135,7 @@ func stageCell(steps []seat.StepResult, now time.Time) StageCell { switch r := stepRank(s.Outcome); { case r > worst: worst, c.Outcome, c.Count = r, s.Outcome, 1 - case s.Outcome == c.Outcome: + case r == worst: c.Count++ } waited, ran := waitedRan(s, now) From 19f06be6c17d9c070f25badce9b3d3d66ea557b5 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 11:03:27 +0100 Subject: [PATCH 3/5] Runner's list: each row names its branch, every branch's when none is named The pipelines page lists every watched branch's pipelines together, the branch a column of each row, so the short row carries the pipeline's branch; list already answered every branch when none was named, and its description now says so. The seat mesh-pipeline-runner's form rises to 11 for the field. Builds: design 47 H2 H-A-533 (hq 1b1e1984) --- .../go/seats/meshpipelinerunner/contract.go | 10 ++++++---- .../seats/mesh-pipeline-runner/seat.json | 8 ++++++-- .../ts/seats/meshpipelinerunner/index.d.ts | 2 ++ .../mesh-delivery-pipeline/internal/pipeline/read.go | 5 +++-- .../internal/pipeline/read_test.go | 11 ++++++++++- 5 files changed, 27 insertions(+), 9 deletions(-) diff --git a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go index ddc60ede8..5543cbcfe 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go @@ -14,13 +14,13 @@ const Seat = "mesh-pipeline-runner" // Form is the form of the seat's values, events and answers this contract was generated at (design 47 H2 §780): // a reader of a value of another form says "form N, this reader knows M". -const Form = 10 +const Form = 11 // The forms and the digest of the fields this contract was generated from: the generator's compare fails a definition // whose fields changed while its forms did not (design 47 H2 §780). const ( - generatedForms = "10" - generatedFieldsDigest = "AcceptAnswer=224df0394653 Accepted=d2b011e5090f AskAgainAnswer=224df0394653 CancelAnswer=a0dcc32b3f57 EndAgainAnswer=a0dcc32b3f57 FailedStep=cd7184342136 Fill=7a76c9ceb157 FillingEvent=5bd4df78ed84 FullEvent=5bd4df78ed84 KeptAnswer=dfe0d48bc169 KeptByLevelDigestValue=f06c90f7da7f KeptResult=af5f81f189b7 ListAnswer=284210b3c054 LogEntry=b059967b2ae4 Member=8a103baec01f Mover=5db376275bcf MoverEnded=4b35095f6829 MoverRow=b61f41d131a3 Pipeline=2663792125bf PipelineEnded=e3f4c58f93c8 PipelineEndedEvent=cb44007f7173 PipelineEndedPhases=9d1c33ce4cc4 PipelineEndedPhasesBuild=a08d49692a09 PipelineEndedPhasesComposition=a08d49692a09 PipelineEndedPhasesIntegration=a08d49692a09 PipelineEndedPhasesLint=a08d49692a09 PipelineEndedPhasesUnit=a08d49692a09 PipelineEndedPhasesValidate=a08d49692a09 PipelineRow=f58dbdcaf2d4 PipelineStarted=582f8ff3b28d PipelineStartedEvent=eaa401af4117 PipelinesByBranchRevisionAgainNValue=693580eed498 PipelinesByBranchRevisionUnfinishedModuleValue=693580eed498 PipelinesByBranchRevisionValue=693580eed498 PipelinesByBranchRunRunValue=693580eed498 PipelinesByBranchSourcePublishedPackageVersionValue=693580eed498 PipelinesByStepsPipelineMoverValue=94de99db7816 PlaceAnswer=a0dcc32b3f57 PlaceUnfinishedAnswer=ed94ced4513a Published=d9af3024dacc QueueByQueueNextValue=765a2918a728 QueueByRunningPipelineValue=ed94ced4513a QueueByWaitingSequenceValue=99605298ae13 RePinnedEvent=92fd04bfa6d3 RerunAnswer=9b7efd0df344 ReviewAnswer=f397b8965179 RoomEvent=5bd4df78ed84 RunAnswer=96bd45aa2e62 RunStarted=b280617410c3 RunStartedEvent=0767a9358fa3 Shared=c981cf6aa860 SharedAskedBy=c9b30cc4d0d0 ShowAnswer=48b8cecc529a StandsAnswer=0afa3693bf3b StartAnswer=ed94ced4513a StepEndedEvent=799020642c19 StepEvent=64f18c40ed5d StepLogByPipelineValue=ffdde090a101 StepResult=0dac0e15d017 StepStartedEvent=799020642c19 TestCounts=9c1332427159 TestRun=ca5a87f3b6b8 TestRunPackage=a7d30558470d TestRunReader=c9b30cc4d0d0 TestRunsAnswer=7ab81a45ca33 TestRunsDropAnswer=8ee70b35469d ToolchainUsed=43b6d42376fb Wait=21e4ee7a3ef1 WaitEndedEvent=2bf6d38041c0 WaitHeldEvent=2bf6d38041c0 Waiting=ed94ced4513a WhyCarriedAnswer=8e2fcea6479f Widening=e2790a307466" + generatedForms = "11" + generatedFieldsDigest = "AcceptAnswer=224df0394653 Accepted=d2b011e5090f AskAgainAnswer=224df0394653 CancelAnswer=a0dcc32b3f57 EndAgainAnswer=a0dcc32b3f57 FailedStep=cd7184342136 Fill=7a76c9ceb157 FillingEvent=5bd4df78ed84 FullEvent=5bd4df78ed84 KeptAnswer=dfe0d48bc169 KeptByLevelDigestValue=f06c90f7da7f KeptResult=af5f81f189b7 ListAnswer=284210b3c054 LogEntry=b059967b2ae4 Member=8a103baec01f Mover=5db376275bcf MoverEnded=4b35095f6829 MoverRow=b61f41d131a3 Pipeline=2663792125bf PipelineEnded=e3f4c58f93c8 PipelineEndedEvent=cb44007f7173 PipelineEndedPhases=9d1c33ce4cc4 PipelineEndedPhasesBuild=a08d49692a09 PipelineEndedPhasesComposition=a08d49692a09 PipelineEndedPhasesIntegration=a08d49692a09 PipelineEndedPhasesLint=a08d49692a09 PipelineEndedPhasesUnit=a08d49692a09 PipelineEndedPhasesValidate=a08d49692a09 PipelineRow=397a8219a855 PipelineStarted=582f8ff3b28d PipelineStartedEvent=eaa401af4117 PipelinesByBranchRevisionAgainNValue=693580eed498 PipelinesByBranchRevisionUnfinishedModuleValue=693580eed498 PipelinesByBranchRevisionValue=693580eed498 PipelinesByBranchRunRunValue=693580eed498 PipelinesByBranchSourcePublishedPackageVersionValue=693580eed498 PipelinesByStepsPipelineMoverValue=94de99db7816 PlaceAnswer=a0dcc32b3f57 PlaceUnfinishedAnswer=ed94ced4513a Published=d9af3024dacc QueueByQueueNextValue=765a2918a728 QueueByRunningPipelineValue=ed94ced4513a QueueByWaitingSequenceValue=99605298ae13 RePinnedEvent=92fd04bfa6d3 RerunAnswer=9b7efd0df344 ReviewAnswer=f397b8965179 RoomEvent=5bd4df78ed84 RunAnswer=96bd45aa2e62 RunStarted=b280617410c3 RunStartedEvent=0767a9358fa3 Shared=c981cf6aa860 SharedAskedBy=c9b30cc4d0d0 ShowAnswer=48b8cecc529a StandsAnswer=0afa3693bf3b StartAnswer=ed94ced4513a StepEndedEvent=799020642c19 StepEvent=64f18c40ed5d StepLogByPipelineValue=ffdde090a101 StepResult=0dac0e15d017 StepStartedEvent=799020642c19 TestCounts=9c1332427159 TestRun=ca5a87f3b6b8 TestRunPackage=a7d30558470d TestRunReader=c9b30cc4d0d0 TestRunsAnswer=7ab81a45ca33 TestRunsDropAnswer=8ee70b35469d ToolchainUsed=43b6d42376fb Wait=21e4ee7a3ef1 WaitEndedEvent=2bf6d38041c0 WaitHeldEvent=2bf6d38041c0 Waiting=ed94ced4513a WhyCarriedAnswer=8e2fcea6479f Widening=e2790a307466" ) const ( @@ -73,7 +73,7 @@ func VerbDescription(verb string) string { case VerbShow: return "One pipeline: naming a mover, its steps alone; with no mover, each mover's row (its module, outcome and failed step), never every step of every mover, or the steps of any mover the step and state filters hold; and its step log, with the stores' fill (design 47 H2 §789, H-A-376). Reads only." case VerbList: - return "The pipelines and runs of a module, a branch or a commit, newest first: by default one short row per pipeline, the newest 20 (its key, call, source, revision, start, end, outcome, movers' count, its steps counted per outcome and first failed or could-not-run step with its module and why); the whole pipelines, each record with its movers and steps counted, never its steps (show gives those), only with full and a limit (design 47 H2 H-A-376, H-A-467). Reads only." + return "The pipelines and runs of a module, a branch or a commit, newest first, of every branch when none is named (design 47 H2 H-A-533): by default one short row per pipeline, the newest 20 (its key, branch, call, source, revision, start, end, outcome, movers' count, its steps counted per outcome and first failed or could-not-run step with its module and why); the whole pipelines, each record with its movers and steps counted, never its steps (show gives those), only with full and a limit (design 47 H2 H-A-376, H-A-467). Reads only." case VerbStands: return "What stands still, and since when: each step not ended and each wait held. Reads only." case VerbWhyCarried: @@ -921,6 +921,8 @@ const ( // PipelineRow is one pipeline in list's short form, with its source, revision and its steps counted per outcome (design 47 H2 H-A-376, H-A-467). type PipelineRow struct { + // the watched branch, or the branch of a run on request: a column of the pipelines page, which lists every branch's together (design 47 H2 H-A-533) + Branch string `json:"branch,omitempty"` // the merge call whose source revision the take-in took in Call string `json:"call,omitempty"` Ended *time.Time `json:"ended,omitempty"` diff --git a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json index 33f62f7f3..9da66533b 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json @@ -178,7 +178,7 @@ }, { "name": "list", - "description": "The pipelines and runs of a module, a branch or a commit, newest first: by default one short row per pipeline, the newest 20 (its key, call, source, revision, start, end, outcome, movers' count, its steps counted per outcome and first failed or could-not-run step with its module and why); the whole pipelines, each record with its movers and steps counted, never its steps (show gives those), only with full and a limit (design 47 H2 H-A-376, H-A-467). Reads only.", + "description": "The pipelines and runs of a module, a branch or a commit, newest first, of every branch when none is named (design 47 H2 H-A-533): by default one short row per pipeline, the newest 20 (its key, branch, call, source, revision, start, end, outcome, movers' count, its steps counted per outcome and first failed or could-not-run step with its module and why); the whole pipelines, each record with its movers and steps counted, never its steps (show gives those), only with full and a limit (design 47 H2 H-A-376, H-A-467). Reads only.", "input": { "type": "object", "properties": { @@ -2296,6 +2296,10 @@ "type": "string", "description": "the pipeline's key" }, + "branch": { + "type": "string", + "description": "the watched branch, or the branch of a run on request: a column of the pipelines page, which lists every branch's together (design 47 H2 H-A-533)" + }, "call": { "type": "string", "description": "the merge call whose source revision the take-in took in" @@ -2378,5 +2382,5 @@ ] } }, - "form": 10 + "form": 11 } diff --git a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts index 28be0c5f7..56cd74691 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts @@ -430,6 +430,8 @@ export interface PipelineEnded { /** one pipeline in list's short form, with its source, revision and its steps counted per outcome (design 47 H2 H-A-376, H-A-467) */ export interface PipelineRow { + /** the watched branch, or the branch of a run on request: a column of the pipelines page, which lists every branch's together (design 47 H2 H-A-533) */ + "branch"?: string; /** the merge call whose source revision the take-in took in */ "call"?: string; "ended"?: string; diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/read.go b/modules/mesh-delivery-pipeline/internal/pipeline/read.go index 2699dcf43..584ed38b4 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/read.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/read.go @@ -249,7 +249,8 @@ func MoverRows(p seat.Pipeline) []seat.MoverRow { return out } -// List is the pipelines and runs of a module, a branch, a commit or a run, newest started first (§83): by default one +// List is the pipelines and runs of a module, a branch, a commit or a run, newest started first (§83), of every branch when +// none is named, each row naming its branch (design 47 H2 H-A-533): by default one // short row per pipeline, the newest ListRows or Limit (design 47 H2 H-A-376); with Full and a Limit each one's record with // its movers and steps counted, its steps empty (H-A-191). func (r Reads) List(in seat.ListInput) (seat.ListAnswer, error) { @@ -288,7 +289,7 @@ func (r Reads) List(in seat.ListInput) (seat.ListAnswer, error) { for _, p := range out { // A row carries its source, its revision and its steps counted per outcome (design 47 H2 H-A-467): a page's list is // one read of the short form. - rows = append(rows, seat.PipelineRow{Pipeline: p.Pipeline, Call: p.Call, Source: p.Source, Revision: p.Revision, + rows = append(rows, seat.PipelineRow{Pipeline: p.Pipeline, Branch: p.Branch, Call: p.Call, Source: p.Source, Revision: p.Revision, Started: p.Started, Ended: p.Ended, Outcome: p.Outcome, MoverCount: p.MoverCount, Steps: stepCounts(steps[p.Pipeline]), Failed: firstFailed(steps[p.Pipeline])}) } diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/read_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/read_test.go index 93d44a278..430eeb04d 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/read_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/read_test.go @@ -157,12 +157,21 @@ func TestReads(t *testing.T) { a, err := r.List(seat.ListInput{Branch: "gone"}) raw, _ := json.Marshal(a.Rows) return fmt.Sprint(string(raw), " ", len(a.Pipelines)), err - }, `[{"call":"call-2","ended":"2026-11-11T10:01:00Z","failed":{"artifact":"zeta:program","module":"zeta","outcome":"could not run","step":"unit","why":"its node lacks node-build-node"},"mover-count":1,"outcome":"failed","pipeline":"gone.2","revision":5,"source":2,"started":"2026-11-11T10:00:00Z","steps":{"could not run":1,"failed":1}}] 0`}, + }, `[{"branch":"gone","call":"call-2","ended":"2026-11-11T10:01:00Z","failed":{"artifact":"zeta:program","module":"zeta","outcome":"could not run","step":"unit","why":"its node lacks node-build-node"},"mover-count":1,"outcome":"failed","pipeline":"gone.2","revision":5,"source":2,"started":"2026-11-11T10:00:00Z","steps":{"could not run":1,"failed":1}}] 0`}, // Design 47 H2 H-A-467: a row counts the steps per outcome, a mover's kept steps (H-A-187) with them. {"list's row counts its steps per outcome", func() (string, error) { a, err := r.List(seat.ListInput{Branch: "next"}) return fmt.Sprint(a.Rows[0].Source, " ", a.Rows[0].Steps), err }, "8 map[passed:2 waiting:1]"}, + // Design 47 H2 H-A-533: naming no branch, list answers every branch's pipelines together, each row naming its branch. + {"list with no branch answers every branch's, newest first, each row naming its branch", func() (string, error) { + a, err := r.List(seat.ListInput{}) + var s []string + for _, row := range a.Rows { + s = append(s, row.Branch+":"+row.Pipeline) + } + return strings.Join(s, " "), err + }, "beta:beta.3.alpha main:main.7.gamma gone:gone.2 main:main.7.alpha next:next.8"}, {"list's full needs a limit", func() (string, error) { _, err := r.List(seat.ListInput{Full: true}) return "", err From a770eb5103429f0d91308d2ab5b5f8afe627d9e8 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 11:03:27 +0100 Subject: [PATCH 4/5] Pipelines page: every branch's newest together, filtered only by a module The operator found a pipelines view filtered by branch name makes no sense: the page and the terminal view now list the newest pipelines of every branch together, newest first, the branch a column, and offer one filter, a module (the pipelines that carry it). A delivery still links to its pipeline from its branch's list, or from every branch's list by the row's branch. Builds: design 47 H2 H-A-533 (hq 1b1e1984) --- .../cmd/mesh-delivery-cli/main.go | 20 ++-- .../cmd/mesh-delivery-cli/main_test.go | 21 ++-- .../mesh-delivery-view/integration_test.go | 6 +- .../internal/view/pipelines.go | 97 +++++++++++-------- .../internal/view/pipelines_test.go | 46 +++++++-- .../internal/view/pipelinespage.go | 29 +++--- .../mesh-delivery-view/internal/view/serve.go | 13 +-- 7 files changed, 147 insertions(+), 85 deletions(-) diff --git a/modules/mesh-delivery-view/cmd/mesh-delivery-cli/main.go b/modules/mesh-delivery-view/cmd/mesh-delivery-cli/main.go index c5db6c24b..b8585a484 100644 --- a/modules/mesh-delivery-view/cmd/mesh-delivery-cli/main.go +++ b/modules/mesh-delivery-view/cmd/mesh-delivery-cli/main.go @@ -3,8 +3,8 @@ // to write the operator's answer to an ask that needs no proof of who answered (the view refuses the merge's Approve). `holds` // lists every fingerprint the assigner holds with its node, cause and answer; `hold-release [words]` and // `hold-keep [words]` answer its hold ask, again when the operator changes their mind (issue 1906). -// `pipelines [branch]` and `pipeline [mover]` are the pipelines page (design 47 H2 H-A-467): a branch's newest -// pipelines, one pipeline's mover rows or one mover's steps; with -follow printed again at each change the runner's events say. +// `pipelines [module]` and `pipeline [mover]` are the pipelines page (design 47 H2 H-A-467, H-A-533): every +// branch's newest pipelines (of a module when named), one pipeline by tier and stage, or one mover's steps; with -follow printed again at each change the runner's events say. package main import ( @@ -36,7 +36,7 @@ func run(args []string, socket string, out, errOut io.Writer) int { asJSON := fs.Bool("json", false, "print the rows as JSON") follow := fs.Bool("follow", false, "pipelines and pipeline: print again at each change the runner's events say, until interrupted") next := fs.String("next", "", "pipeline: the cursor of the next page a pipeline's answer named") - limit := fs.Int("limit", view.DefaultPipelinesLimit, "pipelines: the newest this many pipelines of the branch") + limit := fs.Int("limit", view.DefaultPipelinesLimit, "pipelines: the newest this many pipelines") if err := fs.Parse(args); err != nil { return 2 } @@ -66,7 +66,7 @@ func run(args []string, socket string, out, errOut io.Writer) int { } if fs.NArg() > 0 { if fs.Arg(0) != "answer" || fs.NArg() < 3 { - fmt.Fprintln(errOut, "mesh-delivery-cli shows the rows, or answers: mesh-delivery-cli answer