From 5dfb357333ff1a4b94bc636989c1905b1b59fab3 Mon Sep 17 00:00:00 2001 From: jochen Date: Thu, 19 Nov 2026 16:51:10 +0100 Subject: [PATCH 1/5] gitea: the package seats take a publish with a digest and no parts (held says published, else refused not stored) The builder's publish again sends version and digest and no parts; the package seats refused it as not one part. Both registry holders now run the publish conformance cases. Builds: design 47 G A-73, A-417, A-490 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../internal/holder/holder_test.go | 17 ++++++ modules/gitea/cmd/package-registry/seats.go | 2 +- modules/gitea/internal/packageseats/holder.go | 14 +++-- .../internal/packageseats/holder_test.go | 54 +++++++++++++++++++ 4 files changed, 83 insertions(+), 4 deletions(-) diff --git a/modules/distribution/internal/holder/holder_test.go b/modules/distribution/internal/holder/holder_test.go index 08d6aee84..e4628991b 100644 --- a/modules/distribution/internal/holder/holder_test.go +++ b/modules/distribution/internal/holder/holder_test.go @@ -18,6 +18,7 @@ import ( "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient" artifactref "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/containerimageregistryclient/reference" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/publishconformance" ) type memObjects map[string][]byte @@ -666,6 +667,22 @@ func TestTheHolderOfTheTwoImageSeats(t *testing.T) { } } }) + // Design 47 G A-490: the publish contract's no-parts form, as every publish holder is held to it. + t.Run("the publish conformance cases", func(t *testing.T) { + publishconformance.Run(t, func(t *testing.T) publishconformance.Bed { + b := newBed(true) + return publishconformance.Bed{ + Hold: func() { b.store.has[publishconformance.Digest] = true }, + Publish: func(name, version, digest string) publishconformance.Outcome { + got, err := b.h.Publish(ArtifactSeat, builder, PublishRequest{Name: name, Version: version, Kind: KindBundle, Digest: digest, Transfer: "t"}) + o := publishconformance.Outcome{Ended: got.Ended, Lacks: len(got.Missing), Err: err} + if len(b.said) > 0 { + o.Event, o.Reason = b.said[len(b.said)-1].event, b.said[len(b.said)-1].body.Reason + } + return o + }} + }) + }) t.Run("a publish with a version and no parts tags the held digest at the store's size; one not held is not stored", func(t *testing.T) { // Design 47 G A-417, A-73, A-50: the build stored the bundle untagged; the builder's publish of its version with that // digest and no parts tags it and says published, nothing sent; a digest the store holds none of is refused as not diff --git a/modules/gitea/cmd/package-registry/seats.go b/modules/gitea/cmd/package-registry/seats.go index 246da7580..63ddb1f49 100644 --- a/modules/gitea/cmd/package-registry/seats.go +++ b/modules/gitea/cmd/package-registry/seats.go @@ -291,7 +291,7 @@ func verbTools[PI, PA, PPI, PPA, VI, VA, RI, RA any](seat string, holder func() } return []stdio.Tool{ {Name: seat + "." + packageseats.VerbPublish, Input: obj, - Description: "Open a transfer of a package's one file (ADR 0611): its name, the builder's version, kind package, its sha256 digest and the file as its one part; answers the part the forge lacks. A version held with that digest answers held and says published.", + Description: "Open a transfer of a package's one file (ADR 0611): its name, the builder's version, kind package, its sha256 digest and the file as its one part; answers the part the forge lacks. A version held with that digest answers held and says published; with no part at all (the builder's publish again) nothing moves: held says published, else refused as not stored, naming the digest (design 47 G A-490).", Run: run(func(h *packageseats.Holder, args map[string]any) (any, error) { in, err := as[PI](args) if err != nil { diff --git a/modules/gitea/internal/packageseats/holder.go b/modules/gitea/internal/packageseats/holder.go index f16b8a8f3..dff199e88 100644 --- a/modules/gitea/internal/packageseats/holder.go +++ b/modules/gitea/internal/packageseats/holder.go @@ -213,7 +213,9 @@ func (h *Holder) answer(transfer string, r parts.Received) Answer { return Answer{Transfer: transfer, Lacks: r.Lacks, Ended: r.Ended} } -// Publish is `publish` on seat for the proved caller: a package is one file, its digest the file's sha256. +// Publish is `publish` on seat for the proved caller: a package is one file, its digest the file's sha256. With its one +// part the file travels (design 51 *Publishing*); with none (the builder's publish again, design 47 G A-73, A-417) the +// version is said published when the forge holds it under the digest, and refused as not stored otherwise. func (h *Holder) Publish(seat, caller string, p Publish) (Answer, error) { if err := checkPublish(seat, p); err != nil { return Answer{}, err @@ -231,6 +233,12 @@ func (h *Holder) Publish(seat, caller string, p Publish) (Answer, error) { o.Reference = Reference(p.Name, p.Version) return Answer{Transfer: p.Transfer, Ended: true}, h.Say(seat, EventPublished, o) } + // A publish with a version, a digest and no parts (design 47 G A-73, A-417): what the forge holds under the version has + // been said published above; nothing else travels, so the publish is refused as not stored, naming the digest. + if len(p.Parts) == 0 { + reason := fmt.Sprintf("not stored: the forge holds no %s of %s, so version %s names nothing", p.Digest, p.Name, p.Version) + return Answer{Transfer: p.Transfer, Ended: true}, errors.Join(errors.New("publish: "+reason), h.refused(Transfer{Shape: Opening{Publish: p, Seat: seat}}, reason)) + } // The transfer's name is the caller's own (the seat's contract): none would open the seat's one nameless transfer, // which key() still makes a valid id. if strings.TrimSpace(p.Transfer) == "" { @@ -377,8 +385,8 @@ func checkPublish(seat string, p Publish) error { return fmt.Errorf("publish: %s holds packages, not a %s", seat, p.Kind) case !strings.HasPrefix(p.Digest, "sha256:"): return fmt.Errorf("publish: digest %q is no sha256 digest", p.Digest) - case len(p.Parts) != 1 || p.Parts[0].Digest != p.Digest: - return errors.New("publish: a package is one file, its one part the package's digest") + case len(p.Parts) > 1 || (len(p.Parts) == 1 && p.Parts[0].Digest != p.Digest): + return errors.New("publish: a package is one file, its one part the package's digest, or no part at all") } return nil } diff --git a/modules/gitea/internal/packageseats/holder_test.go b/modules/gitea/internal/packageseats/holder_test.go index 9fd27c9b2..9e41d5560 100644 --- a/modules/gitea/internal/packageseats/holder_test.go +++ b/modules/gitea/internal/packageseats/holder_test.go @@ -10,6 +10,7 @@ import ( "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/parts" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/publishconformance" ) type memObjects map[string][]byte @@ -50,10 +51,21 @@ func (b builder) Recorded(_, _, _ string) (bool, string, error) { return b.ok, " // forge is the forge's package registry: seat -> name@version -> file. type forge struct { files map[string]map[string][]byte + digests map[string]string // seat+name@version -> a digest held with no bytes kept removed []string } +func (f *forge) holdDigest(seat, name, version, d string) { + if f.digests == nil { + f.digests = map[string]string{} + } + f.digests[seat+" "+name+"@"+version] = d +} + func (f *forge) Held(seat, name, version string) (string, bool, error) { + if d, ok := f.digests[seat+" "+name+"@"+version]; ok { + return d, true, nil + } b, ok := f.files[seat][name+"@"+version] if !ok { return "", false, nil @@ -150,6 +162,48 @@ func TestTheForgeHoldsBothPackageSeats(t *testing.T) { } } }) + // Design 47 G A-490: the publish contract's no-parts form, as every publish holder is held to it. + t.Run("the publish conformance cases", func(t *testing.T) { + publishconformance.Run(t, func(t *testing.T) publishconformance.Bed { + b := newBed(true) + return publishconformance.Bed{ + Hold: func() { + b.forge.holdDigest(GoSeat, publishconformance.Name, publishconformance.Version, publishconformance.Digest) + }, + Publish: func(name, version, digest string) publishconformance.Outcome { + a, err := b.h.Publish(GoSeat, goBuild, Publish{Transfer: "t", Name: name, Version: version, Kind: KindPackage, Digest: digest}) + o := publishconformance.Outcome{Ended: a.Ended, Lacks: len(a.Lacks), Err: err} + if len(b.said) > 0 { + o.Event, o.Reason = b.said[len(b.said)-1].event, b.said[len(b.said)-1].o.Reason + } + return o + }} + }) + }) + // Design 47 G A-73, A-417: the builder's publish again names the version and the digest and no parts. + t.Run("a publish with a digest and no parts is published when held, refused as not stored when not", func(t *testing.T) { + for _, seat := range []string{NpmSeat, GoSeat} { + b := newBed(true) + none := pub("mesh-sdk", "0.1.0", file) + none.Parts = nil + a, err := b.h.Publish(seat, goBuild, none) + if err == nil || !strings.Contains(err.Error(), "not stored") || !strings.Contains(err.Error(), digest(file)) || !a.Ended { + t.Fatalf("%s: a publish of a digest the forge lacks answered %+v, %v; want refused as not stored, naming the digest", seat, a, err) + } + if len(b.said) != 1 || b.said[0].event != EventRefused || !strings.Contains(b.said[0].o.Reason, digest(file)) || !b.findings["publish-refused mesh-sdk@0.1.0"] { + t.Errorf("%s: said %+v, findings %v; want refused with the digest and the finding raised", seat, b.said, b.findings) + } + b = newBed(true) + if _, ok := b.forge.files[seat]; !ok { + b.forge.files[seat] = map[string][]byte{} + } + b.forge.files[seat]["mesh-sdk@0.1.0"] = file + a, err = b.h.Publish(seat, goBuild, none) + if err != nil || !a.Ended || len(a.Lacks) != 0 || len(b.said) != 1 || b.said[0].event != EventPublished || b.said[0].o.Reference != "mesh-sdk@0.1.0" { + t.Errorf("%s: a held digest answered %+v, %v, said %+v; want published", seat, a, err, b.said) + } + } + }) // Tools review F4 and running review F2's kind: a seat's incoming is read per seat with the cap its binding // carries; an open transfer is armed with its idle key, re-armed for the rest when it took a chunk since, and // dropped with its chunks when it had none for 24 hours; a cap from the binding refuses a transfer past it. From 13d43a7de0669f28c55e37d3b47d6d0a7ecb7a93 Mon Sep 17 00:00:00 2001 From: jochen Date: Thu, 19 Nov 2026 17:04:55 +0100 Subject: [PATCH 2/5] gitea: a no-parts publish of a version held under another digest is refused as not stored, named by its digest; conformance runs on both package seats The builder's republish recognises a refusal by the words not stored. Builds: design 47 G A-490, A-490a Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../internal/holder/holder_test.go | 2 +- modules/gitea/internal/packageseats/holder.go | 6 ++- .../internal/packageseats/holder_test.go | 38 ++++++++++--------- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/modules/distribution/internal/holder/holder_test.go b/modules/distribution/internal/holder/holder_test.go index e4628991b..bec32edc6 100644 --- a/modules/distribution/internal/holder/holder_test.go +++ b/modules/distribution/internal/holder/holder_test.go @@ -672,7 +672,7 @@ func TestTheHolderOfTheTwoImageSeats(t *testing.T) { publishconformance.Run(t, func(t *testing.T) publishconformance.Bed { b := newBed(true) return publishconformance.Bed{ - Hold: func() { b.store.has[publishconformance.Digest] = true }, + Hold: func(d string) { b.store.has[d] = true }, Publish: func(name, version, digest string) publishconformance.Outcome { got, err := b.h.Publish(ArtifactSeat, builder, PublishRequest{Name: name, Version: version, Kind: KindBundle, Digest: digest, Transfer: "t"}) o := publishconformance.Outcome{Ended: got.Ended, Lacks: len(got.Missing), Err: err} diff --git a/modules/gitea/internal/packageseats/holder.go b/modules/gitea/internal/packageseats/holder.go index dff199e88..ab75d02a9 100644 --- a/modules/gitea/internal/packageseats/holder.go +++ b/modules/gitea/internal/packageseats/holder.go @@ -226,8 +226,10 @@ func (h *Holder) Publish(seat, caller string, p Publish) (Answer, error) { return Answer{}, fmt.Errorf("publish: the forge cannot say whether it holds %s@%s: %w", p.Name, p.Version, err) } else if ok { if d != p.Digest { - reason := fmt.Sprintf("%s@%s is published with %s, not %s", p.Name, p.Version, d, p.Digest) - return Answer{Transfer: p.Transfer, Ended: true}, h.refused(Transfer{Shape: Opening{Publish: p, Seat: seat}}, reason) + // A no-parts publish names nothing the forge holds: it is refused as not stored (A-490), which the builder's + // republish recognises by those words. + reason := fmt.Sprintf("not stored: %s@%s is published with %s, not %s", p.Name, p.Version, d, p.Digest) + return Answer{Transfer: p.Transfer, Ended: true}, errors.Join(errors.New("publish: "+reason), h.refused(Transfer{Shape: Opening{Publish: p, Seat: seat}}, reason)) } o := outcomeOf(p, "") o.Reference = Reference(p.Name, p.Version) diff --git a/modules/gitea/internal/packageseats/holder_test.go b/modules/gitea/internal/packageseats/holder_test.go index 9e41d5560..95a15a3f0 100644 --- a/modules/gitea/internal/packageseats/holder_test.go +++ b/modules/gitea/internal/packageseats/holder_test.go @@ -162,24 +162,26 @@ func TestTheForgeHoldsBothPackageSeats(t *testing.T) { } } }) - // Design 47 G A-490: the publish contract's no-parts form, as every publish holder is held to it. - t.Run("the publish conformance cases", func(t *testing.T) { - publishconformance.Run(t, func(t *testing.T) publishconformance.Bed { - b := newBed(true) - return publishconformance.Bed{ - Hold: func() { - b.forge.holdDigest(GoSeat, publishconformance.Name, publishconformance.Version, publishconformance.Digest) - }, - Publish: func(name, version, digest string) publishconformance.Outcome { - a, err := b.h.Publish(GoSeat, goBuild, Publish{Transfer: "t", Name: name, Version: version, Kind: KindPackage, Digest: digest}) - o := publishconformance.Outcome{Ended: a.Ended, Lacks: len(a.Lacks), Err: err} - if len(b.said) > 0 { - o.Event, o.Reason = b.said[len(b.said)-1].event, b.said[len(b.said)-1].o.Reason - } - return o - }} + // Design 47 G A-490, A-490a: the publish contract's no-parts form, as every publish holder is held to it, per seat. + for _, seat := range []string{GoSeat, NpmSeat} { + t.Run("the publish conformance cases on "+seat, func(t *testing.T) { + publishconformance.Run(t, func(t *testing.T) publishconformance.Bed { + b := newBed(true) + return publishconformance.Bed{ + Hold: func(d string) { + b.forge.holdDigest(seat, publishconformance.Name, publishconformance.Version, d) + }, + Publish: func(name, version, digest string) publishconformance.Outcome { + a, err := b.h.Publish(seat, goBuild, Publish{Transfer: "t", Name: name, Version: version, Kind: KindPackage, Digest: digest}) + o := publishconformance.Outcome{Ended: a.Ended, Lacks: len(a.Lacks), Err: err} + if len(b.said) > 0 { + o.Event, o.Reason = b.said[len(b.said)-1].event, b.said[len(b.said)-1].o.Reason + } + return o + }} + }) }) - }) + } // Design 47 G A-73, A-417: the builder's publish again names the version and the digest and no parts. t.Run("a publish with a digest and no parts is published when held, refused as not stored when not", func(t *testing.T) { for _, seat := range []string{NpmSeat, GoSeat} { @@ -332,7 +334,7 @@ func TestTheForgeHoldsBothPackageSeats(t *testing.T) { // The same version published with other content is refused, never uploaded over. b = newBed(true) b.forge.files[NpmSeat] = map[string][]byte{"x@0.1.0": []byte("first")} - if _, err := b.h.Publish(NpmSeat, nodeBuild, pub("x", "0.1.0", file)); err != nil || len(b.said) != 1 || b.said[0].event != EventRefused { + if _, err := b.h.Publish(NpmSeat, nodeBuild, pub("x", "0.1.0", file)); err == nil || !strings.Contains(err.Error(), "not stored") || len(b.said) != 1 || b.said[0].event != EventRefused { t.Errorf("a published version with other content: %v, said %+v", err, b.said) } }) From f85199f624a99589efeb3a04177f564f00418e8c Mon Sep 17 00:00:00 2001 From: jochen Date: Thu, 19 Nov 2026 17:09:16 +0100 Subject: [PATCH 3/5] gitea: the not-stored refusal for another digest applies to the no-parts publish only; the one-part publish keeps trunk's refusal Builds: design 47 G A-490, A-490a Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- modules/gitea/internal/packageseats/holder.go | 13 +++++++++---- modules/gitea/internal/packageseats/holder_test.go | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/modules/gitea/internal/packageseats/holder.go b/modules/gitea/internal/packageseats/holder.go index ab75d02a9..53ca97aa0 100644 --- a/modules/gitea/internal/packageseats/holder.go +++ b/modules/gitea/internal/packageseats/holder.go @@ -226,10 +226,15 @@ func (h *Holder) Publish(seat, caller string, p Publish) (Answer, error) { return Answer{}, fmt.Errorf("publish: the forge cannot say whether it holds %s@%s: %w", p.Name, p.Version, err) } else if ok { if d != p.Digest { - // A no-parts publish names nothing the forge holds: it is refused as not stored (A-490), which the builder's - // republish recognises by those words. - reason := fmt.Sprintf("not stored: %s@%s is published with %s, not %s", p.Name, p.Version, d, p.Digest) - return Answer{Transfer: p.Transfer, Ended: true}, errors.Join(errors.New("publish: "+reason), h.refused(Transfer{Shape: Opening{Publish: p, Seat: seat}}, reason)) + reason := fmt.Sprintf("%s@%s is published with %s, not %s", p.Name, p.Version, d, p.Digest) + if len(p.Parts) == 0 { + // The builder's publish again names nothing the forge holds under that digest: refused as not stored (A-490, + // A-490a), the words its republish recognises. + reason = "not stored: " + reason + return Answer{Transfer: p.Transfer, Ended: true}, errors.Join(errors.New("publish: "+reason), h.refused(Transfer{Shape: Opening{Publish: p, Seat: seat}}, reason)) + } + // A one-part publish of a taken version is refused with an event only, as the registry would (the builder's "version taken"). + return Answer{Transfer: p.Transfer, Ended: true}, h.refused(Transfer{Shape: Opening{Publish: p, Seat: seat}}, reason) } o := outcomeOf(p, "") o.Reference = Reference(p.Name, p.Version) diff --git a/modules/gitea/internal/packageseats/holder_test.go b/modules/gitea/internal/packageseats/holder_test.go index 95a15a3f0..c11ac064b 100644 --- a/modules/gitea/internal/packageseats/holder_test.go +++ b/modules/gitea/internal/packageseats/holder_test.go @@ -334,7 +334,7 @@ func TestTheForgeHoldsBothPackageSeats(t *testing.T) { // The same version published with other content is refused, never uploaded over. b = newBed(true) b.forge.files[NpmSeat] = map[string][]byte{"x@0.1.0": []byte("first")} - if _, err := b.h.Publish(NpmSeat, nodeBuild, pub("x", "0.1.0", file)); err == nil || !strings.Contains(err.Error(), "not stored") || len(b.said) != 1 || b.said[0].event != EventRefused { + if _, err := b.h.Publish(NpmSeat, nodeBuild, pub("x", "0.1.0", file)); err != nil || len(b.said) != 1 || b.said[0].event != EventRefused { t.Errorf("a published version with other content: %v, said %+v", err, b.said) } }) From 4bdcedd0f009e92eb74b807bf79653f214cd7f65 Mon Sep 17 00:00:00 2001 From: jochen Date: Thu, 19 Nov 2026 21:34:20 +0100 Subject: [PATCH 4/5] Registry holders take a one-part publish made while the build runs: a reserved artifact with no digest yet accepts it (A-490j) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Builds: design 47 G A-490j, §381, A-415 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../internal/holder/holder_test.go | 33 +++++++++++++++++ .../distribution/internal/holder/reserved.go | 7 ++-- .../internal/holder/reserved_test.go | 1 + .../internal/packageseats/holder_test.go | 35 +++++++++++++++++++ .../gitea/internal/packageseats/reserved.go | 7 ++-- .../internal/packageseats/reserved_test.go | 1 + 6 files changed, 80 insertions(+), 4 deletions(-) diff --git a/modules/distribution/internal/holder/holder_test.go b/modules/distribution/internal/holder/holder_test.go index bec32edc6..aa57b8926 100644 --- a/modules/distribution/internal/holder/holder_test.go +++ b/modules/distribution/internal/holder/holder_test.go @@ -683,6 +683,39 @@ func TestTheHolderOfTheTwoImageSeats(t *testing.T) { }} }) }) + // Design 47 G A-490j: the one-part publish a build module makes while it builds, as every publish holder is held to it, + // checked through the real Reserved against the builder's answer. + t.Run("the publish while the build runs", func(t *testing.T) { + publishconformance.RunReserved(t, func(t *testing.T) publishconformance.ReservedBed { + b := newBed(true) + answer := "" + b.h.Builder = Reserved{Ask: func(string, any) (json.RawMessage, error) { + if answer == "" { + return nil, errors.New("no reserved version of m/tools") + } + return json.RawMessage(answer), nil + }} + return publishconformance.ReservedBed{ + Reserve: func(r publishconformance.Reservation) { + d := map[publishconformance.Reservation]string{publishconformance.NoDigestYet: "", publishconformance.SameDigest: part.Digest, + publishconformance.OtherDigest: digestOf([]byte("another"))}[r] + answer = `{"module":"m","version":"0.1.0","artifacts":[{"artifact":"m:tools","digest":"` + d + `"}]}` + }, + PublishWhole: func() publishconformance.Outcome { + r := req("t-whole") + r.Version = "0.1.0" + a, err := b.h.Publish(ArtifactSeat, builder, r) + if err == nil && !a.Ended { + _, err = b.h.PublishPart(ArtifactSeat, builder, PartRequest{Transfer: "t-whole", Digest: part.Digest, Last: true, Data: blob}) + } + o := publishconformance.Outcome{Err: err} + if len(b.said) > 0 { + o.Event, o.Reason = b.said[len(b.said)-1].event, b.said[len(b.said)-1].body.Reason + } + return o + }} + }) + }) t.Run("a publish with a version and no parts tags the held digest at the store's size; one not held is not stored", func(t *testing.T) { // Design 47 G A-417, A-73, A-50: the build stored the bundle untagged; the builder's publish of its version with that // digest and no parts tags it and says published, nothing sent; a digest the store holds none of is refused as not diff --git a/modules/distribution/internal/holder/reserved.go b/modules/distribution/internal/holder/reserved.go index b649431d5..4df57c131 100644 --- a/modules/distribution/internal/holder/reserved.go +++ b/modules/distribution/internal/holder/reserved.go @@ -9,7 +9,7 @@ import ( // 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 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). @@ -34,7 +34,10 @@ func (r Reserved) Recorded(name, version, digest string) (bool, string, error) { return false, fmt.Sprintf("%s reserved %s for %s, not %s", a.Module, a.Version, name, version), nil } 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 (design 47 G §369, A-415, A-490j). Its record then meets what + // the holder holds: the published kept on the reservation marks the artifact, and a digest that differs fails the build. + if art.Digest == digest || art.Digest == "" { return true, "", nil } } diff --git a/modules/distribution/internal/holder/reserved_test.go b/modules/distribution/internal/holder/reserved_test.go index faa32b074..5e0b33973 100644 --- a/modules/distribution/internal/holder/reserved_test.go +++ b/modules/distribution/internal/holder/reserved_test.go @@ -19,6 +19,7 @@ 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: "the artifact is not built 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: "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: "the builder refused the name", err: errors.New("no entry carries registry/mesh-image"), why: "no entry carries registry/mesh-image"}, diff --git a/modules/gitea/internal/packageseats/holder_test.go b/modules/gitea/internal/packageseats/holder_test.go index c11ac064b..45674e492 100644 --- a/modules/gitea/internal/packageseats/holder_test.go +++ b/modules/gitea/internal/packageseats/holder_test.go @@ -3,6 +3,7 @@ package packageseats import ( "crypto/sha256" "encoding/hex" + "encoding/json" "errors" "strings" "testing" @@ -182,6 +183,40 @@ func TestTheForgeHoldsBothPackageSeats(t *testing.T) { }) }) } + // Design 47 G A-490j: the one-part publish a build module makes while it builds, as every publish holder is held to it, per + // seat, checked through the real Reserved against the builder's answer. + for _, seat := range []string{GoSeat, NpmSeat} { + t.Run("the publish while the build runs on "+seat, func(t *testing.T) { + publishconformance.RunReserved(t, func(t *testing.T) publishconformance.ReservedBed { + b := newBed(true) + whole := []byte("a package built now") + answer := "" + b.h.Builder = Reserved{Ask: func(string, any) (json.RawMessage, error) { + if answer == "" { + return nil, errors.New("no reserved version of mesh-sdk") + } + return json.RawMessage(answer), nil + }} + return publishconformance.ReservedBed{ + Reserve: func(r publishconformance.Reservation) { + d := map[publishconformance.Reservation]string{publishconformance.NoDigestYet: "", publishconformance.SameDigest: digest(whole), + publishconformance.OtherDigest: digest([]byte("another"))}[r] + answer = `{"module":"mesh-sdk","version":"0.1.19","artifacts":[{"artifact":"mesh-sdk:` + seat + `","digest":"` + d + `"}]}` + }, + PublishWhole: func() publishconformance.Outcome { + a, err := b.h.Publish(seat, goBuild, pub("mesh-sdk", "0.1.19", whole)) + if err == nil && !a.Ended { + _, err = b.h.PublishPart(seat, goBuild, "t-mesh-sdk", digest(whole), 0, true, whole) + } + o := publishconformance.Outcome{Err: err} + if len(b.said) > 0 { + o.Event, o.Reason = b.said[len(b.said)-1].event, b.said[len(b.said)-1].o.Reason + } + return o + }} + }) + }) + } // Design 47 G A-73, A-417: the builder's publish again names the version and the digest and no parts. t.Run("a publish with a digest and no parts is published when held, refused as not stored when not", func(t *testing.T) { for _, seat := range []string{NpmSeat, GoSeat} { diff --git a/modules/gitea/internal/packageseats/reserved.go b/modules/gitea/internal/packageseats/reserved.go index 15da4fad9..4373a31a5 100644 --- a/modules/gitea/internal/packageseats/reserved.go +++ b/modules/gitea/internal/packageseats/reserved.go @@ -9,7 +9,7 @@ import ( // 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 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). @@ -34,7 +34,10 @@ func (r Reserved) Recorded(name, version, digest string) (bool, string, error) { return false, fmt.Sprintf("%s reserved %s for %s, not %s", a.Module, a.Version, name, version), nil } 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 (design 47 G §369, A-415, A-490j). Its record then meets what + // the holder holds: the published kept on the reservation marks the artifact, and a digest that differs fails the build. + if art.Digest == digest || art.Digest == "" { return true, "", nil } } diff --git a/modules/gitea/internal/packageseats/reserved_test.go b/modules/gitea/internal/packageseats/reserved_test.go index dff3f891f..ad81738ce 100644 --- a/modules/gitea/internal/packageseats/reserved_test.go +++ b/modules/gitea/internal/packageseats/reserved_test.go @@ -19,6 +19,7 @@ func reservedChecksAPublishAgainstTheReservation(t *testing.T) { }{ {name: "the reserved version and digest", answer: `{"module":"mesh-sdk","version":"0.1.19","artifacts":[{"artifact":"mesh-sdk:ts","digest":"sha256:aa"}]}`, ok: true}, {name: "another artifact of it carries the digest", answer: `{"module":"mesh-sdk","version":"0.1.19","artifacts":[{"artifact":"mesh-sdk:go"},{"artifact":"mesh-sdk:ts","digest":"sha256:aa"}]}`, ok: true}, + {name: "the artifact is not built yet", answer: `{"module":"mesh-sdk","version":"0.1.19","artifacts":[{"artifact":"mesh-sdk:ts"}]}`, ok: true}, {name: "another digest", answer: `{"module":"mesh-sdk","version":"0.1.19","artifacts":[{"artifact":"mesh-sdk:ts","digest":"sha256:bb"}]}`, why: "another digest than sha256:aa"}, {name: "another version reserved", answer: `{"module":"mesh-sdk","version":"0.1.20","artifacts":[]}`, why: "reserved 0.1.20 for @novox/mesh-sdk, not 0.1.19"}, {name: "the builder refused the name", err: errors.New("no entry carries @novox/mesh-sdk"), why: "no entry carries @novox/mesh-sdk"}, From ac2cd3749cb8b5f7a77f31cd4ddd05a2712a5400 Mon Sep 17 00:00:00 2001 From: jochen Date: Thu, 19 Nov 2026 21:39:35 +0100 Subject: [PATCH 5/5] Registry holders: the distribution holder keeps trunk's check; the package holders run the kit's held-under-another-digest case on both seats (A-490j, A-490a) Builds: design 47 G A-490j, A-490a Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../internal/holder/holder_test.go | 33 ------------------- .../distribution/internal/holder/reserved.go | 7 ++-- .../internal/holder/reserved_test.go | 1 - .../internal/packageseats/holder_test.go | 1 + 4 files changed, 3 insertions(+), 39 deletions(-) diff --git a/modules/distribution/internal/holder/holder_test.go b/modules/distribution/internal/holder/holder_test.go index aa57b8926..bec32edc6 100644 --- a/modules/distribution/internal/holder/holder_test.go +++ b/modules/distribution/internal/holder/holder_test.go @@ -683,39 +683,6 @@ func TestTheHolderOfTheTwoImageSeats(t *testing.T) { }} }) }) - // Design 47 G A-490j: the one-part publish a build module makes while it builds, as every publish holder is held to it, - // checked through the real Reserved against the builder's answer. - t.Run("the publish while the build runs", func(t *testing.T) { - publishconformance.RunReserved(t, func(t *testing.T) publishconformance.ReservedBed { - b := newBed(true) - answer := "" - b.h.Builder = Reserved{Ask: func(string, any) (json.RawMessage, error) { - if answer == "" { - return nil, errors.New("no reserved version of m/tools") - } - return json.RawMessage(answer), nil - }} - return publishconformance.ReservedBed{ - Reserve: func(r publishconformance.Reservation) { - d := map[publishconformance.Reservation]string{publishconformance.NoDigestYet: "", publishconformance.SameDigest: part.Digest, - publishconformance.OtherDigest: digestOf([]byte("another"))}[r] - answer = `{"module":"m","version":"0.1.0","artifacts":[{"artifact":"m:tools","digest":"` + d + `"}]}` - }, - PublishWhole: func() publishconformance.Outcome { - r := req("t-whole") - r.Version = "0.1.0" - a, err := b.h.Publish(ArtifactSeat, builder, r) - if err == nil && !a.Ended { - _, err = b.h.PublishPart(ArtifactSeat, builder, PartRequest{Transfer: "t-whole", Digest: part.Digest, Last: true, Data: blob}) - } - o := publishconformance.Outcome{Err: err} - if len(b.said) > 0 { - o.Event, o.Reason = b.said[len(b.said)-1].event, b.said[len(b.said)-1].body.Reason - } - return o - }} - }) - }) t.Run("a publish with a version and no parts tags the held digest at the store's size; one not held is not stored", func(t *testing.T) { // Design 47 G A-417, A-73, A-50: the build stored the bundle untagged; the builder's publish of its version with that // digest and no parts tags it and says published, nothing sent; a digest the store holds none of is refused as not diff --git a/modules/distribution/internal/holder/reserved.go b/modules/distribution/internal/holder/reserved.go index 4df57c131..b649431d5 100644 --- a/modules/distribution/internal/holder/reserved.go +++ b/modules/distribution/internal/holder/reserved.go @@ -9,7 +9,7 @@ import ( // 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 or none yet (A-490j). 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. 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). @@ -34,10 +34,7 @@ func (r Reserved) Recorded(name, version, digest string) (bool, string, error) { return false, fmt.Sprintf("%s reserved %s for %s, not %s", a.Module, a.Version, name, version), nil } for _, art := range a.Artifacts { - // 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 (design 47 G §369, A-415, A-490j). Its record then meets what - // the holder holds: the published kept on the reservation marks the artifact, and a digest that differs fails the build. - if art.Digest == digest || art.Digest == "" { + if art.Digest == digest { return true, "", nil } } diff --git a/modules/distribution/internal/holder/reserved_test.go b/modules/distribution/internal/holder/reserved_test.go index 5e0b33973..faa32b074 100644 --- a/modules/distribution/internal/holder/reserved_test.go +++ b/modules/distribution/internal/holder/reserved_test.go @@ -19,7 +19,6 @@ 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: "the artifact is not built 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: "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: "the builder refused the name", err: errors.New("no entry carries registry/mesh-image"), why: "no entry carries registry/mesh-image"}, diff --git a/modules/gitea/internal/packageseats/holder_test.go b/modules/gitea/internal/packageseats/holder_test.go index 45674e492..405b9e210 100644 --- a/modules/gitea/internal/packageseats/holder_test.go +++ b/modules/gitea/internal/packageseats/holder_test.go @@ -203,6 +203,7 @@ func TestTheForgeHoldsBothPackageSeats(t *testing.T) { publishconformance.OtherDigest: digest([]byte("another"))}[r] answer = `{"module":"mesh-sdk","version":"0.1.19","artifacts":[{"artifact":"mesh-sdk:` + seat + `","digest":"` + d + `"}]}` }, + Hold: func() { b.forge.holdDigest(seat, "mesh-sdk", "0.1.19", digest([]byte("first"))) }, PublishWhole: func() publishconformance.Outcome { a, err := b.h.Publish(seat, goBuild, pub("mesh-sdk", "0.1.19", whole)) if err == nil && !a.Ended {