Builds: design 47 G A-318 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
99 lines
4.5 KiB
Go
99 lines
4.5 KiB
Go
package view
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
mma "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
|
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants"
|
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/trunk"
|
|
"git.novox.be/novox/mesh-sdk/go/keys"
|
|
)
|
|
|
|
// The holders, states and buckets the view names, taken from its own manifest (module.json: its `reads`, `invokes` and
|
|
// `consumes`); a unit row checks them against it (TestTheNamesAreTheManifests). No contract names a holder (novox/hq
|
|
// ADR 0625 §4, ADR 0634 §1). The indexer's module and its reads are the catalog client's.
|
|
const (
|
|
IndexerModule = "mesh-delivery-indexer"
|
|
// ProvisionsRead is the seat mesh-provisioner's state provisions as the manifest's `reads` names it (the seat form, resolved at
|
|
// the seat's holder, A-318).
|
|
ProvisionsSeat = "mesh-provisioner"
|
|
ProvisionsState = "provisions"
|
|
ProvisionsRead = "seat:" + ProvisionsSeat + "." + ProvisionsState
|
|
WatchmanModule = "mesh-delivery-watchman"
|
|
GateModule = "mesh-delivery-gate"
|
|
TellerModule = "mesh-delivery-teller"
|
|
EngineModule = "node-engine"
|
|
|
|
// The indexer's states the view reads.
|
|
CandidatesBucket = IndexerModule + "_candidates"
|
|
TakenBucket = IndexerModule + "_taken"
|
|
PackagesState = "packages"
|
|
PackagesBucket = IndexerModule + "_" + PackagesState
|
|
// IndexerPredefinedState and IndexerConfigCandidatesState are the indexer's states of the foundation's predefined list
|
|
// and of the config candidates; PredefinedListKey is the one key of the first.
|
|
IndexerPredefinedState = "predefined"
|
|
PredefinedListKey = "list"
|
|
IndexerConfigCandidatesState = "config-candidates"
|
|
|
|
// The seats mesh-module-assigner's and mesh-wants' views the process follows, its pictures named in the seat form
|
|
// `<seat>_<state>` (design 47 G §717, A-303): no module is named. Where a name must be the holder's real bucket (the
|
|
// watchman's stuck key) the process reads it from the holder it follows (views.ProcessReader.HolderBucket).
|
|
AssignmentsState = "assignments"
|
|
AssignmentsBucket = mma.Seat + "_" + AssignmentsState
|
|
WantsBucket = meshwants.Seat + "_" + meshwants.StateWants
|
|
AsksBucket = meshwants.Seat + "_" + meshwants.StateAsks
|
|
|
|
// SourceBucket names, in the model's entries, each watched branch's source as the seat mesh-delivery's verb source answers
|
|
// it, keyed by the escaped branch (design 47 G §507, A-173): never a bucket the view reads. The teller's state answers as
|
|
// the view follows it by its views family (design 47 G §431, A-175): its picture `<owner>_<state>`.
|
|
SourceBucket = GateModule + "_source"
|
|
AnswersState = "answers"
|
|
AnswersBucket = TellerModule + "_" + AnswersState
|
|
|
|
// The watchman's and the node-engine's states.
|
|
PresenceBucket = WatchmanModule + "_presence"
|
|
StuckBucket = WatchmanModule + "_stuck"
|
|
HaveBucket = EngineModule + "_have"
|
|
|
|
// StepsState is the state of steps each build module keeps (reads: mesh-build-<language>.steps), whose pauses are buildstep's.
|
|
StepsState = "steps"
|
|
|
|
// The revisions each of those states keeps per key.
|
|
AnswersHistory = 5
|
|
AssignerAsksHistory = 5
|
|
|
|
// SignersRead is the seat mesh-vault's state of signing keys as a manifest's `reads` names it (the seat form, resolved at the seat's
|
|
// holder, A-210), SignersKeyKey its one key.
|
|
VaultSeat = "mesh-vault"
|
|
SignersState = "signers"
|
|
SignersRead = "seat:" + VaultSeat + "." + SignersState
|
|
SignersKeyKey = "key"
|
|
)
|
|
|
|
// CandidatesKey is the key, in the indexer's candidates, of a group: the group name as a key part. ParseCandidatesKey is its inverse.
|
|
func CandidatesKey(group string) (string, error) {
|
|
if group == "" {
|
|
return "", fmt.Errorf("view: the group name is empty")
|
|
}
|
|
return keys.EscapeName(group), nil
|
|
}
|
|
|
|
// ParseCandidatesKey is the inverse of CandidatesKey.
|
|
func ParseCandidatesKey(key string) (string, error) {
|
|
group, err := keys.UnescapeName(key)
|
|
if err != nil || group == "" {
|
|
return "", fmt.Errorf("view: %q is not a candidates key: %v", key, err)
|
|
}
|
|
return group, nil
|
|
}
|
|
|
|
// PackagesKey is the key, in the indexer's packages, of a mesh Go module (its module path): the path as a key part. It refuses
|
|
// a path that is no mesh Go module's.
|
|
func PackagesKey(module string) (string, error) {
|
|
if _, _, ok := trunk.PackageRepository(module); !ok {
|
|
return "", fmt.Errorf("view: %q is no mesh Go module's path", module)
|
|
}
|
|
return meshcatalog.PackagesByModuleKey(keys.EscapeName(module)), nil
|
|
}
|