diff --git a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline-tools/main.go b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline-tools/main.go index fea92533..6780b8ec 100644 --- a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline-tools/main.go +++ b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline-tools/main.go @@ -88,16 +88,13 @@ func Tools(r pipeline.Reads) []stdio.Tool { return out } -// Module is the runner's module, and Prefix its tools' prefix (design 47 G §539: runner_first_views, runner_health). -const ( - Module = "mesh-delivery-pipeline" - Prefix = "runner" -) +// Prefix is the runner's tools' prefix (design 47 G §539: runner_first_views, runner_health). +const Prefix = "runner" // FirstViewTools are the runner's `_first_views` and `_first_view_again` over its state first-views // (design 47 G §77, §200): each view it holds or waits for, since when, and asked again by hand, a hand act. -func FirstViewTools(st stdio.KeptState, acts views.HandActs, now func() time.Time) []stdio.Tool { - return views.StatusTools(Module, Prefix+"_first_views", Prefix+"_first_view_again", st, acts, now) +func FirstViewTools(module string, st stdio.KeptState, acts views.HandActs, now func() time.Time) []stdio.Tool { + return views.StatusTools(module, Prefix+"_first_views", Prefix+"_first_view_again", st, acts, now) } // HealthTool is the runner's health check, run outside its process (design 47 G §76, §468, §495; A-164): it reads the @@ -179,7 +176,7 @@ func main() { func(n string) (buscalls.Fill, error) { return busstate.ObjectsOf(n).Fill() }, func(n string) (*stdio.LogInfo, error) { return stdio.Log(n).Info() }, time.Now) r := pipeline.Reads{Pipelines: kept{stdio.State(seat.StatePipelines)}, Kept: kept{stdio.State(seat.StateKept)}, Fill: fill} - tools := append(Tools(r), FirstViewTools(stdio.State(views.StatusState), meshhandactsclient.Recorder{Ask: stdio.Ask}, time.Now)...) + tools := append(Tools(r), FirstViewTools(os.Getenv(stdio.ServedAs), stdio.State(views.StatusState), meshhandactsclient.Recorder{Ask: stdio.Ask}, time.Now)...) tools = append(tools, WaitsTool(r), ReleaseTool(stdio.Ask)) tools = append(tools, UnloggedTools(stdio.State(seat.StatePipelines), stdio.Log(seat.StateStepLog), meshhandactsclient.Recorder{Ask: stdio.Ask}, func(f string, a ...any) { fmt.Fprintf(os.Stderr, "[mesh-delivery-pipeline-tools] "+f+"\n", a...) })...) diff --git a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline-tools/main_test.go b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline-tools/main_test.go index 6b75e988..33518ca3 100644 --- a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline-tools/main_test.go +++ b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline-tools/main_test.go @@ -28,7 +28,7 @@ func TestTools(t *testing.T) { for _, tl := range Tools(pipeline.Reads{Pipelines: none{}, Kept: none{}}) { names = append(names, tl.Name) } - for _, tl := range FirstViewTools(stdio.State(views.StatusState), nil, nil) { + for _, tl := range FirstViewTools("the-runner", stdio.State(views.StatusState), nil, nil) { names = append(names, tl.Name) } // RN25 (§468, §76; A-164): the health check is the bundle's runner_health. diff --git a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline-tools/ownname_test.go b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline-tools/ownname_test.go new file mode 100644 index 00000000..d43b869a --- /dev/null +++ b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline-tools/ownname_test.go @@ -0,0 +1,34 @@ +package main + +import ( + "io/fs" + "os" + "path/filepath" + "regexp" + "strings" + "testing" +) + +// No code of the pipeline runner names its own module: its tools' first views and its buckets take the module its credential (or +// the runtime that serves its tools) names (design 47 G A-296, §428). The manifest alone says it. +func TestNoCodeNamesTheRunnersOwnModule(t *testing.T) { + name := regexp.MustCompile(`"mesh-delivery-pipeline(_[^"]*)?"`) + err := filepath.WalkDir("../..", func(path string, d fs.DirEntry, err error) error { + if err != nil || d.IsDir() || !strings.HasSuffix(path, ".go") || strings.HasSuffix(path, "_test.go") { + return err + } + src, err := os.ReadFile(path) + if err != nil { + return err + } + for i, line := range strings.Split(string(src), "\n") { + if !strings.HasPrefix(strings.TrimSpace(line), "//") && name.MatchString(line) { + t.Errorf("%s:%d names the runner's own module: %s", path, i+1, strings.TrimSpace(line)) + } + } + return nil + }) + if err != nil { + t.Fatal(err) + } +}