Files
mesh-delivery/modules/mesh-delivery-view/internal/view/catalog.go
T
jschoubben 2940df27b1 VW5: the view follows the catalog half per watched branch through meshcatalogclient's branch follower
The process and the tools bundle read the catalog half through Branches
(FollowBranchesProcess, FollowBranches) and Branches.Entry instead of one
view of a branch named in code; the module's value carries the entry's
manifest-digest bare and computes none. The manifest consumes
registration-changed and source-moved and invokes registrations, and
revision, entry and source in the long form with the fields relied on.
The built binary committed at the module's root goes.

Builds: design 47 G §532, §614, §558, §506, §578, A-103

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
2026-11-12 06:03:48 +01:00

59 lines
2.9 KiB
Go

package view
// The view reads the catalog half of the delivery through the seat mesh-catalog (design 47, Two graphs; ADR 0656 §6):
// a first view of its verb `revision`, then each trunk revision its event `catalog-revision` says, never the indexer's
// state `modules`. The model keeps the picture it always kept (one value per module, its history for the reach), so each
// entry of a revision is handed to it in the form of that value.
import (
"encoding/json"
"fmt"
"strings"
"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"
)
// CatalogSeat is the seat whose verb `revision` and event `catalog-revision` the view reads the modules from, as its
// manifest's `invokes` and `consumes` name them.
const CatalogSeat = meshcatalog.Seat
// ModulesBucket names the model's picture of the catalog half's modules (and its history): the model's label, no
// bucket of anybody's.
const ModulesBucket = CatalogSeat + "_modules"
// ModuleValue is the value of one module of the model, as the model decodes it, made from the catalog entry (its JSON):
// the fingerprint is the entry's `fp` (the only form there is), the manifest's digest the entry's `manifest-digest`, the
// source revisions are the entry's inputs'. A manifest
// held for unknown fields has no verdict here: the model reads the fingerprint and the commit.
func ModuleValue(entry json.RawMessage) (json.RawMessage, error) {
var e meshcatalog.CatalogEntry
if err := json.Unmarshal(entry, &e); err != nil || e.Module == "" {
return nil, fmt.Errorf("a catalog entry does not read: %v", err)
}
v := meshcatalog.ModulesByModuleValue{Commit: e.Commit, Fp2: e.Fp, None2: e.None, Path: e.Path, Repository: e.Repository, Packages: e.Packages}
// The entry carries the digest of its manifest's bytes as the indexer read them, `sha256:` and the 64 hex digits; the
// model keeps the bare digits, as the value it always kept, and computes none (design 47 G §506, §578).
v.Manifest = strings.TrimPrefix(e.ManifestDigest, "sha256:")
if e.Verdict == meshcatalogclient.VerdictAccepted || e.Verdict == meshcatalogclient.VerdictRefused {
v.Verdict = e.Verdict
}
if in := e.Inputs; in != nil {
v.Src, v.FpSrc, v.Toolchains, v.Paths, v.Warnings = in.Src, in.FpSrc, in.Toolchains, in.Paths, in.Warnings
if f := in.From; f != nil && v.Manifest != "" {
v.Inputs2 = &meshcatalog.ModulesByModuleValueInputs2{Bases: f.Bases, Builder: f.Builder, Contexts: f.Contexts,
ImportForm: f.ImportForm, Imports: f.Imports, Locks: f.Locks, Packages: f.Packages, Paths: f.Paths, Tree: f.Tree}
}
if v.Verdict == meshcatalogclient.VerdictRefused {
v.Problems = in.Problems
}
}
if v.Verdict == meshcatalogclient.VerdictRefused && len(v.Problems) == 0 {
v.Verdict = ""
}
if v.Verdict != meshcatalogclient.VerdictRefused {
v.Warnings = nil
}
return meshcatalogclient.EncodeModule(v)
}