Contracts: the catalog seat's manifest-digest helpers move to its client, out of the generated root (H-A-200)
The seat generator's check failed every unit step of the contracts mover (pipeline main.43): manifestdigest.go was
written by hand under go/seats/meshcatalog (598125a1), a generated root every file of which is the generator's. The two
helpers move to the seat's hand-written client meshcatalogclient and their callers in the builder and the indexer
follow; the generator then writes the contract as the module holds it. steprun's generator test now also holds this
repository's own contracts module in step under both roots.
Builds: design 47 G §370, G §578, H §774, H-A-200 (ADR 0608 §5)
This commit is contained in:
@@ -45,7 +45,7 @@ func (m *entryManifests) keep(e meshcatalog.CatalogEntry) error {
|
||||
if m.byFp == nil {
|
||||
m.byFp = map[string]catalogue.Manifest{}
|
||||
}
|
||||
m.byFp[meshcatalog.BareManifestDigest(e.ManifestDigest)] = mf
|
||||
m.byFp[meshcatalogclient.BareManifestDigest(e.ManifestDigest)] = mf
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -291,7 +291,7 @@ func (b *Builder) take(ctx context.Context, o Origin, key string, m meshcatalog.
|
||||
// built against, its packages and needs, and the named paths of its artifacts when every artifact names them.
|
||||
func ModuleOf(e meshcatalog.CatalogEntry) meshcatalog.ModulesByModuleValue {
|
||||
m := meshcatalog.ModulesByModuleValue{Repository: e.Repository, Path: e.Path, Commit: e.Commit, Fp2: e.Fp, None2: e.None,
|
||||
Manifest: meshcatalog.BareManifestDigest(e.ManifestDigest), Packages: e.Packages, Needs: e.Needs}
|
||||
Manifest: meshcatalogclient.BareManifestDigest(e.ManifestDigest), Packages: e.Packages, Needs: e.Needs}
|
||||
if len(e.Bases) > 0 {
|
||||
m.Inputs2 = &meshcatalog.ModulesByModuleValueInputs2{Bases: e.Bases}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
||||
"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/meshcatalog"
|
||||
)
|
||||
@@ -64,7 +65,7 @@ func (b *Builder) buildEntry(ctx context.Context, e meshbuilds.BuildEntry) (outc
|
||||
return meshbuilds.StepEndedOutcomeCouldNotRun, fmt.Sprintf("the entry of %s at %s is of %s at %s", e.Module, e.Fingerprint, entry.Module, entry.Commit)
|
||||
}
|
||||
// A package the entry names with no pin is built against its publish, waited for (H-A-192, H-A-165).
|
||||
pinned, outcome, said := b.awaitPublished(ctx, entry.Module, entry.Fp, meshcatalog.BareManifestDigest(entry.ManifestDigest), entry.Packages)
|
||||
pinned, outcome, said := b.awaitPublished(ctx, entry.Module, entry.Fp, meshcatalogclient.BareManifestDigest(entry.ManifestDigest), entry.Packages)
|
||||
if outcome != "" {
|
||||
return outcome, said
|
||||
}
|
||||
@@ -81,8 +82,8 @@ func (b *Builder) buildEntry(ctx context.Context, e meshbuilds.BuildEntry) (outc
|
||||
}
|
||||
return meshbuilds.StepEndedOutcomeFailed, failedWords
|
||||
}
|
||||
m := meshcatalog.ModulesByModuleValue{Repository: entry.Repository, Commit: entry.Commit, Fp2: entry.Fp, Manifest: meshcatalog.BareManifestDigest(entry.ManifestDigest), Path: entry.Path,
|
||||
Toolchains: CatalogToolchains(b.agreedFor(ctx, meshcatalog.BareManifestDigest(entry.ManifestDigest))), Packages: entry.Packages}
|
||||
m := meshcatalog.ModulesByModuleValue{Repository: entry.Repository, Commit: entry.Commit, Fp2: entry.Fp, Manifest: meshcatalogclient.BareManifestDigest(entry.ManifestDigest), Path: entry.Path,
|
||||
Toolchains: CatalogToolchains(b.agreedFor(ctx, meshcatalogclient.BareManifestDigest(entry.ManifestDigest))), Packages: entry.Packages}
|
||||
b.consider(ctx, entry.Module, m)
|
||||
select {
|
||||
case log := <-ended:
|
||||
@@ -113,7 +114,7 @@ func (b *Builder) passedWithItsVersion(ctx context.Context, entry meshcatalog.Ca
|
||||
if !reserving {
|
||||
return meshbuilds.StepEndedOutcomePassed, ""
|
||||
}
|
||||
plan, planErr, _ := b.planOf(ctx, meshcatalog.BareManifestDigest(entry.ManifestDigest))
|
||||
plan, planErr, _ := b.planOf(ctx, meshcatalogclient.BareManifestDigest(entry.ManifestDigest))
|
||||
switch {
|
||||
case planErr != nil:
|
||||
return meshbuilds.StepEndedOutcomeCouldNotRun, fmt.Sprintf("%s at %s: the plan cannot be read to judge its version: %v", entry.Module, entry.Fp, planErr)
|
||||
|
||||
+4
-1
@@ -1,4 +1,7 @@
|
||||
package meshcatalog
|
||||
package meshcatalogclient
|
||||
|
||||
// The two helpers below are hand-written, so they live in the seat's client, never under its contract's generated
|
||||
// root (design 47 H, H-A-200; ADR 0608 §5).
|
||||
|
||||
import "strings"
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package meshcatalogclient
|
||||
|
||||
import "testing"
|
||||
|
||||
// An entry's manifest-digest carries sha256: and the module's value and the key of `manifests` the 64 digits bare, one
|
||||
// digest in two forms (design 47 G §578); the two helpers live in the seat's client, outside its contract's generated
|
||||
// root (H-A-200).
|
||||
func TestAManifestDigestIsPrefixedForTheEntryAndBareForTheKey(t *testing.T) {
|
||||
const bare = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
|
||||
for _, tc := range []struct{ in, entry, key string }{
|
||||
{bare, "sha256:" + bare, bare},
|
||||
{"sha256:" + bare, "sha256:" + bare, bare},
|
||||
{"", "", ""},
|
||||
} {
|
||||
if got := EntryManifestDigest(tc.in); got != tc.entry {
|
||||
t.Errorf("EntryManifestDigest(%q) = %q, want %q", tc.in, got, tc.entry)
|
||||
}
|
||||
if got := BareManifestDigest(tc.in); got != tc.key {
|
||||
t.Errorf("BareManifestDigest(%q) = %q, want %q", tc.in, got, tc.key)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"reflect"
|
||||
"slices"
|
||||
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/graph"
|
||||
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
||||
@@ -30,7 +31,7 @@ const CatalogEntryLayout = 1
|
||||
// ModuleValueOf gives the module's value back from the entry alone. The acting rules are the revision's to add.
|
||||
func CatalogEntryOf(module string, cur meshcatalog.ModulesByModuleValue, m catalogue.Manifest, raw string, n graph.Node) meshcatalog.CatalogEntry {
|
||||
e := meshcatalog.CatalogEntry{V: CatalogEntryLayout, Module: module, Repository: cur.Repository, Path: cur.Path,
|
||||
Commit: cur.Commit, Manifest: manifestWhole(raw), ManifestDigest: meshcatalog.EntryManifestDigest(cur.Manifest), Verdict: cur.Verdict, Fp: n.FP, None: n.None, Bases: n.Bases,
|
||||
Commit: cur.Commit, Manifest: manifestWhole(raw), ManifestDigest: meshcatalogclient.EntryManifestDigest(cur.Manifest), Verdict: cur.Verdict, Fp: n.FP, None: n.None, Bases: n.Bases,
|
||||
Packages: maps.Clone(cur.Packages), Provides: n.Provides, Requires: n.Requires, Awaits: n.Awaits, Invokes: n.Invokes,
|
||||
Serves: n.Serves, LeftOut: n.LeftOut, Main: MainOf(m), Contributes: contributesOf(m)}
|
||||
// requires names every requirement as catalogue.Manifest.Wants lists them, optional ones and those only contributes names
|
||||
@@ -67,7 +68,7 @@ func CatalogEntryOf(module string, cur meshcatalog.ModulesByModuleValue, m catal
|
||||
// ruling on milestone 47/G finding 1; ADR 0656 §6: one form of the fact). The old line's fields (the old-form
|
||||
// fingerprint, the reader needs) are not kept.
|
||||
func ModuleValueOf(e meshcatalog.CatalogEntry) meshcatalog.ModulesByModuleValue {
|
||||
v := meshcatalog.ModulesByModuleValue{V: keys.Version, Repository: e.Repository, Path: e.Path, Commit: e.Commit, Manifest: meshcatalog.BareManifestDigest(e.ManifestDigest),
|
||||
v := meshcatalog.ModulesByModuleValue{V: keys.Version, Repository: e.Repository, Path: e.Path, Commit: e.Commit, Manifest: meshcatalogclient.BareManifestDigest(e.ManifestDigest),
|
||||
Verdict: e.Verdict, Fp2: e.Fp, None2: e.None, Packages: maps.Clone(e.Packages)}
|
||||
if in := e.Inputs; in != nil {
|
||||
v.Toolchains, v.Paths, v.Problems, v.Warnings, v.Unknown = maps.Clone(in.Toolchains), maps.Clone(in.Paths), in.Problems, in.Warnings, in.Unknown
|
||||
|
||||
@@ -544,7 +544,7 @@ func (k *KeptTrunk) reread(ctx context.Context, o Objects) error {
|
||||
}
|
||||
manifests := map[string]string{}
|
||||
for _, e := range entries {
|
||||
if d := meshcatalog.BareManifestDigest(e.ManifestDigest); d != "" && e.Manifest != nil {
|
||||
if d := meshcatalogclient.BareManifestDigest(e.ManifestDigest); d != "" && e.Manifest != nil {
|
||||
if raw, err := json.Marshal(e.Manifest); err == nil {
|
||||
manifests[d] = string(raw)
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||
"git.novox.be/novox/mesh-sdk/go/views"
|
||||
)
|
||||
@@ -94,7 +95,7 @@ func TestTheKeptTrunkIsReadAtTheStartAndOncePerHeardRevision(t *testing.T) {
|
||||
}
|
||||
// A-487c: the manifests by digest and the verb revision asked of the trunk's newest answer from the view held.
|
||||
listed = objects.n.Load()
|
||||
if raw, err := kept.Manifest(meshcatalog.BareManifestDigest(keptDigest("ca-trust"))); err != nil || raw != `{"module":"ca-trust"}` {
|
||||
if raw, err := kept.Manifest(meshcatalogclient.BareManifestDigest(keptDigest("ca-trust"))); err != nil || raw != `{"module":"ca-trust"}` {
|
||||
t.Errorf("the held manifest = %q (%v), want the entry's manifest", raw, err)
|
||||
}
|
||||
if a, err := Revision(context.Background(), objects, kept, meshcatalog.RevisionInput{}); err != nil || a.Revision.Revision != 2 || len(a.Entries) != 2 {
|
||||
|
||||
@@ -100,6 +100,14 @@ func TestAContractsModulesGeneratedFilesAreComparedWithTheGenerator(t *testing.T
|
||||
if got, err := OutOfStep(plain, GeneratedRootGo); err != nil || len(got) != 0 {
|
||||
t.Errorf("a module naming no generated-from compared: %v %v", got, err)
|
||||
}
|
||||
// This repository's own contracts module is in step with the generator under both roots: a hand-written file
|
||||
// under a generated root (go/seats/meshcatalog/manifestdigest.go, pipeline main.43) failed every unit step of its
|
||||
// mover; a seat's hand-written helper lives in its client (design 47 H, H-A-200; ADR 0608 §5).
|
||||
for _, root := range []string{GeneratedRootGo, GeneratedRootTS} {
|
||||
if got, err := OutOfStep(filepath.Join("..", "..", "mesh-delivery-contracts"), root); err != nil || len(got) != 0 {
|
||||
t.Errorf("mesh-delivery-contracts, root %s: %v %v, want nothing out of step", root, got, err)
|
||||
}
|
||||
}
|
||||
|
||||
// The build ask answers them beside what it built, and with a failed build too.
|
||||
built := 0
|
||||
|
||||
Reference in New Issue
Block a user