A tools program that serves a seat's verbs as tools reads a verb's description from the generated contract, one copy taken from seat.json, instead of writing it again. Generated again in all five folders by mesh-delivery's seatgen (feat/47-H2 b65b6173), which now writes VerbDescription; seatgen -check clean, every package's vet and tests green. Builds: design 47 H2 H-A-449
833 lines
36 KiB
Go
833 lines
36 KiB
Go
// Code generated by seatgen from the seat definitions; DO NOT EDIT.
|
|
|
|
// Package meshmoduleassigner is the contract of the seat "mesh-module-assigner", defined whole (seats/mesh-module-assigner/seat.json): The seat that places modules on nodes (ADR 0567): the state of assignments and the proposals that change it.
|
|
package meshmoduleassigner
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
// Seat is the seat's name.
|
|
const Seat = "mesh-module-assigner"
|
|
|
|
// Form is the form of the seat's values, events and answers this contract was generated at (design 47 H2 §780):
|
|
// a reader of a value of another form says "form N, this reader knows M".
|
|
const Form = 1
|
|
|
|
// The forms and the digest of the fields this contract was generated from: the generator's compare fails a definition
|
|
// whose fields changed while its forms did not (design 47 H2 §780).
|
|
const (
|
|
generatedForms = "1"
|
|
generatedFieldsDigest = "AddedModule=86d996df19e5 AgainAnswer=7538f2f5e68e Assignments=35d7df192c2c AssignmentsAnswer=7538f2f5e68e AssignmentsByNodeModuleValue=d1cd12b2f2c1 AssignmentsByNodeNodeValue=db6ec13499b1 AssignmentsByNodeNodeValueModulesItem=ff109e5089e1 AssignmentsChangedEvent=cba8c7b1146b AssignmentsEvent=dd2f1e6e7554 AssignmentsEventWarrant=d3a0ac80d144 AssignmentsJudgedEvent=cba8c7b1146b AssignmentsProposedEvent=cba8c7b1146b AssignmentsWithdrawnEvent=cba8c7b1146b CandidatesByProposalNodeValue=e9101198663c FoundTunnel=59407b3b9e91 FoundTunnelPeer=e2c1bf409d9b Holding=83dfb6708156 ModulePlacement=de58899ce871 NodeDecided=b11afd08e31b PlacedModule=8028d613f043 PlacementAnswer=dc2681a31254 Proposal=22b1f754d84c ProposalChange=061c4d347de3 ProposalChangeKeys=5509aa3ebbbf ProposalsAnswer=7538f2f5e68e ProposalsByProposalValue=adf5f375b486 ProposeAnswer=7538f2f5e68e Provider=04872f6afbfa PulsesByAnswerProposalNodeValue=70085a06db0a PulsesByAskProposalValue=70085a06db0a SeatHolders=75c827768704 SeatHoldersBySeatNodeValue=a22be181bc1e SeatHoldersBySeatValue=a22be181bc1e SeatHoldersHoldersItem=04872f6afbfa Verdict=17b6e2d41196 Warrant=df8d847f9c5e WithdrawAnswer=7538f2f5e68e"
|
|
)
|
|
|
|
const (
|
|
VerbAssignments = "assignments"
|
|
VerbProposals = "proposals"
|
|
VerbPropose = "propose"
|
|
VerbWithdraw = "withdraw"
|
|
VerbAgain = "again"
|
|
VerbPlacement = "placement"
|
|
)
|
|
|
|
const (
|
|
EventAssignmentsProposed = "assignments-proposed"
|
|
EventAssignmentsWithdrawn = "assignments-withdrawn"
|
|
EventAssignmentsJudged = "assignments-judged"
|
|
EventAssignmentsChanged = "assignments-changed"
|
|
)
|
|
|
|
// Verbs is every verb the seat serves, in its definition's order: a new copy each call.
|
|
func Verbs() []string {
|
|
return []string{VerbAssignments, VerbProposals, VerbPropose, VerbWithdraw, VerbAgain, VerbPlacement}
|
|
}
|
|
|
|
// VerbDescription is a verb's description as the seat's definition says it, "" for a verb the seat does not serve or
|
|
// does not describe (design 47 H2 H-A-449).
|
|
func VerbDescription(verb string) string {
|
|
switch verb {
|
|
case VerbAssignments:
|
|
return "Read the assignments: one node's key, the nodes one module is placed on, or every key, each with its revision, and how full the state is against its cap. With history, one node's or one module's changes in order: a revision the state keeps whole, an older one as the proposal's changes from its assignments-changed event."
|
|
case VerbProposals:
|
|
return "Every open proposal of assignments: its changes, the revision of each key it was laid over, its candidates, every node's answer, the differences computed and answered, its verdict and its ask. Narrowed to one by id."
|
|
case VerbPropose:
|
|
return "Propose a change of assignments, with why: laid over the current keys and refused at once, naming every finding, when the result cannot be placed (two modules on one host port, a provider not placed, a seat held once held twice, two nodes with one address, two hubs, a module the indexer does not hold, a node with no record). Otherwise the nodes it touches compose it in shadow and answer, and on a passing verdict the operator is asked to approve it. Who proposes is the caller, as the runtime proves it. An add-node from mesh-enrolment, whose warrant names its node and address, is written with no ask of its own: its Approve is the enrolment's (ADR 0587 §7)."
|
|
case VerbWithdraw:
|
|
return "Withdraw an open proposal: its key and its candidates are deleted and assignments-withdrawn carries it whole. With why."
|
|
case VerbAgain:
|
|
return "Judge an open proposal now with the answers that stand, and raise its ask again when its verdict passes and the operator's channel does not hold the ask. Nothing more: the recovery of a proposal whose judgement or ask was lost."
|
|
case VerbPlacement:
|
|
return "Read the placements of one module as the assignments rows hold them: for each watched branch a node runs it from, the nodes that run it from there."
|
|
}
|
|
return ""
|
|
}
|
|
|
|
// Events is every event published on the seat's subject: a new copy each call.
|
|
func Events() []string {
|
|
return []string{EventAssignmentsProposed, EventAssignmentsWithdrawn, EventAssignmentsJudged, EventAssignmentsChanged}
|
|
}
|
|
|
|
// Family is where the seat's events are kept: the shared events stream, filtered to the seat's subjects.
|
|
const (
|
|
Family = "mesh-module-assigner.events"
|
|
FamilyMaxAgeDays = 7
|
|
)
|
|
|
|
// SubjectAssignmentsProposed is where assignments-proposed is published.
|
|
const SubjectAssignmentsProposed = "mesh.seat.mesh-module-assigner.event.assignments-proposed"
|
|
|
|
// SubjectAssignmentsWithdrawn is where assignments-withdrawn is published.
|
|
const SubjectAssignmentsWithdrawn = "mesh.seat.mesh-module-assigner.event.assignments-withdrawn"
|
|
|
|
// SubjectAssignmentsJudged is where assignments-judged is published.
|
|
const SubjectAssignmentsJudged = "mesh.seat.mesh-module-assigner.event.assignments-judged"
|
|
|
|
// SubjectAssignmentsChanged is where assignments-changed is published.
|
|
const SubjectAssignmentsChanged = "mesh.seat.mesh-module-assigner.event.assignments-changed"
|
|
|
|
const (
|
|
StateAssignments = "assignments"
|
|
StateProposals = "proposals"
|
|
StateCandidates = "candidates"
|
|
StatePulses = "pulses"
|
|
StateSeatHolders = "seat-holders"
|
|
)
|
|
|
|
// AssignmentsByNodeNodeKey is the key of one value of the state assignments under the form "<node>.node".
|
|
func AssignmentsByNodeNodeKey(node string) string { return node + ".node" }
|
|
|
|
// ParseAssignmentsByNodeNodeKey reads the parts of a key of the form "<node>.node", in the order of the form; the last result is false for a key of another form.
|
|
func ParseAssignmentsByNodeNodeKey(key string) (string, bool) {
|
|
rest := key
|
|
v0, after0, found0 := strings.Cut(rest, ".node")
|
|
if !found0 || v0 == "" {
|
|
return "", false
|
|
}
|
|
rest = after0
|
|
if rest != "" {
|
|
return "", false
|
|
}
|
|
return v0, true
|
|
}
|
|
|
|
// DecodeAssignmentsByNodeNodeValue reads one value of the state assignments under the form "<node>.node" as another part wrote it: a field AssignmentsByNodeNodeValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
|
|
func DecodeAssignmentsByNodeNodeValue(raw []byte) (AssignmentsByNodeNodeValue, int, error) {
|
|
var v AssignmentsByNodeNodeValue
|
|
if err := json.Unmarshal(raw, &v); err != nil {
|
|
return v, 0, err
|
|
}
|
|
return v, formRead(raw), nil
|
|
}
|
|
|
|
// AssignmentsByNodeModuleKey is the key of one value of the state assignments under the form "<node>.<module>".
|
|
func AssignmentsByNodeModuleKey(node, module string) string { return node + "." + module }
|
|
|
|
// ParseAssignmentsByNodeModuleKey reads the parts of a key of the form "<node>.<module>", in the order of the form; the last result is false for a key of another form.
|
|
func ParseAssignmentsByNodeModuleKey(key string) (string, string, bool) {
|
|
rest := key
|
|
v0, after0, found0 := strings.Cut(rest, ".")
|
|
if !found0 || v0 == "" {
|
|
return "", "", false
|
|
}
|
|
rest = after0
|
|
if rest == "" {
|
|
return "", "", false
|
|
}
|
|
v2 := rest
|
|
rest = ""
|
|
if rest != "" {
|
|
return "", "", false
|
|
}
|
|
return v0, v2, true
|
|
}
|
|
|
|
// DecodeAssignmentsByNodeModuleValue reads one value of the state assignments under the form "<node>.<module>" as another part wrote it: a field AssignmentsByNodeModuleValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
|
|
func DecodeAssignmentsByNodeModuleValue(raw []byte) (AssignmentsByNodeModuleValue, int, error) {
|
|
var v AssignmentsByNodeModuleValue
|
|
if err := json.Unmarshal(raw, &v); err != nil {
|
|
return v, 0, err
|
|
}
|
|
return v, formRead(raw), nil
|
|
}
|
|
|
|
// ProposalsByProposalKey is the key of one value of the state proposals under the form "<proposal>".
|
|
func ProposalsByProposalKey(proposal string) string { return proposal }
|
|
|
|
// ParseProposalsByProposalKey reads the parts of a key of the form "<proposal>", in the order of the form; the last result is false for a key of another form.
|
|
func ParseProposalsByProposalKey(key string) (string, bool) {
|
|
rest := key
|
|
if rest == "" {
|
|
return "", false
|
|
}
|
|
v0 := rest
|
|
rest = ""
|
|
if rest != "" {
|
|
return "", false
|
|
}
|
|
return v0, true
|
|
}
|
|
|
|
// DecodeProposalsByProposalValue reads one value of the state proposals under the form "<proposal>" as another part wrote it: a field ProposalsByProposalValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
|
|
func DecodeProposalsByProposalValue(raw []byte) (ProposalsByProposalValue, int, error) {
|
|
var v ProposalsByProposalValue
|
|
if err := json.Unmarshal(raw, &v); err != nil {
|
|
return v, 0, err
|
|
}
|
|
return v, formRead(raw), nil
|
|
}
|
|
|
|
// CandidatesByProposalNodeKey is the key of one value of the state candidates under the form "<proposal>.<node>".
|
|
func CandidatesByProposalNodeKey(proposal, node string) string { return proposal + "." + node }
|
|
|
|
// ParseCandidatesByProposalNodeKey reads the parts of a key of the form "<proposal>.<node>", in the order of the form; the last result is false for a key of another form.
|
|
func ParseCandidatesByProposalNodeKey(key string) (string, string, bool) {
|
|
rest := key
|
|
v0, after0, found0 := strings.Cut(rest, ".")
|
|
if !found0 || v0 == "" {
|
|
return "", "", false
|
|
}
|
|
rest = after0
|
|
if rest == "" {
|
|
return "", "", false
|
|
}
|
|
v2 := rest
|
|
rest = ""
|
|
if rest != "" {
|
|
return "", "", false
|
|
}
|
|
return v0, v2, true
|
|
}
|
|
|
|
// DecodeCandidatesByProposalNodeValue reads one value of the state candidates under the form "<proposal>.<node>" as another part wrote it: a field CandidatesByProposalNodeValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
|
|
func DecodeCandidatesByProposalNodeValue(raw []byte) (CandidatesByProposalNodeValue, int, error) {
|
|
var v CandidatesByProposalNodeValue
|
|
if err := json.Unmarshal(raw, &v); err != nil {
|
|
return v, 0, err
|
|
}
|
|
return v, formRead(raw), nil
|
|
}
|
|
|
|
// PulsesByAnswerProposalNodeKey is the key of one value of the state pulses under the form "answer.<proposal>.<node>".
|
|
func PulsesByAnswerProposalNodeKey(proposal, node string) string {
|
|
return "answer." + proposal + "." + node
|
|
}
|
|
|
|
// ParsePulsesByAnswerProposalNodeKey reads the parts of a key of the form "answer.<proposal>.<node>", in the order of the form; the last result is false for a key of another form.
|
|
func ParsePulsesByAnswerProposalNodeKey(key string) (string, string, bool) {
|
|
rest := key
|
|
if !strings.HasPrefix(rest, "answer.") {
|
|
return "", "", false
|
|
}
|
|
rest = rest[7:]
|
|
v1, after1, found1 := strings.Cut(rest, ".")
|
|
if !found1 || v1 == "" {
|
|
return "", "", false
|
|
}
|
|
rest = after1
|
|
if rest == "" {
|
|
return "", "", false
|
|
}
|
|
v3 := rest
|
|
rest = ""
|
|
if rest != "" {
|
|
return "", "", false
|
|
}
|
|
return v1, v3, true
|
|
}
|
|
|
|
// DecodePulsesByAnswerProposalNodeValue reads one value of the state pulses under the form "answer.<proposal>.<node>" as another part wrote it: a field PulsesByAnswerProposalNodeValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
|
|
func DecodePulsesByAnswerProposalNodeValue(raw []byte) (PulsesByAnswerProposalNodeValue, int, error) {
|
|
var v PulsesByAnswerProposalNodeValue
|
|
if err := json.Unmarshal(raw, &v); err != nil {
|
|
return v, 0, err
|
|
}
|
|
return v, formRead(raw), nil
|
|
}
|
|
|
|
// PulsesByAskProposalKey is the key of one value of the state pulses under the form "ask.<proposal>".
|
|
func PulsesByAskProposalKey(proposal string) string { return "ask." + proposal }
|
|
|
|
// ParsePulsesByAskProposalKey reads the parts of a key of the form "ask.<proposal>", in the order of the form; the last result is false for a key of another form.
|
|
func ParsePulsesByAskProposalKey(key string) (string, bool) {
|
|
rest := key
|
|
if !strings.HasPrefix(rest, "ask.") {
|
|
return "", false
|
|
}
|
|
rest = rest[4:]
|
|
if rest == "" {
|
|
return "", false
|
|
}
|
|
v1 := rest
|
|
rest = ""
|
|
if rest != "" {
|
|
return "", false
|
|
}
|
|
return v1, true
|
|
}
|
|
|
|
// DecodePulsesByAskProposalValue reads one value of the state pulses under the form "ask.<proposal>" as another part wrote it: a field PulsesByAskProposalValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
|
|
func DecodePulsesByAskProposalValue(raw []byte) (PulsesByAskProposalValue, int, error) {
|
|
var v PulsesByAskProposalValue
|
|
if err := json.Unmarshal(raw, &v); err != nil {
|
|
return v, 0, err
|
|
}
|
|
return v, formRead(raw), nil
|
|
}
|
|
|
|
// SeatHoldersBySeatKey is the key of one value of the state seat-holders under the form "<seat>".
|
|
func SeatHoldersBySeatKey(seat string) string { return seat }
|
|
|
|
// ParseSeatHoldersBySeatKey reads the parts of a key of the form "<seat>", in the order of the form; the last result is false for a key of another form.
|
|
func ParseSeatHoldersBySeatKey(key string) (string, bool) {
|
|
rest := key
|
|
if rest == "" {
|
|
return "", false
|
|
}
|
|
v0 := rest
|
|
rest = ""
|
|
if rest != "" {
|
|
return "", false
|
|
}
|
|
return v0, true
|
|
}
|
|
|
|
// DecodeSeatHoldersBySeatValue reads one value of the state seat-holders under the form "<seat>" as another part wrote it: a field SeatHoldersBySeatValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
|
|
func DecodeSeatHoldersBySeatValue(raw []byte) (SeatHoldersBySeatValue, int, error) {
|
|
var v SeatHoldersBySeatValue
|
|
if err := json.Unmarshal(raw, &v); err != nil {
|
|
return v, 0, err
|
|
}
|
|
return v, formRead(raw), nil
|
|
}
|
|
|
|
// SeatHoldersBySeatNodeKey is the key of one value of the state seat-holders under the form "<seat>.<node>".
|
|
func SeatHoldersBySeatNodeKey(seat, node string) string { return seat + "." + node }
|
|
|
|
// ParseSeatHoldersBySeatNodeKey reads the parts of a key of the form "<seat>.<node>", in the order of the form; the last result is false for a key of another form.
|
|
func ParseSeatHoldersBySeatNodeKey(key string) (string, string, bool) {
|
|
rest := key
|
|
v0, after0, found0 := strings.Cut(rest, ".")
|
|
if !found0 || v0 == "" {
|
|
return "", "", false
|
|
}
|
|
rest = after0
|
|
if rest == "" {
|
|
return "", "", false
|
|
}
|
|
v2 := rest
|
|
rest = ""
|
|
if rest != "" {
|
|
return "", "", false
|
|
}
|
|
return v0, v2, true
|
|
}
|
|
|
|
// DecodeSeatHoldersBySeatNodeValue reads one value of the state seat-holders under the form "<seat>.<node>" as another part wrote it: a field SeatHoldersBySeatNodeValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
|
|
func DecodeSeatHoldersBySeatNodeValue(raw []byte) (SeatHoldersBySeatNodeValue, int, error) {
|
|
var v SeatHoldersBySeatNodeValue
|
|
if err := json.Unmarshal(raw, &v); err != nil {
|
|
return v, 0, err
|
|
}
|
|
return v, formRead(raw), nil
|
|
}
|
|
|
|
// AddedModule is what the want a candidate would write for a module carries of its build, in the want's own forms (the seat mesh-wants' state wants: `version` and `parts`; copied here because a seat definition cannot reuse another repository's seat's forms, design 47 G A-316).
|
|
type AddedModule struct {
|
|
// the digest of each of the module's parts, by `<module>:<artifact>` (design 47 G section 379)
|
|
Parts map[string]string `json:"parts,omitempty"`
|
|
// the module's released version, for people; none for a build of another watched branch (design 47 G section 379)
|
|
Version string `json:"version,omitempty"`
|
|
}
|
|
|
|
// Assignments is one node's assignments assembled.
|
|
type Assignments struct {
|
|
Decided NodeDecided `json:"decided"`
|
|
Holds []Holding `json:"holds,omitempty"`
|
|
Modules []PlacedModule `json:"modules"`
|
|
Node string `json:"node"`
|
|
// by provision, the provider chosen for the node
|
|
Pins map[string]Provider `json:"pins,omitempty"`
|
|
Revision string `json:"revision,omitempty"`
|
|
V int64 `json:"v,omitempty"`
|
|
}
|
|
|
|
// AssignmentsEventWarrant is who approved it, through which channel, when.
|
|
type AssignmentsEventWarrant struct {
|
|
At time.Time `json:"at"`
|
|
Warrant string `json:"warrant"`
|
|
Words string `json:"words"`
|
|
}
|
|
|
|
// AssignmentsEvent is what each assignments event carries.
|
|
type AssignmentsEvent struct {
|
|
// for assignments-withdrawn, why it ended
|
|
Ended string `json:"ended,omitempty"`
|
|
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
|
|
Form int64 `json:"form,omitempty"`
|
|
// for assignments-changed, by node the revisions before and after and the modules added, removed or changed
|
|
Nodes []map[string]any `json:"nodes,omitempty"`
|
|
Proposal Proposal `json:"proposal"`
|
|
// who approved it, through which channel, when
|
|
Warrant *AssignmentsEventWarrant `json:"warrant,omitempty"`
|
|
}
|
|
|
|
// FoundTunnel is a tunnel found on the machine when it was adopted: everything but its private key.
|
|
type FoundTunnel struct {
|
|
Address string `json:"address,omitempty"`
|
|
Config string `json:"config,omitempty"`
|
|
Interface string `json:"interface"`
|
|
Mtu int64 `json:"mtu,omitempty"`
|
|
Peers []FoundTunnelPeer `json:"peers,omitempty"`
|
|
Port int64 `json:"port,omitempty"`
|
|
PublicKey string `json:"public-key,omitempty"`
|
|
Range string `json:"range,omitempty"`
|
|
Unit string `json:"unit,omitempty"`
|
|
}
|
|
|
|
// FoundTunnelPeer is one peer of a found tunnel.
|
|
type FoundTunnelPeer struct {
|
|
Address string `json:"address,omitempty"`
|
|
PublicKey string `json:"public-key"`
|
|
}
|
|
|
|
// Holding is one seat a module placed on the node holds.
|
|
type Holding struct {
|
|
Claim string `json:"claim"`
|
|
Kind string `json:"kind,omitempty"`
|
|
Module string `json:"module"`
|
|
Scope string `json:"scope,omitempty"`
|
|
Site string `json:"site,omitempty"`
|
|
}
|
|
|
|
// ModulePlacement is the nodes that run a module from one watched branch.
|
|
type ModulePlacement struct {
|
|
Branch string `json:"branch"`
|
|
// the fingerprint of the build these nodes run from the branch; absent, the newest delivered of the branch (design 47 H 750, H-A-39): one row per branch and build
|
|
Build string `json:"build,omitempty"`
|
|
Nodes []string `json:"nodes"`
|
|
}
|
|
|
|
// NodeDecided is what a person decides of a node; no secret and no key material.
|
|
type NodeDecided struct {
|
|
Account string `json:"account,omitempty"`
|
|
AccountHome string `json:"account-home,omitempty"`
|
|
Address string `json:"address,omitempty"`
|
|
Adopted bool `json:"adopted,omitempty"`
|
|
AgentAccount string `json:"agent-account,omitempty"`
|
|
AgentAccountHome string `json:"agent-account-home,omitempty"`
|
|
Endpoint string `json:"endpoint,omitempty"`
|
|
Hub bool `json:"hub,omitempty"`
|
|
// on the hub, the name a person gave a peer of that tunnel, by its public key
|
|
PeerNames map[string]string `json:"peer-names,omitempty"`
|
|
PublicDomain string `json:"public-domain,omitempty"`
|
|
Site string `json:"site,omitempty"`
|
|
Taken []string `json:"taken,omitempty"`
|
|
// the tunnel found on the node when it was adopted
|
|
Tunnel *FoundTunnel `json:"tunnel,omitempty"`
|
|
}
|
|
|
|
// PlacedModule is one module placed on a node.
|
|
type PlacedModule struct {
|
|
// by provision, the provider each requirement that keeps data is bound to
|
|
Bindings map[string]Provider `json:"bindings,omitempty"`
|
|
// the watched branch this node runs the module from; absent, the first watched branch of the module's registration (design 47 G 14)
|
|
Branch string `json:"branch,omitempty"`
|
|
// the fingerprint of the build the node runs; absent, the newest delivered of the branch (design 47 G 78, 402)
|
|
Build string `json:"build,omitempty"`
|
|
HasLayer bool `json:"has-layer,omitempty"`
|
|
HasMeshWide bool `json:"has-mesh-wide,omitempty"`
|
|
// this node's settings layer of the module's assignments
|
|
Layer map[string]any `json:"layer,omitempty"`
|
|
// the whole mesh's settings layer of the module's assignments
|
|
MeshWide map[string]any `json:"mesh-wide,omitempty"`
|
|
// config values a person set in the whole mesh's layer, for a module in the settings form
|
|
MeshWideValues map[string]any `json:"mesh-wide-values,omitempty"`
|
|
Module string `json:"module"`
|
|
// the host port each declared port is published on, by the port the software listens on
|
|
Ports map[string]int64 `json:"ports,omitempty"`
|
|
// config values a person set in this node's layer, for a module in the settings form
|
|
Values map[string]any `json:"values,omitempty"`
|
|
}
|
|
|
|
// Proposal is an open proposal.
|
|
type Proposal struct {
|
|
Again *time.Time `json:"again,omitempty"`
|
|
Ask string `json:"ask,omitempty"`
|
|
At time.Time `json:"at"`
|
|
// by node whose key it changes, the revision of the key it was laid over (0: none)
|
|
Base map[string]int64 `json:"base"`
|
|
By string `json:"by"`
|
|
Changes []ProposalChange `json:"changes"`
|
|
ExportDigest string `json:"export-digest,omitempty"`
|
|
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
|
|
Form int64 `json:"form,omitempty"`
|
|
HandBack bool `json:"hand-back,omitempty"`
|
|
ID string `json:"id"`
|
|
Must []string `json:"must,omitempty"`
|
|
Seed bool `json:"seed,omitempty"`
|
|
// answering, failed or asked
|
|
State string `json:"state"`
|
|
V int64 `json:"v,omitempty"`
|
|
Verdict *Verdict `json:"verdict,omitempty"`
|
|
Warrant *Warrant `json:"warrant,omitempty"`
|
|
Why string `json:"why"`
|
|
Withdrawn string `json:"withdrawn,omitempty"`
|
|
Words string `json:"words,omitempty"`
|
|
Written *time.Time `json:"written,omitempty"`
|
|
}
|
|
|
|
// ProposalChangeKeys is the public halves of a joining node's keys.
|
|
type ProposalChangeKeys struct {
|
|
Identity string `json:"identity"`
|
|
Overlay string `json:"overlay,omitempty"`
|
|
Sealing string `json:"sealing"`
|
|
Serving string `json:"serving,omitempty"`
|
|
}
|
|
|
|
// ProposalChange is one change of a proposal.
|
|
type ProposalChange struct {
|
|
Bindings map[string]Provider `json:"bindings,omitempty"`
|
|
// for place, the watched branch the node runs the module from; absent, the first watched branch of the module's registration (design 47 G 14)
|
|
Branch string `json:"branch,omitempty"`
|
|
// for place, the build of that branch the node runs, a return to an earlier build being this one value; absent, the newest delivered of the branch (ADR 0666 section 24)
|
|
Build string `json:"build,omitempty"`
|
|
Claim string `json:"claim,omitempty"`
|
|
Decided *NodeDecided `json:"decided,omitempty"`
|
|
Field string `json:"field,omitempty"`
|
|
// the public halves of a joining node's keys
|
|
Keys *ProposalChangeKeys `json:"keys,omitempty"`
|
|
Kind string `json:"kind,omitempty"`
|
|
Layer map[string]any `json:"layer,omitempty"`
|
|
MeshWide map[string]any `json:"mesh-wide,omitempty"`
|
|
MeshWideValues map[string]any `json:"mesh-wide-values,omitempty"`
|
|
Module string `json:"module,omitempty"`
|
|
Node string `json:"node"`
|
|
// place, take-off, pin, unpin, hold, unhold, decide, config, seed, add-node or remove-node
|
|
Op string `json:"op"`
|
|
Ports map[string]int64 `json:"ports,omitempty"`
|
|
Provider *Provider `json:"provider,omitempty"`
|
|
Provision string `json:"provision,omitempty"`
|
|
Scope string `json:"scope,omitempty"`
|
|
Site string `json:"site,omitempty"`
|
|
// a decided field's value
|
|
Value any `json:"value,omitempty"`
|
|
Values map[string]any `json:"values,omitempty"`
|
|
// the node's whole assignments, for a seed
|
|
Whole *Assignments `json:"whole,omitempty"`
|
|
}
|
|
|
|
// Provider is the module on a node that answers a requirement or holds a seat.
|
|
type Provider struct {
|
|
Module string `json:"module"`
|
|
Node string `json:"node"`
|
|
}
|
|
|
|
// SeatHoldersHoldersItem is a type of the contract.
|
|
type SeatHoldersHoldersItem struct {
|
|
Module string `json:"module"`
|
|
Node string `json:"node"`
|
|
}
|
|
|
|
// SeatHolders is one key of seat-holders.
|
|
type SeatHolders struct {
|
|
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
|
|
Form int64 `json:"form,omitempty"`
|
|
Holders []SeatHoldersHoldersItem `json:"holders"`
|
|
Node string `json:"node,omitempty"`
|
|
// the claim names no seat of the seat list
|
|
Outside bool `json:"outside,omitempty"`
|
|
Scope string `json:"scope"`
|
|
Seat string `json:"seat"`
|
|
V int64 `json:"v,omitempty"`
|
|
}
|
|
|
|
// Verdict is the holder's judgement of a proposal's answers.
|
|
type Verdict struct {
|
|
// every node's answer to its candidate, by node
|
|
Answers map[string]map[string]any `json:"answers,omitempty"`
|
|
At time.Time `json:"at"`
|
|
Carried map[string][]string `json:"carried,omitempty"`
|
|
Fails []string `json:"fails,omitempty"`
|
|
Intended map[string][]string `json:"intended,omitempty"`
|
|
Notes []string `json:"notes,omitempty"`
|
|
Silent []string `json:"silent,omitempty"`
|
|
// waits, pass or fail
|
|
State string `json:"state"`
|
|
Unintended map[string][]string `json:"unintended,omitempty"`
|
|
Until *time.Time `json:"until,omitempty"`
|
|
}
|
|
|
|
// Warrant is the enrolment's warrant an add-node carries.
|
|
type Warrant struct {
|
|
Address string `json:"address"`
|
|
Ask string `json:"ask"`
|
|
Node string `json:"node"`
|
|
Warrant string `json:"warrant"`
|
|
}
|
|
|
|
// AssignmentsInput is what assignments takes.
|
|
type AssignmentsInput struct {
|
|
// "true": the changes in order, from the stream and the state's revisions
|
|
History string `json:"history,omitempty"`
|
|
// one module: the nodes it is placed on
|
|
Module string `json:"module,omitempty"`
|
|
// one node
|
|
Node string `json:"node,omitempty"`
|
|
// "true": who holds each seat, and on which node (the state seat-holders); with node, that node's
|
|
Seats string `json:"seats,omitempty"`
|
|
}
|
|
|
|
// The values of AssignmentsInput's history.
|
|
const (
|
|
AssignmentsInputHistoryTrue = "true"
|
|
AssignmentsInputHistoryFalse = "false"
|
|
)
|
|
|
|
// The values of AssignmentsInput's seats.
|
|
const (
|
|
AssignmentsInputSeatsTrue = "true"
|
|
AssignmentsInputSeatsFalse = "false"
|
|
)
|
|
|
|
// AssignmentsAnswer is what assignments answers.
|
|
type AssignmentsAnswer = map[string]any
|
|
|
|
// ProposalsInput is what proposals takes.
|
|
type ProposalsInput struct {
|
|
// one proposal's id
|
|
ID string `json:"id,omitempty"`
|
|
}
|
|
|
|
// ProposalsAnswer is what proposals answers.
|
|
type ProposalsAnswer = map[string]any
|
|
|
|
// ProposeInput is what propose takes.
|
|
type ProposeInput struct {
|
|
// the changes, each an object with `op`: place (node, module, ports, bindings), take-off (node, module), pin (node, provision, provider {node, module}), unpin (node, provision), hold (node, module, claim, scope, kind, site), unhold (node, module, claim), decide (node, field, value: a decided field of the node, its address among them), config (node, module, mesh-wide, layer, mesh-wide-values, values), add-node (node, decided, keys: a joining node, mesh-enrolment's alone, the proposal's one change, with the enrolment's warrant, its tunnel key alone at the operator's yes; ADR 0587 §7), remove-node (node: a joining node never confirmed, taken off when its enrolment ends; mesh-enrolment's alone, on the same warrant)
|
|
Changes []map[string]any `json:"changes"`
|
|
// for an add-node alone: the enrolment's warrant {node, address, ask, warrant}, naming the change's node and address
|
|
Warrant map[string]any `json:"warrant,omitempty"`
|
|
// why, shown to the operator with the proposal
|
|
Why string `json:"why"`
|
|
}
|
|
|
|
// ProposeAnswer is what propose answers.
|
|
type ProposeAnswer = map[string]any
|
|
|
|
// WithdrawInput is what withdraw takes.
|
|
type WithdrawInput struct {
|
|
// the proposal's id
|
|
ID string `json:"id"`
|
|
// why, kept in the event
|
|
Why string `json:"why"`
|
|
}
|
|
|
|
// WithdrawAnswer is what withdraw answers.
|
|
type WithdrawAnswer = map[string]any
|
|
|
|
// AgainInput is what again takes.
|
|
type AgainInput struct {
|
|
// the proposal's id
|
|
ID string `json:"id"`
|
|
}
|
|
|
|
// AgainAnswer is what again answers.
|
|
type AgainAnswer = map[string]any
|
|
|
|
// PlacementInput is what placement takes.
|
|
type PlacementInput struct {
|
|
// the module
|
|
Module string `json:"module"`
|
|
}
|
|
|
|
// PlacementAnswer is what placement answers.
|
|
type PlacementAnswer struct {
|
|
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
|
|
Form int64 `json:"form,omitempty"`
|
|
// one per branch and build, the nodes that run the module from it
|
|
Placements []ModulePlacement `json:"placements"`
|
|
}
|
|
|
|
// AssignmentsProposedEvent is the body of the event assignments-proposed.
|
|
type AssignmentsProposedEvent = AssignmentsEvent
|
|
|
|
// AssignmentsWithdrawnEvent is the body of the event assignments-withdrawn.
|
|
type AssignmentsWithdrawnEvent = AssignmentsEvent
|
|
|
|
// AssignmentsJudgedEvent is the body of the event assignments-judged.
|
|
type AssignmentsJudgedEvent = AssignmentsEvent
|
|
|
|
// AssignmentsChangedEvent is the body of the event assignments-changed.
|
|
type AssignmentsChangedEvent = AssignmentsEvent
|
|
|
|
// AssignmentsByNodeNodeValueModulesItem is a type of the contract.
|
|
type AssignmentsByNodeNodeValueModulesItem struct {
|
|
// the digest of the module key's value it stands for
|
|
Digest string `json:"digest"`
|
|
Module string `json:"module"`
|
|
}
|
|
|
|
// AssignmentsByNodeNodeValue is one value of the state assignments under the key <node>.node.
|
|
type AssignmentsByNodeNodeValue struct {
|
|
Decided NodeDecided `json:"decided"`
|
|
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
|
|
Form int64 `json:"form,omitempty"`
|
|
Holds []Holding `json:"holds,omitempty"`
|
|
// the modules placed, in the order the composition reads them
|
|
Modules []AssignmentsByNodeNodeValueModulesItem `json:"modules"`
|
|
Node string `json:"node"`
|
|
Pins map[string]Provider `json:"pins,omitempty"`
|
|
V int64 `json:"v,omitempty"`
|
|
}
|
|
|
|
// AssignmentsByNodeModuleValue is one value of the state assignments under the key <node>.<module>.
|
|
type AssignmentsByNodeModuleValue struct {
|
|
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
|
|
Form int64 `json:"form,omitempty"`
|
|
Node string `json:"node"`
|
|
Placed PlacedModule `json:"placed"`
|
|
// the value it replaces while a write is under way
|
|
Previous *PlacedModule `json:"previous,omitempty"`
|
|
V int64 `json:"v,omitempty"`
|
|
}
|
|
|
|
// ProposalsByProposalValue is one value of the state proposals under the key <proposal>.
|
|
type ProposalsByProposalValue = Proposal
|
|
|
|
// CandidatesByProposalNodeValue is one value of the state candidates under the key <proposal>.<node>.
|
|
type CandidatesByProposalNodeValue struct {
|
|
// by module name, each module the candidate adds to this node without a want there: the `version` and `parts` the want it would write carries (design 47 G A-316); the node-engine builds such a module from this entry
|
|
Added map[string]AddedModule `json:"added,omitempty"`
|
|
// the node's assignments with the proposal laid over it; absent when the proposal takes its key away
|
|
Assignments *Assignments `json:"assignments,omitempty"`
|
|
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
|
|
Form int64 `json:"form,omitempty"`
|
|
Proposal string `json:"proposal"`
|
|
// the proposal changes this node's composition through another's key
|
|
Reached bool `json:"reached,omitempty"`
|
|
V int64 `json:"v,omitempty"`
|
|
}
|
|
|
|
// PulsesByAnswerProposalNodeValue is one value of the state pulses under the key answer.<proposal>.<node>.
|
|
type PulsesByAnswerProposalNodeValue struct {
|
|
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
|
|
Form int64 `json:"form,omitempty"`
|
|
V int64 `json:"v,omitempty"`
|
|
}
|
|
|
|
// PulsesByAskProposalValue is one value of the state pulses under the key ask.<proposal>.
|
|
type PulsesByAskProposalValue struct {
|
|
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
|
|
Form int64 `json:"form,omitempty"`
|
|
V int64 `json:"v,omitempty"`
|
|
}
|
|
|
|
// SeatHoldersBySeatValue is one value of the state seat-holders under the key <seat>.
|
|
type SeatHoldersBySeatValue = SeatHolders
|
|
|
|
// SeatHoldersBySeatNodeValue is one value of the state seat-holders under the key <seat>.<node>.
|
|
type SeatHoldersBySeatNodeValue = SeatHolders
|
|
|
|
// DecodeAssignmentsAnswer reads a AssignmentsAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
|
|
func DecodeAssignmentsAnswer(raw []byte) (AssignmentsAnswer, int, error) {
|
|
var v AssignmentsAnswer
|
|
if err := json.Unmarshal(raw, &v); err != nil {
|
|
return v, 0, err
|
|
}
|
|
return v, formRead(raw), nil
|
|
}
|
|
|
|
// DecodeProposalsAnswer reads a ProposalsAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
|
|
func DecodeProposalsAnswer(raw []byte) (ProposalsAnswer, int, error) {
|
|
var v ProposalsAnswer
|
|
if err := json.Unmarshal(raw, &v); err != nil {
|
|
return v, 0, err
|
|
}
|
|
return v, formRead(raw), nil
|
|
}
|
|
|
|
// DecodeProposeAnswer reads a ProposeAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
|
|
func DecodeProposeAnswer(raw []byte) (ProposeAnswer, int, error) {
|
|
var v ProposeAnswer
|
|
if err := json.Unmarshal(raw, &v); err != nil {
|
|
return v, 0, err
|
|
}
|
|
return v, formRead(raw), nil
|
|
}
|
|
|
|
// DecodeWithdrawAnswer reads a WithdrawAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
|
|
func DecodeWithdrawAnswer(raw []byte) (WithdrawAnswer, int, error) {
|
|
var v WithdrawAnswer
|
|
if err := json.Unmarshal(raw, &v); err != nil {
|
|
return v, 0, err
|
|
}
|
|
return v, formRead(raw), nil
|
|
}
|
|
|
|
// DecodeAgainAnswer reads a AgainAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
|
|
func DecodeAgainAnswer(raw []byte) (AgainAnswer, int, error) {
|
|
var v AgainAnswer
|
|
if err := json.Unmarshal(raw, &v); err != nil {
|
|
return v, 0, err
|
|
}
|
|
return v, formRead(raw), nil
|
|
}
|
|
|
|
// DecodePlacementAnswer reads a PlacementAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
|
|
func DecodePlacementAnswer(raw []byte) (PlacementAnswer, int, error) {
|
|
var v PlacementAnswer
|
|
if err := json.Unmarshal(raw, &v); err != nil {
|
|
return v, 0, err
|
|
}
|
|
return v, formRead(raw), nil
|
|
}
|
|
|
|
// DecodeAssignmentsProposedEvent reads a AssignmentsProposedEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
|
|
func DecodeAssignmentsProposedEvent(raw []byte) (AssignmentsProposedEvent, int, error) {
|
|
var v AssignmentsProposedEvent
|
|
if err := json.Unmarshal(raw, &v); err != nil {
|
|
return v, 0, err
|
|
}
|
|
return v, formRead(raw), nil
|
|
}
|
|
|
|
// DecodeAssignmentsWithdrawnEvent reads a AssignmentsWithdrawnEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
|
|
func DecodeAssignmentsWithdrawnEvent(raw []byte) (AssignmentsWithdrawnEvent, int, error) {
|
|
var v AssignmentsWithdrawnEvent
|
|
if err := json.Unmarshal(raw, &v); err != nil {
|
|
return v, 0, err
|
|
}
|
|
return v, formRead(raw), nil
|
|
}
|
|
|
|
// DecodeAssignmentsJudgedEvent reads a AssignmentsJudgedEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
|
|
func DecodeAssignmentsJudgedEvent(raw []byte) (AssignmentsJudgedEvent, int, error) {
|
|
var v AssignmentsJudgedEvent
|
|
if err := json.Unmarshal(raw, &v); err != nil {
|
|
return v, 0, err
|
|
}
|
|
return v, formRead(raw), nil
|
|
}
|
|
|
|
// DecodeAssignmentsChangedEvent reads a AssignmentsChangedEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
|
|
func DecodeAssignmentsChangedEvent(raw []byte) (AssignmentsChangedEvent, int, error) {
|
|
var v AssignmentsChangedEvent
|
|
if err := json.Unmarshal(raw, &v); err != nil {
|
|
return v, 0, err
|
|
}
|
|
return v, formRead(raw), nil
|
|
}
|
|
|
|
// formRead is the form a value says on the wire: 1 when it says none, or is no object.
|
|
func formRead(raw []byte) int {
|
|
var f struct {
|
|
Form int `json:"form"`
|
|
}
|
|
if json.Unmarshal(raw, &f) != nil || f.Form < 1 {
|
|
return 1
|
|
}
|
|
return f.Form
|
|
}
|