From b058389d4693e66cd1de798fda10d635b15d4768 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 22:18:00 +0100 Subject: [PATCH] Contracts: the catalog seat's manifest-digest helpers move to its client, out of the generated root (H-A-200) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- .../cmd/mesh-delivery-builder/catalog.go | 2 +- .../internal/build/run.go | 2 +- .../internal/build/step.go | 9 ++++---- .../meshcatalogclient}/manifestdigest.go | 5 ++++- .../meshcatalogclient/manifestdigest_test.go | 22 +++++++++++++++++++ .../internal/index/catalog_graph.go | 5 +++-- .../internal/index/catalog_revisions.go | 2 +- .../internal/index/kept_trunk_test.go | 3 ++- .../steprun/generated_test.go | 8 +++++++ 9 files changed, 47 insertions(+), 11 deletions(-) rename modules/mesh-delivery-contracts/go/{seats/meshcatalog => clients/meshcatalogclient}/manifestdigest.go (84%) create mode 100644 modules/mesh-delivery-contracts/go/clients/meshcatalogclient/manifestdigest_test.go diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/catalog.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/catalog.go index 1bb73b98..1d935875 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/catalog.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/catalog.go @@ -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 } diff --git a/modules/mesh-delivery-builder/internal/build/run.go b/modules/mesh-delivery-builder/internal/build/run.go index 7f76e535..ba6f3e3c 100644 --- a/modules/mesh-delivery-builder/internal/build/run.go +++ b/modules/mesh-delivery-builder/internal/build/run.go @@ -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} } diff --git a/modules/mesh-delivery-builder/internal/build/step.go b/modules/mesh-delivery-builder/internal/build/step.go index a61187ed..09687285 100644 --- a/modules/mesh-delivery-builder/internal/build/step.go +++ b/modules/mesh-delivery-builder/internal/build/step.go @@ -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) diff --git a/modules/mesh-delivery-contracts/go/seats/meshcatalog/manifestdigest.go b/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/manifestdigest.go similarity index 84% rename from modules/mesh-delivery-contracts/go/seats/meshcatalog/manifestdigest.go rename to modules/mesh-delivery-contracts/go/clients/meshcatalogclient/manifestdigest.go index b48e93ff..1496f40d 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshcatalog/manifestdigest.go +++ b/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/manifestdigest.go @@ -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" diff --git a/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/manifestdigest_test.go b/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/manifestdigest_test.go new file mode 100644 index 00000000..a9c85992 --- /dev/null +++ b/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/manifestdigest_test.go @@ -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) + } + } +} diff --git a/modules/mesh-delivery-indexer/internal/index/catalog_graph.go b/modules/mesh-delivery-indexer/internal/index/catalog_graph.go index ef3c1f86..906f2263 100644 --- a/modules/mesh-delivery-indexer/internal/index/catalog_graph.go +++ b/modules/mesh-delivery-indexer/internal/index/catalog_graph.go @@ -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 diff --git a/modules/mesh-delivery-indexer/internal/index/catalog_revisions.go b/modules/mesh-delivery-indexer/internal/index/catalog_revisions.go index 8addf0a8..ec1e7717 100644 --- a/modules/mesh-delivery-indexer/internal/index/catalog_revisions.go +++ b/modules/mesh-delivery-indexer/internal/index/catalog_revisions.go @@ -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) } diff --git a/modules/mesh-delivery-indexer/internal/index/kept_trunk_test.go b/modules/mesh-delivery-indexer/internal/index/kept_trunk_test.go index 3b585be1..21a2f59e 100644 --- a/modules/mesh-delivery-indexer/internal/index/kept_trunk_test.go +++ b/modules/mesh-delivery-indexer/internal/index/kept_trunk_test.go @@ -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 { diff --git a/modules/mesh-delivery-sdk/steprun/generated_test.go b/modules/mesh-delivery-sdk/steprun/generated_test.go index 9be27bc9..5d190045 100644 --- a/modules/mesh-delivery-sdk/steprun/generated_test.go +++ b/modules/mesh-delivery-sdk/steprun/generated_test.go @@ -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 -- 2.54.0