diff --git a/modules/mesh-build-go/cmd/mesh-build-go/asks.go b/modules/mesh-build-go/cmd/mesh-build-go/asks.go index 1ba9be038..8991c7b77 100644 --- a/modules/mesh-build-go/cmd/mesh-build-go/asks.go +++ b/modules/mesh-build-go/cmd/mesh-build-go/asks.go @@ -56,7 +56,10 @@ func (m *Module) askSteps(steps []StepTool) steprun.AskSteps { // Puller is the module's pull of its seat's asks, on source (the runtime's seat pull when nil). func (m *Module) Puller(steps []StepTool, source steprun.AskSource) *steprun.Puller { if source == nil { - source = steprun.SeatAsks{Language: sdkstep.AskGo} + source = &steprun.SeatAsks{Language: sdkstep.AskGo, Logf: m.Say} + if m.Callers == nil { + m.Callers = steprun.SeatListCallers(sdkstep.AskGo, m.Say) + } } capacity := m.Capacity // The capacity's own change wakes the puller (issue 1887): the runtime's watch of the config value as mesh-config @@ -88,7 +91,7 @@ func (m *Module) Puller(steps []StepTool, source steprun.AskSource) *steprun.Pul if m.SayEvent != nil { say = steprun.SayOn(sdkstep.AskGo, m.Node, m.SayEvent) } - return &steprun.Puller{Source: source, Language: sdkstep.AskGo, Say: say, Node: m.Node, Put: m.Steps, PausePut: m.Pauses, Load: load, ForgetPause: m.ForgetPause, WatchPauses: m.WatchPauses, PauseKeys: m.ReadPauses.Keys, + return &steprun.Puller{Source: source, Language: sdkstep.AskGo, Say: say, Callers: m.Callers, Node: m.Node, Put: m.Steps, PausePut: m.Pauses, Load: load, ForgetPause: m.ForgetPause, WatchPauses: m.WatchPauses, PauseKeys: m.ReadPauses.Keys, Capacity: capacity, SettingsFile: settings, WatchConfig: watch, CoresPerStep: cores, BuildHours: hours, Logf: m.Say, Has: m.Has, Run: func(ctx context.Context, a sdkstep.StepAsk) (any, error) { if err := m.Check(ctx); err != nil { diff --git a/modules/mesh-build-go/cmd/mesh-build-go/asks_integration_test.go b/modules/mesh-build-go/cmd/mesh-build-go/asks_integration_test.go index 8766d9215..9fe1d64d0 100644 --- a/modules/mesh-build-go/cmd/mesh-build-go/asks_integration_test.go +++ b/modules/mesh-build-go/cmd/mesh-build-go/asks_integration_test.go @@ -52,7 +52,11 @@ func TestTheModuleTakesADeliveryAskBeforeAnEarlierCheck(t *testing.T) { first := deliveryAsk() for _, a := range []sdkstep.StepAsk{check, first} { raw, _ := sdkstep.EncodeStepAsk(a) + // A build rides main's subject, any other kind a named asker's (design 47 G §543). subject, _ := sdkstep.AskSubject(a.Language, a.Kind) + if a.Kind != sdkstep.AskDelivery { + subject, _ = sdkstep.AskSubjectBy(a.Language, a.Kind, "mesh-delivery-checker") + } if _, err := js.Publish(ctx, subject, raw); err != nil { t.Fatal(err) } diff --git a/modules/mesh-build-go/cmd/mesh-build-go/asks_say_test.go b/modules/mesh-build-go/cmd/mesh-build-go/asks_say_test.go index 2c8f1ccdd..f10e55ab4 100644 --- a/modules/mesh-build-go/cmd/mesh-build-go/asks_say_test.go +++ b/modules/mesh-build-go/cmd/mesh-build-go/asks_say_test.go @@ -11,11 +11,15 @@ import ( func TestPullerSaysTheSeatsEventsOnItsNodesSubject(t *testing.T) { var subjects []string m := &Module{Node: "ace", Capacity: func() int { return 0 }, + Callers: func(kind string) ([]string, bool) { return []string{"mesh-pipeline-runner"}, kind == "step" }, SayEvent: func(subject string, _ any, _ string) error { subjects = append(subjects, subject); return nil }} p := m.Puller(nil, steprun.NewFakeAsks()) if p.Say == nil { t.Fatal("the puller says no event") } + if got, ok := p.Callers("step"); !ok || len(got) != 1 { + t.Fatalf("the puller checks the callers of %v, %v, not the module's", got, ok) + } seat, _ := sdkstep.BuildSeat(sdkstep.AskGo) for _, event := range []string{"ask-taken", "step-progress", "step-ended"} { if err := p.Say(event, nil, "id"); err != nil { diff --git a/modules/mesh-build-go/cmd/mesh-build-go/module.go b/modules/mesh-build-go/cmd/mesh-build-go/module.go index eee129e90..3b179c5e3 100644 --- a/modules/mesh-build-go/cmd/mesh-build-go/module.go +++ b/modules/mesh-build-go/cmd/mesh-build-go/module.go @@ -24,6 +24,9 @@ const CheckRound = 10 * time.Minute // Module is the Go build module's one running state: the node it runs on, its recipe, the toolchain guard and the // states it writes (toolchains, steps). type Module struct { + // Callers says which seats the build seat's definition lists as callers of an accepted kind (steprun.SeatListCallers when + // the module pulls through its runtime; nil in a test checks no named asker): design 47 G §543, A-163. + Callers func(kind string) ([]string, bool) // SayEvent publishes an event of the go build seat on a seat subject (stdio.SeatPublish; nil says none, a test's): the // puller's ask-taken, step-progress and step-ended (design 47 G §496, §602). SayEvent func(subject string, body any, id string) error diff --git a/modules/mesh-build-image/cmd/mesh-build-image/asks.go b/modules/mesh-build-image/cmd/mesh-build-image/asks.go index e2f2e188e..95ea231a4 100644 --- a/modules/mesh-build-image/cmd/mesh-build-image/asks.go +++ b/modules/mesh-build-image/cmd/mesh-build-image/asks.go @@ -37,7 +37,10 @@ func (m *Module) askSteps(steps []StepTool) steprun.AskSteps { // Puller is the module's pull of its seat's asks, on source (the runtime's seat pull when nil). func (m *Module) Puller(steps []StepTool, source steprun.AskSource) *steprun.Puller { if source == nil { - source = steprun.SeatAsks{Language: sdkstep.AskImage} + source = &steprun.SeatAsks{Language: sdkstep.AskImage, Logf: m.Say} + if m.Callers == nil { + m.Callers = steprun.SeatListCallers(sdkstep.AskImage, m.Say) + } } capacity := m.Capacity // The capacity's own change wakes the puller (issue 1887): the runtime's watch of the config value as mesh-config @@ -66,7 +69,7 @@ func (m *Module) Puller(steps []StepTool, source steprun.AskSource) *steprun.Pul if m.SayEvent != nil { say = steprun.SayOn(sdkstep.AskImage, m.Node, m.SayEvent) } - return &steprun.Puller{Source: source, Language: sdkstep.AskImage, Say: say, Node: m.Node, Put: m.Steps, PausePut: m.Pauses, Load: load, ForgetPause: m.ForgetPause, WatchPauses: m.WatchPauses, PauseKeys: m.ReadPauses.Keys, + return &steprun.Puller{Source: source, Language: sdkstep.AskImage, Say: say, Callers: m.Callers, Node: m.Node, Put: m.Steps, PausePut: m.Pauses, Load: load, ForgetPause: m.ForgetPause, WatchPauses: m.WatchPauses, PauseKeys: m.ReadPauses.Keys, Capacity: capacity, SettingsFile: settings, WatchConfig: watch, CoresPerStep: cores, BuildHours: hours, Eligible: m.Eligible, Logf: m.Say, Run: func(ctx context.Context, a sdkstep.StepAsk) (any, error) { if err := m.Check(ctx); err != nil { diff --git a/modules/mesh-build-image/cmd/mesh-build-image/asks_say_test.go b/modules/mesh-build-image/cmd/mesh-build-image/asks_say_test.go index afe9e94e5..dd42d4a9a 100644 --- a/modules/mesh-build-image/cmd/mesh-build-image/asks_say_test.go +++ b/modules/mesh-build-image/cmd/mesh-build-image/asks_say_test.go @@ -11,11 +11,15 @@ import ( func TestPullerSaysTheSeatsEventsOnItsNodesSubject(t *testing.T) { var subjects []string m := &Module{Node: "ace", Capacity: func() int { return 0 }, + Callers: func(kind string) ([]string, bool) { return []string{"mesh-pipeline-runner"}, kind == "step" }, SayEvent: func(subject string, _ any, _ string) error { subjects = append(subjects, subject); return nil }} p := m.Puller(nil, steprun.NewFakeAsks()) if p.Say == nil { t.Fatal("the puller says no event") } + if got, ok := p.Callers("step"); !ok || len(got) != 1 { + t.Fatalf("the puller checks the callers of %v, %v, not the module's", got, ok) + } seat, _ := sdkstep.BuildSeat(sdkstep.AskImage) for _, event := range []string{"ask-taken", "step-progress", "step-ended"} { if err := p.Say(event, nil, "id"); err != nil { diff --git a/modules/mesh-build-image/cmd/mesh-build-image/module.go b/modules/mesh-build-image/cmd/mesh-build-image/module.go index b9b9bd84b..d1799f421 100644 --- a/modules/mesh-build-image/cmd/mesh-build-image/module.go +++ b/modules/mesh-build-image/cmd/mesh-build-image/module.go @@ -20,6 +20,9 @@ const CheckRound = 10 * time.Minute // Module is the image build module's one running state. type Module struct { + // Callers says which seats the build seat's definition lists as callers of an accepted kind (steprun.SeatListCallers when + // the module pulls through its runtime; nil in a test checks no named asker): design 47 G §543, A-163. + Callers func(kind string) ([]string, bool) // SayEvent publishes an event of the image build seat on a seat subject (stdio.SeatPublish; nil says none, a test's): the // puller's ask-taken, step-progress and step-ended (design 47 G §496, §602). SayEvent func(subject string, body any, id string) error diff --git a/modules/mesh-build-node/cmd/mesh-build-node/asks.go b/modules/mesh-build-node/cmd/mesh-build-node/asks.go index fcdfdc37e..b2043f107 100644 --- a/modules/mesh-build-node/cmd/mesh-build-node/asks.go +++ b/modules/mesh-build-node/cmd/mesh-build-node/asks.go @@ -47,7 +47,10 @@ func (m *Module) askSteps(steps []StepTool) steprun.AskSteps { // Puller is the module's pull of its seat's asks, on source (the runtime's seat pull when nil). func (m *Module) Puller(steps []StepTool, source steprun.AskSource) *steprun.Puller { if source == nil { - source = steprun.SeatAsks{Language: sdkstep.AskNode} + source = &steprun.SeatAsks{Language: sdkstep.AskNode, Logf: m.Say} + if m.Callers == nil { + m.Callers = steprun.SeatListCallers(sdkstep.AskNode, m.Say) + } } capacity := m.Capacity // The capacity's own change wakes the puller (issue 1887): the runtime's watch of the config value as mesh-config @@ -76,7 +79,7 @@ func (m *Module) Puller(steps []StepTool, source steprun.AskSource) *steprun.Pul if m.SayEvent != nil { say = steprun.SayOn(sdkstep.AskNode, m.Node, m.SayEvent) } - return &steprun.Puller{Source: source, Language: sdkstep.AskNode, Say: say, Node: m.Node, Put: m.Steps, PausePut: m.Pauses, Load: load, ForgetPause: m.ForgetPause, WatchPauses: m.WatchPauses, PauseKeys: m.ReadPauses.Keys, + return &steprun.Puller{Source: source, Language: sdkstep.AskNode, Say: say, Callers: m.Callers, Node: m.Node, Put: m.Steps, PausePut: m.Pauses, Load: load, ForgetPause: m.ForgetPause, WatchPauses: m.WatchPauses, PauseKeys: m.ReadPauses.Keys, Capacity: capacity, SettingsFile: settings, WatchConfig: watch, CoresPerStep: cores, BuildHours: hours, Logf: m.Say, Run: func(ctx context.Context, a sdkstep.StepAsk) (any, error) { if err := m.Prepare(ctx); err != nil { diff --git a/modules/mesh-build-node/cmd/mesh-build-node/asks_say_test.go b/modules/mesh-build-node/cmd/mesh-build-node/asks_say_test.go index 5869cb558..3ab0b2618 100644 --- a/modules/mesh-build-node/cmd/mesh-build-node/asks_say_test.go +++ b/modules/mesh-build-node/cmd/mesh-build-node/asks_say_test.go @@ -11,11 +11,15 @@ import ( func TestPullerSaysTheSeatsEventsOnItsNodesSubject(t *testing.T) { var subjects []string m := &Module{Node: "ace", Capacity: func() int { return 0 }, + Callers: func(kind string) ([]string, bool) { return []string{"mesh-pipeline-runner"}, kind == "step" }, SayEvent: func(subject string, _ any, _ string) error { subjects = append(subjects, subject); return nil }} p := m.Puller(nil, steprun.NewFakeAsks()) if p.Say == nil { t.Fatal("the puller says no event") } + if got, ok := p.Callers("step"); !ok || len(got) != 1 { + t.Fatalf("the puller checks the callers of %v, %v, not the module's", got, ok) + } seat, _ := sdkstep.BuildSeat(sdkstep.AskNode) for _, event := range []string{"ask-taken", "step-progress", "step-ended"} { if err := p.Say(event, nil, "id"); err != nil { diff --git a/modules/mesh-build-node/cmd/mesh-build-node/module.go b/modules/mesh-build-node/cmd/mesh-build-node/module.go index d81efb06d..a5efcaab1 100644 --- a/modules/mesh-build-node/cmd/mesh-build-node/module.go +++ b/modules/mesh-build-node/cmd/mesh-build-node/module.go @@ -25,6 +25,9 @@ const CheckRound = 10 * time.Minute // Module is the Node build module's one running state: the node it runs on, its recipe, the toolchain guard, the // toolchain directory and the states it writes (toolchains, steps). type Module struct { + // Callers says which seats the build seat's definition lists as callers of an accepted kind (steprun.SeatListCallers when + // the module pulls through its runtime; nil in a test checks no named asker): design 47 G §543, A-163. + Callers func(kind string) ([]string, bool) // SayEvent publishes an event of the node build seat on a seat subject (stdio.SeatPublish; nil says none, a test's): the // puller's ask-taken, step-progress and step-ended (design 47 G §496, §602). SayEvent func(subject string, body any, id string) error