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
This commit is contained in:
2026-11-23 02:45:23 +01:00
parent a1a8e7cc34
commit bda5a8f6ef
4 changed files with 43 additions and 7 deletions
@@ -11,6 +11,7 @@ import (
mcc "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshconditionsclient" 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" 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" wants "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants"
"mesh-delivery-pipeline/internal/pipeline" "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 // hearWantsProgress takes a step progress of the seat mesh-wants, and of the seat mesh-builds (design 47 H2 H-A-514
// is armed again from now (H-A-395). // 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 { func hearWantsProgress(hub handlers, c *pipeline.AskClock, logf func(string, ...any)) error {
return hub.Handle(wants.SubjectStepProgressAll, func(m jetstream.Msg) { for _, on := range []struct{ seat, subject string }{{wants.Seat, wants.SubjectStepProgressAll}, {meshbuilds.Seat, meshbuilds.SubjectStepProgressAll}} {
var ev wants.StepProgressEvent 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 == "" { if err := json.Unmarshal(m.Data(), &ev); err != nil || ev.Ask == "" {
logf("%s is no step-progress: %v", m.Subject(), err) logf("%s is no step-progress: %v", m.Subject(), err)
_ = m.Term() _ = m.Term()
return return
} }
progressed(c, wants.Seat, ev.Ask, logf) progressed(c, onSeat, ev.Ask, logf)
_ = m.Ack() _ = m.Ack()
}) }
} }
// askBoundExpired takes the expiry of an ask's bound (§778): it ends its step. // askBoundExpired takes the expiry of an ask's bound (§778): it ends its step.
@@ -2,6 +2,7 @@ package main
import ( import (
"context" "context"
"maps"
"slices" "slices"
"testing" "testing"
"time" "time"
@@ -10,6 +11,7 @@ import (
mcc "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshconditionsclient" 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" 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" "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) { 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) 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 }
@@ -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. // 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", "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-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", "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. // 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", "mesh-catalog.seat-definition-changed", "mesh-catalog.seat-definition-removed",
@@ -68,6 +68,7 @@
"node-build-image.step-progress", "node-build-image.step-progress",
"mesh-wants.step-ended", "mesh-wants.step-ended",
"mesh-wants.step-progress", "mesh-wants.step-progress",
"mesh-builds.step-progress",
"mesh-wants.ask-taken", "mesh-wants.ask-taken",
"node-engine.running", "node-engine.running",
"mesh-catalog.registration-changed", "mesh-catalog.registration-changed",