BLD11: the three build modules take the version from the ask as MESH_VERSION; version.numbered is no longer heard

The Go compile, the Node tsc/esbuild/npm and the image's buildah bud get the
build argument MESH_VERSION from the version the build ask carries. The late
publish on version.numbered goes (code, tests, the consumes of the Go and
image manifests). The image's label and tag and a program's stamp are open
(question to the lead): the design names no key or symbol.

Builds: design 47 G §349, §370, §413

Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
This commit is contained in:
2026-11-11 11:00:52 +01:00
parent 25bbd55539
commit 357967308f
18 changed files with 106 additions and 264 deletions
@@ -54,7 +54,7 @@ func (m *Module) buildTool() StepTool {
"workspace": map[string]any{"type": "string", "description": "the workspace id build_go_fetch answered"},
"module": map[string]any{"type": "string", "description": "the module's directory in the workspace, . for the repository's root"},
"artifact": map[string]any{"type": "string", "description": "the artifact's name in the module's manifest"},
"version": map[string]any{"type": "string", "description": "the version the builder gave a package at the trunk's claim; absent for a candidate, whose package is not published"},
"version": map[string]any{"type": "string", "description": "the version the build ask carries for the artifact: a Go package's tag, and the build argument MESH_VERSION of every artifact; absent for a candidate, whose package is not published"},
"seat": map[string]any{"type": "string", "description": "the registry seat the artifact is published through, as the build ask names it"},
"publish": map[string]any{"type": "boolean", "description": "true for a merged trunk commit alone: the build writes the shared Go caches; without it (a candidate) they are read beneath a throwaway layer"},
},
@@ -114,8 +114,9 @@ func (m *Module) build(ctx context.Context, args map[string]any) (any, error) {
if art == nil {
return nil, fmt.Errorf("the module %s has no artifact %q (it has %s)", manifest.Module, name, strings.Join(names, ", "))
}
// The version the build ask carries is the build's argument MESH_VERSION for every artifact (design 47 G §370).
version, _ := args["version"].(string)
if art.Kind == catalogue.ArtifactPackage && art.Language == "go" {
version, _ := args["version"].(string)
seat, _ := args["seat"].(string)
return m.buildGoPackage(ctx, workspace, dir, *art, version, seat)
}
@@ -153,7 +154,11 @@ func (m *Module) build(ctx context.Context, args map[string]any) (any, error) {
if err != nil {
return nil, err
}
if r := run(ctx, m.buildEnv(dir), "go", cmd...); r.Status != 0 || r.Err != "" {
env := m.buildEnv(dir)
if version != "" {
env = append(env, "MESH_VERSION="+version)
}
if r := run(ctx, env, "go", cmd...); r.Status != 0 || r.Err != "" {
return nil, fmt.Errorf("go build of %s: %s", art.Name, causeLine(r.Err+"\n"+r.Stderr+"\n"+r.Stdout))
}
if err := m.insideModule(workspace, dir, out); err != nil {
@@ -255,3 +255,34 @@ func TestAManifestFallingBackToAPredefinedKeyBuilds(t *testing.T) {
t.Errorf("result = %+v", res)
}
}
// Design 47 G §370 (BLD11): a build ask carrying a version gives the compile the build argument MESH_VERSION, and one
// without gives none.
func TestTheBuildGetsTheVersionTheAskCarriesAsMeshVersion(t *testing.T) {
for _, version := range []string{"1.4.3", ""} {
m, states, calls := buildModule(t, manifestWith(goBundle), "binary")
for _, tool := range m.Tools(m.StepTools()) {
if tool.Name == "build_go_build" {
if _, err := tool.Run(map[string]any{"workspace": "ws1", "module": "modules/demo", "artifact": "tools", "version": version}); err != nil {
t.Fatal(err)
}
}
}
if st := states.waitEnd(t); st.State != sdkstep.StepPassed {
t.Fatalf("the step ended %s: %s", st.State, st.Reason)
}
got := ""
for _, r := range *calls {
if strings.HasPrefix(r.line, "go ") {
for _, e := range r.env {
if strings.HasPrefix(e, "MESH_VERSION=") {
got = strings.TrimPrefix(e, "MESH_VERSION=")
}
}
}
}
if got != version {
t.Errorf("ask version %q: the compile's MESH_VERSION = %q", version, got)
}
}
}
@@ -1,27 +0,0 @@
package main
// The late publish (CAT-BG2): a numbered bundle or archive's held digest published under its version, by the build
// modules' one late publish (buildstep/latepublish.go).
import (
"context"
"git.novox.be/novox/mesh-catalog/modules/mesh-build-go/buildstep"
stdio "git.novox.be/novox/mesh-sdk/go"
)
// NumberedPattern is the event type this module consumes for the late publish, as its manifest's `consumes` names it.
const NumberedPattern = buildstep.NumberedPattern
// LatePublish publishes a numbered bundle or archive's held digest under its version on the artifact seat; a Go package
// publishes at its build, an image is mesh-build-image's.
func (m *Module) LatePublish(ctx context.Context, body []byte) (bool, error) {
call := m.Call
if call == nil {
call = stdio.Ask
}
return buildstep.LatePublish(ctx, call, body, ArtifactSeat, "bundle", "archive")
}
// hearNumbered hears the builder's version.numbered for the late publish.
func (m *Module) hearNumbered(ctx context.Context) { buildstep.HearNumbered(ctx, m.LatePublish) }
@@ -88,8 +88,6 @@ func main() {
if m.Node != "" {
// The seat's asks, pulled once Serve has the runtime's channel; a pull before it is said and tried again.
go func() { _ = puller.Pull(ctx) }()
// The builder's version.numbered, for the late publish of a held digest (latepublish.go).
go m.hearNumbered(ctx)
}
if err := stdio.Serve("", append(m.Tools(steps), m.SeatTools(puller)...)); err != nil {
logf("%v", err)
@@ -186,9 +186,9 @@ func TestTheModuleInvokesTheArtifactSeatsVerbsAndWritesNoStore(t *testing.T) {
}
}
}
// The late publish hears the builder's version.numbered (latepublish.go).
if !slices.Contains(m.Consumes, NumberedPattern) {
t.Errorf("consumes %v lack %s", m.Consumes, NumberedPattern)
// The version comes in the ask: no consume of version.numbered (design 47 G §349, §413).
if slices.Contains(m.Consumes, "mesh-delivery-builder.version.numbered") {
t.Errorf("consumes %v still hear version.numbered", m.Consumes)
}
for _, r := range m.Resources {
if r["id"] == "registry" {
@@ -313,57 +313,3 @@ func TestEachGoPackageOfAModuleInAFolderIsPublishedUnderItsOwnModulePath(t *test
}
}
}
// CAT-BG2 (design 51 *The versions*): the builder's version.numbered for a bundle or an archive publishes the held
// digest under its version, sending nothing; a digest the holder no longer holds fails the event (offered again),
// and what is not this module's to publish is let pass.
func TestTheNumberedEventPublishesAHeldDigestUnderItsVersion(t *testing.T) {
digest := "sha256:" + strings.Repeat("ab", 32)
other := "sha256:" + strings.Repeat("cd", 32)
numbered := func(kind, seat, digest string) []byte {
raw, err := builds.EncodeVersionNumbered(builds.VersionNumbered{Name: "mod/tools", Kind: kind, Version: "0.1.4",
Module: "mod", Fingerprint: "fp", Commit: "c0", Digest: digest, Seat: seat})
if err != nil {
t.Fatal(err)
}
return raw
}
for _, c := range []struct {
name string
body []byte
did, fail bool
}{
{"a held bundle is tagged", numbered("bundle", ArtifactSeat, digest), true, false},
{"an archive with no seat named goes to the artifact seat", numbered("archive", "", digest), true, false},
{"a digest the holder lacks fails, sending nothing", numbered("bundle", ArtifactSeat, other), false, true},
{"a Go package is not published late", numbered("package", GoPackageSeat, digest), false, false},
{"an image is mesh-build-image's", numbered("image", "container-image-registry", digest), false, false},
{"no digest, nothing to publish", numbered("bundle", ArtifactSeat, ""), false, false},
{"an unreadable body fails", []byte(`{"name":"mod/tools"}`), false, true},
} {
t.Run(c.name, func(t *testing.T) {
m := &Module{}
s := withStore(t, m)
s.blobs["mod/tools@"+digest] = []byte("held")
did, err := m.LatePublish(t.Context(), c.body)
if did != c.did || (err != nil) != c.fail {
t.Fatalf("did %v, err %v; want did %v, fail %v", did, err, c.did, c.fail)
}
for _, k := range s.asked {
if strings.HasSuffix(k, ".publish-part") {
t.Errorf("a late publish sent a part: %v", s.asked)
}
}
if !c.did {
return
}
if len(s.published) != 1 {
t.Fatalf("published %v", s.published)
}
p := s.published[0]
if p.Name != "mod/tools" || p.Version != "0.1.4" || p.Digest != digest || p.Fingerprint != "fp" || p.Commit != "c0" {
t.Errorf("published %+v", p)
}
})
}
}