Compare commits

..
7 Commits
Author SHA1 Message Date
mesh-tools e3fff86f1a Merge pull request 'The artifact registry takes a publish whose reservation names no digest yet, and refuses a version it holds at another digest (H-A-387, H-A-393)' (#734) from fix/47-H1-registry-takes-unreserved into main 2026-11-21 23:24:04 +00:00
jschoubben 7765947476 The artifact registry refuses a held version published at another digest (H-A-393)
While the reserved digest is still empty, a second publish of the same
version with another digest passed the reservation check and the store's
Put moved the version's tag. Publish now refuses it in its held branch,
before the reservation is asked, naming both digests, with the publish's
finding and refused said as any refusal; the same digest is taken as before.
The store's Held answers the digest it holds at the version when it differs.

Builds: design 47 H H-A-393, design 47 G A-490j
2026-11-22 00:18:20 +01:00
jschoubben 69940d1019 The artifact registry takes a publish whose reservation names no digest yet (H-A-387)
The builder records a build's digests only at its end, while the Go build
module publishes during the build step with the reserved version (H-A-373),
so the distribution holder's strict digest check refused every archive-only
publish with "reserved ... for another digest". Recorded now takes an
artifact whose reserved digest is empty, as A-490j decided for every holder,
still refuses a different recorded digest, and its refusal names the case:
the digest reserved and the one published, or no reservation of the version.

Builds: design 47 H H-A-387, design 47 G A-490j
2026-11-22 00:14:30 +01:00
mesh-tools 7030e1420c Merge pull request 'The Go build module fetches an archive-only lane of a module without Go code; every publish of the Go and Node build modules names the ask's version (H-A-371, H-A-372, H-A-373)' (#733) from fix/47-H1-go-fetch-archive-only into main 2026-11-21 22:49:52 +00:00
jschoubben b5c05b326a Go build module: a bundle's and an archive's publish carry the version the ask reserved
Every bundle and archive was published with an empty version, a by-digest
publish, so the builder marked none against its reservation: the same kind
as the Node build module's bundles.

Builds: design 47 H H-A-373
2026-11-21 23:45:30 +01:00
jschoubben ebf4d9896b Node build module: a bundle's publish carries the version the ask reserved
Every bundle was published with an empty version, a by-digest publish, so
the builder never saw package-published and the bundle was not marked
against its reservation.

Builds: design 47 H H-A-372
2026-11-21 23:38:37 +01:00
jschoubben 02371b32de Go build module: a module directory that chooses no Go module is an empty scope
The builder sends a module's directory with every lane, and an archive is
packed by the Go build seat, so the fetch's refusal of a directory without
go.mod left every archive-only module without Go code unbuildable. Such a
directory is now an empty scope (the empty scope file written); a Go bundle
or package without go.mod still fails at its build step, naming it.

Builds: design 47 H H-A-371
2026-11-21 23:37:51 +01:00
15 changed files with 184 additions and 64 deletions
@@ -62,8 +62,9 @@ func (b fakeBuilder) Recorded(string, string, string) (bool, string, error) {
}
type fakeStore struct {
has map[string]bool
put []map[string][]byte
has map[string]bool
held map[string]string // name@version to the digest the store holds there
put []map[string][]byte
}
func (s *fakeStore) Has(_, d string) (bool, error) { return s.has[d], nil }
@@ -71,8 +72,17 @@ func (s *fakeStore) Put(t PublishRequest, parts map[string][]byte) (string, erro
s.put = append(s.put, parts)
return t.Name + "@" + t.Digest, nil
}
func (s *fakeStore) Held(string, string, string) (string, bool, error) { return "", false, nil }
func (s *fakeStore) Holds(r PublishRequest) (bool, error) { return s.has[r.Digest], nil }
func (s *fakeStore) Held(name, version, digest string) (string, string, error) {
switch d := s.held[name+"@"+version]; d {
case "":
return "", "", nil
case digest:
return name + "@" + d, "", nil
default:
return "", d, nil
}
}
func (s *fakeStore) Holds(r PublishRequest) (bool, error) { return s.has[r.Digest], nil }
type said struct {
seat, event string
@@ -317,6 +327,16 @@ func TestTheHolderOfTheTwoImageSeats(t *testing.T) {
_, err := b.h.Publish(ArtifactSeat, builder, req("t"))
return err
}, "the builder did not reserve it"},
{"a version the store holds at another digest", func(b *bed) error {
b.store.held = map[string]string{"m/program@0.1.4": "sha256:bb"}
r := req("t")
r.Digest = "sha256:aa"
_, err := b.h.Publish(ArtifactSeat, builder, r) // the reservation names no digest yet: the bed's builder says yes
if !b.findings["publish-refused m/program@0.1.4"] || len(b.store.put) != 0 {
return errors.New("not refused loudly, or stored")
}
return err
}, "the store holds m/program@0.1.4 at digest sha256:bb, not sha256:aa"},
{"an image on the artifact seat", func(b *bed) error {
r := req("t")
r.Kind = KindImage
+4 -4
View File
@@ -208,15 +208,15 @@ func (o *OCI) layerSize(t PublishRequest, parts map[string][]byte) (int64, error
}
// Held is the reference of name at version when the store holds digest under it.
func (o *OCI) Held(name, version, digest string) (string, bool, error) {
func (o *OCI) Held(name, version, digest string) (string, string, error) {
d, err := o.Digest(name, version)
if err != nil || d == "" {
return "", false, err
return "", "", err
}
if d != digest {
return "", false, nil
return "", d, nil
}
return name + "@" + d, true, nil
return name + "@" + d, "", nil
}
// Holds is whether the store holds what r's digest names under r's name: an image's manifest by its digest, or a bundle's
@@ -3,13 +3,14 @@ package holder
import (
"encoding/json"
"fmt"
"strings"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
)
// Reserved is the holder's check of a publish against the builder's reservation (novox/hq design 47 §381, §478, §504): it asks the
// seat mesh-builds' verb reserved with the publish's name and version, a package's name in its ecosystem, and accepts the publish
// only when that version is the one reserved and an artifact of it has the publish's digest. It reads no catalog and a publish gains
// only when that version is the one reserved and an artifact of it has the publish's digest or none recorded yet (A-490j). It reads no catalog and a publish gains
// no field. It is the Builder the holder's Check asks.
type Reserved struct {
// Ask is the runtime's request and reply over the bus (mesh-sdk stdio.Ask).
@@ -31,12 +32,20 @@ func (r Reserved) Recorded(name, version, digest string) (bool, string, error) {
return false, "", fmt.Errorf("%s answered no reservation for %s@%s: %s", Address, name, version, raw)
}
if a.Version != version {
return false, fmt.Sprintf("%s reserved %s for %s, not %s", a.Module, a.Version, name, version), nil
return false, fmt.Sprintf("%s has no reservation of version %s of %s (it reserved %s)", a.Module, version, name, a.Version), nil
}
var reserved []string
for _, art := range a.Artifacts {
if art.Digest == digest {
// An artifact whose build has not recorded its digest yet takes the publish: the builder records a build's digests only when
// the build ends, while the build module publishes during it with the reserved version (design 47 G §369, A-415, A-490j,
// H-A-387). A digest the build then records that differs from what the holder holds fails the build.
if art.Digest == digest || art.Digest == "" {
return true, "", nil
}
reserved = append(reserved, art.Digest)
}
return false, fmt.Sprintf("%s reserved %s@%s for another digest than %s", a.Module, name, version, digest), nil
if len(reserved) == 0 {
return false, fmt.Sprintf("%s reserved %s@%s with no artifact, so no digest takes %s", a.Module, name, version, digest), nil
}
return false, fmt.Sprintf("%s reserved %s@%s for digest %s, not %s", a.Module, name, version, strings.Join(reserved, ", "), digest), nil
}
@@ -19,8 +19,10 @@ func reservedChecksAPublishAgainstTheReservation(t *testing.T) {
}{
{name: "the reserved version and digest", answer: `{"module":"mesh-image","version":"0.1.7","artifacts":[{"artifact":"mesh-image:image","digest":"sha256:aa"}]}`, ok: true},
{name: "another artifact of it carries the digest", answer: `{"module":"mesh-image","version":"0.1.7","artifacts":[{"artifact":"mesh-image:aux"},{"artifact":"mesh-image:image","digest":"sha256:aa"}]}`, ok: true},
{name: "another digest", answer: `{"module":"mesh-image","version":"0.1.7","artifacts":[{"artifact":"mesh-image:image","digest":"sha256:bb"}]}`, why: "another digest than sha256:aa"},
{name: "another version reserved", answer: `{"module":"mesh-image","version":"0.1.8","artifacts":[]}`, why: "reserved 0.1.8 for registry/mesh-image, not 0.1.7"},
{name: "no digest recorded yet", answer: `{"module":"mesh-image","version":"0.1.7","artifacts":[{"artifact":"mesh-image:image"}]}`, ok: true},
{name: "another digest", answer: `{"module":"mesh-image","version":"0.1.7","artifacts":[{"artifact":"mesh-image:image","digest":"sha256:bb"}]}`, why: "reserved registry/mesh-image@0.1.7 for digest sha256:bb, not sha256:aa"},
{name: "no artifact reserved", answer: `{"module":"mesh-image","version":"0.1.7","artifacts":[]}`, why: "with no artifact, so no digest takes sha256:aa"},
{name: "another version reserved", answer: `{"module":"mesh-image","version":"0.1.8","artifacts":[]}`, why: "no reservation of version 0.1.7 of registry/mesh-image (it reserved 0.1.8)"},
{name: "the builder refused the name", err: errors.New("no entry carries registry/mesh-image"), why: "no entry carries registry/mesh-image"},
{name: "an answer that is none", answer: `{"error":"x"}`, why: "answered no reservation"},
} {
@@ -141,8 +141,9 @@ type Store interface {
// Put stores a publish's parts under its name and version and answers the reference's path (SeatReference).
Put(r PublishRequest, parts map[string][]byte) (reference string, err error)
// Held is the reference's path of name at version when the store already holds digest under it: a rebuild of a held
// fingerprint answers it and stores nothing.
Held(name, version, digest string) (reference string, ok bool, err error)
// fingerprint answers it and stores nothing. When the store holds the version at another digest, other names that digest
// and reference is empty; neither is set when the store holds no such version.
Held(name, version, digest string) (reference, other string, err error)
// Holds says whether the store holds what a publish's digest names under its name: an image's manifest, or a bundle's or
// an archive's blob. The store is the artifact store (A-50): `artifact-store://<name>/blobs/<digest>` is that blob.
Holds(r PublishRequest) (bool, error)
@@ -266,15 +267,19 @@ func (h *Holder) Publish(seat, caller string, r PublishRequest) (PublishAnswer,
}
// A rebuild of a held fingerprint answers the held version and stores nothing.
if r.Version != "" {
var ref string
var ok bool
var ref, other string
err := h.timed("the store's read of what it holds (the program's registry)", func() (err error) {
ref, ok, err = h.Store.Held(r.Name, r.Version, r.Digest)
ref, other, err = h.Store.Held(r.Name, r.Version, r.Digest)
return err
})
if err != nil {
return PublishAnswer{}, fmt.Errorf("publish: the store cannot say whether it holds %s@%s: %w", r.Name, r.Version, err)
} else if ok {
} else if other != "" {
// A second publish of a held version with another digest is refused before the reservation is asked, as the forge
// holds the first (A-490j, H-A-393): while the reserved digest is still empty it would pass, and the store's Put
// would move the version's tag.
return h.refusePublish(seat, r, fmt.Sprintf("the store holds %s@%s at digest %s, not %s", r.Name, r.Version, other, r.Digest))
} else if ref != "" {
return PublishAnswer{Transfer: r.Transfer, Ended: true}, h.timed("the published event on the seat", func() error {
return h.Say(seat, EventPublished, h.eventOf(seat, r, SeatReference(seat, ref), ""))
})
@@ -298,6 +303,16 @@ func (h *Holder) Publish(seat, caller string, r PublishRequest) (PublishAnswer,
return answerOf(got), nil
}
// refusePublish ends a publish refused before anything is stored: its finding raised, refused said on the seat, the reason
// answered.
func (h *Holder) refusePublish(seat string, r PublishRequest, reason string) (PublishAnswer, error) {
h.Finding("publish-refused", r.Name+"@"+r.Version, reason, true)
if err := h.Say(seat, EventRefused, h.eventOf(seat, r, "", reason)); err != nil {
return PublishAnswer{}, fmt.Errorf("publish: %s, and the refused is not said: %w", reason, err)
}
return PublishAnswer{Transfer: r.Transfer, Ended: true}, errors.New("publish: " + reason)
}
// tagHeld is a publish with a version, a digest and no parts (design 47 G A-417, A-73, A-50): what the store holds of that
// digest under the name (the build's untagged publish, the artifact store's blob) is checked against the builder's reservation
// and tagged with the version, and published is said; when the store holds none of it, the publish is refused as not stored,
@@ -311,13 +326,7 @@ func (h *Holder) tagHeld(seat string, r PublishRequest) (PublishAnswer, error) {
if err != nil {
return PublishAnswer{}, fmt.Errorf("publish: the store cannot say whether it holds %s of %s: %w", r.Digest, r.Name, err)
}
refuse := func(reason string) (PublishAnswer, error) {
h.Finding("publish-refused", r.Name+"@"+r.Version, reason, true)
if err := h.Say(seat, EventRefused, h.eventOf(seat, r, "", reason)); err != nil {
return PublishAnswer{}, fmt.Errorf("publish: %s, and the refused is not said: %w", reason, err)
}
return PublishAnswer{Transfer: r.Transfer, Ended: true}, errors.New("publish: " + reason)
}
refuse := func(reason string) (PublishAnswer, error) { return h.refusePublish(seat, r, reason) }
if !held {
return refuse(fmt.Sprintf("not stored: the store holds no %s of %s, so version %s names nothing", r.Digest, r.Name, r.Version))
}
@@ -46,9 +46,9 @@ func (m *Module) httpClient() *http.Client {
// buildArchive packs one archive artifact of the module in dir: a pinned file when it names a url, else the directory
// `from` of the module's tree.
func (m *Module) buildArchive(ctx context.Context, workspace, module, name, dir string, art catalogue.Artifact, keep *sdkstep.KeptFor) (any, error) {
func (m *Module) buildArchive(ctx context.Context, workspace, module, name, dir string, art catalogue.Artifact, version string, keep *sdkstep.KeptFor) (any, error) {
if art.URL != "" {
return m.pinnedArchive(ctx, workspace, module, name, art, keep)
return m.pinnedArchive(ctx, workspace, module, name, art, version, keep)
}
from := strings.Trim(path.Clean("/"+filepath.ToSlash(art.From)), "/")
if strings.TrimSpace(art.From) == "" {
@@ -80,12 +80,12 @@ func (m *Module) buildArchive(ctx context.Context, workspace, module, name, dir
if !within(realDir, realRoot) {
return nil, fmt.Errorf("the archive %s is taken from %q, which lies outside the module: it resolves to %s, and the module is %s", art.Name, art.From, realRoot, realDir)
}
return m.packInto(ctx, workspace, module, name, art.Name, "archive", root, keep)
return m.packInto(ctx, workspace, module, name, art.Name, "archive", version, root, keep)
}
// pinnedArchive fetches the file an artifact is pinned to, checks it against the pin, lays it out as the artifact says
// (kept whole as `file`, or unpacked from `within`) and packs it.
func (m *Module) pinnedArchive(ctx context.Context, workspace, module, name string, art catalogue.Artifact, keep *sdkstep.KeptFor) (any, error) {
func (m *Module) pinnedArchive(ctx context.Context, workspace, module, name string, art catalogue.Artifact, version string, keep *sdkstep.KeptFor) (any, error) {
file, err := m.pinnedFile(ctx, workspace, art)
if err != nil {
return nil, fmt.Errorf("%s: %w", art.Name, err)
@@ -114,7 +114,7 @@ func (m *Module) pinnedArchive(ctx context.Context, workspace, module, name stri
} else if err := unpackUpstream(file, laid, art.Within); err != nil {
return nil, fmt.Errorf("%s: %s (%s): %w", art.Name, art.URL, art.Version, err)
}
return m.packInto(ctx, workspace, module, name, art.Name, "archive", laid, keep)
return m.packInto(ctx, workspace, module, name, art.Name, "archive", version, laid, keep)
}
// pinnedFile is the path of the pinned file in the workspace: kept from an earlier build when its bytes are still the
@@ -6,6 +6,7 @@ import (
"context"
"crypto/sha256"
"encoding/hex"
"encoding/json"
"errors"
"io"
"net"
@@ -305,3 +306,66 @@ func TestAnArchiveOfALinkedModuleDirectoryIsRefused(t *testing.T) {
t.Errorf("an archive of outside files was left: %v", entries)
}
}
// H-A-371: an archive-only lane of a module with no Go code fetches (its directory chooses no Go module: an empty
// scope, never a refusal) and packs its archive.
func TestAnArchiveOnlyLaneOfAModuleWithNoGoCodeFetchesAndPacks(t *testing.T) {
files := map[string]string{}
fixture := filepath.Join("testdata", "repos", "archive")
err := filepath.Walk(fixture, func(p string, info os.FileInfo, err error) error {
if err != nil || info.IsDir() {
return err
}
body, err := os.ReadFile(p)
rel, _ := filepath.Rel(fixture, p)
files[strings.TrimSuffix(filepath.ToSlash(rel), ".fixture")] = string(body)
return err
})
if err != nil {
t.Fatal(err)
}
// Another module of the repository holds Go code; the archive module's directory holds none.
f := &fakeStep{gomods: "modules/other/go.mod\n", files: files}
m, states := fetchModule(t, f)
withStore(t, m)
if _, err := fetchTool(t, m)(map[string]any{"repository": "novox/mesh-catalog", "commit": commitSHA, "dir": "modules/demo"}); err != nil {
t.Fatal(err)
}
st := states.waitEnd(t)
if st.State != sdkstep.StepPassed {
t.Fatalf("the fetch ended %s: %s", st.State, st.Reason)
}
var fetched FetchResult
if err := json.Unmarshal(st.Result, &fetched); err != nil {
t.Fatal(err)
}
if len(fetched.Modules) != 0 {
t.Errorf("the fetch chose the Go modules %v, want none", fetched.Modules)
}
if b, err := os.ReadFile(filepath.Join(m.Work, fetched.Workspace, scopeMark)); err != nil || len(b) != 0 {
t.Errorf("the scope beside the tree is %q, %v; want the empty scope", b, err)
}
for _, l := range f.lines() {
if strings.HasPrefix(l, "go ") {
t.Errorf("a fetch that chose no Go module ran %s", l)
}
}
for _, tool := range m.Tools(m.StepTools()) {
if tool.Name == "build_go_build" {
if _, err := tool.Run(map[string]any{"workspace": fetched.Workspace, "module": "modules/demo", "artifact": "files"}); err != nil {
t.Fatal(err)
}
}
}
st = states.waitEnd(t)
if st.State != sdkstep.StepPassed {
t.Fatalf("the build ended %s: %s", st.State, st.Reason)
}
var res BuildResult
if err := json.Unmarshal(st.Result, &res); err != nil {
t.Fatal(err)
}
if res.Artifact != "files" || res.Size == 0 || res.Reference == "" || len(archiveOf(t, res)) != res.Size {
t.Errorf("the archive was not packed and published: %+v", res)
}
}
@@ -129,7 +129,7 @@ func (m *Module) build(ctx context.Context, args map[string]any) (any, error) {
return m.buildGoPackage(ctx, workspace, dir, *art, version, seat)
}
if art.Kind == "archive" {
return m.buildArchive(ctx, workspace, module, manifest.Module, dir, *art, keep)
return m.buildArchive(ctx, workspace, module, manifest.Module, dir, *art, version, keep)
}
if art.Kind != "bundle" || art.Language != "go" {
return nil, fmt.Errorf("the artifact %s of %s is a %s of language %q: this module builds Go bundles and archives", name, manifest.Module, art.Kind, art.Language)
@@ -176,7 +176,7 @@ func (m *Module) build(ctx context.Context, args map[string]any) (any, error) {
if err := m.insideModule(workspace, dir, out); err != nil {
return nil, fmt.Errorf("the output directory of %s: %w", art.Name, err)
}
res, err := m.packInto(ctx, workspace, module, manifest.Module, art.Name, "bundle", out, keep)
res, err := m.packInto(ctx, workspace, module, manifest.Module, art.Name, "bundle", version, out, keep)
if err != nil {
return nil, err
}
@@ -186,16 +186,17 @@ func (m *Module) build(ctx context.Context, args map[string]any) (any, error) {
// packInto packs a directory with mesh-sdk's Pack, as the build agent packs every artifact, and publishes the archive
// on the seat oci-artifact-registry from this process, after the build step ended (design 51 *Publishing*; publish.go):
// a candidate's as a trunk build's, under <module>/<artifact> by its digest, of kind (bundle or archive). The step
// answers the reference; a publish the seat refuses fails the step `not stored:`, unless keep names the build of the
// artifact store's holder, which this node then keeps and answers as kept (keptbuilds.go). The packed bytes never stay on
// the node: they are held in this process until the publish answered (the lead's decision L9).
func (m *Module) packInto(ctx context.Context, workspace, module, name, artifact, kind, root string, keep *sdkstep.KeptFor) (BuildResult, error) {
// a candidate's as a trunk build's, under <module>/<artifact> by its digest and the ask's version (H-A-373), of kind
// (bundle or archive). The step answers the reference; a publish the seat refuses fails the step `not stored:`, unless
// keep names the build of the artifact store's holder, which this node then keeps and answers as kept (keptbuilds.go).
// The packed bytes never stay on the node: they are held in this process until the publish answered (the lead's
// decision L9).
func (m *Module) packInto(ctx context.Context, workspace, module, name, artifact, kind, version, root string, keep *sdkstep.KeptFor) (BuildResult, error) {
archive, digest, err := steprun.Pack(root)
if err != nil {
return BuildResult{}, fmt.Errorf("packing %s: %w", artifact, err)
}
if err := m.publishArchive(ctx, name, artifact, kind, digest, archive); err != nil {
if err := m.publishArchive(ctx, name, artifact, kind, version, digest, archive); err != nil {
if keep == nil {
return BuildResult{}, fmt.Errorf("%s%s: %w", builds.NotStored, artifact, err)
}
@@ -57,10 +57,16 @@ func buildModule(t *testing.T, manifest, content string) (*Module, *keptStates,
}
func runBuild(t *testing.T, m *Module, states *keptStates, artifact string) (BuildResult, sdkstep.Step) {
t.Helper()
return runBuildArgs(t, m, states, map[string]any{"workspace": "ws1", "module": "modules/demo", "artifact": artifact})
}
// runBuildArgs runs the build tool with args, such as an ask's version, and answers what its step ended with.
func runBuildArgs(t *testing.T, m *Module, states *keptStates, args map[string]any) (BuildResult, sdkstep.Step) {
t.Helper()
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": artifact}); err != nil {
if _, err := tool.Run(args); err != nil {
t.Fatal(err)
}
}
@@ -691,8 +691,8 @@ func cleanDir(dir string) string {
// scopedDirs are the go.mod directories of all that a module directory dir chooses: dir itself and each directory its
// go.mod replaces with a local path, followed through their own replaces (design 47 G, A-447), in order. A directory
// the tree holds no go.mod for is left out. A directory holding no go.mod chooses every go.mod under it, and one that
// chooses no Go module at all is an error naming it (A-447a).
// the tree holds no go.mod for is left out. A directory holding no go.mod chooses every go.mod under it (A-447a), and one that
// chooses no Go module at all is an empty scope (H-A-371).
func scopedDirs(tree, dir string, paths, all []string) ([]string, error) {
have := map[string]bool{}
for _, d := range all {
@@ -752,8 +752,8 @@ func scopedDirs(tree, dir string, paths, all []string) ([]string, error) {
out = append(out, d)
}
}
if len(out) == 0 {
return nil, fmt.Errorf("the module directory %q holds no Go module (no go.mod in it or under it)", dir)
}
// A directory that chooses no Go module (a module with an archive artifact and no Go code) is an empty scope, never
// a refusal: the builder sends its directory with every lane, and its archive is packed here. A Go bundle or package
// whose directory holds no go.mod fails at its build step, naming it (design 47 H, H-A-371).
return out, nil
}
@@ -58,7 +58,7 @@ func TestAFetchAskedWithADirectoryChoosesItsModuleAndWhatItReplacesAlone(t *test
{"seats", []string{"seats/a", "seats/b"}}, // a go.mod per seat, none in seats itself
{".", []string{"."}}, // the root holds a go.mod
{"rootless/x", []string{"rootless/x/go"}}, // Go code lies in go/
{"modules/none", nil}, // chooses no Go module: an error naming it
{"modules/none", []string{}}, // chooses no Go module: an empty scope (H-A-371)
} {
tree := t.TempDir()
for d, body := range mods {
@@ -70,12 +70,6 @@ func TestAFetchAskedWithADirectoryChoosesItsModuleAndWhatItReplacesAlone(t *test
}
}
got, err := scopedDirs(tree, cleanDir(c.dir), nil, all)
if c.want == nil {
if err == nil || !strings.Contains(err.Error(), c.dir) {
t.Errorf("dir %q chose %v, %v; want an error naming it", c.dir, got, err)
}
continue
}
if err != nil || !reflect.DeepEqual(got, c.want) {
t.Errorf("dir %q chooses %v, %v; want %v", c.dir, got, err, c.want)
}
@@ -23,9 +23,10 @@ func transferName(module, artifact, digest string) string {
return steprun.TransferName(module, artifact, digest)
}
// publishArchive publishes body, of digest, as <module>/<artifact> of kind (bundle or archive) on the artifact seat.
func (m *Module) publishArchive(ctx context.Context, module, artifact, kind, digest string, body []byte) error {
return m.publishOn(ctx, ArtifactSeat, module+"/"+artifact, kind, "", digest, transferName(module, artifact, digest), body)
// publishArchive publishes body, of digest, as <module>/<artifact> of kind (bundle or archive) on the artifact seat, under
// the version the ask reserved, so the builder marks it against its reservation (design 47 H, H-A-373).
func (m *Module) publishArchive(ctx context.Context, module, artifact, kind, version, digest string, body []byte) error {
return m.publishOn(ctx, ArtifactSeat, module+"/"+artifact, kind, version, digest, transferName(module, artifact, digest), body)
}
// publishOn publishes body through steprun.PublishOne: through Call when a test set it, else the runtime's request
@@ -102,11 +102,12 @@ func archiveOf(t *testing.T, res BuildResult) []byte {
}
// 1587-S2 (ADR 0498 §1): a done build answers a reference of the stated form whose tail is the build's digest, and the
// store holds the archive there; a bundle and an archive alike.
// store holds the archive there; a bundle and an archive alike. Each publish names the version the ask reserved, so the
// builder marks it against its reservation (design 47 H, H-A-373).
func TestADoneBuildAnswersTheReferenceOfTheArchiveItPushed(t *testing.T) {
m, states, _ := buildModule(t, manifestWith(goBundle), "the program")
store := withStore(t, m)
res, st := runBuild(t, m, states, "tools")
res, st := runBuildArgs(t, m, states, map[string]any{"workspace": "ws1", "module": "modules/demo", "artifact": "tools", "version": "1.4.3"})
if st.State != sdkstep.StepPassed {
t.Fatalf("the step ended %s: %s", st.State, st.Reason)
}
@@ -116,12 +117,18 @@ func TestADoneBuildAnswersTheReferenceOfTheArchiveItPushed(t *testing.T) {
if store.blobs["demo/tools@"+res.Digest] == nil || store.asked[0] != "seat:oci-artifact-registry.publish" {
t.Errorf("the seat was asked %v and holds %d blobs, not demo/tools@%s", store.asked, len(store.blobs), res.Digest)
}
if len(store.published) != 1 || store.published[0].Version != "1.4.3" {
t.Errorf("the bundle was published as %+v, want the ask's version 1.4.3", store.published)
}
a, states2, _ := archiveModule(t, "")
withStore(t, a)
arch, st := runBuild(t, a, states2, "files")
astore := withStore(t, a)
arch, st := runBuildArgs(t, a, states2, map[string]any{"workspace": "ws1", "module": "modules/demo", "artifact": "files", "version": "1.4.3"})
if st.State != sdkstep.StepPassed || arch.Reference != "oci-artifact-registry/demo/files@"+arch.Digest {
t.Errorf("the archive artifact: %s %q, reference %q", st.State, st.Reason, arch.Reference)
}
if len(astore.published) != 1 || astore.published[0].Version != "1.4.3" {
t.Errorf("the archive was published as %+v, want the ask's version 1.4.3", astore.published)
}
}
// 1587-S3 (ADR 0498 §2), CAT-BG1: a publish the seat's holder refuses fails the step `not stored: <artifact>: <the
@@ -198,8 +198,9 @@ func (m *Module) build(ctx context.Context, args map[string]any) (any, error) {
return nil, fmt.Errorf("packing %s: %w", a.Name, err)
}
// Published from this process once the build ended, a candidate's as a trunk build's (ADR 0498 §1 §2; CAT-BN3): the
// step answers the seat's reference, or fails not stored. The packed bytes are never written to the node (L9).
if err := m.publishOn(ctx, steprun.ArtifactSeat, a.module+"/"+a.Name, "bundle", "", digest, archive); err != nil {
// step answers the seat's reference, or fails not stored. The packed bytes are never written to the node (L9). The
// publish carries the version the ask reserved, so the builder marks the bundle against its reservation (H-A-372).
if err := m.publishOn(ctx, steprun.ArtifactSeat, a.module+"/"+a.Name, "bundle", version, digest, archive); err != nil {
return nil, fmt.Errorf("%s%s: %w", builds.NotStored, a.Name, err)
}
files := []string{}
@@ -94,11 +94,14 @@ func archiveOf(t *testing.T, r BuildResult) []byte {
}
// 1587-S6 (ADR 0498 §1; CAT-BN3): a done bundle is published through oci-artifact-registry and answers the seat's
// reference of its archive, under the manifest's module.
// reference of its archive, under the manifest's module. Its publish names the version the ask reserved, so the bundle
// is marked against its reservation (design 47 H, H-A-372).
func TestADoneBundleAnswersTheReferenceOfTheArchiveItPushed(t *testing.T) {
m, _, _ := builtMachine(t, ``)
store := withStore(t, m)
out, err := m.build(context.Background(), buildArgs())
args := buildArgs()
args["version"] = "1.4.3"
out, err := m.build(context.Background(), args)
if err != nil {
t.Fatal(err)
}
@@ -109,6 +112,9 @@ func TestADoneBundleAnswersTheReferenceOfTheArchiveItPushed(t *testing.T) {
if store.blobs["m/tools@"+r.Digest] == nil || len(store.seats) != 1 || store.seats[0] != steprun.ArtifactSeat {
t.Errorf("the holder holds %d files through %v, not m/tools@%s through %s", len(store.blobs), store.seats, r.Digest, steprun.ArtifactSeat)
}
if len(store.published) != 1 || store.published[0].Version != "1.4.3" {
t.Errorf("the bundle was published as %+v, want the ask's version 1.4.3", store.published)
}
}
// 1587-S7 and S8 (ADR 0498 §2, the lead's decision L9): a publish the holder refuses fails the step `not stored: