C1c-2b: the three build modules keep a run's answer in an outputs store and serve the verb output

Each module's puller keeps an answer over what step-ended carries inline in the object store `outputs` its manifest requires
(template objects, 256 MiB) and its tools serve `<seat>.output` from it; the manifest claims the verb.

Builds: design 47 G A-254, A-257

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
2026-11-12 09:39:54 +01:00
parent 5b77eb18f8
commit 333e3c21a5
18 changed files with 92 additions and 17 deletions
@@ -91,7 +91,7 @@ func (m *Module) Puller(steps []StepTool, source steprun.AskSource) *steprun.Pul
if m.SayEvent != nil {
say = steprun.SayOn(sdkstep.AskGo, m.Node, m.SayEvent)
}
return &steprun.Puller{Source: source, Language: sdkstep.AskGo, Say: say, Callers: m.Callers, Node: m.Node, Put: m.Steps, PausePut: m.Pauses, Load: load, ForgetPause: m.ForgetPause, WatchPauses: m.WatchPauses, PauseKeys: m.ReadPauses.Keys,
return &steprun.Puller{KeepOutput: steprun.KeepOutputIn(m.Outputs), Source: source, Language: sdkstep.AskGo, Say: say, Callers: m.Callers, Node: m.Node, Put: m.Steps, PausePut: m.Pauses, Load: load, ForgetPause: m.ForgetPause, WatchPauses: m.WatchPauses, PauseKeys: m.ReadPauses.Keys,
Capacity: capacity, SettingsFile: settings, WatchConfig: watch, CoresPerStep: cores, BuildHours: hours, Logf: m.Say, Has: m.Has,
Run: func(ctx context.Context, a sdkstep.StepAsk) (any, error) {
if err := m.Check(ctx); err != nil {
@@ -112,7 +112,7 @@ func (m *Module) Puller(steps []StepTool, source steprun.AskSource) *steprun.Pul
// SeatTools are the seat's verbs on this node (ADR 0525 §10): what it runs, and its pause and resume.
func (m *Module) SeatTools(p *steprun.Puller) []stdio.Tool {
return append(steprun.SeatTools(Seat, "Go", p), m.stepsTool(), m.keptArtifactVerb())
return append(steprun.SeatTools(Seat, "Go", p), m.stepsTool(), m.keptArtifactVerb(), steprun.OutputTool(Seat, steprun.ReadOutputFrom(m.Outputs)))
}
// StepEndTool ends one step left running (issue 1890); the module's steps state is the one it reads and writes.
@@ -119,7 +119,7 @@ func mustJSON(v any) []byte { b, _ := json.Marshal(v); return b }
// the node's build capacity as a setting, with the builder's default; the seat's verbs are served as its tools.
func TestManifestClaimsTheGoBuildSeatAndReadsItsCapacity(t *testing.T) {
m := readManifest(t)
if len(m.Claims) != 1 || m.Claims[0].Name != Seat || !slices.Equal(m.Claims[0].Serves, []string{"current", "drop", "pause", "resume", "steps", "kept-artifact"}) {
if len(m.Claims) != 1 || m.Claims[0].Name != Seat || !slices.Equal(m.Claims[0].Serves, []string{"current", "drop", "pause", "resume", "steps", "kept-artifact", "output"}) {
t.Fatalf("claims = %+v", m.Claims)
}
if len(m.Reads) != 0 {
@@ -151,12 +151,14 @@ func TestManifestRequiresForgeAccountKeepsKeysAndTakesFilesFromTemplates(t *test
// detected-steps: the state of the verb steps (design 47 G §326, §414), asked by the template state.
// kept-builds: the builds kept for the artifact store's holder (keptbuilds.go), by the template objects (W12.5).
kept := map[string]any{"name": "kept-builds", "storage": "object-store", "template": "objects", "options": map[string]any{"max-mib": float64(1024)}}
// outputs: a run's answer over what step-ended carries inline, by the template objects (design 47 G A-254).
outputs := map[string]any{"name": "outputs", "storage": "object-store", "template": "objects", "options": map[string]any{"max-mib": float64(256)}}
detected := map[string]any{"name": "detected-steps", "storage": "key-value", "template": "state", "options": map[string]any{"history": float64(1)}}
// The findings are asked in requires as a part that is no foundation part asks them (design 47 G §529, A-30).
findings := map[string]any{"name": "findings", "storage": "key-value", "template": "state"}
findingEvents := map[string]any{"name": "finding-events", "storage": "stream", "template": "events", "options": map[string]any{
"events": []any{"finding-written.*", "finding-cleared.*", "findings-stated.*"}, "max-age-days": float64(7), "max-mib": float64(16)}}
if want := []any{detected, kept, "artifact-store", "forge-account", "go-toolchain", "go-package-registry", "node-tools", findings, findingEvents}; !reflect.DeepEqual(m.Requires, want) {
if want := []any{detected, kept, outputs, "artifact-store", "forge-account", "go-toolchain", "go-package-registry", "node-tools", findings, findingEvents}; !reflect.DeepEqual(m.Requires, want) {
t.Errorf("requires = %v, want %v", m.Requires, want)
}
keeps := false
@@ -15,6 +15,7 @@ import (
seat "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"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/steprun"
stdio "git.novox.be/novox/mesh-sdk/go"
"git.novox.be/novox/mesh-sdk/go/busstate"
)
@@ -69,6 +70,7 @@ func main() {
m.ReadManifest = askManifest
m.AskInput = stdio.Ask
m.KeptBuilds = busstate.ObjectsOf(KeptBuildsStore)
m.Outputs = busstate.ObjectsOf(steprun.OutputsStore)
m.Self = strings.TrimSpace(os.Getenv("MESH_MODULE"))
m.Probe = ProbeGo(m.Home, m.Cache)
m.Bubblewrap = ProbeBubblewrap
@@ -126,7 +126,9 @@ type Module struct {
// KeptBuilds is the object store of the builds kept for the artifact store's holder (keptbuilds.go); nil keeps none.
// Self is this module's name as the runtime launched it (MESH_MODULE), the first part of the store's name on the bus.
KeptBuilds KeptObjects
Self string
// Outputs is the object store of a run's answers over what step-ended carries inline (steprun.OutputsStore); nil keeps none.
Outputs steprun.OutputObjects
Self string
// SayToolchain says an event on a seat's subject (stdio.SeatPublish; nil says none, a test's); ToolchainProgram finds the go
// program whose digest the toolchain's is (exec.LookPath when nil).
+10 -1
View File
@@ -31,7 +31,8 @@
"pause",
"resume",
"steps",
"kept-artifact"
"kept-artifact",
"output"
]
}
],
@@ -104,6 +105,14 @@
"max-mib": 1024
}
},
{
"name": "outputs",
"storage": "object-store",
"template": "objects",
"options": {
"max-mib": 256
}
},
"artifact-store",
"forge-account",
"go-toolchain",
@@ -69,7 +69,7 @@ func (m *Module) Puller(steps []StepTool, source steprun.AskSource) *steprun.Pul
if m.SayEvent != nil {
say = steprun.SayOn(sdkstep.AskImage, m.Node, m.SayEvent)
}
return &steprun.Puller{Source: source, Language: sdkstep.AskImage, Say: say, Callers: m.Callers, Node: m.Node, Put: m.Steps, PausePut: m.Pauses, Load: load, ForgetPause: m.ForgetPause, WatchPauses: m.WatchPauses, PauseKeys: m.ReadPauses.Keys,
return &steprun.Puller{KeepOutput: steprun.KeepOutputIn(m.Outputs), Source: source, Language: sdkstep.AskImage, Say: say, Callers: m.Callers, Node: m.Node, Put: m.Steps, PausePut: m.Pauses, Load: load, ForgetPause: m.ForgetPause, WatchPauses: m.WatchPauses, PauseKeys: m.ReadPauses.Keys,
Capacity: capacity, SettingsFile: settings, WatchConfig: watch, CoresPerStep: cores, BuildHours: hours, Eligible: m.Eligible, Logf: m.Say,
Run: func(ctx context.Context, a sdkstep.StepAsk) (any, error) {
if err := m.Check(ctx); err != nil {
@@ -84,7 +84,7 @@ func (m *Module) Puller(steps []StepTool, source steprun.AskSource) *steprun.Pul
// SeatTools are the seat's verbs on this node (ADR 0525 §10).
func (m *Module) SeatTools(p *steprun.Puller) []stdio.Tool {
return append(steprun.SeatTools(Seat, "image", p), m.stepsTool(), m.keptArtifactVerb())
return append(steprun.SeatTools(Seat, "image", p), m.stepsTool(), m.keptArtifactVerb(), steprun.OutputTool(Seat, steprun.ReadOutputFrom(m.Outputs)))
}
// StepEndTool ends one step left running (issue 1890); the module's steps state is the one it reads and writes.
@@ -15,7 +15,7 @@ import (
// what the mesh fills reaches its files).
func TestTheModuleInvokesTheImageSeatAndHoldsNoRegistry(t *testing.T) {
var m struct {
Requires []string `json:"requires"`
Requires []any `json:"requires"`
Invokes []string `json:"invokes"`
Consumes []string `json:"consumes"`
}
@@ -35,7 +35,7 @@ func TestTheModuleInvokesTheImageSeatAndHoldsNoRegistry(t *testing.T) {
if !slices.Equal(m.Consumes, consumes) {
t.Errorf("consumes = %v, want %v", m.Consumes, consumes)
}
if slices.Contains(m.Requires, "artifact-store") {
if slices.Contains(m.Requires, any("artifact-store")) {
t.Errorf("requires = %v: the module holds no store", m.Requires)
}
if _, err := os.Stat(filepath.Join(moduleDir, "files", "registry")); !os.IsNotExist(err) {
@@ -145,7 +145,9 @@ func TestForgeFilesRenderFromTheBoundValuesInTheModulesOwnHome(t *testing.T) {
// template in the files/ archive (novox/hq ADR 0349 §2).
func TestManifestRequiresForgeAccountKeepsKeysAndTakesFilesFromTemplates(t *testing.T) {
m := readForgeManifest(t)
if want := []any{"forge-account", "rootless-image-build", "node-tools"}; !reflect.DeepEqual(m.Requires, want) {
// outputs: a run's answer over what step-ended carries inline, by the template objects (design 47 G A-254).
outputs := map[string]any{"name": "outputs", "storage": "object-store", "template": "objects", "options": map[string]any{"max-mib": float64(256)}}
if want := []any{outputs, "forge-account", "rootless-image-build", "node-tools"}; !reflect.DeepEqual(m.Requires, want) {
t.Errorf("requires = %v, want %v", m.Requires, want)
}
keeps := false
@@ -17,7 +17,9 @@ import (
reg "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/containerimageregistry"
seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/nodebuildimage"
sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/steprun"
stdio "git.novox.be/novox/mesh-sdk/go"
"git.novox.be/novox/mesh-sdk/go/busstate"
)
// The directories the module's manifest places outside its home (ADR 0466 §1): the workspaces, and buildah's image
@@ -65,6 +67,7 @@ func main() {
logf("announcing the states it keeps: %v", err)
os.Exit(1)
}
m.Outputs = busstate.ObjectsOf(steprun.OutputsStore)
steps := m.StepTools()
booted := time.Now()
puller := m.Puller(steps, nil)
@@ -4,6 +4,7 @@ import (
"encoding/json"
"os"
"path/filepath"
"reflect"
"regexp"
"slices"
"strings"
@@ -125,7 +126,7 @@ func TestManifestKeepsItsStatesClaimsItsBuildSeatAndDeclaresItsHealthTool(t *tes
if want := []string{"keys", MirrorWaitsState, "pauses", "steps"}; !slices.Equal(states, want) {
t.Errorf("state = %v, want %v", states, want)
}
if len(m.Claims) != 1 || m.Claims[0].Name != Seat || !slices.Equal(m.Claims[0].Serves, []string{"current", "drop", "pause", "resume", "steps", "kept-artifact"}) {
if len(m.Claims) != 1 || m.Claims[0].Name != Seat || !slices.Equal(m.Claims[0].Serves, []string{"current", "drop", "pause", "resume", "steps", "kept-artifact", "output"}) {
t.Errorf("claims = %v, want the seat %s alone", m.Claims, Seat)
}
raw, _ := os.ReadFile(filepath.Join(moduleDir, "module.json"))
@@ -211,3 +212,25 @@ func TestTheModuleRequiresNodeToolsItPullsThrough(t *testing.T) {
t.Errorf("requires %v lack node-tools", m.Requires)
}
}
// Design 47 G A-254: the module keeps a run's answer over what step-ended carries inline in an object store of its own, asked for
// in `requires` by the template objects, and serves it through the verb output.
func TestManifestRequiresTheOutputsStore(t *testing.T) {
raw, err := os.ReadFile(moduleDir + "/module.json")
if err != nil {
t.Fatal(err)
}
var doc struct {
Requires []any `json:"requires"`
}
if err := json.Unmarshal(raw, &doc); err != nil {
t.Fatal(err)
}
want := map[string]any{"name": "outputs", "storage": "object-store", "template": "objects", "options": map[string]any{"max-mib": float64(256)}}
for _, r := range doc.Requires {
if reflect.DeepEqual(r, want) {
return
}
}
t.Errorf("requires %v lack %v", doc.Requires, want)
}
@@ -23,6 +23,8 @@ type Module struct {
// Callers says which seats the build seat's definition lists as callers of an accepted kind (steprun.SeatListCallers when
// the module pulls through its runtime; nil in a test checks no named asker): design 47 G §543, A-163.
Callers func(kind string) ([]string, bool)
// Outputs is the object store of a run's answers over what step-ended carries inline (steprun.OutputsStore); nil keeps none.
Outputs steprun.OutputObjects
// SayEvent publishes an event of the image build seat on a seat subject (stdio.SeatPublish; nil says none, a test's): the
// puller's ask-taken, step-progress and step-ended (design 47 G §496, §602).
SayEvent func(subject string, body any, id string) error
+2 -1
View File
@@ -21,7 +21,7 @@
{
"name": "node-build-image",
"scope": "node",
"serves": ["current", "drop", "pause", "resume", "steps", "kept-artifact"]
"serves": ["current", "drop", "pause", "resume", "steps", "kept-artifact", "output"]
}
],
"config": {
@@ -57,6 +57,7 @@
"build_image_health"
],
"requires": [
{"name": "outputs", "storage": "object-store", "template": "objects", "options": {"max-mib": 256}},
"forge-account",
"rootless-image-build",
"node-tools"
@@ -79,7 +79,7 @@ func (m *Module) Puller(steps []StepTool, source steprun.AskSource) *steprun.Pul
if m.SayEvent != nil {
say = steprun.SayOn(sdkstep.AskNode, m.Node, m.SayEvent)
}
return &steprun.Puller{Source: source, Language: sdkstep.AskNode, Say: say, Callers: m.Callers, Node: m.Node, Put: m.Steps, PausePut: m.Pauses, Load: load, ForgetPause: m.ForgetPause, WatchPauses: m.WatchPauses, PauseKeys: m.ReadPauses.Keys,
return &steprun.Puller{KeepOutput: steprun.KeepOutputIn(m.Outputs), Source: source, Language: sdkstep.AskNode, Say: say, Callers: m.Callers, Node: m.Node, Put: m.Steps, PausePut: m.Pauses, Load: load, ForgetPause: m.ForgetPause, WatchPauses: m.WatchPauses, PauseKeys: m.ReadPauses.Keys,
Capacity: capacity, SettingsFile: settings, WatchConfig: watch, CoresPerStep: cores, BuildHours: hours, Logf: m.Say,
Run: func(ctx context.Context, a sdkstep.StepAsk) (any, error) {
if err := m.Prepare(ctx); err != nil {
@@ -94,7 +94,7 @@ func (m *Module) Puller(steps []StepTool, source steprun.AskSource) *steprun.Pul
// SeatTools are the seat's verbs on this node (ADR 0525 §10).
func (m *Module) SeatTools(p *steprun.Puller) []stdio.Tool {
return append(steprun.SeatTools(Seat, "Node", p), m.stepsTool(), m.keptArtifactVerb())
return append(steprun.SeatTools(Seat, "Node", p), m.stepsTool(), m.keptArtifactVerb(), steprun.OutputTool(Seat, steprun.ReadOutputFrom(m.Outputs)))
}
// StepEndTool ends one step left running (issue 1890); the module's steps state is the one it reads and writes.
@@ -18,7 +18,9 @@ import (
seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/nodebuildnode"
sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
dforgekey "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/forgekey"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/steprun"
stdio "git.novox.be/novox/mesh-sdk/go"
"git.novox.be/novox/mesh-sdk/go/busstate"
)
// CacheDir is the cache directory, outside the account's home (ADR 0466 §1; module.json resource `cache`).
@@ -77,6 +79,7 @@ func main() {
logf("announcing the states it keeps: %v", err)
os.Exit(1)
}
m.Outputs = busstate.ObjectsOf(steprun.OutputsStore)
steps := m.StepTools()
booted := time.Now()
puller := m.Puller(steps, nil)
@@ -4,6 +4,7 @@ import (
"encoding/json"
"os"
"path/filepath"
"reflect"
"regexp"
"slices"
"strings"
@@ -117,7 +118,7 @@ func TestManifestKeepsItsStatesClaimsItsBuildSeatAndDeclaresItsHealthTool(t *tes
if want := []string{"keys", "pauses", "steps", "toolchains"}; !slices.Equal(states, want) {
t.Errorf("state = %v, want %v", states, want)
}
if len(m.Claims) != 1 || m.Claims[0].Name != Seat || !slices.Equal(m.Claims[0].Serves, []string{"current", "drop", "pause", "resume", "steps", "kept-artifact"}) {
if len(m.Claims) != 1 || m.Claims[0].Name != Seat || !slices.Equal(m.Claims[0].Serves, []string{"current", "drop", "pause", "resume", "steps", "kept-artifact", "output"}) {
t.Errorf("claims = %v, want the seat %s alone", m.Claims, Seat)
}
if !slices.Contains(m.Tools, HealthTool) {
@@ -277,3 +278,25 @@ func TestTheModuleRequiresNodeToolsItPullsThrough(t *testing.T) {
t.Errorf("requires %v lack node-tools", m.Requires)
}
}
// Design 47 G A-254: the module keeps a run's answer over what step-ended carries inline in an object store of its own, asked for
// in `requires` by the template objects, and serves it through the verb output.
func TestManifestRequiresTheOutputsStore(t *testing.T) {
raw, err := os.ReadFile(moduleDir + "/module.json")
if err != nil {
t.Fatal(err)
}
var doc struct {
Requires []any `json:"requires"`
}
if err := json.Unmarshal(raw, &doc); err != nil {
t.Fatal(err)
}
want := map[string]any{"name": "outputs", "storage": "object-store", "template": "objects", "options": map[string]any{"max-mib": float64(256)}}
for _, r := range doc.Requires {
if reflect.DeepEqual(r, want) {
return
}
}
t.Errorf("requires %v lack %v", doc.Requires, want)
}
@@ -28,6 +28,8 @@ type Module struct {
// Callers says which seats the build seat's definition lists as callers of an accepted kind (steprun.SeatListCallers when
// the module pulls through its runtime; nil in a test checks no named asker): design 47 G §543, A-163.
Callers func(kind string) ([]string, bool)
// Outputs is the object store of a run's answers over what step-ended carries inline (steprun.OutputsStore); nil keeps none.
Outputs steprun.OutputObjects
// SayEvent publishes an event of the node build seat on a seat subject (stdio.SeatPublish; nil says none, a test's): the
// puller's ask-taken, step-progress and step-ended (design 47 G §496, §602).
SayEvent func(subject string, body any, id string) error
+2 -1
View File
@@ -21,7 +21,7 @@
{
"name": "node-build-node",
"scope": "node",
"serves": ["current", "drop", "pause", "resume", "steps", "kept-artifact"]
"serves": ["current", "drop", "pause", "resume", "steps", "kept-artifact", "output"]
}
],
"config": {
@@ -58,6 +58,7 @@
],
"requires": [
{"name": "detected-steps", "storage": "key-value", "template": "state", "options": {"history": 1}},
{"name": "outputs", "storage": "object-store", "template": "objects", "options": {"max-mib": 256}},
"artifact-store",
"forge-account",
"npm-package-registry",