From 6ff7aeb5cf75b9f4f22c044bb13c25da4221ab29 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 9 Nov 2026 20:30:01 +0100 Subject: [PATCH] The indexer fills the catalog graph entry's main from the module's manifest (milestone 47/G W3.1's main, W4.3) The entry's main is the from of the Go artifact the module's process runs, which the check's first tier builds when the module acts. Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ --- .../internal/index/catalog_graph.go | 29 +++++++++++++++++-- .../internal/index/catalog_revisions.go | 2 +- .../internal/index/toolchains_test.go | 13 ++++++++- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/modules/mesh-delivery-indexer/internal/index/catalog_graph.go b/modules/mesh-delivery-indexer/internal/index/catalog_graph.go index c87d0084..eed3191a 100644 --- a/modules/mesh-delivery-indexer/internal/index/catalog_graph.go +++ b/modules/mesh-delivery-indexer/internal/index/catalog_graph.go @@ -10,6 +10,7 @@ import ( "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog" "git.novox.be/novox/mesh-delivery/sdk/graph" + "git.novox.be/novox/mesh-sdk/go/catalogue" ) // The catalog graph (novox/hq ADR 0656; design 47, *Two graphs, one source of truth*): at each revision one entry per @@ -22,11 +23,12 @@ const CatalogEntryLayout = 1 // CatalogEntryOf is the catalog graph entry of one module: the module graph's node of it as a recompute computed it // (its build, provision and verb edges, the verb edges left out on a cycle, ADR 0614), with where the trunk holds it and -// its manifest's digest. The verdict and the acting rules are the revision's to add (they are not the node's). -func CatalogEntryOf(module string, cur meshcatalog.ModulesByModuleValue, n graph.Node) meshcatalog.CatalogEntry { +// its manifest's digest and the main package its process runs (MainOf). The verdict and the acting rules are the revision's to add (they are not the node's). +func CatalogEntryOf(module string, cur meshcatalog.ModulesByModuleValue, m catalogue.Manifest, n graph.Node) meshcatalog.CatalogEntry { e := meshcatalog.CatalogEntry{V: CatalogEntryLayout, Module: module, Repository: cur.Repository, Path: cur.Path, Commit: cur.Commit, Manifest: cur.Manifest, Fp: n.FP, None: n.None, Bases: n.Bases, Packages: n.Packages, - Provides: n.Provides, Requires: n.Requires, Awaits: n.Awaits, Invokes: n.Invokes, Serves: n.Serves, LeftOut: n.LeftOut} + Provides: n.Provides, Requires: n.Requires, Awaits: n.Awaits, Invokes: n.Invokes, Serves: n.Serves, LeftOut: n.LeftOut, + Main: MainOf(m)} for language, t := range n.Toolchains { if e.Toolchains == nil { e.Toolchains = map[string]meshcatalog.BuildEdge{} @@ -63,3 +65,24 @@ func CatalogRevisionOf(rev meshcatalog.CatalogRevision, entries map[string]meshc } return rev, objects, nil } + +// MainOf is the Go main package the check's first tier builds when the module acts (the seat mesh-catalog's entry +// field main): the from of the first Go artifact a process resource of the manifest runs, as the manifest names it; +// empty when it runs none. +func MainOf(m catalogue.Manifest) string { + if m.Build == nil { + return "" + } + for _, r := range m.Resources { + if fmt.Sprint(r["type"]) != "process" { + continue + } + name := fmt.Sprint(r["artifact"]) + for _, a := range m.Build.Artifacts { + if a.Name == name && a.Language == "go" && a.From != "" { + return a.From + } + } + } + return "" +} diff --git a/modules/mesh-delivery-indexer/internal/index/catalog_revisions.go b/modules/mesh-delivery-indexer/internal/index/catalog_revisions.go index ccb52f58..cab54e63 100644 --- a/modules/mesh-delivery-indexer/internal/index/catalog_revisions.go +++ b/modules/mesh-delivery-indexer/internal/index/catalog_revisions.go @@ -178,7 +178,7 @@ func (ix *Indexer) keepTrunkRevision(ctx context.Context, edges map[string]graph } entries := make(map[string]meshcatalog.CatalogEntry, len(edges)) for name, e := range edges { - entries[name] = CatalogEntryOf(name, e.cur, whole[name]) + entries[name] = CatalogEntryOf(name, e.cur, e.manifest, whole[name]) } ix.mu.Lock() src := int64(ix.source.rev) diff --git a/modules/mesh-delivery-indexer/internal/index/toolchains_test.go b/modules/mesh-delivery-indexer/internal/index/toolchains_test.go index 5b9821dc..db367a8c 100644 --- a/modules/mesh-delivery-indexer/internal/index/toolchains_test.go +++ b/modules/mesh-delivery-indexer/internal/index/toolchains_test.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "maps" + "os" "reflect" "slices" "strings" @@ -18,6 +19,7 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-forge-bridge/forgemsg" sdkstep "git.novox.be/novox/mesh-delivery/sdk/buildstep" + "git.novox.be/novox/mesh-sdk/go/catalogue" "git.novox.be/novox/mesh-sdk/go/keys" "git.novox.be/novox/mesh-sdk/go/process" @@ -291,7 +293,16 @@ func TestBasesAreComputedFirstAndNoFingerprintTakesTheBuilder(t *testing.T) { // entries := map[string]meshcatalog.CatalogEntry{} for name := range mods.vals { m, _ := moduleOf(t, mods, name) - entries[name] = CatalogEntryOf(name, m, graphOf(t, ix, name)) + entries[name] = CatalogEntryOf(name, m, catalogue.Manifest{}, graphOf(t, ix, name)) + } + // W3.1's main: the Go main package the module's process runs, read from its manifest (here the indexer's own); a + // manifest that runs no process names none. + own, err := os.ReadFile("../../module.json") + if err != nil { + t.Fatal(err) + } + if m, err := catalogue.Decode(own); err != nil || MainOf(m) != "cmd/mesh-delivery-indexer" || MainOf(catalogue.Manifest{}) != "" { + t.Errorf("the indexer's main = %q (%v), want cmd/mesh-delivery-indexer", MainOf(m), err) } if e := entries["avahi"]; e.Fp != want["avahi"] || e.Commit == "" || e.Manifest == "" || !reflect.DeepEqual(e.Bases, []string{"mesh-tools"}) || e.Toolchains["go"] != (meshcatalog.BuildEdge{Module: "mesh-build-go", Version: "go1.27.1", Recipe: "1"}) {