The view's process follows the trunk's catalog half (first view of the seat mesh-catalog's verb revision, then each catalog-revision of branch main) and hands each changed entry to its model in the form of the value it always kept; its tools read the newest trunk revision through the verb. The manifest invokes seat:mesh-catalog.revision and consumes mesh-catalog.catalog-revision instead of the indexer's modules read tool and views family. Builds: design 47 G §196, test 61 Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
59 lines
2.8 KiB
Go
59 lines
2.8 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"
|
|
|
|
"git.novox.be/novox/mesh-delivery/contracts/go/clients/meshcatalogclient"
|
|
"git.novox.be/novox/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 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}
|
|
if len(e.Manifest) > 0 {
|
|
// The entry holds its manifest whole; the model keeps the digest of its bytes, as the value it always kept does.
|
|
raw, _ := json.Marshal(e.Manifest)
|
|
v.Manifest = meshcatalogclient.ManifestDigest(raw)
|
|
}
|
|
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)
|
|
}
|