Regenerate the domain contracts; hand-acts and conditions clients; operator-channel client moves; the seat-set package ends (ADR 0634, ADR 0635; issue 1966)
Claude-Session: https://claude.ai/code/session_01JG73KJNrH5EgFXMKKYSrig
This commit is contained in:
@@ -3,6 +3,13 @@
|
||||
// Package nodeengine is the contract of the seat "node-engine", defined whole (seats/node-engine/seat.json): The node seat every node's engine holds (novox/hq ADR 0563, ADR 0618 §3, §4): its hand acts on the operator's warrant, its read-only judgements, its compositions and what it reads of a manifest. Each verb is answered on this node's subject, mesh.seat.node-engine.tool.<verb>.<node>, and each event is published on mesh.seat.node-engine.event.<event>.<node>, the node's name its last token.
|
||||
package nodeengine
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Seat is the seat's name.
|
||||
const Seat = "node-engine"
|
||||
|
||||
@@ -57,6 +64,222 @@ func SubjectManifestReadsChanged(caller string) string {
|
||||
return "mesh.seat.node-engine.event.manifest-reads-changed." + caller
|
||||
}
|
||||
|
||||
const (
|
||||
StateHave = "have"
|
||||
StateComposed = "composed"
|
||||
StateData = "data"
|
||||
StatePackages = "packages"
|
||||
StateHealth = "health"
|
||||
)
|
||||
|
||||
// HaveByNodeModuleKey is the key of one value of the state have under the form "<node>.<module>".
|
||||
func HaveByNodeModuleKey(node, module string) string { return node + "." + module }
|
||||
|
||||
// ParseHaveByNodeModuleKey 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 ParseHaveByNodeModuleKey(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
|
||||
}
|
||||
|
||||
// DecodeHaveByNodeModuleValue reads one value of the state have under the form "<node>.<module>", refusing a field HaveByNodeModuleValue does not know and any text after the value.
|
||||
func DecodeHaveByNodeModuleValue(raw []byte) (HaveByNodeModuleValue, error) {
|
||||
var v HaveByNodeModuleValue
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.DisallowUnknownFields()
|
||||
if err := dec.Decode(&v); err != nil {
|
||||
return v, err
|
||||
}
|
||||
if dec.More() {
|
||||
return v, errors.New("text after the value")
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// HaveByNodeNodeKey is the key of one value of the state have under the form "<node>.node".
|
||||
func HaveByNodeNodeKey(node string) string { return node + ".node" }
|
||||
|
||||
// ParseHaveByNodeNodeKey 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 ParseHaveByNodeNodeKey(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
|
||||
}
|
||||
|
||||
// DecodeHaveByNodeNodeValue reads one value of the state have under the form "<node>.node", refusing a field HaveByNodeNodeValue does not know and any text after the value.
|
||||
func DecodeHaveByNodeNodeValue(raw []byte) (HaveByNodeNodeValue, error) {
|
||||
var v HaveByNodeNodeValue
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.DisallowUnknownFields()
|
||||
if err := dec.Decode(&v); err != nil {
|
||||
return v, err
|
||||
}
|
||||
if dec.More() {
|
||||
return v, errors.New("text after the value")
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// ComposedByNodeModuleFingerprintKey is the key of one value of the state composed under the form "<node>.<module>.<fingerprint>".
|
||||
func ComposedByNodeModuleFingerprintKey(node, module, fingerprint string) string {
|
||||
return node + "." + module + "." + fingerprint
|
||||
}
|
||||
|
||||
// ParseComposedByNodeModuleFingerprintKey reads the parts of a key of the form "<node>.<module>.<fingerprint>", in the order of the form; the last result is false for a key of another form.
|
||||
func ParseComposedByNodeModuleFingerprintKey(key string) (string, string, string, bool) {
|
||||
rest := key
|
||||
v0, after0, found0 := strings.Cut(rest, ".")
|
||||
if !found0 || v0 == "" {
|
||||
return "", "", "", false
|
||||
}
|
||||
rest = after0
|
||||
v2, after2, found2 := strings.Cut(rest, ".")
|
||||
if !found2 || v2 == "" {
|
||||
return "", "", "", false
|
||||
}
|
||||
rest = after2
|
||||
if rest == "" {
|
||||
return "", "", "", false
|
||||
}
|
||||
v4 := rest
|
||||
rest = ""
|
||||
if rest != "" {
|
||||
return "", "", "", false
|
||||
}
|
||||
return v0, v2, v4, true
|
||||
}
|
||||
|
||||
// DecodeComposedByNodeModuleFingerprintValue reads one value of the state composed under the form "<node>.<module>.<fingerprint>", refusing a field ComposedByNodeModuleFingerprintValue does not know and any text after the value.
|
||||
func DecodeComposedByNodeModuleFingerprintValue(raw []byte) (ComposedByNodeModuleFingerprintValue, error) {
|
||||
var v ComposedByNodeModuleFingerprintValue
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.DisallowUnknownFields()
|
||||
if err := dec.Decode(&v); err != nil {
|
||||
return v, err
|
||||
}
|
||||
if dec.More() {
|
||||
return v, errors.New("text after the value")
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// DataByNodeModuleKey is the key of one value of the state data under the form "<node>.<module>".
|
||||
func DataByNodeModuleKey(node, module string) string { return node + "." + module }
|
||||
|
||||
// ParseDataByNodeModuleKey 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 ParseDataByNodeModuleKey(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
|
||||
}
|
||||
|
||||
// DecodeDataByNodeModuleValue reads one value of the state data under the form "<node>.<module>", refusing a field DataByNodeModuleValue does not know and any text after the value.
|
||||
func DecodeDataByNodeModuleValue(raw []byte) (DataByNodeModuleValue, error) {
|
||||
var v DataByNodeModuleValue
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.DisallowUnknownFields()
|
||||
if err := dec.Decode(&v); err != nil {
|
||||
return v, err
|
||||
}
|
||||
if dec.More() {
|
||||
return v, errors.New("text after the value")
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// PackagesByNodeKey is the key of one value of the state packages under the form "<node>".
|
||||
func PackagesByNodeKey(node string) string { return node }
|
||||
|
||||
// ParsePackagesByNodeKey reads the parts of a key of the form "<node>", in the order of the form; the last result is false for a key of another form.
|
||||
func ParsePackagesByNodeKey(key string) (string, bool) {
|
||||
rest := key
|
||||
if rest == "" {
|
||||
return "", false
|
||||
}
|
||||
v0 := rest
|
||||
rest = ""
|
||||
if rest != "" {
|
||||
return "", false
|
||||
}
|
||||
return v0, true
|
||||
}
|
||||
|
||||
// DecodePackagesByNodeValue reads one value of the state packages under the form "<node>", refusing a field PackagesByNodeValue does not know and any text after the value.
|
||||
func DecodePackagesByNodeValue(raw []byte) (PackagesByNodeValue, error) {
|
||||
var v PackagesByNodeValue
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.DisallowUnknownFields()
|
||||
if err := dec.Decode(&v); err != nil {
|
||||
return v, err
|
||||
}
|
||||
if dec.More() {
|
||||
return v, errors.New("text after the value")
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// HealthByNodeKey is the key of one value of the state health under the form "<node>".
|
||||
func HealthByNodeKey(node string) string { return node }
|
||||
|
||||
// ParseHealthByNodeKey reads the parts of a key of the form "<node>", in the order of the form; the last result is false for a key of another form.
|
||||
func ParseHealthByNodeKey(key string) (string, bool) {
|
||||
rest := key
|
||||
if rest == "" {
|
||||
return "", false
|
||||
}
|
||||
v0 := rest
|
||||
rest = ""
|
||||
if rest != "" {
|
||||
return "", false
|
||||
}
|
||||
return v0, true
|
||||
}
|
||||
|
||||
// DecodeHealthByNodeValue reads one value of the state health under the form "<node>", refusing a field HealthByNodeValue does not know and any text after the value.
|
||||
func DecodeHealthByNodeValue(raw []byte) (HealthByNodeValue, error) {
|
||||
var v HealthByNodeValue
|
||||
dec := json.NewDecoder(bytes.NewReader(raw))
|
||||
dec.DisallowUnknownFields()
|
||||
if err := dec.Decode(&v); err != nil {
|
||||
return v, err
|
||||
}
|
||||
if dec.More() {
|
||||
return v, errors.New("text after the value")
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// Act is one act asked through the seat, as acts reads it (ADR 0563 §9).
|
||||
type Act struct {
|
||||
// the act: hand-over, access-act, judge-directories or setuid-search
|
||||
@@ -561,3 +784,104 @@ type RefusedEvent = ActSaid
|
||||
|
||||
// ManifestReadsChangedEvent is the body of the event manifest-reads-changed.
|
||||
type ManifestReadsChangedEvent = ManifestReadsChanged
|
||||
|
||||
// HaveByNodeModuleValue is one value of the state have under the key <node>.<module>.
|
||||
type HaveByNodeModuleValue struct {
|
||||
Build string `json:"build,omitempty"`
|
||||
BuildAlone bool `json:"build-alone,omitempty"`
|
||||
// the composition's digest
|
||||
Composed string `json:"composed,omitempty"`
|
||||
Detail string `json:"detail,omitempty"`
|
||||
// the fingerprint held
|
||||
Fp string `json:"fp,omitempty"`
|
||||
// the accounts handed
|
||||
Handed map[string]any `json:"handed,omitempty"`
|
||||
// how it is
|
||||
Health string `json:"health"`
|
||||
Judgement string `json:"judgement,omitempty"`
|
||||
Kept []string `json:"kept,omitempty"`
|
||||
// how far it has come
|
||||
Phase string `json:"phase"`
|
||||
// a pull the engine waits for
|
||||
PullWait map[string]any `json:"pull-wait,omitempty"`
|
||||
Sealed []string `json:"sealed,omitempty"`
|
||||
SealedAt map[string]any `json:"sealed-at,omitempty"`
|
||||
// the user list written
|
||||
UserList map[string]any `json:"user-list,omitempty"`
|
||||
V int64 `json:"v"`
|
||||
// what it waits for
|
||||
Waits string `json:"waits,omitempty"`
|
||||
}
|
||||
|
||||
// HaveByNodeNodeValue is one value of the state have under the key <node>.node.
|
||||
type HaveByNodeNodeValue struct {
|
||||
Busy map[string]any `json:"busy,omitempty"`
|
||||
Candidates map[string]map[string]any `json:"candidates,omitempty"`
|
||||
Composed string `json:"composed,omitempty"`
|
||||
// own, or the controller's
|
||||
Composes string `json:"composes,omitempty"`
|
||||
ComposesWhy string `json:"composes-why,omitempty"`
|
||||
Filters map[string]any `json:"filters,omitempty"`
|
||||
Profile map[string]any `json:"profile,omitempty"`
|
||||
// the node's record: its tunnel and certificate
|
||||
Record map[string]any `json:"record,omitempty"`
|
||||
Sealed []string `json:"sealed,omitempty"`
|
||||
SealedAt map[string]any `json:"sealed-at,omitempty"`
|
||||
Strays map[string]any `json:"strays,omitempty"`
|
||||
V int64 `json:"v"`
|
||||
Windows map[string]any `json:"windows,omitempty"`
|
||||
}
|
||||
|
||||
// ComposedByNodeModuleFingerprintValue is one value of the state composed under the key <node>.<module>.<fingerprint>.
|
||||
type ComposedByNodeModuleFingerprintValue struct {
|
||||
Data bool `json:"Data,omitempty"`
|
||||
FP string `json:"FP"`
|
||||
Filled []string `json:"Filled,omitempty"`
|
||||
Module string `json:"Module"`
|
||||
Node string `json:"Node"`
|
||||
// the node's own adoption, identities, groups, libraries and provisioner account
|
||||
Own map[string]any `json:"Own,omitempty"`
|
||||
// the module's plan
|
||||
Plan map[string]any `json:"Plan,omitempty"`
|
||||
// why the composition was refused
|
||||
Refused string `json:"Refused,omitempty"`
|
||||
Resources []map[string]any `json:"Resources,omitempty"`
|
||||
V int64 `json:"V,omitempty"`
|
||||
}
|
||||
|
||||
// DataByNodeModuleValue is one value of the state data under the key <node>.<module>.
|
||||
type DataByNodeModuleValue struct {
|
||||
Digest string `json:"digest"`
|
||||
Items []map[string]any `json:"items"`
|
||||
Module string `json:"module"`
|
||||
Node string `json:"node"`
|
||||
V int64 `json:"v,omitempty"`
|
||||
}
|
||||
|
||||
// PackagesByNodeValuePackagesItem is a type of the contract.
|
||||
type PackagesByNodeValuePackagesItem struct {
|
||||
Absent bool `json:"absent,omitempty"`
|
||||
Modules []string `json:"modules,omitempty"`
|
||||
Package string `json:"package,omitempty"`
|
||||
}
|
||||
|
||||
// PackagesByNodeValue is one value of the state packages under the key <node>.
|
||||
type PackagesByNodeValue struct {
|
||||
Node string `json:"node"`
|
||||
Packages []PackagesByNodeValuePackagesItem `json:"packages"`
|
||||
}
|
||||
|
||||
// HealthByNodeValue is one value of the state health under the key <node>.
|
||||
type HealthByNodeValue struct {
|
||||
At string `json:"at"`
|
||||
Contract int64 `json:"contract,omitempty"`
|
||||
Fallback map[string]any `json:"fallback,omitempty"`
|
||||
Found []map[string]any `json:"found,omitempty"`
|
||||
Network map[string]any `json:"network,omitempty"`
|
||||
Node string `json:"node"`
|
||||
Peers []map[string]any `json:"peers,omitempty"`
|
||||
Relogin []map[string]any `json:"relogin,omitempty"`
|
||||
Root []map[string]any `json:"root,omitempty"`
|
||||
Units map[string]any `json:"units,omitempty"`
|
||||
V int64 `json:"v"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user