assigner: each bind of the package-published consumer wakes every waiting run (issue 1984, review round 1)

The bind wake stood in main.go untested. It now sits beside the
consumer's handler in hearPublished, which registers both: each bind of
the assigner's consumer of package-published wakes every run waiting for
a package's publish to read published again, since an event said while
the consumer was not bound is never heard.

Test: TestTheCompositionStepRunsOneAskPerMachine, the wait's rows gain
"bind": x/go published with no event heard, a bind of the consumer wakes
each waiting run, which reads it published and puts its run ask with the
pin (failed first, no end within 10 s, with the bind's hearer removed).

Builds: design 47 H2 H-A-630 (2) (hq 1cdfa6ff); H-A-628 (3) (hq cea6404c)
This commit is contained in:
2026-11-23 23:06:56 +01:00
parent 8a1605d283
commit 051e104f1b
3 changed files with 25 additions and 9 deletions
@@ -303,8 +303,10 @@ func TestTheCompositionStepRunsOneAskPerMachine(t *testing.T) {
// 1984/AC9; H-A-628 (3), (4); H-A-629 (1), (2): x's build not published yet: each run waits, its value naming x/go in `waits`
// with the time its wait began, its bound bound.<run key> armed for package-wait-minutes, the step saying fetch naming the
// package; at the publish heard each reads published again and puts its run ask with the pin, `waits` and the bound gone, the
// step saying run; past the bound each ends could not run naming the package and the bound, no run ask put.
for _, publish := range []bool{true, false} {
// step saying run; past the bound each ends could not run naming the package and the bound, no run ask put. H-A-630 (2): a
// bind of the consumer, the publish said while it was not bound, wakes each to read it published.
for _, how := range []string{"published", "bind", "past its bound"} {
publish := how != "past its bound"
u := newRunStand(t, "src2:e1", "src2:e1", "d1")
u.publishedAt = nil
journal := newLogLines()
@@ -344,12 +346,24 @@ func TestTheCompositionStepRunsOneAskPerMachine(t *testing.T) {
t.Errorf("the waiting run %s of %v holds %+v, its bound %s; want x/go in waits and package-wait-minutes' bound", key, keys, run.Waits, ttl)
}
}
if !publish {
switch how {
case "past its bound":
for _, key := range keys {
kv.expire(runBoundPrefix + key)
u.runs.expired(runBoundPrefix + key)
}
} else {
case "bind":
hub := &eventsOf{handle: map[string]func(jetstream.Msg){}}
if err := hearPublished(hub, u.runs, t.Logf); err != nil {
t.Fatal(err)
}
u.mu.Lock()
u.publishedAt = map[string]string{"src2:x1": "0.1.9"}
u.mu.Unlock()
for _, bound := range hub.bound {
bound(time.Now())
}
default:
// H-A-630 (1): a package-published of another package wakes no run waiting for x/go, so it asks no published; x's own
// wakes each.
hub := &eventsOf{handle: map[string]func(jetstream.Msg){}}
@@ -376,7 +390,7 @@ func TestTheCompositionStepRunsOneAskPerMachine(t *testing.T) {
select {
case out = <-done:
case <-time.After(10 * time.Second):
t.Fatalf("publish %v: the waiting step said no end", publish)
t.Fatalf("%s: the waiting step said no end", how)
}
journal.await(t, "the composition step of m says run", 1)
if !publish {
@@ -332,10 +332,13 @@ func (r *compositionRuns) publishWake(artifact string) <-chan struct{} {
// hearPublished hears the seat mesh-builds' package-published on the assigner's durable consumer: the runs waiting for the
// package its artifact publishes are woken (heardPublished, design 47 H2 H-A-630 (1)); one that does not read wakes none and is
// journaled.
// journaled. Each bind of the consumer wakes every waiting run (heardBind, H-A-630 (2)): an event said while it was not bound is
// never heard, so no run waits until its bound alone ends it while its package stands published.
func hearPublished(hub interface {
Handle(string, func(jetstream.Msg)) error
OnBound(func(time.Time))
}, r *compositionRuns, logf func(string, ...any)) error {
hub.OnBound(func(time.Time) { r.heardBind() })
return hub.Handle(meshbuilds.SubjectPackagePublished, func(m jetstream.Msg) {
ev, _, err := meshbuilds.DecodePackagePublishedEvent(m.Data())
if err != nil || ev.Artifact == "" {
@@ -518,11 +518,10 @@ func follow(ctx context.Context, js jetstream.JetStream, nc process.Subscriber,
}
// The seat mesh-builds' package-published wakes the runs waiting for the package its artifact publishes, which read published
// again; each bind of the consumer, which hears no event said before it was made, wakes every waiting run (design 47 H2
// H-A-628 (3), H-A-630 (1); H-A-326, H-A-328).
// H-A-628 (3), H-A-630 (1), (2); H-A-326, H-A-328).
if err := hearPublished(hub, runs, logger.Printf); err != nil {
logger.Printf("the seat mesh-builds' package-published is not heard, so a composition run waiting for a package reads published only at its start: %v", err)
logger.Printf("the seat mesh-builds' package-published is not heard, so a composition run waiting for a package reads published only at its start and at each bind: %v", err)
}
hub.OnBound(func(time.Time) { runs.heardBind() })
}
if inputs != nil {
var runEnded func(buildstep.StepEnded) error