Files
mesh-delivery/modules/mesh-delivery-view/internal/view/names.go
T
jschoubben cd9a373067 D1 (view): the view's tools ask the indexer, the assigner and the wants' bucket of the holders of their seats
The tools program asks indexer_read_*, assigner_read_* and indexer_pending of the module holding the seat mesh-catalog or mesh-wants when it asks, and names the wants' real bucket from that holder at each status; the assigner's module constant goes.

Builds: design 47 G §428, §717, A-210, A-300, A-318

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
2026-11-12 23:01:34 +01:00

94 lines
4.2 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.
ProvisionsRead = "mesh-provisioner.provisions"
WatchmanModule = "mesh-delivery-watchman"
GateModule = "mesh-delivery-gate"
TellerModule = "mesh-delivery-teller"
VaultModule = "mesh-vault"
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 vault's state of signing keys as a manifest's `reads` names it, SignersKeyKey its one key.
SignersRead = VaultModule + ".signers"
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
}