D1 (pipeline runner): the runner's tools take their module from the runtime that serves them
The first views tools name the module the runtime serves them as, not a constant of the runner's name; a guard test finds none in its code. Builds: design 47 G A-296, §428 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
@@ -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 `<module>_first_views` and `<module>_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...) })...)
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user