From 9a7cc2b632435cd79df6d34324f30a070b162f42 Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 22 Nov 2026 01:35:11 +0100 Subject: [PATCH] BM publish version (sdk): publishParts refuses a Go package or a bundle that names no version A publish by its digest alone marks no reservation, so no build module may publish a Go package or a bundle without the version its ask reserved; the refusal is loud and comes before the seat is asked. An archive may still publish by its digest. Builds: design 47 H2 H-A-373, H-A-373 (addendum) --- .../mesh-delivery-sdk/steprun/narrate_test.go | 31 ++++++++++++++++--- modules/mesh-delivery-sdk/steprun/publish.go | 7 +++++ 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/modules/mesh-delivery-sdk/steprun/narrate_test.go b/modules/mesh-delivery-sdk/steprun/narrate_test.go index a8c1500b2..b777b0857 100644 --- a/modules/mesh-delivery-sdk/steprun/narrate_test.go +++ b/modules/mesh-delivery-sdk/steprun/narrate_test.go @@ -15,13 +15,15 @@ import ( ) // CAT-NR1: a build's publish on a seat says asked, waiting on the seat (on every tick of NarrateEvery while the holder -// has not answered), and stored or refused, each as the ask's phase written to its running step key. +// has not answered), and stored or refused, each as the ask's phase written to its running step key. Design 47 H2 +// H-A-373: a Go package or a bundle with no version is refused before the seat is asked; an archive publishes by digest. func TestABuildNarratesItsPublishOnASeat(t *testing.T) { digest := "sha256:" + strings.Repeat("c", 64) for name, c := range map[string]struct { - answer error - ticks int - want []string + answer error + ticks int + seat, kind, version string + want []string }{ "stored": {want: []string{ "asked go-package-registry: publish of mod 1.2.3 at " + digest, @@ -34,6 +36,15 @@ func TestABuildNarratesItsPublishOnASeat(t *testing.T) { "waiting on go-package-registry: publish of mod 1.2.3 at " + digest + ", 5m0s since asked", "waiting on go-package-registry: publish of mod 1.2.3 at " + digest + ", 10m0s since asked", "stored on go-package-registry: publish of mod 1.2.3 at " + digest + " (0 of its 1 parts sent, the rest held)"}}, + "a Go package with no version, refused": {version: "-", answer: errors.New("never asked"), want: []string{ + "asked go-package-registry: publish of mod at " + digest, + "refused by go-package-registry: publish of mod at " + digest + ": go-package-registry's publish of mod (package) names no version: a Go package and every bundle publish under the version the ask reserved"}}, + "a Node bundle with no version, refused": {seat: NpmSeat, kind: "bundle", version: "-", answer: errors.New("never asked"), want: []string{ + "asked npm-package-registry: publish of mod at " + digest, + "refused by npm-package-registry: publish of mod at " + digest + ": npm-package-registry's publish of mod (bundle) names no version: a Go package and every bundle publish under the version the ask reserved"}}, + "an archive by its digest, stored": {seat: ArtifactSeat, kind: "archive", version: "-", want: []string{ + "asked oci-artifact-registry: publish of mod at " + digest, + "stored on oci-artifact-registry: publish of mod at " + digest + " (0 of its 1 parts sent, the rest held)"}}, } { t.Run(name, func(t *testing.T) { clock := time.Date(2026, 11, 4, 16, 0, 0, 0, time.UTC) @@ -72,7 +83,17 @@ func TestABuildNarratesItsPublishOnASeat(t *testing.T) { } ctx := context.WithValue(context.Background(), phaseKey{}, ph) done := make(chan error, 1) - go func() { done <- PublishOne(ctx, call, GoSeat, "mod", "package", "1.2.3", digest, "t", []byte("x")) }() + seat, kind, version := GoSeat, "package", "1.2.3" + if c.seat != "" { + seat = c.seat + } + if c.kind != "" { + kind = c.kind + } + if c.version == "-" { + version = "" + } + go func() { done <- PublishOne(ctx, call, seat, "mod", kind, version, digest, "t", []byte("x")) }() line := func() { select { case <-wrote: diff --git a/modules/mesh-delivery-sdk/steprun/publish.go b/modules/mesh-delivery-sdk/steprun/publish.go index 945a5f630..1d9495003 100644 --- a/modules/mesh-delivery-sdk/steprun/publish.go +++ b/modules/mesh-delivery-sdk/steprun/publish.go @@ -96,6 +96,13 @@ func PublishFault(err error) error { } func publishParts(ctx context.Context, call SeatCall, seat string, in reg.PublishInput, ps []parts.Part) (parts.Sent, error) { + // Design 47 H2 H-A-373: a publish on the Go package registry seat, and every bundle's, names the version the ask + // reserved; one by its digest alone marks no reservation, so it is refused before the seat is asked. An archive may + // still publish by its digest where no version is reserved for it. + if in.Version == "" && (seat == GoSeat || in.Kind == reg.PublishInputKindBundle) { + return parts.Sent{}, fmt.Errorf("%s's publish of %s (%s) names no version: a Go package and every bundle publish under the version the ask reserved", + seat, in.Name, in.Kind) + } switch seat { case ImageSeat: s, err := imageclient.Publish(ctx, imageclient.Call(call), in, ps)