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
@@ -170,6 +170,10 @@ func (m *Module) build(ctx context.Context, args map[string]any) (any, error) {
argv = append(argv, "--target", art.Target)
}
argv = append(argv, imageArgs(manifest)...)
// The version the build ask carries is the build argument MESH_VERSION (design 47 G §370).
if version != "" {
argv = append(argv, "--build-arg", "MESH_VERSION="+version)
}
argv = append(argv, contextDir)
if r := m.Run(ctx, m.env(), "buildah", argv...); r.Status != 0 || r.Err != "" {
m.sayFailure("buildah bud of "+art.Name+" of "+manifest.Module, r)
@@ -330,3 +330,20 @@ func TestAManifestFallingBackToAPredefinedKeyBuilds(t *testing.T) {
t.Errorf("result = %+v", res)
}
}
// Design 47 G §370 (BLD11): a build ask carrying a version gives the image build the build argument MESH_VERSION.
func TestTheImageBuildGetsTheVersionTheAskCarriesAsMeshVersion(t *testing.T) {
m, f, states := setup(t, same)
if _, st := runBuild(t, m, states, map[string]any{"version": "1.4.3"}); st.State != sdkstep.StepPassed {
t.Fatalf("step = %+v", st)
}
bud := f.called("bud")
if len(bud) != 1 || !strings.Contains(bud[0].line, "--build-arg MESH_VERSION=1.4.3") {
t.Fatalf("bud = %+v", bud)
}
m, f, states = setup(t, same)
runBuild(t, m, states, nil)
if bud := f.called("bud"); len(bud) != 1 || strings.Contains(bud[0].line, "MESH_VERSION") {
t.Fatalf("a build with no version: %+v", bud)
}
}
@@ -27,8 +27,8 @@ func TestTheModuleInvokesTheImageSeatAndHoldsNoRegistry(t *testing.T) {
"seat:container-image-registry.mirror", "seat:mesh-module-assigner.assignments"}; !slices.Equal(m.Invokes, want) {
t.Errorf("invokes = %v, want %v", m.Invokes, want)
}
// The builder's version.numbered for the late publish (ADR 0617 §1), and the seat's outcomes a copy waits on.
consumes := []string{NumberedPattern}
// The seat's outcomes a copy waits on; the version comes in the ask, so version.numbered is not heard (design 47 G §413).
consumes := []string{}
for _, e := range OutcomeEvents {
consumes = append(consumes, "container-image-registry."+e)
}
@@ -1,23 +0,0 @@
package main
// The late publish (novox/hq ADR 0617 §1, CAT-BI1): an image whose floor the builder did not know yet is built
// unnumbered and published by its digest; once the builder numbers it, its version.numbered publishes the held digest
// under that version through the image seat, sending nothing (buildstep/latepublish.go, the build modules' one).
import (
"context"
"git.novox.be/novox/mesh-catalog/modules/mesh-build-go/buildstep"
)
// 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 image's held digest under its version on the image seat; a bundle or an archive is
// mesh-build-go's.
func (m *Module) LatePublish(ctx context.Context, body []byte) (bool, error) {
return buildstep.LatePublish(ctx, m.call(), body, buildstep.ImageSeat, KindImage)
}
// hearNumbered hears the builder's version.numbered for the late publish.
func (m *Module) hearNumbered(ctx context.Context) { buildstep.HearNumbered(ctx, m.LatePublish) }
@@ -76,8 +76,6 @@ func main() {
// The image seat's outcomes, which a copy waits on (the manifest's consumes), and the copies' waits in
// mirror-waits, where another instance writes an outcome it heard.
go hearOutcomes(ctx, m.Outcomes)
// The builder's version.numbered, for the late publish of an image built unnumbered (ADR 0617 §1).
go m.hearNumbered(ctx)
go waits.Follow("", m.Outcomes.Changed)
}
if m.Node != "" {
@@ -9,7 +9,6 @@ import (
"testing"
reg "git.novox.be/novox/mesh-delivery/contracts/go/seats/containerimageregistry"
builds "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds"
sdkstep "git.novox.be/novox/mesh-delivery/sdk/buildstep"
)
@@ -123,50 +122,3 @@ func TestATrunkBuildPublishesThroughTheImageSeatOnlyWhatTheHolderLacks(t *testin
t.Errorf("a tag that is not one: step = %+v", st)
}
}
// ADR 0617 §1: the builder's version.numbered for an image publishes the held digest under its version through the image
// seat, sending nothing; a digest the holder lacks fails the event (offered again); what is not this module's passes.
func TestTheNumberedEventPublishesAHeldImageUnderItsVersion(t *testing.T) {
digest := "sha256:" + strings.Repeat("ab", 32)
numbered := func(kind, seat, digest string) []byte {
raw, err := builds.EncodeVersionNumbered(builds.VersionNumbered{Name: "fixture-image/server", Kind: kind, Version: "1.4.0",
Module: "fixture-image", Fingerprint: "fp", Commit: "c0", Digest: digest, Seat: seat})
if err != nil {
t.Fatal(err)
}
return raw
}
for name, c := range map[string]struct {
body []byte
did, fail bool
}{
"a held image is numbered": {body: numbered("image", reg.Seat, digest), did: true},
"a digest the holder lacks fails": {body: numbered("image", reg.Seat, "sha256:"+strings.Repeat("cd", 32)), fail: true},
"a bundle is mesh-build-go's": {body: numbered("bundle", "oci-artifact-registry", digest)},
"an event naming no seat is a bundle's": {body: numbered("image", "", digest)},
"no digest, nothing to publish": {body: numbered("image", reg.Seat, "")},
} {
t.Run(name, func(t *testing.T) {
m, f, _ := setup(t, same)
f.held[digest] = true
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)
}
if len(f.sent) != 0 {
t.Errorf("a late publish sent parts: %v", f.sent)
}
if !c.did {
return
}
if len(f.published) != 1 {
t.Fatalf("published %+v", f.published)
}
p := f.published[0]
if p.Name != "fixture-image/server" || p.Kind != KindImage || p.Version != "1.4.0" || p.Digest != digest ||
p.Fingerprint != "fp" || p.Commit != "c0" || len(p.Parts) != 1 || p.Parts[0].Digest != digest {
t.Errorf("published %+v", p)
}
})
}
}
-1
View File
@@ -68,7 +68,6 @@
"seat:mesh-module-assigner.assignments"
],
"consumes": [
"mesh-delivery-builder.version.numbered",
"container-image-registry.published",
"container-image-registry.refused"
],