build modules: the checker seat's invoke, its client and its fixtures go; a run's input is asked of the seat mesh-wants

The kinds check and recheck stay in H1 (H-A-117).

Builds: design 47 H §764 (the checker (H1)); lead answers H-A-57, H-A-117

Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
This commit is contained in:
2026-11-20 04:59:05 +01:00
parent ba0330c205
commit c91ab3acfa
13 changed files with 45 additions and 46 deletions
@@ -1,7 +1,7 @@
package main
// What this module keeps on the bus, announced from its code (novox/hq ADR 0495 §2 §5; issue 1790): every state it
// keeps, each readable by others, since another module reads each today (the builder, the checker and the indexer read toolchains; the builder and the checker read steps; gitea reads keys). A state of its own that it
// keeps, each readable by others, since another module reads each today (the builder and the indexer read toolchains; the builder reads steps; gitea reads keys). A state of its own that it
// did not name here is refused at the call (stdio.Keeps).
import (
@@ -55,7 +55,7 @@ func TestTheModuleTakesADeliveryAskBeforeAnEarlierCheck(t *testing.T) {
// 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")
subject, _ = sdkstep.AskSubjectBy(a.Language, a.Kind, "mesh-delivery-runner")
}
if _, err := js.Publish(ctx, subject, raw); err != nil {
t.Fatal(err)
@@ -87,7 +87,7 @@ func TestTheModuleTakesADeliveryAskBeforeAnEarlierCheck(t *testing.T) {
ended := 0
states.mu.Lock()
for _, a := range []sdkstep.StepAsk{first, check} {
asker := "mesh-delivery-checker" // a named ask's step is keyed under its asker, main's under its node (§481)
asker := "mesh-delivery-runner" // a named ask's step is keyed under its asker, main's under its node (§481)
if a.Kind == sdkstep.AskDelivery {
asker = ""
}
@@ -198,7 +198,7 @@ func TestACheckAsksDigestIsTheToolsAnswerInTheCall(t *testing.T) {
}
}
ask := m.askSteps(steps)
a := sdkstep.StepAsk{ID: sdkstep.NewID(), Kind: sdkstep.AskCheck, Language: sdkstep.AskGo, Asker: "mesh-delivery-checker",
a := sdkstep.StepAsk{ID: sdkstep.NewID(), Kind: sdkstep.AskCheck, Language: sdkstep.AskGo, Asker: "mesh-delivery-runner",
At: time.Now(), Check: &sdkstep.CheckJob{Fetch: sdkstep.Fetch{Repository: "novox/x", Commit: askCommit}, Levels: []string{sdkstep.LevelUnit}}}
out, err := steprun.RunAsk(context.Background(), ask, a)
if err != nil {
@@ -166,14 +166,15 @@ func TestAComposeAskFailsLoudly(t *testing.T) {
}
// Design 47 G §615: the module reads the manifests a compose ask names from the catalog graph's entry, by the seat's verb
// entry, and invokes no tool of the delivery indexer. 1921 (B0): a run's input is asked of the checker seat's verb input, as
// the manifest invokes it, and no state of the checker's inputs is read (ADR 0596 §2).
// entry, and invokes no tool of the delivery indexer. 1921 (B0): a run's input is asked of the seat mesh-wants' verb input, as
// the manifest invokes it, and no state of the checker's inputs is read (ADR 0596 §2); the seat mesh-delivery-checker is no
// longer invoked (design 47 H §764, H-A-57).
func TestTheModuleReadsTheCatalogEntries(t *testing.T) {
m := readManifest(t)
if !slices.Contains(m.Invokes, catalogclient.EntryVerb) || slices.ContainsFunc(m.Invokes, func(i string) bool { return strings.HasPrefix(i, "mesh-delivery-indexer") }) {
t.Errorf("invokes = %v: want %s and no tool of the indexer", m.Invokes, catalogclient.EntryVerb)
}
if !slices.Contains(m.Invokes, runInputVerb) || slices.Contains(m.Reads, "mesh-delivery-checker.inputs") {
if !slices.Contains(m.Invokes, runInputVerb) || slices.ContainsFunc(m.Invokes, func(i string) bool { return strings.HasPrefix(i, "seat:mesh-delivery-checker") }) || slices.Contains(m.Reads, "mesh-delivery-checker.inputs") {
t.Errorf("invokes = %v, reads = %v: want %s invoked and no inputs state read", m.Invokes, m.Reads, runInputVerb)
}
}
@@ -116,7 +116,7 @@ type Module struct {
// request names each manifest it gives by digest with (compose.go, design 47 G §615); GoModCache, when set, is the Go module cache in place of Cache's (a test).
ReadEntry func(fingerprint string) (meshcat.CatalogEntry, error)
// AskInput asks a seat verb the module invokes (module.json) as the runtime calls it (stdio.Ask): the verb a run ask's
// input names, answering the input by its digest (meshdeliverycheckerclient.ReadInput).
// input names, answering the input by its digest (the seat mesh-wants' verb input).
AskInput func(key string, body any) (json.RawMessage, error)
// PlaceHead, when set, lays a run's head at a directory instead of fetching it (a test).
PlaceHead func(ctx context.Context, h sdkstep.RunHead, dir string) error
@@ -63,7 +63,7 @@ func TestACheckAskReachesTheTestStepPastItsPackages(t *testing.T) {
}
}
}
a := sdkstep.StepAsk{ID: sdkstep.NewID(), Kind: sdkstep.AskCheck, Language: sdkstep.AskGo, Asker: "mesh-delivery-checker",
a := sdkstep.StepAsk{ID: sdkstep.NewID(), Kind: sdkstep.AskCheck, Language: sdkstep.AskGo, Asker: "mesh-delivery-runner",
At: time.Now(), Check: &sdkstep.CheckJob{Fetch: sdkstep.Fetch{Repository: "novox/x", Commit: askCommit}, Levels: []string{sdkstep.LevelUnit}}}
out, err := steprun.RunAsk(context.Background(), m.askSteps(steps), a)
got := ""
+5 -10
View File
@@ -19,7 +19,7 @@ import (
"path/filepath"
"strings"
checker "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker"
meshwants "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants"
sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/steprun"
)
@@ -50,22 +50,21 @@ func (m *Module) run(ctx context.Context, fetch steprun.StepFunc, a sdkstep.Step
}
// inputOf is the input a run names, asked of the seat verb the ask names (module.json invokes it) and checked against
// its digest and size: bytes that are not the input named refuse the ask. A verb marked chunks (the seat mesh-catalog's
// its digest and size: bytes that are not the input named refuse the ask. A verb marked chunks (the seats mesh-catalog's and mesh-wants'
// input, of any size) is asked by the plain seat call: the tool runner receives the chunks and hands this module the
// whole file in the member `file` (design 47 G A-237, A-249); another seat's input answers its bytes in `input`.
// whole file in the member `file` (design 47 G A-237, A-249).
func (m *Module) inputOf(in sdkstep.RunInput) ([]byte, error) {
if m.AskInput == nil {
return nil, errors.New("this module asks no seat verb for a run's input")
}
// A verb that does not answer fails the step; an answer that is not the input named refuses the ask.
raw, err := m.AskInput(in.Verb, checker.InputInput{Digest: in.Digest})
raw, err := m.AskInput(in.Verb, meshwants.InputInput{Digest: in.Digest})
if err != nil {
return nil, fmt.Errorf("asking %s for the input %s: %w", in.Verb, in.Digest, err)
}
var a struct {
Digest string `json:"digest"`
File string `json:"file"`
Input string `json:"input"`
}
if err := json.Unmarshal(raw, &a); err != nil {
return nil, steprun.Refuse("%s answered no input for %s: %v", in.Verb, in.Digest, err)
@@ -73,11 +72,7 @@ func (m *Module) inputOf(in sdkstep.RunInput) ([]byte, error) {
if a.Digest != in.Digest {
return nil, steprun.Refuse("%s answered the input %q, asked %s", in.Verb, a.Digest, in.Digest)
}
text := a.File
if text == "" {
text = a.Input
}
body, err := base64.StdEncoding.DecodeString(text)
body, err := base64.StdEncoding.DecodeString(a.File)
if err != nil {
return nil, steprun.Refuse("%s answered the input %s in no base64: %v", in.Verb, in.Digest, err)
}
@@ -16,8 +16,7 @@ import (
"github.com/nats-io/nats.go"
"github.com/nats-io/nats.go/jetstream"
checkerclient "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient"
checker "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker"
meshwants "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants"
sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/steprun"
"git.novox.be/novox/mesh-sdk/go/testbus"
@@ -25,7 +24,7 @@ import (
// 1921/C3: a run ask put on the Go build seat's check stream is pulled by the module started whole on the real bus and
// answered on its step key <node>.<ask id>: the program, run shut off over its heads and its input (asked by digest of the
// seat verb the ask names, which a fake checker answers on the bus as the checker's verb input does), answers its last
// seat verb the ask names, which a fake assigner answers on the bus as the seat's verb input does), answers its last
// line and exit; a program cannot write under its heads, and one
// that dials the machine's network is shut off, and its key ends failed, the answer kept (design 47 G A-290).
func TestARunAskIsAnsweredOnTheBusAndItsProgramIsShutOff(t *testing.T) {
@@ -63,13 +62,13 @@ func TestARunAskIsAnsweredOnTheBusAndItsProgramIsShutOff(t *testing.T) {
}
m.PlaceHead = func(_ context.Context, h sdkstep.RunHead, dir string) error { return os.MkdirAll(dir, 0o700) }
body := `{"v":1}`
// The checker's verb input on the bus, and the module asking it as the runtime calls a seat verb it invokes.
// The wants seat's verb input on the bus, and the module asking it as the runtime calls a seat verb it invokes.
asked := make(chan string, 4)
sub, err := nc.Subscribe("mesh.seat.mesh-delivery-checker.tool.input", func(msg *nats.Msg) {
var ask checker.InputInput
sub, err := nc.Subscribe("mesh.seat.mesh-wants.tool.input", func(msg *nats.Msg) {
var ask meshwants.InputInput
_ = json.Unmarshal(msg.Data, &ask)
asked <- ask.Digest
reply, _ := json.Marshal(map[string]any{"result": checkerclient.InputAnswerOf([]byte(body))})
reply, _ := json.Marshal(map[string]any{"result": inputAnswerOf([]byte(body))})
_ = msg.Respond(reply)
})
if err != nil {
@@ -81,7 +80,7 @@ func TestARunAskIsAnsweredOnTheBusAndItsProgramIsShutOff(t *testing.T) {
return nil, errors.New("asked " + key)
}
data, _ := json.Marshal(b)
msg, err := nc.Request("mesh.seat.mesh-delivery-checker.tool.input", data, 5*time.Second)
msg, err := nc.Request("mesh.seat.mesh-wants.tool.input", data, 5*time.Second)
if err != nil {
return nil, err
}
@@ -15,8 +15,7 @@ import (
"testing"
"time"
checkerclient "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient"
checker "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker"
meshwants "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants"
sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/composer"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/steprun"
@@ -25,17 +24,24 @@ import (
const runCommit = "5555555555555555555555555555555555555555"
// runInputVerb is the seat verb a run ask's input is served on, as the checker names it in the ask.
const runInputVerb = checkerclient.InputVerb
// runInputVerb is the seat verb a run ask's input is served on, as the ask names it.
const runInputVerb = "seat:mesh-wants.input"
// answersInput is a seat verb serving body by its digest, as the checker's verb input answers (sdkstep.RunInputAnswer).
// inputAnswerOf is the seat mesh-wants's answer of the input body as the tool runner hands it over: the digest and
// the whole file.
func inputAnswerOf(body []byte) map[string]any {
sum := sha256.Sum256(body)
return map[string]any{"digest": hex.EncodeToString(sum[:]), "chunks": 1, "file": base64.StdEncoding.EncodeToString(body)}
}
// answersInput is a seat verb serving body by its digest, as the seat mesh-wants' verb input answers.
func answersInput(body string) func(key string, b any) (json.RawMessage, error) {
return func(key string, b any) (json.RawMessage, error) {
ask, _ := b.(checker.InputInput)
ask, _ := b.(meshwants.InputInput)
if sum := sha256.Sum256([]byte(body)); key != runInputVerb || ask.Digest != hex.EncodeToString(sum[:]) {
return nil, fmt.Errorf("the checker keeps no input %s", ask.Digest)
return nil, fmt.Errorf("the assigner keeps no input %s", ask.Digest)
}
return json.Marshal(checkerclient.InputAnswerOf([]byte(body)))
return json.Marshal(inputAnswerOf([]byte(body)))
}
}
@@ -45,7 +51,7 @@ func runAskOf(t *testing.T, body string) sdkstep.StepAsk {
if err != nil {
t.Fatal(err)
}
return sdkstep.StepAsk{ID: sdkstep.NewID(), Kind: sdkstep.AskCheck, Language: sdkstep.AskGo, Asker: "mesh-delivery-checker", At: time.Now(),
return sdkstep.StepAsk{ID: sdkstep.NewID(), Kind: sdkstep.AskCheck, Language: sdkstep.AskGo, Asker: "mesh-delivery-runner", At: time.Now(),
Run: &sdkstep.RunJob{Program: sdkstep.RunProgram{Repository: "novox/mesh-delivery", Commit: runCommit, Dir: ".", Package: "./cmd/prog"},
Heads: []sdkstep.RunHead{{Repository: "novox/mesh-sdk", Commit: runCommit}, {Repository: "novox/mesh-host", Commit: runCommit}},
Input: in, Args: []string{"-seats"}}}
@@ -112,7 +118,7 @@ func TestAKeptProgramIsRunOverItsHeadsAndInput(t *testing.T) {
m.Inside, m.Run = true, StepRunner(t.TempDir())
// An input other than the one named is refused, naming it; one the verb does not answer fails the step, saying why.
m.AskInput = func(_ string, b any) (json.RawMessage, error) {
return json.Marshal(checker.InputAnswer{Digest: b.(checker.InputInput).Digest, Input: base64.StdEncoding.EncodeToString([]byte(`{"other":1}`))})
return json.Marshal(map[string]any{"digest": b.(meshwants.InputInput).Digest, "chunks": 1, "file": base64.StdEncoding.EncodeToString([]byte(`{"other":1}`))})
}
if _, err := m.run(context.Background(), fetch, a); err == nil || !strings.Contains(err.Error(), "is not the one the ask names") || !errors.As(err, new(*steprun.Refusal)) {
t.Errorf("a wrong input: %v", err)
@@ -182,22 +188,22 @@ func TestARunsInputIsAskedOfTheVerbTheAskNames(t *testing.T) {
// answersInputOn is answersInput for the seat verb wanted.
func answersInputOn(wanted, body string) func(key string, b any) (json.RawMessage, error) {
return func(key string, b any) (json.RawMessage, error) {
ask, _ := b.(checker.InputInput)
ask, _ := b.(meshwants.InputInput)
if sum := sha256.Sum256([]byte(body)); key != wanted || ask.Digest != hex.EncodeToString(sum[:]) {
return nil, fmt.Errorf("%s keeps no input %s", key, ask.Digest)
}
return json.Marshal(checkerclient.InputAnswerOf([]byte(body)))
return json.Marshal(inputAnswerOf([]byte(body)))
}
}
// Design 47 G A-237, A-249: the input of a run is of any size: the mesh-catalog seat's verb input, marked chunks, is asked by the
// Design 47 G A-237, A-249: the input of a run is of any size: the mesh-wants seat's verb input, marked chunks, is asked by the
// plain seat call and answers {digest, chunks, file}, the file whole as the tool runner received it; the bytes are checked.
func TestARunsInputOfAnySizeIsTakenFromTheChunkedVerb(t *testing.T) {
body := strings.Repeat("0123456789", 300000) // 3 MB
sum := sha256.Sum256([]byte(body))
in := sdkstep.RunInput{Verb: "seat:mesh-catalog.input", Digest: hex.EncodeToString(sum[:]), Size: len(body)}
m := &Module{AskInput: func(key string, b any) (json.RawMessage, error) {
if ask, _ := b.(checker.InputInput); key != in.Verb || ask.Digest != in.Digest {
if ask, _ := b.(meshwants.InputInput); key != in.Verb || ask.Digest != in.Digest {
return nil, fmt.Errorf("%s keeps no input %v", key, b)
}
return json.Marshal(map[string]any{"digest": in.Digest, "chunks": 6, "file": base64.StdEncoding.EncodeToString([]byte(body))})
+1 -2
View File
@@ -9,10 +9,9 @@ require (
git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds v0.0.0-00010101000000-000000000000
git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/containerimageregistryclient v0.0.0-00010101000000-000000000000
git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient v0.0.0-00010101000000-000000000000
git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient v0.0.0-00010101000000-000000000000
git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/containerimageregistry v0.0.0-00010101000000-000000000000
git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog v0.0.0-00010101000000-000000000000
git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker v0.0.0-00010101000000-000000000000
git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants v0.0.0-00010101000000-000000000000
git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/nodebuildgo v0.0.0-00010101000000-000000000000
git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk v0.0.0-00010101000000-000000000000
git.novox.be/novox/mesh-sdk/go v0.0.0-00010101000000-000000000000
-1
View File
@@ -43,7 +43,6 @@
"seat:oci-artifact-registry.publish-part",
"seat:go-package-registry.publish",
"seat:go-package-registry.publish-part",
"seat:mesh-delivery-checker.input",
"seat:mesh-catalog.input",
"seat:mesh-wants.input",
"seat:mesh-module-assigner.assignments",
@@ -1,7 +1,7 @@
package main
// What this module keeps on the bus, announced from its code (novox/hq ADR 0495 §2 §5; issue 1790): every state it
// keeps, each readable by others, since another module reads each today (the builder, the checker and the indexer read toolchains; the builder and the checker read steps; gitea reads keys). A state of its own that it
// keeps, each readable by others, since another module reads each today (the builder and the indexer read toolchains; the builder reads steps; gitea reads keys). A state of its own that it
// did not name here is refused at the call (stdio.Keeps).
import (
@@ -32,7 +32,7 @@ func fakeSteps(calls *[]string) []StepTool {
}
func nodeAsk(kind string) sdkstep.StepAsk {
a := sdkstep.StepAsk{ID: sdkstep.NewID(), Kind: kind, Language: sdkstep.AskNode, Asker: "mesh-delivery-checker", At: time.Now()}
a := sdkstep.StepAsk{ID: sdkstep.NewID(), Kind: kind, Language: sdkstep.AskNode, Asker: "mesh-delivery-runner", At: time.Now()}
fetch := sdkstep.Fetch{Repository: "novox/mesh-catalog", Commit: askCommit}
if kind == sdkstep.AskDelivery {
a.Asker = "mesh-delivery-builder"