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
This commit is contained in:
2026-11-22 00:14:30 +01:00
parent 7030e1420c
commit 69940d1019
2 changed files with 17 additions and 6 deletions
@@ -3,13 +3,14 @@ package holder
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"strings"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds" "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 // 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 // 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. // no field. It is the Builder the holder's Check asks.
type Reserved struct { type Reserved struct {
// Ask is the runtime's request and reply over the bus (mesh-sdk stdio.Ask). // 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) return false, "", fmt.Errorf("%s answered no reservation for %s@%s: %s", Address, name, version, raw)
} }
if a.Version != version { 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 { 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 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: "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 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: "no digest recorded yet", answer: `{"module":"mesh-image","version":"0.1.7","artifacts":[{"artifact":"mesh-image:image"}]}`, ok: true},
{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: "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: "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"}, {name: "an answer that is none", answer: `{"error":"x"}`, why: "answered no reservation"},
} { } {