Files
mesh-delivery/modules/mesh-delivery-view/internal/view/catalog.go
T
jschoubben f8eea0000a V1: the view reads the H1 want, source, source-moved and held take-ins
A want counts as applied by its fingerprint and a motion event is keyed by
it; the want's newest and rule, and the state held back read from them, go
with the assigner's holds. A branch's source is {v, source, call, heads}
with no group, its source-moved is read by its source, and the delivered
event names no group. indexer_pending's held take-ins are said in the
tiers' pending words with their branch, source, why and since, naming no
module. The view reads no source stamp on a module. Its seat list, its
first-view tool answers and its manifest name no callers; its source invoke
reads call, not group.

Builds: design 47 H §737, §744, §750, §752, §764 (the gate's groups; the indexer's pending and groups; the assigner's holds; the callers lists); lead answers H-A-26, H-A-37, H-A-48, H-A-66, H-A-78, H-A-102, H-A-109 (hq 3433db0e)

Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
2026-11-20 04:20:33 +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.Toolchains, v.Paths, v.Warnings = 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)
}