BM4: each build module keeps a run's test output in its outputs objects

The Go build module's level answers its text in output (test2json's Output
lines), the Node build module's what its commands wrote; the delivery SDK's step
run keeps it as <node>.<ask> in the module's outputs objects, which each module
asks for in requires (1 GiB, kept 7 days) and reads through the verb output at
form 2. Each module's kit test runs the SDK's SeatVerbs.

Builds: design 47 H2 §791, §820; H-A-412 (1), H-A-412 second addendum (a), H-A-421, H-A-434
This commit is contained in:
2026-11-22 01:32:40 +01:00
parent 46990669de
commit 1697b7041c
15 changed files with 154 additions and 27 deletions
@@ -75,6 +75,10 @@ type TestResult struct {
// By is the build module and the SDK it was built with (sdkstep.By): the checker names it when a failure hides
// its cause.
By string `json:"by,omitempty"`
// Output is the level's text (design 47 H2 §791, H-A-412 second addendum (a)): what each command the level ran wrote,
// its stdout then its stderr, in the order they ran. The delivery SDK's step run takes it out of the answer and keeps
// it as the run's output in the outputs objects; it is never part of a check's answer.
Output string `json:"output,omitempty"`
// OutOfStep are the generated TypeScript files of a contracts module out of step with the seat generator (CAT-BN2,
// steprun.OutOfStep): the unit level fails on any, Why naming each. Absent when none is.
OutOfStep []string `json:"out-of-step,omitempty"`
@@ -156,6 +160,7 @@ func (m *Module) testLevel(ctx context.Context, args map[string]any) (*TestResul
}
var check, run time.Duration
var failed []Failure
var text strings.Builder
tested := false
for _, tg := range targets {
scripts, err := packageScripts(tg.dir)
@@ -176,6 +181,8 @@ func (m *Module) testLevel(ctx context.Context, args map[string]any) (*TestResul
}
// a command that could not start is not a verdict: the step fails. One that ran and said no is.
ran := func(name string, r forgekey.Ran, report string) error {
text.WriteString(r.Stdout)
text.WriteString(r.Stderr)
if r.Err != "" {
return fmt.Errorf("%s could not be run: status %d %s: %s", name, r.Status, r.Err, firstLine(r.Stderr))
}
@@ -225,7 +232,7 @@ func (m *Module) testLevel(ctx context.Context, args map[string]any) (*TestResul
}
return res, nil
}
res.Failed = failed
res.Failed, res.Output = failed, text.String()
var why []string
for _, f := range failed {
why = append(why, failureWhy(f))
@@ -111,6 +111,7 @@ func TestTheIntegrationLevelRunsItsScriptAndReportsSetupAndRunningApart(t *testi
workspaceWith(t, work, map[string]string{"index.ts": `export const a = 1;`, "tsconfig.json": `{}`,
"package.json": `{"scripts":{"test":"x","test:integration":"node --test int"}}`})
f.cost["tsc"], f.cost["npm"] = 2*time.Second, 40*time.Second
f.answer["npm"] = forgekey.Ran{Stdout: "ok 1 - joins\n", Stderr: "(node) warning\n"}
out, err := m.test(context.Background(), testArgs("integration"))
if err != nil {
t.Fatal(err)
@@ -127,6 +128,10 @@ func TestTheIntegrationLevelRunsItsScriptAndReportsSetupAndRunningApart(t *testi
if !slices.Contains(last.env, "MESH_TEST_LEVEL_BOUND=1m0s") {
t.Errorf("the integration script ran with %v, not the level's bound MESH_TEST_LEVEL_BOUND=1m0s", last.env)
}
// Design 47 H2 §791, H-A-412 (a): the level's answer carries its text in output, what its commands wrote.
if !strings.HasSuffix(r.Output, "ok 1 - joins\n(node) warning\n") {
t.Errorf("the level's output is %q, want the script's stdout then its stderr", r.Output)
}
if tsc := f.calls[0]; strings.Join(tsc.args[1:], " ") != "--noEmit -p ." {
t.Errorf("a package with a tsconfig was checked with %s", joined(tsc))
}
@@ -3,13 +3,16 @@ package main
import (
"context"
"encoding/json"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/steprun"
"errors"
"os"
"path/filepath"
"strings"
"testing"
"time"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/steprun"
"git.novox.be/novox/mesh-sdk/go/buscalls"
buildrun "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildrun"
sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/steprun/conformance"
@@ -81,6 +84,26 @@ func TestTheStepsSayAFailedNetworkAsATransportFault(t *testing.T) {
// every step ask the runner sends it is refused ("this build module says no step's end"), as the first live pipeline met.
func TestTheStepsCanSayAStepsEnd(t *testing.T) {
conformance.StepEnds(t, (&Module{Node: "kitnode"}).askSteps(nil))
// Design 47 H2 §791, §801, H-A-412, H-A-421: the seat's verbs current, output and answer keep the build-step part's form 2,
// and a pipeline step's run output is kept in the module's outputs objects and read back through output.
m := &Module{Node: "kitnode", Capacity: func() int { return 1 }, Outputs: kitObjects{}}
conformance.SeatVerbs(t, Seat, m.SeatTools(m.Puller(nil, steprun.NewFakeAsks())), m.askSteps(nil))
}
// kitObjects is an outputs store in memory, for the kit's SeatVerbs.
type kitObjects map[string][]byte
func (k kitObjects) Put(name string, data []byte, _ string) (buscalls.ObjectInfo, error) {
k[name] = data
return buscalls.ObjectInfo{Name: name}, nil
}
func (k kitObjects) Get(name string) (buscalls.ObjectData, error) {
d, ok := k[name]
if !ok {
return buscalls.ObjectData{}, errors.New("object not found")
}
return buscalls.ObjectData{Data: d}, nil
}
// A-489c (A-489a): the module's puller counts the runs its steps state says started, not the bus's deliveries (an ask given back before
@@ -290,8 +290,9 @@ func TestTheModuleRequiresNodeToolsItPullsThrough(t *testing.T) {
}
}
// Design 47 G A-254, A-313, A-314: the module keeps a run's answer over what step-ended carries inline in the steps state's own
// objects store, sized in `requires` by the state option objects-max-mib, and serves it through the verb output.
// Design 47 G A-254, A-313, A-314: the module keeps a step's end over what step-ended carries inline in the steps state's own
// objects store, sized in `requires` by the state option objects-max-mib, and serves it through the verb answer (H2 H-A-412
// addendum); and a run's test output in its outputs objects, 1 GiB kept 7 days, read by the verb output (H2 §791, §820).
func TestManifestRequiresTheStepsStateWithItsObjectsStore(t *testing.T) {
raw, err := os.ReadFile(moduleDir + "/module.json")
if err != nil {
@@ -303,11 +304,12 @@ func TestManifestRequiresTheStepsStateWithItsObjectsStore(t *testing.T) {
if err := json.Unmarshal(raw, &doc); err != nil {
t.Fatal(err)
}
want := map[string]any{"name": "steps", "storage": "key-value", "template": "state", "options": map[string]any{"ttl-seconds": float64(172800), "objects-max-mib": float64(256)}}
for _, r := range doc.Requires {
if reflect.DeepEqual(r, want) {
return
for _, want := range []map[string]any{
{"name": "steps", "storage": "key-value", "template": "state", "options": map[string]any{"ttl-seconds": float64(172800), "objects-max-mib": float64(256)}},
{"name": "outputs", "storage": "object-store", "template": "objects", "options": map[string]any{"max-mib": float64(1024), "max-age-days": float64(7)}},
} {
if !slices.ContainsFunc(doc.Requires, func(r any) bool { return reflect.DeepEqual(r, any(want)) }) {
t.Errorf("requires %v lack %v", doc.Requires, want)
}
}
t.Errorf("requires %v lack %v", doc.Requires, want)
}