From bda5a8f6ef05bb142f429ac1d94397005576bf63 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 02:45:23 +0100 Subject: [PATCH] Runner: the seat mesh-builds' step-progress arms its ask's bound again A build step whose build waited for a package ended ask-unanswered after ten minutes, since only mesh-wants' step-progress armed a bound again. The runner now consumes and hears the seat mesh-builds' step-progress the same way. Builds: design 47 H2 H-A-514 addendum --- .../cmd/mesh-delivery-pipeline/askbounds.go | 23 ++++++++++++++----- .../cmd/mesh-delivery-pipeline/drops_test.go | 22 ++++++++++++++++++ .../mesh-delivery-pipeline/manifest_test.go | 4 +++- modules/mesh-delivery-pipeline/module.json | 1 + 4 files changed, 43 insertions(+), 7 deletions(-) diff --git a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/askbounds.go b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/askbounds.go index 3d42b1674..6020618e3 100644 --- a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/askbounds.go +++ b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/askbounds.go @@ -11,6 +11,7 @@ import ( mcc "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshconditionsclient" condseat "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds" wants "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants" "mesh-delivery-pipeline/internal/pipeline" @@ -91,19 +92,29 @@ func progressed(c *pipeline.AskClock, onSeat, ask string, logf func(string, ...a } } -// hearWantsProgress takes a step progress of the seat mesh-wants as its holder's word on the ask it names: the ask's bound -// is armed again from now (H-A-395). +// hearWantsProgress takes a step progress of the seat mesh-wants, and of the seat mesh-builds (design 47 H2 H-A-514 +// addendum), as its holder's word on the ask it names: the ask's bound on that seat is armed again from now (H-A-395). func hearWantsProgress(hub handlers, c *pipeline.AskClock, logf func(string, ...any)) error { - return hub.Handle(wants.SubjectStepProgressAll, func(m jetstream.Msg) { - var ev wants.StepProgressEvent + for _, on := range []struct{ seat, subject string }{{wants.Seat, wants.SubjectStepProgressAll}, {meshbuilds.Seat, meshbuilds.SubjectStepProgressAll}} { + if err := hub.Handle(on.subject, progressOn(on.seat, c, logf)); err != nil { + return err + } + } + return nil +} + +// progressOn is the handler of one seat's step-progress: the ask it names, its bound on onSeat armed again from now. +func progressOn(onSeat string, c *pipeline.AskClock, logf func(string, ...any)) func(jetstream.Msg) { + return func(m jetstream.Msg) { + var ev wants.StepProgressEvent // mesh-builds' step-progress carries the fields of mesh-wants' if err := json.Unmarshal(m.Data(), &ev); err != nil || ev.Ask == "" { logf("%s is no step-progress: %v", m.Subject(), err) _ = m.Term() return } - progressed(c, wants.Seat, ev.Ask, logf) + progressed(c, onSeat, ev.Ask, logf) _ = m.Ack() - }) + } } // askBoundExpired takes the expiry of an ask's bound (§778): it ends its step. diff --git a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/drops_test.go b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/drops_test.go index 7191b9bc6..be00b5ea4 100644 --- a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/drops_test.go +++ b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/drops_test.go @@ -2,6 +2,7 @@ package main import ( "context" + "maps" "slices" "testing" "time" @@ -10,6 +11,7 @@ import ( mcc "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshconditionsclient" condseat "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds" "mesh-delivery-pipeline/internal/pipeline" ) @@ -83,4 +85,24 @@ func TestMissedBoundsAtTheStart(t *testing.T) { if want := []string{key("wordaaaa000005") + " 1m0s", key("goneaaaa000008") + " 1s"}; !slices.Equal(rearmed, want) { t.Errorf("armed again at the start %v, want %v", rearmed, want) } + + // Design 47 H2 H-A-514 addendum: the seat mesh-builds' step-progress arms its ask's bound again from now, as mesh-wants' does. + progress := map[string]func(jetstream.Msg){} + if err := hearWantsProgress(handlerMap(progress), c, t.Logf); err != nil { + t.Fatal(err) + } + hear, ok := progress[meshbuilds.SubjectStepProgressAll] + if !ok { + t.Fatalf("step-progress is heard on %v, want the seat mesh-builds' too", slices.Sorted(maps.Keys(progress))) + } + rearmed = nil + hear(dataMsg{data: []byte(`{"ask":"buildaaa000009","asker":"main.1.m","phase":"build","at":"2026-11-23T02:41:00Z"}`), acks: new([]string)}) + if want := []string{pipeline.AskBoundKey(meshbuilds.Seat, "buildaaa000009") + " 10m0s"}; !slices.Equal(rearmed, want) { + t.Errorf("a mesh-builds step-progress armed %v, want %v", rearmed, want) + } } + +// handlerMap is a hub that keeps each handler by its pattern. +type handlerMap map[string]func(jetstream.Msg) + +func (h handlerMap) Handle(pattern string, f func(jetstream.Msg)) error { h[pattern] = f; return nil } diff --git a/modules/mesh-delivery-pipeline/manifest_test.go b/modules/mesh-delivery-pipeline/manifest_test.go index a26fd0c81..05dd24838 100644 --- a/modules/mesh-delivery-pipeline/manifest_test.go +++ b/modules/mesh-delivery-pipeline/manifest_test.go @@ -96,7 +96,9 @@ func TestManifest(t *testing.T) { // design 47 H2 §777, §778: the bound of an ask on mesh-builds and mesh-wants counts from its holder's pull. "mesh-builds.ask-taken", "mesh-wants.ask-taken", "node-build-node.step-ended", "node-build-image.step-ended", "node-build-go.ask-taken", "node-build-node.ask-taken", "node-build-image.ask-taken", - "node-build-go.step-progress", "node-build-node.step-progress", "node-build-image.step-progress", "mesh-wants.step-ended", "mesh-wants.step-progress", "node-engine.running", "mesh-catalog.registration-changed", + "node-build-go.step-progress", "node-build-node.step-progress", "node-build-image.step-progress", "mesh-wants.step-ended", "mesh-wants.step-progress", + // H-A-514 addendum: the seat mesh-builds says step-progress of a build step that builds or waits for a package. + "mesh-builds.step-progress", "node-engine.running", "mesh-catalog.registration-changed", "mesh-catalog.catalog-revision", "mesh-catalog.version-released", "mesh-conditions.findings-asked", "mesh-delivery.recovery-merged", // A-186: the seat list its write verbs' callers are checked against, heard as it changes. "mesh-catalog.seat-definition-changed", "mesh-catalog.seat-definition-removed", diff --git a/modules/mesh-delivery-pipeline/module.json b/modules/mesh-delivery-pipeline/module.json index 5296680b9..6e7b82b38 100644 --- a/modules/mesh-delivery-pipeline/module.json +++ b/modules/mesh-delivery-pipeline/module.json @@ -68,6 +68,7 @@ "node-build-image.step-progress", "mesh-wants.step-ended", "mesh-wants.step-progress", + "mesh-builds.step-progress", "mesh-wants.ask-taken", "node-engine.running", "mesh-catalog.registration-changed",