Files
mesh-delivery/modules/mesh-delivery-checker/internal/check/trunkview.go
T
jschoubben 71a35a6376 MV1: move contracts and sdk under modules/, importers follow
The delivery repository's contracts and SDK live under modules/ as
mesh-delivery-contracts and mesh-delivery-sdk, their Go module paths
renamed to match the folders (the TypeScript names already did), and
every importer in mesh-delivery, mesh-catalog, mesh-host, mesh-tools
and mesh-sdk follows in the same group: a design as it should be, one
path per module, checked by the group's check building every importer.

Builds: design 47 G §427, §88

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
2026-11-12 05:09:56 +01:00

32 lines
1.1 KiB
Go

package check
import (
"encoding/json"
"fmt"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
)
// TrunkVerb is the key of the seat verb the trunk heads are asked by (design 47 G §197).
const TrunkVerb = "seat:" + meshcatalog.Seat + "." + meshcatalog.VerbRevision
// TrunkHeads reads the trunk head of every repository out of the seat mesh-catalog's answer of `revision`. A candidate's
// revision is no trunk's and is refused.
func TrunkHeads(raw json.RawMessage) (map[string]string, error) {
var a meshcatalog.RevisionAnswer
if err := json.Unmarshal(raw, &a); err != nil {
return nil, fmt.Errorf("the catalog half's revision does not read: %w", err)
}
if a.Revision == nil {
return nil, fmt.Errorf("the catalog half's revision answers no revision (none-yet: %v)", a.NoneYet)
}
if a.Revision.Kind != "trunk" {
return nil, fmt.Errorf("the catalog half's revision %d is a %q revision, not a trunk's", a.Revision.Revision, a.Revision.Kind)
}
heads := map[string]string{}
for _, h := range a.Revision.Trunk {
heads[h.Repository] = h.Commit
}
return heads, nil
}