Files
mesh-catalog/modules/distribution/cmd/distribution/builds.go
T
jschoubben 0be81ae036 Join 11: the merged heads compile where no area's fix is owed
The join's importers name the delivery repository's moved contracts and sdk
(MV1), node-tools' tests use mesh-sdk's gate, the duplicate node-engine claim
rule of the reader release gives way to G's, and the assigner names its first
watched branch, never a constant. The seat holders' AnswerSeat callers are
area 6's.

Builds: design 47 G join 11 (merge of fix round 11)

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
2026-11-12 10:41:44 +01:00

67 lines
2.2 KiB
Go

package main
// The build modules the windows' driver counts (design 47 G §610, A-156, A-82): the modules that claim a build seat
// (`node-build-*`) in the catalog half, followed per watched branch by the seat mesh-catalog's client on the program's
// one views reader. No list of names is kept here, and none is configured.
import (
"encoding/json"
"slices"
"strings"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
catalog "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
)
// buildSeatPrefix starts the name of every seat a build module claims.
const buildSeatPrefix = "node-build-"
// buildModulesOf are the modules among entries whose manifest claims a build seat, sorted.
func buildModulesOf(entries map[string]catalog.CatalogEntry) []string {
var out []string
for module, e := range entries {
claims, _ := e.Manifest["claims"].([]any)
for _, c := range claims {
if name, _ := c.(map[string]any)["name"].(string); strings.HasPrefix(name, buildSeatPrefix) {
out = append(out, module)
break
}
}
}
slices.Sort(out)
return out
}
// claimsBuildSeat says whether a module's entry, as the branch follower tells it, claims a build seat.
func claimsBuildSeat(module string, raw json.RawMessage) bool {
var e catalog.CatalogEntry
if json.Unmarshal(raw, &e) != nil {
return true // an entry not read may be one: the driver judges again
}
return len(buildModulesOf(map[string]catalog.CatalogEntry{module: e})) == 1
}
// branchesBuilds answers the driver's build modules from the catalog half of every followed branch; with a branch that has
// no first view yet it is an error naming it, never no build module.
type branchesBuilds struct{ b *meshcatalogclient.Branches }
func (h branchesBuilds) Modules() ([]string, error) {
if err := h.b.Ready(); err != nil {
return nil, err
}
all := map[string]catalog.CatalogEntry{}
for _, branch := range h.b.Followed() {
c, ok := h.b.Catalog(branch)
if !ok {
continue
}
half, _ := c.View() // a branch at none-yet is ready and empty (§614)
for m, e := range half.Entries {
if _, ok := all[m]; !ok {
all[m] = e
}
}
}
return buildModulesOf(all), nil
}