Compare commits

...
Author SHA1 Message Date
jschoubben f85199f624 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
2026-11-19 17:09:16 +01:00
jschoubben 13d43a7de0 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
2026-11-19 17:04:55 +01:00
jschoubben 5dfb357333 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
2026-11-19 16:51:10 +01:00
4 changed files with 92 additions and 4 deletions
@@ -18,6 +18,7 @@ import (
"git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient" "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" 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 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(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}
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) { 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 // 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 // digest and no parts tags it and says published, nothing sent; a digest the store holds none of is refused as not
+1 -1
View File
@@ -291,7 +291,7 @@ func verbTools[PI, PA, PPI, PPA, VI, VA, RI, RA any](seat string, holder func()
} }
return []stdio.Tool{ return []stdio.Tool{
{Name: seat + "." + packageseats.VerbPublish, Input: obj, {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) { Run: run(func(h *packageseats.Holder, args map[string]any) (any, error) {
in, err := as[PI](args) in, err := as[PI](args)
if err != nil { if err != nil {
+18 -3
View File
@@ -213,7 +213,9 @@ func (h *Holder) answer(transfer string, r parts.Received) Answer {
return Answer{Transfer: transfer, Lacks: r.Lacks, Ended: r.Ended} 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) { func (h *Holder) Publish(seat, caller string, p Publish) (Answer, error) {
if err := checkPublish(seat, p); err != nil { if err := checkPublish(seat, p); err != nil {
return Answer{}, err return Answer{}, err
@@ -225,12 +227,25 @@ func (h *Holder) Publish(seat, caller string, p Publish) (Answer, error) {
} else if ok { } else if ok {
if d != p.Digest { if d != p.Digest {
reason := fmt.Sprintf("%s@%s is published with %s, not %s", p.Name, p.Version, d, p.Digest) 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) return Answer{Transfer: p.Transfer, Ended: true}, h.refused(Transfer{Shape: Opening{Publish: p, Seat: seat}}, reason)
} }
o := outcomeOf(p, "") o := outcomeOf(p, "")
o.Reference = Reference(p.Name, p.Version) o.Reference = Reference(p.Name, p.Version)
return Answer{Transfer: p.Transfer, Ended: true}, h.Say(seat, EventPublished, o) 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, // 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. // which key() still makes a valid id.
if strings.TrimSpace(p.Transfer) == "" { if strings.TrimSpace(p.Transfer) == "" {
@@ -377,8 +392,8 @@ func checkPublish(seat string, p Publish) error {
return fmt.Errorf("publish: %s holds packages, not a %s", seat, p.Kind) return fmt.Errorf("publish: %s holds packages, not a %s", seat, p.Kind)
case !strings.HasPrefix(p.Digest, "sha256:"): case !strings.HasPrefix(p.Digest, "sha256:"):
return fmt.Errorf("publish: digest %q is no sha256 digest", p.Digest) return fmt.Errorf("publish: digest %q is no sha256 digest", p.Digest)
case len(p.Parts) != 1 || p.Parts[0].Digest != p.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") return errors.New("publish: a package is one file, its one part the package's digest, or no part at all")
} }
return nil return nil
} }
@@ -10,6 +10,7 @@ import (
"git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient" "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/parts"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/publishconformance"
) )
type memObjects map[string][]byte 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. // forge is the forge's package registry: seat -> name@version -> file.
type forge struct { type forge struct {
files map[string]map[string][]byte files map[string]map[string][]byte
digests map[string]string // seat+name@version -> a digest held with no bytes kept
removed []string 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) { 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] b, ok := f.files[seat][name+"@"+version]
if !ok { if !ok {
return "", false, nil return "", false, nil
@@ -150,6 +162,50 @@ func TestTheForgeHoldsBothPackageSeats(t *testing.T) {
} }
} }
}) })
// 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} {
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 // 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 // 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. // dropped with its chunks when it had none for 24 hours; a cap from the binding refuses a transfer past it.