S1: the step runner says a done build's import set as imports-reported

AskSteps gains SayImports, called once at the end of a build that read its imports
(any branch; the indexer judges the fingerprint), with the module, the fingerprint
asked, the commit and the imports; SayImportsOn publishes it on
mesh.seat.<seat>.event.imports-reported.<node> (buildstep.ImportsReportedSubject),
id per module and fingerprint. A failed say is journalled and leaves the answer
standing; BuildAnswer.Imports stays as the say's input.

Builds: design 47 H2 H-A-517, H-A-518, H-A-532 DQ-2, DQ-7, DMC-2
This commit is contained in:
2026-11-23 11:02:25 +01:00
parent 9b81842090
commit 286f2b668d
5 changed files with 90 additions and 3 deletions
@@ -368,6 +368,13 @@ func TestAskSubjectsStreamsAndKeys(t *testing.T) {
if l, n, err := ParseStepEndedSubject(subj); err != nil || l != AskNode || n != "ace" {
t.Errorf("parse %q: %s %s %v", subj, l, n, err)
}
// Design 47 H2 H-A-532 DQ-2: a build's import set is said on its own node's subject of the seat.
if s, err := ImportsReportedSubject(AskNode, "ace"); err != nil || s != "mesh.seat.node-build-node.event.imports-reported.ace" {
t.Errorf("imports-reported subject %q %v", s, err)
}
if _, err := ImportsReportedSubject(AskGo, "a.b"); err == nil {
t.Error("an imports-reported subject of a dotted node")
}
end, err := EndOf(stepAsk(), "ace", OutcomePassed)
if err != nil {
t.Fatal(err)
@@ -337,6 +337,19 @@ func StepEndedSubject(language, node string) (string, error) {
return "mesh.seat." + seat + ".event.step-ended." + node, nil
}
// ImportsReportedSubject is where the holder of a language's build seat on node says a build's import set, the event
// imports-reported of the part build-step (design 47 H2 H-A-517, H-A-532 DQ-2).
func ImportsReportedSubject(language, node string) (string, error) {
seat, err := BuildSeat(language)
if err != nil {
return "", err
}
if err := checkNode(node); err != nil {
return "", err
}
return "mesh.seat." + seat + ".event.imports-reported." + node, nil
}
// ParseStepEndedSubject is the inverse of StepEndedSubject.
func ParseStepEndedSubject(subject string) (language, node string, err error) {
rest, ok := strings.CutPrefix(subject, "mesh.seat.node-build-")
@@ -11,6 +11,7 @@ import (
"sort"
"strings"
nodebuildgo "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/nodebuildgo"
sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
trunk "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/trunk"
)
@@ -60,6 +61,11 @@ type AskSteps struct {
// event step-ended on that node's subject (sdkstep.StepEndedSubject), under the ask's id. Nil runs no step ask.
Node string
SayStep func(end sdkstep.StepEnded) error
// SayImports says a build's import set as the seat's event imports-reported on Node's subject (SayImportsOn): a
// build that read its imports says them at its end, whatever its branch, and the indexer keeps the set only for the
// fingerprint main's modules state holds (design 47 H2 H-A-517, H-A-532 DQ-2, DMC-2). A say that fails leaves the
// build's answer standing and is said in the journal. Nil says none.
SayImports func(nodebuildgo.ImportsReported) error
// Outputs are the holder's outputs objects (OutputsStore), where a test step keeps its run's output as `<node>.<ask
// id>` (design 47 H2 §791, H-A-412), which the seat's verb output reads (OutputTool). Nil keeps none, said in the journal.
Outputs OutputObjects
@@ -324,10 +330,30 @@ func (s AskSteps) build(ctx context.Context, job sdkstep.BuildJob, version strin
return nil, err
}
answer.Imports = read.Imports
s.sayImports(job, read.Imports)
}
return answer, nil
}
// sayImports says the import set a done build read (design 47 H2 H-A-517, H-A-532 DQ-2): the module, the fingerprint
// it was asked for, its commit and the imports, an empty list when its programs import no mesh package. A failed say is
// said in the journal and never fails the build (principle 3: loud, not lost).
func (s AskSteps) sayImports(job sdkstep.BuildJob, imports []string) {
if s.SayImports == nil {
return
}
body := nodebuildgo.ImportsReported{Node: s.Node, Module: job.Module, Fingerprint: job.Fp, Imports: imports}
if job.Fetch != nil {
body.Commit = job.Fetch.Commit
}
if body.Imports == nil {
body.Imports = []string{}
}
if err := s.SayImports(body); err != nil && s.Logf != nil {
s.Logf("the import set of %s at %s was not said: %v", job.Module, job.Fp, err)
}
}
func (s AskSteps) check(ctx context.Context, job sdkstep.CheckJob) (any, error) {
return s.checkTexts(ctx, job, nil)
}
@@ -84,8 +84,19 @@ func TestRunAskBuilds(t *testing.T) {
r.calls = append(r.calls, "imports "+string(b))
return map[string]any{"imports": []string{"git.novox.be/novox/mesh-sdk/go/announce", "git.novox.be/novox/mesh-sdk/go/health"}}, nil
}
// Design 47 H2 H-A-517, H-A-532 DQ-2: a done build that read its imports says them once, as imports-reported on the
// seat's subject of its node; a failed build says none, and a say that fails leaves the answer standing, journalled.
var said []string
var sayErr error
var journal []string
steps.Node, steps.Logf = "anchor", func(f string, a ...any) { journal = append(journal, fmt.Sprintf(f, a...)) }
steps.SayImports = SayImportsOn(sdkstep.AskGo, "anchor", func(subject string, body any, id string) error {
b, _ := json.Marshal(body)
said = append(said, subject+" "+id+" "+string(b))
return sayErr
})
// Issue 1585: the ask's package versions reach the fetch, and the ask's own fetch arguments stay as they were.
a := ask(sdkstep.BuildJob{Module: "m", Path: "modules/m", Publish: true,
a := ask(sdkstep.BuildJob{Module: "m", Path: "modules/m", Publish: true, Fp: "fp-1",
Fetch: &sdkstep.Fetch{Repository: "novox/x", Commit: runCommit},
Artifacts: []sdkstep.AskArtifact{{Artifact: "base", From: "registry/b@sha256:00"}, {Artifact: "bundle"}, {Artifact: "lib", Seat: "go-package-registry", Version: "v0.1.15"}}})
a.Packages = sdkstep.PackageVersions{"git.novox.be/novox/mesh-sdk/go": runCommit}
@@ -101,8 +112,8 @@ func TestRunAskBuilds(t *testing.T) {
got := strings.Join(r.calls, "\n")
want := `copy {"artifact":"base","from":"registry/b@sha256:00","module":"m"}
fetch {"commit":"` + runCommit + `","packages":{"git.novox.be/novox/mesh-sdk/go":"` + runCommit + `"},"repository":"novox/x"}
build {"artifact":"bundle","module":"modules/m","publish":true,"version":"0.1.16","workspace":"/w/1"}
build {"artifact":"lib","module":"modules/m","publish":true,"seat":"go-package-registry","version":"v0.1.15","workspace":"/w/1"}
build {"artifact":"bundle","fp":"fp-1","module":"modules/m","publish":true,"version":"0.1.16","workspace":"/w/1"}
build {"artifact":"lib","fp":"fp-1","module":"modules/m","publish":true,"seat":"go-package-registry","version":"v0.1.15","workspace":"/w/1"}
imports {"module":"modules/m","workspace":"/w/1"}`
if got != want {
t.Fatalf("calls:\n%s\nwant:\n%s", got, want)
@@ -117,6 +128,19 @@ imports {"module":"modules/m","workspace":"/w/1"}`
if !slices.Equal(answer.Imports, []string{"git.novox.be/novox/mesh-sdk/go/announce", "git.novox.be/novox/mesh-sdk/go/health"}) {
t.Errorf("the answer's imports are %v", answer.Imports)
}
wantSaid := `mesh.seat.node-build-go.event.imports-reported.anchor imports-reported.m.fp-1 {"commit":"` + runCommit +
`","fingerprint":"fp-1","imports":["git.novox.be/novox/mesh-sdk/go/announce","git.novox.be/novox/mesh-sdk/go/health"],"module":"m","node":"anchor"}`
if len(said) != 1 || said[0] != wantSaid {
t.Errorf("said %q, want once %q", said, wantSaid)
}
said, sayErr = nil, errors.New("no responders")
if out, err := RunAsk(context.Background(), steps, a); err != nil || len(out.(sdkstep.BuildAnswer).Artifacts) != 3 {
t.Errorf("a failed say failed the build: %v, %v", out, err)
}
if len(said) != 1 || len(journal) != 1 || !strings.Contains(journal[0], "the import set of m at fp-1 was not said: no responders") {
t.Errorf("a failed say: said %q, journal %q; want it said in the journal", said, journal)
}
said, sayErr = nil, nil
// Design 47 H2 H-A-482 addendum (a): a failed build keeps its error text, as the build module bounded it, as the ask's
// output object, which the verb output answers.
@@ -130,6 +154,9 @@ imports {"module":"modules/m","workspace":"/w/1"}`
if _, err := RunAsk(context.Background(), steps, failed); err == nil {
t.Fatal("a failed build answered no error")
}
if len(said) != 0 {
t.Errorf("a failed build said its imports: %q", said)
}
got2, err := readOutput(outputs, "ace", failed.ID, nil)
if err != nil || !strings.Contains(got2.Output, `bundle: esbuild for code: status 1 | ✘ [ERROR] Could not resolve "./missing"`) || got2.Size != len(got2.Output) {
t.Errorf("the failed build's output = %+v, %v; want its error text kept", got2, err)
@@ -9,6 +9,7 @@ import (
"strings"
"time"
nodebuildgo "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/nodebuildgo"
sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
stdio "git.novox.be/novox/mesh-sdk/go"
)
@@ -357,6 +358,19 @@ func SayStepOn(language, node string, publish func(subject string, body any, id
}
}
// SayImportsOn is AskSteps.SayImports on a language's build seat of node: the event imports-reported published with
// publish (stdio.SeatPublish) on sdkstep.ImportsReportedSubject, under an id per module and fingerprint, so a build said
// again is kept once (design 47 H2 H-A-517, H-A-532 DQ-2).
func SayImportsOn(language, node string, publish func(subject string, body any, id string) error) func(nodebuildgo.ImportsReported) error {
return func(r nodebuildgo.ImportsReported) error {
subject, err := sdkstep.ImportsReportedSubject(language, node)
if err != nil {
return err
}
return publish(subject, r, "imports-reported."+r.Module+"."+r.Fingerprint)
}
}
// SayOn is a holder's Puller.Say: an event of the language's build seat published on that seat's subject of node with
// publish (stdio.SeatPublish), `mesh.seat.node-build-<language>.event.<event>.<node>`.
func SayOn(language, node string, publish func(subject string, body any, id string) error) func(event string, body any, id string) error {