Design 47 H1 (4): a candidate's entry may name a package with no version yet

An entry names an unpublished package with an empty version, never left out, so a run on request's candidate checks its packages as an entry's (CheckEntry), not as an ask's. Built against the SDK head aee7e4c2 (fix/47-H1-sdk-empty-pin), which goes in the same merge call.

Builds: design 47 H S8 (H-pins-spec-and-gaps item 4, L10), H-A-204
This commit is contained in:
2026-11-20 23:25:24 +01:00
parent 64d5490ea2
commit 52f7a5b6f6
2 changed files with 33 additions and 1 deletions
@@ -39,7 +39,9 @@ func checkCandidateModule(m meshcatalog.CandidatesByGroupValuePullsItemFpsValue)
return fmt.Errorf("index: the named path %q names no git object", p)
}
}
if err := sdkstep.PackageVersions(m.Packages).Check(); err != nil {
// An entry names a package with no published version yet with an empty version (design 47 H S8, H-A-204): it is checked
// as an entry's packages, not as an ask's.
if err := sdkstep.PackageVersions(m.Packages).CheckEntry(); err != nil {
return err
}
if m.Fp2 != "" {
@@ -0,0 +1,30 @@
package index
import (
"strings"
"testing"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
)
// TestCheckCandidateModulePins: an entry's package with no published version (an empty pin) passes a run on request's
// candidate; a pin that is no version is refused (design 47 H S8, the pin specification's item 4).
func TestCheckCandidateModulePins(t *testing.T) {
for _, c := range []struct {
name string
packages map[string]string
ok bool
}{
{"an empty pin", map[string]string{"git.example/novox/lib/go": ""}, true},
{"a version", map[string]string{"git.example/novox/lib/go": "v0.1.4"}, true},
{"no version", map[string]string{"git.example/novox/lib/go": "latest"}, false},
} {
t.Run(c.name, func(t *testing.T) {
m := meshcatalog.CandidatesByGroupValuePullsItemFpsValue{Fp2: "src2:" + strings.Repeat("ab", 32), Packages: c.packages}
err := checkCandidateModule(m)
if (err == nil) != c.ok {
t.Errorf("checkCandidateModule(%v) = %v, want ok %v", c.packages, err, c.ok)
}
})
}
}