diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reservedverb_test.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reservedverb_test.go index 022a454c1..89c332e43 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reservedverb_test.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reservedverb_test.go @@ -213,4 +213,31 @@ func TestTheProcessAnswersReserved(t *testing.T) { } close(release) await(t, saidTaken, "ask-5's ask-taken once let go") + + // The H-A-514 addendum: while an ask builds or its build waits for a package, the builder says the seat mesh-builds' + // step-progress of it at each tick of its minute clock, so the runner's bound of the ask is armed again. + tick := make(chan time.Time) + progressed := make(chan meshbuilds.StepProgressEvent, 1) + building := make(chan string, 1) + pq := &stepQueue{node: "n1", builder: blockingBuilder{started: building}, taken: &takenFake{vals: map[string][]byte{}, ttls: map[string]time.Duration{}}, + takenBound: 10 * time.Minute, inProgress: func() time.Duration { return 0 }, logf: t.Logf, now: time.Now, running: map[string]*runningAsk{}, + progress: func() (<-chan time.Time, func()) { return tick, func() {} }, + say: func(_ context.Context, subject, _ string, body any) error { + if p, ok := body.(meshbuilds.StepProgressEvent); ok && subject == meshbuilds.SubjectStepProgress("n1") { + progressed <- p + } + return nil + }} + pq.take(t.Context(), stepMsg("ask-7")) + await(t, building, "the build of ask-7") + at := time.Date(2026, 11, 23, 2, 41, 0, 0, time.UTC) + tick <- at + select { + case p := <-progressed: + if p.Ask != "ask-7" || p.Asker != "main.1.m" || p.Phase != meshbuilds.StepProgressEventPhaseBuild || !p.At.Equal(at) { + t.Errorf("step-progress said %+v", p) + } + case <-time.After(5 * time.Second): + t.Error("no step-progress was said of ask-7 while it builds") + } } diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/stepqueue.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/stepqueue.go index 1f30a7084..389ab0a1b 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/stepqueue.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/stepqueue.go @@ -66,6 +66,9 @@ type stepQueue struct { takenBound time.Duration // inProgress is how often a running ask is said in progress: the seat definition's in-progress. inProgress func() time.Duration + // progress is the clock step-progress is said on while an ask builds or its build waits for a package: every + // stepProgressEvery (design 47 H2 H-A-514 addendum); a test's when set. + progress func() (<-chan time.Time, func()) // say publishes a seat event of the builder (emitSeatEvent). say func(ctx context.Context, subject, id string, body any) error logf func(string, ...any) @@ -75,6 +78,19 @@ type stepQueue struct { running map[string]*runningAsk } +// stepProgressEvery is how often the builder says step-progress of an ask it builds (design 47 H2 H-A-514 addendum): once a +// minute, as the seat mesh-wants' holder says its own. +const stepProgressEvery = time.Minute + +// progressClock is the clock of step-progress: the test's, else a ticker of stepProgressEvery. +func (q *stepQueue) progressClock() (<-chan time.Time, func()) { + if q.progress != nil { + return q.progress() + } + t := time.NewTicker(stepProgressEvery) + return t.C, t.Stop +} + // runningAsk is an ask the builder took and builds now. type runningAsk struct { run meshbuilds.StepRun @@ -163,6 +179,10 @@ func (q *stepQueue) build(ctx context.Context, m queueMsg, id string, ra *runnin defer t.Stop() tick = t.C } + // step-progress is said every minute while the step builds or waits for a package, so the asker's bound of the ask is + // armed again (design 47 H2 H-A-514 addendum). + progress, stop := q.progressClock() + defer stop() done := make(chan meshbuilds.StepEnded, 1) go func() { done <- q.builder.BuildStep(ctx, id, ra.run) }() var end meshbuilds.StepEnded @@ -172,6 +192,11 @@ func (q *stepQueue) build(ctx context.Context, m queueMsg, id string, ra *runnin waiting = false case <-tick: _ = m.InProgress() + case at := <-progress: + p := meshbuilds.StepProgressEvent{Ask: id, Asker: ra.run.Pipeline, Phase: meshbuilds.StepProgressEventPhaseBuild, At: at.UTC()} + if err := q.say(ctx, meshbuilds.SubjectStepProgress(q.node), fmt.Sprintf("%s-progress-%d", id, at.UnixNano()), p); err != nil { + q.logf("saying step-progress of %s: %v", id, err) + } } } if err := q.say(context.WithoutCancel(ctx), meshbuilds.SubjectStepEnded(q.node), id, end); err != nil {