H2 K1: every seat package read tolerantly, saying its form

A reader of another part's value refused a field it did not know, so a holder
that added one broke every reader until each was rebuilt. Every package is
generated again by mesh-delivery's seatgen (feat/47-H2 ff7db337): each
generated decoder keeps unknown fields, returns the form read (1 when absent)
and each package states its Form (1 everywhere, left out on the wire). The
hand-written clients take the three values, and the node-engine client's
ask, answer, composition and have decoders keep unknown fields too; their tests
now hold that tolerance. seatgen -check clean in all five folders.

Builds: design 47 H2 §780; H-A-350 DMC-4
This commit is contained in:
2026-11-21 23:15:25 +01:00
parent 28cb4d5441
commit 2172a8732d
41 changed files with 2514 additions and 543 deletions
+2 -2
View File
@@ -101,7 +101,7 @@ func DecodeNode(data []byte) (seat.AssignmentsByNodeNodeValue, error) {
if err := checkVersion(data); err != nil {
return seat.AssignmentsByNodeNodeValue{}, err
}
n, err := seat.DecodeAssignmentsByNodeNodeValue(data)
n, _, err := seat.DecodeAssignmentsByNodeNodeValue(data)
if err != nil {
return n, fmt.Errorf("meshmoduleassignerclient: value does not fit its shape: %w", err)
}
@@ -141,7 +141,7 @@ func DecodeModule(data []byte) (seat.AssignmentsByNodeModuleValue, error) {
if err := checkVersion(data); err != nil {
return seat.AssignmentsByNodeModuleValue{}, err
}
m, err := seat.DecodeAssignmentsByNodeModuleValue(data)
m, _, err := seat.DecodeAssignmentsByNodeModuleValue(data)
if err != nil {
return m, fmt.Errorf("meshmoduleassignerclient: value does not fit its shape: %w", err)
}
+8 -8
View File
@@ -128,10 +128,10 @@ func CheckAnswer(a seat.ComposeCandidateAnswer) error {
return nil
}
// strictDecode reads data into v, refusing an unknown key.
func strictDecode(data []byte, v any, what string) error {
// readDecode reads data into v, keeping a key it does not know (design 47 H2 §780: a reader of another part's value
// decodes it tolerantly).
func readDecode(data []byte, v any, what string) error {
d := json.NewDecoder(bytes.NewReader(data))
d.DisallowUnknownFields()
d.UseNumber() // a number in an object the contract leaves open (the composition input) keeps its digits as written
if err := d.Decode(v); err != nil {
return fmt.Errorf("node-engine: %s does not fit its shape: %w", what, err)
@@ -147,10 +147,10 @@ func EncodeAsk(a seat.ComposeCandidateInput) ([]byte, error) {
return json.Marshal(a)
}
// DecodeAsk reads an ask strictly; it refuses an unknown key and what EncodeAsk refuses.
// DecodeAsk reads an ask tolerantly, keeping a key it does not know; it refuses what EncodeAsk refuses.
func DecodeAsk(data []byte) (seat.ComposeCandidateInput, error) {
var a seat.ComposeCandidateInput
if err := strictDecode(data, &a, "a compose-candidate ask"); err != nil {
if err := readDecode(data, &a, "a compose-candidate ask"); err != nil {
return seat.ComposeCandidateInput{}, err
}
return a, checkAsk(a)
@@ -165,8 +165,8 @@ func EncodeAnswer(a seat.ComposeCandidateAnswer) ([]byte, error) {
return json.Marshal(a)
}
// DecodeAnswer reads an answer strictly; it refuses an unknown version (ErrUnknownVersion), an unknown key and what
// CheckAnswer refuses.
// DecodeAnswer reads an answer tolerantly, keeping a key it does not know; it refuses an unknown version
// (ErrUnknownVersion) and what CheckAnswer refuses.
func DecodeAnswer(data []byte) (seat.ComposeCandidateAnswer, error) {
var probe struct {
V *int64 `json:"v"`
@@ -178,7 +178,7 @@ func DecodeAnswer(data []byte) (seat.ComposeCandidateAnswer, error) {
return seat.ComposeCandidateAnswer{}, fmt.Errorf("%w: this reader reads %d", ErrUnknownVersion, Version)
}
var a seat.ComposeCandidateAnswer
if err := strictDecode(data, &a, "a compose-candidate answer"); err != nil {
if err := readDecode(data, &a, "a compose-candidate answer"); err != nil {
return seat.ComposeCandidateAnswer{}, err
}
return a, CheckAnswer(a)
+4 -4
View File
@@ -24,8 +24,8 @@ func TestComposeCandidateRoundTripsAndRefuses(t *testing.T) {
if a, err := DecodeAsk(raw); err != nil || a.Candidate != key || !a.Input {
t.Fatalf("ask round trip: %v, %+v", err, a)
}
if _, err := DecodeAsk([]byte(`{"candidate":"` + key + `","other":1}`)); err == nil {
t.Error("an ask with an unknown key was read")
if a, err := DecodeAsk([]byte(`{"candidate":"` + key + `","other":1}`)); err != nil || a.Candidate != key {
t.Errorf("an ask with an unknown key is refused (§780 reads it tolerantly): %+v, %v", a, err)
}
if _, err := EncodeAsk(seat.ComposeCandidateInput{Candidate: "nope"}); err == nil {
t.Error("an ask naming no candidate key was encoded")
@@ -46,8 +46,8 @@ func TestComposeCandidateRoundTripsAndRefuses(t *testing.T) {
if err != nil || back.Verdict != Refused || len(back.Modules) != 3 || !reflect.DeepEqual(back.Input, good.Input) {
t.Fatalf("answer round trip: %v, %+v", err, back)
}
if _, err := DecodeAnswer([]byte(strings.Replace(string(raw), `"took"`, `"other":1,"took"`, 1))); err == nil {
t.Error("an answer with an unknown key was read")
if _, err := DecodeAnswer([]byte(strings.Replace(string(raw), `"took"`, `"other":1,"took"`, 1))); err != nil {
t.Errorf("an answer with an unknown key is refused (§780 reads it tolerantly): %v", err)
}
if _, err := DecodeAnswer([]byte(strings.Replace(string(raw), `"v":1`, `"v":2`, 1))); !errors.Is(err, ErrUnknownVersion) {
t.Errorf("an answer at another version read as %v", err)
+3 -5
View File
@@ -289,16 +289,14 @@ func EncodeComposition(c Composition) ([]byte, error) {
return json.Marshal(w)
}
// DecodeComposition reads a composition; it refuses an unknown version (keys.ErrUnknownVersion), a field it does not
// know, and what EncodeComposition refuses.
// DecodeComposition reads a composition tolerantly, keeping a field it does not know (design 47 H2 §780); it refuses an
// unknown version (keys.ErrUnknownVersion) and what EncodeComposition refuses.
func DecodeComposition(data []byte) (Composition, error) {
if err := keys.CheckVersion(data); err != nil {
return Composition{}, err
}
var w composedWire
d := json.NewDecoder(bytes.NewReader(data))
d.DisallowUnknownFields()
if err := d.Decode(&w); err != nil {
if err := json.Unmarshal(data, &w); err != nil {
return Composition{}, fmt.Errorf("node-engine: a composition does not fit its shape: %w", err)
}
c := Composition{V: w.V, Node: w.Node, Module: w.Module, FP: w.FP, Data: w.Data, Resources: w.Resources,
+2 -2
View File
@@ -124,8 +124,8 @@ func TestCompositionRefusals(t *testing.T) {
if _, err := DecodeComposition([]byte(`{"v":2,"node":"ace","resources":[]}`)); err == nil {
t.Error("a composition of version 2 is read")
}
if _, err := DecodeComposition([]byte(`{"v":1,"node":"ace","resources":[],"extra":1}`)); err == nil {
t.Error("a composition with a field it does not know is read")
if c, err := DecodeComposition([]byte(`{"v":1,"node":"ace","resources":[],"extra":1}`)); err != nil || c.Node != "ace" {
t.Errorf("a composition with a field it does not know is refused (§780 reads it tolerantly): %v", err)
}
if _, err := DecodeComposition([]byte(`{"v":1,"node":"ace","resources":[],"signature":"x"}`)); err != nil {
t.Errorf("a signed composition of the ended controller is refused: %v", err)
+6 -6
View File
@@ -101,13 +101,13 @@ func EncodeHave(h seat.HaveByNodeModuleValue) ([]byte, error) {
return json.Marshal(h)
}
// DecodeHave reads a have; it refuses an unknown version (keys.ErrUnknownVersion), a field the contract does not know and
// what EncodeHave refuses.
// DecodeHave reads a have; it refuses an unknown version (keys.ErrUnknownVersion) and what EncodeHave refuses, and keeps a field
// the contract does not know (design 47 H2 §780).
func DecodeHave(data []byte) (seat.HaveByNodeModuleValue, error) {
if err := keys.CheckVersion(data); err != nil {
return seat.HaveByNodeModuleValue{}, err
}
h, err := seat.DecodeHaveByNodeModuleValue(data)
h, _, err := seat.DecodeHaveByNodeModuleValue(data)
if err != nil {
return seat.HaveByNodeModuleValue{}, fmt.Errorf("node-engine: value does not fit its shape: %w", err)
}
@@ -145,13 +145,13 @@ func EncodeHaveNode(n seat.HaveByNodeNodeValue) ([]byte, error) {
return json.Marshal(n)
}
// DecodeHaveNode reads a node's facts; it refuses an unknown version (keys.ErrUnknownVersion), a field the contract does
// not know and what EncodeHaveNode refuses.
// DecodeHaveNode reads a node's facts; it refuses an unknown version (keys.ErrUnknownVersion) and what EncodeHaveNode
// refuses, and keeps a field the contract does not know (design 47 H2 §780).
func DecodeHaveNode(data []byte) (seat.HaveByNodeNodeValue, error) {
if err := keys.CheckVersion(data); err != nil {
return seat.HaveByNodeNodeValue{}, err
}
n, err := seat.DecodeHaveByNodeNodeValue(data)
n, _, err := seat.DecodeHaveByNodeNodeValue(data)
if err != nil {
return seat.HaveByNodeNodeValue{}, fmt.Errorf("node-engine: value does not fit its shape: %w", err)
}
+2 -2
View File
@@ -55,8 +55,8 @@ func TestHaveCodec(t *testing.T) {
if _, err := DecodeHave([]byte(`{"v":2,"phase":"running","health":"ok"}`)); !errors.Is(err, keys.ErrUnknownVersion) {
t.Fatalf("version 2: %v", err)
}
if _, err := DecodeHave([]byte(`{"v":1,"phase":"running","health":"ok","extra":1}`)); err == nil {
t.Fatal("an unknown field is read")
if h, err := DecodeHave([]byte(`{"v":1,"phase":"running","health":"ok","extra":1}`)); err != nil || h.Phase != "running" {
t.Fatalf("an unknown field is refused (§780 reads it tolerantly): %v", err)
}
t.Run("SameHaveComparesTimesAsInstants", func(t *testing.T) {
at := time.Date(2026, 11, 5, 12, 0, 0, 0, time.UTC)
+4 -3
View File
@@ -30,12 +30,13 @@ func EncodeHealth(h seat.HealthByNodeValue) ([]byte, error) {
return json.Marshal(h)
}
// DecodeHealth reads a report; it refuses another version (keys.ErrUnknownVersion) and a field the contract does not know.
// DecodeHealth reads a report; it refuses another version (keys.ErrUnknownVersion) and keeps a field the contract does not know
// (design 47 H2 §780).
func DecodeHealth(raw []byte) (seat.HealthByNodeValue, error) {
if err := keys.CheckVersion(raw); err != nil {
return seat.HealthByNodeValue{}, err
}
h, err := seat.DecodeHealthByNodeValue(raw)
h, _, err := seat.DecodeHealthByNodeValue(raw)
if err != nil {
return seat.HealthByNodeValue{}, fmt.Errorf("node-engine: a node's health report is not readable: %w", err)
}
@@ -76,7 +77,7 @@ func DecodeData(raw []byte) (seat.DataByNodeModuleValue, error) {
if err := keys.CheckVersion(raw); err != nil {
return seat.DataByNodeModuleValue{}, err
}
d, err := seat.DecodeDataByNodeModuleValue(raw)
d, _, err := seat.DecodeDataByNodeModuleValue(raw)
if err != nil {
return seat.DataByNodeModuleValue{}, fmt.Errorf("node-engine: a module's data items are not readable: %w", err)
}
+247 -2
View File
@@ -3,11 +3,25 @@
// Package meshbroker is the contract of the seat "mesh-broker", defined whole (seats/mesh-broker/seat.json): The mesh's bus, and the bus state modules ask of it in requires (design 25 § 12). create, apply, recreate and drop are granted to the bus module's own credential alone.
package meshbroker
import "time"
import (
"encoding/json"
"time"
)
// Seat is the seat's name.
const Seat = "mesh-broker"
// 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 = "ddc1534e14865923e0c10a7670539ae3f11349c8f6282f31992d2b337d39c498"
)
const (
VerbList = "list"
VerbShow = "show"
@@ -174,6 +188,8 @@ type Held struct {
// its own configuration, where no template fits
Configuration map[string]any `json:"configuration,omitempty"`
Fill *Fill `json:"fill,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// its local name in the module's manifest
LocalName string `json:"local-name"`
// the module asking it
@@ -239,6 +255,8 @@ type Said struct {
// its own configuration, where no template fits
Configuration map[string]any `json:"configuration,omitempty"`
Fill *Fill `json:"fill,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// the settings held
Held map[string]any `json:"held,omitempty"`
// its local name in the module's manifest
@@ -309,6 +327,8 @@ type ListAnswer struct {
Caps *ListAnswerCaps `json:"caps,omitempty"`
// every entry
Entries []Held `json:"entries"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
}
// ShowInput is what show takes.
@@ -341,6 +361,8 @@ type CheckAnswerDifferencesItem struct {
type CheckAnswer struct {
// every difference
Differences []CheckAnswerDifferencesItem `json:"differences"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
}
// OrphansInput is what orphans takes.
@@ -351,6 +373,8 @@ type OrphansInput struct {
type OrphansAnswer struct {
// every orphan
Entries []Held `json:"entries"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
}
// CreateInput is what create takes.
@@ -378,6 +402,8 @@ type DropInput = Warranted
type DropAnswer struct {
// it is gone
Dropped bool `json:"dropped"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// the snapshot taken first
Snapshot string `json:"snapshot,omitempty"`
}
@@ -400,6 +426,8 @@ type SnapshotGetAnswer struct {
Digest string `json:"digest,omitempty"`
// why not: snapshot damaged, snapshot missing, snapshot protected or snapshot taken before milestone G; set alone
Error string `json:"error,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// the entry's local name
Local string `json:"local,omitempty"`
Module string `json:"module,omitempty"`
@@ -427,6 +455,8 @@ type SnapshotRestoreAnswer struct {
Busy string `json:"busy,omitempty"`
// why not; set alone
Error string `json:"error,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
}
// SnapshotRestoreCancelInput is what snapshot-restore-cancel takes.
@@ -445,6 +475,8 @@ type SnapshotRestoreCancelAnswer struct {
Busy string `json:"busy,omitempty"`
// why not; set alone
Error string `json:"error,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
}
// SnapshotRemoveInput is what snapshot-remove takes.
@@ -465,6 +497,8 @@ type SnapshotRemoveAnswer struct {
Busy string `json:"busy,omitempty"`
// why not; set alone
Error string `json:"error,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
}
// CreatedEvent is the body of the event created.
@@ -498,7 +532,9 @@ type DroppedEvent = Said
type SnapshotRestoredEvent struct {
Act string `json:"act"`
// when failed
Error string `json:"error,omitempty"`
Error string `json:"error,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
Outcome string `json:"outcome"`
Request string `json:"request"`
}
@@ -511,3 +547,212 @@ const (
// BusStateForm is the form of the provision bus-state.
type BusStateForm = Binding
// DecodeListAnswer reads a ListAnswer 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 DecodeListAnswer(raw []byte) (ListAnswer, int, error) {
var v ListAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeShowAnswer reads a ShowAnswer 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 DecodeShowAnswer(raw []byte) (ShowAnswer, int, error) {
var v ShowAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeCheckAnswer reads a CheckAnswer 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 DecodeCheckAnswer(raw []byte) (CheckAnswer, int, error) {
var v CheckAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeOrphansAnswer reads a OrphansAnswer 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 DecodeOrphansAnswer(raw []byte) (OrphansAnswer, int, error) {
var v OrphansAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeCreateAnswer reads a CreateAnswer 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 DecodeCreateAnswer(raw []byte) (CreateAnswer, int, error) {
var v CreateAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeApplyAnswer reads a ApplyAnswer 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 DecodeApplyAnswer(raw []byte) (ApplyAnswer, int, error) {
var v ApplyAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeRecreateAnswer reads a RecreateAnswer 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 DecodeRecreateAnswer(raw []byte) (RecreateAnswer, int, error) {
var v RecreateAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeDropAnswer reads a DropAnswer 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 DecodeDropAnswer(raw []byte) (DropAnswer, int, error) {
var v DropAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeSnapshotGetAnswer reads a SnapshotGetAnswer 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 DecodeSnapshotGetAnswer(raw []byte) (SnapshotGetAnswer, int, error) {
var v SnapshotGetAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeSnapshotRestoreAnswer reads a SnapshotRestoreAnswer 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 DecodeSnapshotRestoreAnswer(raw []byte) (SnapshotRestoreAnswer, int, error) {
var v SnapshotRestoreAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeSnapshotRestoreCancelAnswer reads a SnapshotRestoreCancelAnswer 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 DecodeSnapshotRestoreCancelAnswer(raw []byte) (SnapshotRestoreCancelAnswer, int, error) {
var v SnapshotRestoreCancelAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeSnapshotRemoveAnswer reads a SnapshotRemoveAnswer 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 DecodeSnapshotRemoveAnswer(raw []byte) (SnapshotRemoveAnswer, int, error) {
var v SnapshotRemoveAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeCreatedEvent reads a CreatedEvent 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 DecodeCreatedEvent(raw []byte) (CreatedEvent, int, error) {
var v CreatedEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeRefusedEvent reads a RefusedEvent 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 DecodeRefusedEvent(raw []byte) (RefusedEvent, int, error) {
var v RefusedEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeDriftedEvent reads a DriftedEvent 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 DecodeDriftedEvent(raw []byte) (DriftedEvent, int, error) {
var v DriftedEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeDriftClearedEvent reads a DriftClearedEvent 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 DecodeDriftClearedEvent(raw []byte) (DriftClearedEvent, int, error) {
var v DriftClearedEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeFullEvent reads a FullEvent 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 DecodeFullEvent(raw []byte) (FullEvent, int, error) {
var v FullEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeFullClearedEvent reads a FullClearedEvent 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 DecodeFullClearedEvent(raw []byte) (FullClearedEvent, int, error) {
var v FullClearedEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeOrphanedEvent reads a OrphanedEvent 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 DecodeOrphanedEvent(raw []byte) (OrphanedEvent, int, error) {
var v OrphanedEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeRecreatedEvent reads a RecreatedEvent 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 DecodeRecreatedEvent(raw []byte) (RecreatedEvent, int, error) {
var v RecreatedEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeDroppedEvent reads a DroppedEvent 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 DecodeDroppedEvent(raw []byte) (DroppedEvent, int, error) {
var v DroppedEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeSnapshotRestoredEvent reads a SnapshotRestoredEvent 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 DecodeSnapshotRestoredEvent(raw []byte) (SnapshotRestoredEvent, int, error) {
var v SnapshotRestoredEvent
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
}
+82 -12
View File
@@ -4,15 +4,24 @@
package meshconfig
import (
"bytes"
"encoding/json"
"errors"
"strings"
)
// Seat is the seat's name.
const Seat = "mesh-config"
// 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 = "bb4b161b9473b00406c9f007cac28b4631fb96c4c1b16609f97b269d3e0cdae1"
)
const (
VerbConfig = "config"
VerbRenames = "renames"
@@ -78,18 +87,13 @@ func ParseResolvedByNodeModuleKeyKey(key string) (string, string, string, bool)
return v0, v2, v4, true
}
// DecodeResolvedByNodeModuleKeyValue reads one value of the state resolved under the form "<node>.<module>.<key>", refusing a field ResolvedByNodeModuleKeyValue does not know and any text after the value.
func DecodeResolvedByNodeModuleKeyValue(raw []byte) (ResolvedByNodeModuleKeyValue, error) {
// DecodeResolvedByNodeModuleKeyValue reads one value of the state resolved under the form "<node>.<module>.<key>" as another part wrote it: a field ResolvedByNodeModuleKeyValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodeResolvedByNodeModuleKeyValue(raw []byte) (ResolvedByNodeModuleKeyValue, int, error) {
var v ResolvedByNodeModuleKeyValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// ConfigInput is what config takes.
@@ -137,6 +141,8 @@ type RenamesAnswerRenamesItem struct {
// RenamesAnswer is what renames answers.
type RenamesAnswer struct {
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// every open rename
Renames []RenamesAnswerRenamesItem `json:"renames"`
}
@@ -145,6 +151,8 @@ type RenamesAnswer struct {
type RenamedHolderEvent struct {
// when, RFC 3339
At string `json:"at"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// the old name
From string `json:"from"`
// the module
@@ -157,6 +165,8 @@ type RenamedHolderEvent struct {
type RetiringHolderEvent struct {
// the ask's id
Ask string `json:"ask,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// the value's or secret's name
Key string `json:"key"`
Kind string `json:"kind"`
@@ -176,6 +186,8 @@ const (
type RetiredHolderEvent struct {
// the ask's id
Ask string `json:"ask,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// the module
Module string `json:"module"`
// the name
@@ -186,6 +198,8 @@ type RetiredHolderEvent struct {
// ResolvedByNodeModuleKeyValue is one value of the state resolved under the key <node>.<module>.<key>.
type ResolvedByNodeModuleKeyValue struct {
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
Key string `json:"key"`
Module string `json:"module"`
Node string `json:"node"`
@@ -197,3 +211,59 @@ type ResolvedByNodeModuleKeyValue struct {
Trusted bool `json:"trusted,omitempty"`
Value any `json:"value,omitempty"`
}
// DecodeConfigAnswer reads a ConfigAnswer 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 DecodeConfigAnswer(raw []byte) (ConfigAnswer, int, error) {
var v ConfigAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeRenamesAnswer reads a RenamesAnswer 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 DecodeRenamesAnswer(raw []byte) (RenamesAnswer, int, error) {
var v RenamesAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeRenamedHolderEvent reads a RenamedHolderEvent 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 DecodeRenamedHolderEvent(raw []byte) (RenamedHolderEvent, int, error) {
var v RenamedHolderEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeRetiringHolderEvent reads a RetiringHolderEvent 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 DecodeRetiringHolderEvent(raw []byte) (RetiringHolderEvent, int, error) {
var v RetiringHolderEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeRetiredHolderEvent reads a RetiredHolderEvent 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 DecodeRetiredHolderEvent(raw []byte) (RetiredHolderEvent, int, error) {
var v RetiredHolderEvent
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
}
+178 -90
View File
@@ -4,9 +4,7 @@
package meshmoduleassigner
import (
"bytes"
"encoding/json"
"errors"
"strings"
"time"
)
@@ -14,6 +12,17 @@ import (
// 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 = "f21389d1d8b60132bbc05b35395261c01260b7f09f20428722ecb6f888875640"
)
const (
VerbAssignments = "assignments"
VerbProposals = "proposals"
@@ -83,18 +92,13 @@ func ParseAssignmentsByNodeNodeKey(key string) (string, bool) {
return v0, true
}
// DecodeAssignmentsByNodeNodeValue reads one value of the state assignments under the form "<node>.node", refusing a field AssignmentsByNodeNodeValue does not know and any text after the value.
func DecodeAssignmentsByNodeNodeValue(raw []byte) (AssignmentsByNodeNodeValue, error) {
// 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
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// AssignmentsByNodeModuleKey is the key of one value of the state assignments under the form "<node>.<module>".
@@ -119,18 +123,13 @@ func ParseAssignmentsByNodeModuleKey(key string) (string, string, bool) {
return v0, v2, true
}
// DecodeAssignmentsByNodeModuleValue reads one value of the state assignments under the form "<node>.<module>", refusing a field AssignmentsByNodeModuleValue does not know and any text after the value.
func DecodeAssignmentsByNodeModuleValue(raw []byte) (AssignmentsByNodeModuleValue, error) {
// 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
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// ProposalsByProposalKey is the key of one value of the state proposals under the form "<proposal>".
@@ -150,18 +149,13 @@ func ParseProposalsByProposalKey(key string) (string, bool) {
return v0, true
}
// DecodeProposalsByProposalValue reads one value of the state proposals under the form "<proposal>", refusing a field ProposalsByProposalValue does not know and any text after the value.
func DecodeProposalsByProposalValue(raw []byte) (ProposalsByProposalValue, error) {
// 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
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// CandidatesByProposalNodeKey is the key of one value of the state candidates under the form "<proposal>.<node>".
@@ -186,18 +180,13 @@ func ParseCandidatesByProposalNodeKey(key string) (string, string, bool) {
return v0, v2, true
}
// DecodeCandidatesByProposalNodeValue reads one value of the state candidates under the form "<proposal>.<node>", refusing a field CandidatesByProposalNodeValue does not know and any text after the value.
func DecodeCandidatesByProposalNodeValue(raw []byte) (CandidatesByProposalNodeValue, error) {
// 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
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// PulsesByAnswerProposalNodeKey is the key of one value of the state pulses under the form "answer.<proposal>.<node>".
@@ -228,18 +217,13 @@ func ParsePulsesByAnswerProposalNodeKey(key string) (string, string, bool) {
return v1, v3, true
}
// DecodePulsesByAnswerProposalNodeValue reads one value of the state pulses under the form "answer.<proposal>.<node>", refusing a field PulsesByAnswerProposalNodeValue does not know and any text after the value.
func DecodePulsesByAnswerProposalNodeValue(raw []byte) (PulsesByAnswerProposalNodeValue, error) {
// 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
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// PulsesByAskProposalKey is the key of one value of the state pulses under the form "ask.<proposal>".
@@ -263,18 +247,13 @@ func ParsePulsesByAskProposalKey(key string) (string, bool) {
return v1, true
}
// DecodePulsesByAskProposalValue reads one value of the state pulses under the form "ask.<proposal>", refusing a field PulsesByAskProposalValue does not know and any text after the value.
func DecodePulsesByAskProposalValue(raw []byte) (PulsesByAskProposalValue, error) {
// 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
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// SeatHoldersBySeatKey is the key of one value of the state seat-holders under the form "<seat>".
@@ -294,18 +273,13 @@ func ParseSeatHoldersBySeatKey(key string) (string, bool) {
return v0, true
}
// DecodeSeatHoldersBySeatValue reads one value of the state seat-holders under the form "<seat>", refusing a field SeatHoldersBySeatValue does not know and any text after the value.
func DecodeSeatHoldersBySeatValue(raw []byte) (SeatHoldersBySeatValue, error) {
// 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
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// SeatHoldersBySeatNodeKey is the key of one value of the state seat-holders under the form "<seat>.<node>".
@@ -330,18 +304,13 @@ func ParseSeatHoldersBySeatNodeKey(key string) (string, string, bool) {
return v0, v2, true
}
// DecodeSeatHoldersBySeatNodeValue reads one value of the state seat-holders under the form "<seat>.<node>", refusing a field SeatHoldersBySeatNodeValue does not know and any text after the value.
func DecodeSeatHoldersBySeatNodeValue(raw []byte) (SeatHoldersBySeatNodeValue, error) {
// 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
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
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).
@@ -375,6 +344,8 @@ type AssignmentsEventWarrant struct {
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"`
@@ -470,10 +441,12 @@ type Proposal struct {
By string `json:"by"`
Changes []ProposalChange `json:"changes"`
ExportDigest string `json:"export-digest,omitempty"`
HandBack bool `json:"hand-back,omitempty"`
ID string `json:"id"`
Must []string `json:"must,omitempty"`
Seed bool `json:"seed,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"`
@@ -539,6 +512,8 @@ type SeatHoldersHoldersItem struct {
// 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
@@ -649,6 +624,8 @@ type PlacementInput struct {
// 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"`
}
@@ -675,7 +652,9 @@ type AssignmentsByNodeNodeValueModulesItem struct {
// AssignmentsByNodeNodeValue is one value of the state assignments under the key <node>.node.
type AssignmentsByNodeNodeValue struct {
Decided NodeDecided `json:"decided"`
Holds []Holding `json:"holds,omitempty"`
// 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"`
@@ -685,6 +664,8 @@ type AssignmentsByNodeNodeValue struct {
// 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
@@ -701,7 +682,9 @@ type CandidatesByProposalNodeValue struct {
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"`
Proposal string `json:"proposal"`
// 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"`
@@ -709,12 +692,16 @@ type CandidatesByProposalNodeValue struct {
// PulsesByAnswerProposalNodeValue is one value of the state pulses under the key answer.<proposal>.<node>.
type PulsesByAnswerProposalNodeValue struct {
V int64 `json:"v,omitempty"`
// 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 {
V int64 `json:"v,omitempty"`
// 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>.
@@ -722,3 +709,104 @@ 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
}
+219 -4
View File
@@ -3,11 +3,25 @@
// Package meshrecovery is the contract of the seat "mesh-recovery", defined whole (seats/mesh-recovery/seat.json): Takes, sets aside and restores a module's kept data on the live bus, each act in the hand-act log (design 47 G 554). Its verbs answer at once and the result is the event.
package meshrecovery
import "time"
import (
"encoding/json"
"time"
)
// Seat is the seat's name.
const Seat = "mesh-recovery"
// 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 = "855ed5958d0dac251a91148faf0c58ad9dbfa3e86d86aef6c847b8c5de001e81"
)
const (
VerbSnapshotKept = "snapshot-kept"
VerbRestoreKept = "restore-kept"
@@ -205,6 +219,8 @@ type SnapshotKeptAnswer struct {
Busy string `json:"busy,omitempty"`
// why it was not taken; set alone
Error string `json:"error,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
}
// RestoreKeptInput is what restore-kept takes.
@@ -233,6 +249,8 @@ type RestoreKeptAnswer struct {
Busy string `json:"busy,omitempty"`
// why it was not taken; set alone
Error string `json:"error,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
}
// KeptPointsInput is what kept-points takes.
@@ -245,7 +263,9 @@ type KeptPointsInput struct {
// KeptPointsAnswer is what kept-points answers.
type KeptPointsAnswer struct {
Asides []Aside `json:"asides"`
Asides []Aside `json:"asides"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
Points []Point `json:"points"`
Running *Running `json:"running,omitempty"`
// the asides whose record ended at removed that no running act holds: the live data of those names is gone and only the aside holds it; the module's health check fails while one is listed (design 47 G 554, 657, A-129)
@@ -274,6 +294,8 @@ type RestoreAsideAnswer struct {
Busy string `json:"busy,omitempty"`
// why it was not taken; set alone
Error string `json:"error,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
}
// CancelInput is what cancel takes.
@@ -294,6 +316,8 @@ type CancelAnswer struct {
Busy string `json:"busy,omitempty"`
// why not, naming the step an act has begun; set alone
Error string `json:"error,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
}
// TakeInput is what take takes.
@@ -318,6 +342,8 @@ type TakeAnswer struct {
Busy string `json:"busy,omitempty"`
// why it was not taken; set alone
Error string `json:"error,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
}
// RestoreInput is what restore takes.
@@ -346,6 +372,8 @@ type RestoreAnswer struct {
Busy string `json:"busy,omitempty"`
// why it was not taken; set alone
Error string `json:"error,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
}
// RetryInput is what retry takes.
@@ -368,6 +396,8 @@ type RetryAnswer struct {
Busy string `json:"busy,omitempty"`
// why it was not taken; set alone
Error string `json:"error,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
}
// AsideInput is what aside takes.
@@ -390,6 +420,8 @@ type AsideAnswer struct {
Busy string `json:"busy,omitempty"`
// why it was not taken; set alone
Error string `json:"error,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
}
// DiscardAsideInput is what discard-aside takes.
@@ -414,6 +446,8 @@ type DiscardAsideAnswer struct {
Busy string `json:"busy,omitempty"`
// why it was not taken; set alone
Error string `json:"error,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
}
// ExpirePointsInput is what expire-points takes.
@@ -432,6 +466,8 @@ type ExpirePointsAnswer struct {
Busy string `json:"busy,omitempty"`
// why it was not taken; set alone
Error string `json:"error,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
}
// EndedEvent is the body of the event ended.
@@ -509,7 +545,9 @@ type SetAsideEvent struct {
Act string `json:"act"`
// when it was said, RFC 3339
At time.Time `json:"at"`
ID string `json:"id"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
ID string `json:"id"`
// the bus names it was live under, one per bus object
Names []string `json:"names"`
Size int64 `json:"size"`
@@ -521,7 +559,9 @@ type AsideDiscardedEvent struct {
Act string `json:"act"`
// when it was said, RFC 3339
At time.Time `json:"at"`
ID string `json:"id"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
ID string `json:"id"`
// the bus names it was live under, one per bus object
Names []string `json:"names"`
Size int64 `json:"size"`
@@ -546,6 +586,181 @@ type ExpiryEndedEvent struct {
Act string `json:"act"`
// when it was said, RFC 3339
At time.Time `json:"at"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// the number of points the run removed, 0 included
Removed int64 `json:"removed"`
}
// DecodeSnapshotKeptAnswer reads a SnapshotKeptAnswer 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 DecodeSnapshotKeptAnswer(raw []byte) (SnapshotKeptAnswer, int, error) {
var v SnapshotKeptAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeRestoreKeptAnswer reads a RestoreKeptAnswer 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 DecodeRestoreKeptAnswer(raw []byte) (RestoreKeptAnswer, int, error) {
var v RestoreKeptAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeKeptPointsAnswer reads a KeptPointsAnswer 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 DecodeKeptPointsAnswer(raw []byte) (KeptPointsAnswer, int, error) {
var v KeptPointsAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeRestoreAsideAnswer reads a RestoreAsideAnswer 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 DecodeRestoreAsideAnswer(raw []byte) (RestoreAsideAnswer, int, error) {
var v RestoreAsideAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeCancelAnswer reads a CancelAnswer 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 DecodeCancelAnswer(raw []byte) (CancelAnswer, int, error) {
var v CancelAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeTakeAnswer reads a TakeAnswer 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 DecodeTakeAnswer(raw []byte) (TakeAnswer, int, error) {
var v TakeAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeRestoreAnswer reads a RestoreAnswer 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 DecodeRestoreAnswer(raw []byte) (RestoreAnswer, int, error) {
var v RestoreAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeRetryAnswer reads a RetryAnswer 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 DecodeRetryAnswer(raw []byte) (RetryAnswer, int, error) {
var v RetryAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeAsideAnswer reads a AsideAnswer 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 DecodeAsideAnswer(raw []byte) (AsideAnswer, int, error) {
var v AsideAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeDiscardAsideAnswer reads a DiscardAsideAnswer 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 DecodeDiscardAsideAnswer(raw []byte) (DiscardAsideAnswer, int, error) {
var v DiscardAsideAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeExpirePointsAnswer reads a ExpirePointsAnswer 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 DecodeExpirePointsAnswer(raw []byte) (ExpirePointsAnswer, int, error) {
var v ExpirePointsAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeEndedEvent reads a EndedEvent 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 DecodeEndedEvent(raw []byte) (EndedEvent, int, error) {
var v EndedEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeRestoreStartedEvent reads a RestoreStartedEvent 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 DecodeRestoreStartedEvent(raw []byte) (RestoreStartedEvent, int, error) {
var v RestoreStartedEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeRestoredEvent reads a RestoredEvent 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 DecodeRestoredEvent(raw []byte) (RestoredEvent, int, error) {
var v RestoredEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeSetAsideEvent reads a SetAsideEvent 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 DecodeSetAsideEvent(raw []byte) (SetAsideEvent, int, error) {
var v SetAsideEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeAsideDiscardedEvent reads a AsideDiscardedEvent 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 DecodeAsideDiscardedEvent(raw []byte) (AsideDiscardedEvent, int, error) {
var v AsideDiscardedEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodePointRemovedEvent reads a PointRemovedEvent 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 DecodePointRemovedEvent(raw []byte) (PointRemovedEvent, int, error) {
var v PointRemovedEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeExpiryEndedEvent reads a ExpiryEndedEvent 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 DecodeExpiryEndedEvent(raw []byte) (ExpiryEndedEvent, int, error) {
var v ExpiryEndedEvent
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
}
+409 -120
View File
@@ -4,9 +4,7 @@
package nodeengine
import (
"bytes"
"encoding/json"
"errors"
"strings"
"time"
)
@@ -14,6 +12,17 @@ import (
// Seat is the seat's name.
const Seat = "node-engine"
// 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 = "7aedbf50b5318425acb9a4ff0bcb65ab61b3e9276585934936cd2498a7117107"
)
const (
VerbHandOver = "hand-over"
VerbAccessAct = "access-act"
@@ -149,18 +158,13 @@ func ParseHaveByNodeModuleKey(key string) (string, string, bool) {
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) {
// DecodeHaveByNodeModuleValue reads one value of the state have under the form "<node>.<module>" as another part wrote it: a field HaveByNodeModuleValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodeHaveByNodeModuleValue(raw []byte) (HaveByNodeModuleValue, int, error) {
var v HaveByNodeModuleValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// HaveByNodeNodeKey is the key of one value of the state have under the form "<node>.node".
@@ -180,18 +184,13 @@ func ParseHaveByNodeNodeKey(key string) (string, bool) {
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) {
// DecodeHaveByNodeNodeValue reads one value of the state have under the form "<node>.node" as another part wrote it: a field HaveByNodeNodeValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodeHaveByNodeNodeValue(raw []byte) (HaveByNodeNodeValue, int, error) {
var v HaveByNodeNodeValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// ComposedByNodeModuleFingerprintKey is the key of one value of the state composed under the form "<node>.<module>.<fingerprint>".
@@ -223,18 +222,13 @@ func ParseComposedByNodeModuleFingerprintKey(key string) (string, string, string
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) {
// DecodeComposedByNodeModuleFingerprintValue reads one value of the state composed under the form "<node>.<module>.<fingerprint>" as another part wrote it: a field ComposedByNodeModuleFingerprintValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodeComposedByNodeModuleFingerprintValue(raw []byte) (ComposedByNodeModuleFingerprintValue, int, error) {
var v ComposedByNodeModuleFingerprintValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// ComposedByNodeNodeKey is the key of one value of the state composed under the form "<node>.node".
@@ -254,18 +248,13 @@ func ParseComposedByNodeNodeKey(key string) (string, bool) {
return v0, true
}
// DecodeComposedByNodeNodeValue reads one value of the state composed under the form "<node>.node", refusing a field ComposedByNodeNodeValue does not know and any text after the value.
func DecodeComposedByNodeNodeValue(raw []byte) (ComposedByNodeNodeValue, error) {
// DecodeComposedByNodeNodeValue reads one value of the state composed under the form "<node>.node" as another part wrote it: a field ComposedByNodeNodeValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodeComposedByNodeNodeValue(raw []byte) (ComposedByNodeNodeValue, int, error) {
var v ComposedByNodeNodeValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// DataByNodeModuleKey is the key of one value of the state data under the form "<node>.<module>".
@@ -290,18 +279,13 @@ func ParseDataByNodeModuleKey(key string) (string, string, bool) {
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) {
// DecodeDataByNodeModuleValue reads one value of the state data under the form "<node>.<module>" as another part wrote it: a field DataByNodeModuleValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodeDataByNodeModuleValue(raw []byte) (DataByNodeModuleValue, int, error) {
var v DataByNodeModuleValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// PackagesByNodeKey is the key of one value of the state packages under the form "<node>".
@@ -321,18 +305,13 @@ func ParsePackagesByNodeKey(key string) (string, bool) {
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) {
// DecodePackagesByNodeValue reads one value of the state packages under the form "<node>" as another part wrote it: a field PackagesByNodeValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodePackagesByNodeValue(raw []byte) (PackagesByNodeValue, int, error) {
var v PackagesByNodeValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// HealthByNodeKey is the key of one value of the state health under the form "<node>".
@@ -352,18 +331,13 @@ func ParseHealthByNodeKey(key string) (string, bool) {
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) {
// DecodeHealthByNodeValue reads one value of the state health under the form "<node>" as another part wrote it: a field HealthByNodeValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodeHealthByNodeValue(raw []byte) (HealthByNodeValue, int, error) {
var v HealthByNodeValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// FindingsByKeyKey is the key of one value of the state findings under the form "<key>".
@@ -383,18 +357,13 @@ func ParseFindingsByKeyKey(key string) (string, bool) {
return v0, true
}
// DecodeFindingsByKeyValue reads one value of the state findings under the form "<key>", refusing a field FindingsByKeyValue does not know and any text after the value.
func DecodeFindingsByKeyValue(raw []byte) (FindingsByKeyValue, error) {
// DecodeFindingsByKeyValue reads one value of the state findings under the form "<key>" as another part wrote it: a field FindingsByKeyValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodeFindingsByKeyValue(raw []byte) (FindingsByKeyValue, int, error) {
var v FindingsByKeyValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// BoundsByWhatIDKey is the key of one value of the state bounds under the form "<what>.<id>".
@@ -419,18 +388,13 @@ func ParseBoundsByWhatIDKey(key string) (string, string, bool) {
return v0, v2, true
}
// DecodeBoundsByWhatIDValue reads one value of the state bounds under the form "<what>.<id>", refusing a field BoundsByWhatIDValue does not know and any text after the value.
func DecodeBoundsByWhatIDValue(raw []byte) (BoundsByWhatIDValue, error) {
// DecodeBoundsByWhatIDValue reads one value of the state bounds under the form "<what>.<id>" as another part wrote it: a field BoundsByWhatIDValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodeBoundsByWhatIDValue(raw []byte) (BoundsByWhatIDValue, int, error) {
var v BoundsByWhatIDValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// AccountsHanded is the hashes of the users of the list, sealed to the vault.
@@ -500,6 +464,8 @@ type ActSaid struct {
Ask string `json:"ask,omitempty"`
// the caller as the runtime proved it
Caller string `json:"caller"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// the node whose engine says it
Node string `json:"node"`
// what the engine said of it
@@ -521,6 +487,8 @@ const (
type Acts struct {
// the acts, newest first
Acts []Act `json:"acts"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// the node
Node string `json:"node"`
}
@@ -537,6 +505,8 @@ type Adoption struct {
type Asked struct {
// the ask's id: acts shows where it stands
Asked string `json:"asked"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// the node
Node string `json:"node"`
// what happens next, in words
@@ -618,6 +588,8 @@ type Composed struct {
Digest string `json:"digest"`
// the fingerprint of the want composed
Fingerprint string `json:"fingerprint"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// the module
Module string `json:"module"`
// the node
@@ -740,6 +712,8 @@ const (
type ManifestReadsChanged struct {
// when it says it, RFC 3339
At string `json:"at"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// what its engine states it reads now
ManifestReads []string `json:"manifest-reads,omitempty"`
// the node
@@ -903,6 +877,8 @@ const (
type ProcessBuilds struct {
// why they could not be read
Error string `json:"error,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// the node
Node string `json:"node"`
// every process the node-engine started, by module
@@ -969,6 +945,8 @@ type Running struct {
At time.Time `json:"at"`
// the fingerprint of the build it runs; none with stopped
Fingerprint string `json:"fingerprint,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// the health of the build that runs, as the node-engine's have holds it from the module's declared check (ADR 0240); a running with none, said by a node-engine of before design 47 G, reads as healthy (design 47 G 520). SeatsToPassOn reads none of it: an unhealthy holder still holds its seat
Healthy *bool `json:"healthy,omitempty"`
// the digest of that build's manifest, the indexer's manifest of it, read by digest from the catalog half
@@ -985,6 +963,8 @@ type Running struct {
// Said is the answer of a read-only judgement.
type Said struct {
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// the node
Node string `json:"node"`
// the engine's judgement or search, one line per directory or program
@@ -1017,6 +997,8 @@ type SeatListStatus struct {
type SeatList struct {
// why the read failed, for seat-list-again
Error string `json:"error,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// the one line the engine says of it; empty when nothing waits
Health string `json:"health"`
Status SeatListStatus `json:"status"`
@@ -1077,6 +1059,8 @@ type Wait struct {
Bound string `json:"bound,omitempty"`
// the time the bound counts from (design 47 G 266, 269, 498)
ClockFrom *time.Time `json:"clock-from,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// the node waited on: the build node for a kept build; the subject's <node> is the node that says it
Node string `json:"node,omitempty"`
// what it waits on
@@ -1145,6 +1129,8 @@ type RootFreeInput struct {
// RootFreeAnswer is what root-free answers.
type RootFreeAnswer struct {
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// this machine's verdict
Machines []RootVerdict `json:"machines"`
}
@@ -1192,6 +1178,8 @@ type PackagesAnswerKey struct {
// PackagesAnswer is what packages answers.
type PackagesAnswer struct {
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// the node's key as the bus holds it; absent when the engine wrote none
Key *PackagesAnswerKey `json:"key,omitempty"`
// why the key could not be read
@@ -1333,6 +1321,8 @@ type CompositionAnswer struct {
Composition Revision `json:"composition"`
// every resource that differs from what runs, when asked
Diff []map[string]any `json:"diff,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// what the module's have key says now; absent when it says nothing
Have *CompositionAnswerHave `json:"have,omitempty"`
// the move from what runs to the composition read
@@ -1371,6 +1361,8 @@ type CompositionDiffInput struct {
// CompositionDiffAnswer is what composition-diff answers.
type CompositionDiffAnswer struct {
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// the module
Module string `json:"module"`
// the node
@@ -1406,6 +1398,8 @@ type ComposeAnswerPass struct {
// ComposeAnswer is what compose answers.
type ComposeAnswer struct {
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// how the pass went
Pass ComposeAnswerPass `json:"pass"`
// the module whose apply was tried again
@@ -1428,6 +1422,8 @@ type ComposeCandidateAnswer struct {
Candidate string `json:"candidate"`
// when asked with input and a call token: how many chunks of at most 512 KiB carry the composition input, sent on the chunk subject of the call, each acknowledged by the caller (design 47 G A-237b)
Chunks int64 `json:"chunks,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// when asked without a call token: the composition input it composed from, inline, up to what one answer carries (the checker's form, kept until G removes the checker, G-6 section 321)
Input map[string]any `json:"input,omitempty"`
// every module placed on the node, sorted by name
@@ -1459,6 +1455,8 @@ type ManifestReadsInput struct {
// ManifestReadsAnswer is what manifest-reads answers.
type ManifestReadsAnswer struct {
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// the reader capabilities its engine states: the manifest words, forms and seat names it reads; empty for an engine built before it said them, read as the baseline
ManifestReads []string `json:"manifest-reads,omitempty"`
// the node
@@ -1491,6 +1489,8 @@ type ApplyOrderAnswerOrderItem struct {
// ApplyOrderAnswer is what apply-order answers.
type ApplyOrderAnswer 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 row per unapplied changed want, in the order it will be applied
Order []ApplyOrderAnswerOrderItem `json:"order"`
}
@@ -1546,6 +1546,8 @@ type FirstViewsAnswer struct {
Entries []FirstViewsAnswerEntriesItem `json:"entries"`
// one status per owner and state followed, as mesh-sdk's views runtime keeps it
FirstViews []map[string]any `json:"first-views"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// the wants the node-engine keeps (design 47 G 683, 698)
Wants []FirstViewsAnswerWantsItem `json:"wants"`
}
@@ -1580,6 +1582,8 @@ type FirstViewAgainAnswerAsked struct {
type FirstViewAgainAnswer struct {
// the hand ask written
Asked FirstViewAgainAnswerAsked `json:"asked"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// the verb that reads the status, first-views
Read string `json:"read"`
}
@@ -1610,6 +1614,8 @@ type EntryAgainAnswerAsked struct {
type EntryAgainAnswer struct {
// the hand ask written
Asked EntryAgainAnswerAsked `json:"asked"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// the verb that reads the status, first-views
Read string `json:"read"`
}
@@ -1629,6 +1635,8 @@ type ConvergedInput struct {
// ConvergedAnswer is what converged answers.
type ConvergedAnswer struct {
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// the kind of the firewall found, for an adopted node
Found string `json:"found,omitempty"`
// the links of this node that face outside, as the engine classifies them for its filter render (ADR 0140); an allowance with no interface never opens one
@@ -1679,6 +1687,8 @@ type HaveByNodeModuleValue struct {
// the digest of the composition the node runs
Composed string `json:"composed,omitempty"`
Detail string `json:"detail,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// the fingerprint held
Fp string `json:"fp,omitempty"`
Handed *AccountsHanded `json:"handed,omitempty"`
@@ -1737,16 +1747,18 @@ type HaveByNodeNodeValue struct {
// the digest of the node's own composition it runs
Composed string `json:"composed,omitempty"`
// own, or none (empty)
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"`
Record *NodeRecord `json:"record,omitempty"`
Sealed []string `json:"sealed,omitempty"`
SealedAt map[string]string `json:"sealed-at,omitempty"`
Strays []map[string]any `json:"strays,omitempty"`
V int64 `json:"v"`
Windows []map[string]any `json:"windows,omitempty"`
Composes string `json:"composes,omitempty"`
ComposesWhy string `json:"composes-why,omitempty"`
Filters []map[string]any `json:"filters,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
Profile map[string]any `json:"profile,omitempty"`
Record *NodeRecord `json:"record,omitempty"`
Sealed []string `json:"sealed,omitempty"`
SealedAt map[string]string `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>.
@@ -1755,9 +1767,11 @@ type ComposedByNodeModuleFingerprintValue struct {
Data bool `json:"data,omitempty"`
// the files the provisioner fills
FilledFiles []string `json:"filled_files,omitempty"`
Fp string `json:"fp"`
Module string `json:"module"`
Node string `json:"node"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
Fp string `json:"fp"`
Module string `json:"module"`
Node string `json:"node"`
// the module's whole provisioning plan, catalogue.Plan, kept whole: it is the manifest layer's type
Plan map[string]any `json:"plan,omitempty"`
// why the module cannot be composed at this fingerprint
@@ -1775,8 +1789,10 @@ type ComposedByNodeNodeValue struct {
Data bool `json:"data,omitempty"`
// the files the provisioner fills
FilledFiles []string `json:"filled_files,omitempty"`
Node string `json:"node"`
Own *NodeOwn `json:"own,omitempty"`
// 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"`
Own *NodeOwn `json:"own,omitempty"`
// the declaration resources, each saying its module
Resources []map[string]any `json:"resources"`
V int64 `json:"v"`
@@ -1784,7 +1800,9 @@ type ComposedByNodeNodeValue struct {
// DataByNodeModuleValue is one value of the state data under the key <node>.<module>.
type DataByNodeModuleValue struct {
Digest string `json:"digest"`
Digest string `json:"digest"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
Items []PlacedDataItem `json:"items"`
Module string `json:"module"`
Node string `json:"node"`
@@ -1800,6 +1818,8 @@ type PackagesByNodeValuePackagesItem struct {
// PackagesByNodeValue is one value of the state packages under the key <node>.
type PackagesByNodeValue 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"`
Packages []PackagesByNodeValuePackagesItem `json:"packages"`
}
@@ -1807,17 +1827,19 @@ type PackagesByNodeValue struct {
// HealthByNodeValue is one value of the state health under the key <node>.
type HealthByNodeValue struct {
// when
At time.Time `json:"at"`
Contract int64 `json:"contract,omitempty"`
Fallback *LoginFallback `json:"fallback,omitempty"`
Found []NodeDirectory `json:"found,omitempty"`
Network *NetworkHealth `json:"network,omitempty"`
Node string `json:"node"`
Peers []PeerSeen `json:"peers,omitempty"`
Relogin []NodeAccount `json:"relogin,omitempty"`
Root []RootAccountVerdict `json:"root,omitempty"`
Units *UnitsHealth `json:"units,omitempty"`
V int64 `json:"v"`
At time.Time `json:"at"`
Contract int64 `json:"contract,omitempty"`
Fallback *LoginFallback `json:"fallback,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
Found []NodeDirectory `json:"found,omitempty"`
Network *NetworkHealth `json:"network,omitempty"`
Node string `json:"node"`
Peers []PeerSeen `json:"peers,omitempty"`
Relogin []NodeAccount `json:"relogin,omitempty"`
Root []RootAccountVerdict `json:"root,omitempty"`
Units *UnitsHealth `json:"units,omitempty"`
V int64 `json:"v"`
}
// FindingsByKeyValue is one value of the state findings under the key <key>.
@@ -1827,7 +1849,9 @@ type FindingsByKeyValue struct {
// newest first, at most 10
Evidence []FindingEvidence `json:"evidence,omitempty"`
Explanation string `json:"explanation,omitempty"`
Headline string `json:"headline,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
Headline string `json:"headline,omitempty"`
// scope.id.token
Key string `json:"key"`
Kind string `json:"kind"`
@@ -1859,9 +1883,274 @@ const (
// BoundsByWhatIDValue is one value of the state bounds under the key <what>.<id>.
type BoundsByWhatIDValue struct {
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
Module string `json:"module,omitempty"`
// when the wait began, RFC 3339
Since string `json:"since"`
// layout version, 1
V int64 `json:"v"`
}
// DecodeHandOverAnswer reads a HandOverAnswer 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 DecodeHandOverAnswer(raw []byte) (HandOverAnswer, int, error) {
var v HandOverAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeAccessActAnswer reads a AccessActAnswer 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 DecodeAccessActAnswer(raw []byte) (AccessActAnswer, int, error) {
var v AccessActAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeJudgeDirectoriesAnswer reads a JudgeDirectoriesAnswer 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 DecodeJudgeDirectoriesAnswer(raw []byte) (JudgeDirectoriesAnswer, int, error) {
var v JudgeDirectoriesAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeSetuidSearchAnswer reads a SetuidSearchAnswer 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 DecodeSetuidSearchAnswer(raw []byte) (SetuidSearchAnswer, int, error) {
var v SetuidSearchAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeRootFreeAnswer reads a RootFreeAnswer 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 DecodeRootFreeAnswer(raw []byte) (RootFreeAnswer, int, error) {
var v RootFreeAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeActsAnswer reads a ActsAnswer 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 DecodeActsAnswer(raw []byte) (ActsAnswer, int, error) {
var v ActsAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodePackagesAnswer reads a PackagesAnswer 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 DecodePackagesAnswer(raw []byte) (PackagesAnswer, int, error) {
var v PackagesAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeCompositionAnswer reads a CompositionAnswer 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 DecodeCompositionAnswer(raw []byte) (CompositionAnswer, int, error) {
var v CompositionAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeCompositionDiffAnswer reads a CompositionDiffAnswer 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 DecodeCompositionDiffAnswer(raw []byte) (CompositionDiffAnswer, int, error) {
var v CompositionDiffAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeComposeAnswer reads a ComposeAnswer 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 DecodeComposeAnswer(raw []byte) (ComposeAnswer, int, error) {
var v ComposeAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeComposeCandidateAnswer reads a ComposeCandidateAnswer 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 DecodeComposeCandidateAnswer(raw []byte) (ComposeCandidateAnswer, int, error) {
var v ComposeCandidateAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeManifestReadsAnswer reads a ManifestReadsAnswer 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 DecodeManifestReadsAnswer(raw []byte) (ManifestReadsAnswer, int, error) {
var v ManifestReadsAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeApplyOrderAnswer reads a ApplyOrderAnswer 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 DecodeApplyOrderAnswer(raw []byte) (ApplyOrderAnswer, int, error) {
var v ApplyOrderAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeSeatListAnswer reads a SeatListAnswer 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 DecodeSeatListAnswer(raw []byte) (SeatListAnswer, int, error) {
var v SeatListAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeSeatListAgainAnswer reads a SeatListAgainAnswer 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 DecodeSeatListAgainAnswer(raw []byte) (SeatListAgainAnswer, int, error) {
var v SeatListAgainAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeFirstViewsAnswer reads a FirstViewsAnswer 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 DecodeFirstViewsAnswer(raw []byte) (FirstViewsAnswer, int, error) {
var v FirstViewsAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeFirstViewAgainAnswer reads a FirstViewAgainAnswer 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 DecodeFirstViewAgainAnswer(raw []byte) (FirstViewAgainAnswer, int, error) {
var v FirstViewAgainAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeEntryAgainAnswer reads a EntryAgainAnswer 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 DecodeEntryAgainAnswer(raw []byte) (EntryAgainAnswer, int, error) {
var v EntryAgainAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeProcessBuildsAnswer reads a ProcessBuildsAnswer 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 DecodeProcessBuildsAnswer(raw []byte) (ProcessBuildsAnswer, int, error) {
var v ProcessBuildsAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeConvergedAnswer reads a ConvergedAnswer 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 DecodeConvergedAnswer(raw []byte) (ConvergedAnswer, int, error) {
var v ConvergedAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeAskedEvent reads a AskedEvent 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 DecodeAskedEvent(raw []byte) (AskedEvent, int, error) {
var v AskedEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeDoneEvent reads a DoneEvent 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 DecodeDoneEvent(raw []byte) (DoneEvent, int, error) {
var v DoneEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeRefusedEvent reads a RefusedEvent 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 DecodeRefusedEvent(raw []byte) (RefusedEvent, int, error) {
var v RefusedEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeManifestReadsChangedEvent reads a ManifestReadsChangedEvent 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 DecodeManifestReadsChangedEvent(raw []byte) (ManifestReadsChangedEvent, int, error) {
var v ManifestReadsChangedEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeComposedEvent reads a ComposedEvent 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 DecodeComposedEvent(raw []byte) (ComposedEvent, int, error) {
var v ComposedEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeRunningEvent reads a RunningEvent 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 DecodeRunningEvent(raw []byte) (RunningEvent, int, error) {
var v RunningEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeWaitHeldEvent reads a WaitHeldEvent 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 DecodeWaitHeldEvent(raw []byte) (WaitHeldEvent, int, error) {
var v WaitHeldEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeWaitEndedEvent reads a WaitEndedEvent 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 DecodeWaitEndedEvent(raw []byte) (WaitEndedEvent, int, error) {
var v WaitEndedEvent
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
}
@@ -25,7 +25,7 @@ func TestBindWritesTheFindingUntilTheConsumerBinds(t *testing.T) {
t.Fatal("a failed bind was not answered")
}
// Design 47 G 689: the value is the seat's generated finding, read by its strict decoder, key and subject by the rule.
if f, err := seat.DecodeFindingsByScopeIDKindValue(puts[key]); err != nil || f.Observer != "mesh-x" || f.Kind != Kind ||
if f, _, err := seat.DecodeFindingsByScopeIDKindValue(puts[key]); err != nil || f.Observer != "mesh-x" || f.Kind != Kind ||
f.Scope != "module" || f.ID != "mesh-x.placement" || f.Subject.ID != f.ID || f.Severity != "warning" || f.Source == "" {
t.Errorf("the finding is not the seat's generated one: %+v (%v)", f, err)
}
@@ -4,9 +4,7 @@
package meshconditions
import (
"bytes"
"encoding/json"
"errors"
"strings"
"time"
)
@@ -14,6 +12,17 @@ import (
// Seat is the seat's name.
const Seat = "mesh-conditions"
// 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 = "836d2140ddb9934850b5ada7636fc2021b1071822179e9e1090c5d170e94db3a"
)
const (
VerbConditions = "conditions"
VerbSilence = "silence"
@@ -81,18 +90,13 @@ func ParseConditionsByKeyKey(key string) (string, bool) {
return v0, true
}
// DecodeConditionsByKeyValue reads one value of the state conditions under the form "<key>", refusing a field ConditionsByKeyValue does not know and any text after the value.
func DecodeConditionsByKeyValue(raw []byte) (ConditionsByKeyValue, error) {
// DecodeConditionsByKeyValue reads one value of the state conditions under the form "<key>" as another part wrote it: a field ConditionsByKeyValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodeConditionsByKeyValue(raw []byte) (ConditionsByKeyValue, int, error) {
var v ConditionsByKeyValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// FindingsByScopeIDKindKey is the key of one value of the state findings under the form "<scope>.<id>.<kind>".
@@ -122,18 +126,13 @@ func ParseFindingsByScopeIDKindKey(key string) (string, string, string, bool) {
return v0, v2, v4, true
}
// DecodeFindingsByScopeIDKindValue reads one value of the state findings under the form "<scope>.<id>.<kind>", refusing a field FindingsByScopeIDKindValue does not know and any text after the value.
func DecodeFindingsByScopeIDKindValue(raw []byte) (FindingsByScopeIDKindValue, error) {
// DecodeFindingsByScopeIDKindValue reads one value of the state findings under the form "<scope>.<id>.<kind>" as another part wrote it: a field FindingsByScopeIDKindValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodeFindingsByScopeIDKindValue(raw []byte) (FindingsByScopeIDKindValue, int, error) {
var v FindingsByScopeIDKindValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// FindingsViewsByObserverNodeKey is the key of one value of the state findings-views under the form "<observer>.<node>".
@@ -158,18 +157,13 @@ func ParseFindingsViewsByObserverNodeKey(key string) (string, string, bool) {
return v0, v2, true
}
// DecodeFindingsViewsByObserverNodeValue reads one value of the state findings-views under the form "<observer>.<node>", refusing a field FindingsViewsByObserverNodeValue does not know and any text after the value.
func DecodeFindingsViewsByObserverNodeValue(raw []byte) (FindingsViewsByObserverNodeValue, error) {
// DecodeFindingsViewsByObserverNodeValue reads one value of the state findings-views under the form "<observer>.<node>" as another part wrote it: a field FindingsViewsByObserverNodeValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodeFindingsViewsByObserverNodeValue(raw []byte) (FindingsViewsByObserverNodeValue, int, error) {
var v FindingsViewsByObserverNodeValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// Action is one answer the operator may give from a notification.
@@ -220,11 +214,13 @@ type ConditionEvent struct {
Epoch int64 `json:"epoch,omitempty"`
Event string `json:"event"`
// newest first, at most 10
Evidence []Evidence `json:"evidence,omitempty"`
Explanation string `json:"explanation,omitempty"`
First *time.Time `json:"first,omitempty"`
Gaps []ConditionEventGapsItem `json:"gaps,omitempty"`
Headline string `json:"headline,omitempty"`
Evidence []Evidence `json:"evidence,omitempty"`
Explanation string `json:"explanation,omitempty"`
First *time.Time `json:"first,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
Gaps []ConditionEventGapsItem `json:"gaps,omitempty"`
Headline string `json:"headline,omitempty"`
// scope.id.token
Key string `json:"key"`
Kind string `json:"kind,omitempty"`
@@ -298,7 +294,9 @@ type Finding struct {
// newest first, at most 10
Evidence []Evidence `json:"evidence,omitempty"`
Explanation string `json:"explanation,omitempty"`
Headline string `json:"headline,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
Headline string `json:"headline,omitempty"`
// the key's second part
ID string `json:"id"`
Kind string `json:"kind"`
@@ -430,6 +428,8 @@ type FindingsAskedEvent struct {
At time.Time `json:"at"`
// who asked: the keeper, or the person or session that called resync
By string `json:"by"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// to ask one observer; none asks all
Module string `json:"module,omitempty"`
}
@@ -462,11 +462,13 @@ type ConditionsByKeyValue struct {
Count int64 `json:"count,omitempty"`
Epoch int64 `json:"epoch,omitempty"`
// newest first, at most 10
Evidence []Evidence `json:"evidence,omitempty"`
Explanation string `json:"explanation,omitempty"`
First *time.Time `json:"first,omitempty"`
Gaps []ConditionsByKeyValueGapsItem `json:"gaps,omitempty"`
Headline string `json:"headline,omitempty"`
Evidence []Evidence `json:"evidence,omitempty"`
Explanation string `json:"explanation,omitempty"`
First *time.Time `json:"first,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
Gaps []ConditionsByKeyValueGapsItem `json:"gaps,omitempty"`
Headline string `json:"headline,omitempty"`
// scope.id.token
Key string `json:"key"`
Kind string `json:"kind"`
@@ -510,12 +512,88 @@ type FindingsViewsByObserverNodeValueStated struct {
// FindingsViewsByObserverNodeValue is one value of the state findings-views under the key <observer>.<node>.
type FindingsViewsByObserverNodeValue struct {
// the open asks
Asks []string `json:"asks,omitempty"`
Node string `json:"node"`
Observer string `json:"observer"`
Asks []string `json:"asks,omitempty"`
// 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"`
Observer string `json:"observer"`
// the keys it cannot judge yet
Pending []string `json:"pending,omitempty"`
// the last findings-stated set
Stated *FindingsViewsByObserverNodeValueStated `json:"stated,omitempty"`
V int64 `json:"v"`
}
// DecodeConditionsAnswer reads a ConditionsAnswer 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 DecodeConditionsAnswer(raw []byte) (ConditionsAnswer, int, error) {
var v ConditionsAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeSilenceAnswer reads a SilenceAnswer 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 DecodeSilenceAnswer(raw []byte) (SilenceAnswer, int, error) {
var v SilenceAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeResyncAnswer reads a ResyncAnswer 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 DecodeResyncAnswer(raw []byte) (ResyncAnswer, int, error) {
var v ResyncAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeConditionRaisedEvent reads a ConditionRaisedEvent 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 DecodeConditionRaisedEvent(raw []byte) (ConditionRaisedEvent, int, error) {
var v ConditionRaisedEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeConditionChangedEvent reads a ConditionChangedEvent 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 DecodeConditionChangedEvent(raw []byte) (ConditionChangedEvent, int, error) {
var v ConditionChangedEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeConditionClearedEvent reads a ConditionClearedEvent 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 DecodeConditionClearedEvent(raw []byte) (ConditionClearedEvent, int, error) {
var v ConditionClearedEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeFindingsAskedEvent reads a FindingsAskedEvent 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 DecodeFindingsAskedEvent(raw []byte) (FindingsAskedEvent, int, error) {
var v FindingsAskedEvent
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
}
@@ -4,9 +4,7 @@
package meshhandacts
import (
"bytes"
"encoding/json"
"errors"
"strings"
"time"
)
@@ -14,6 +12,17 @@ import (
// Seat is the seat's name.
const Seat = "mesh-hand-acts"
// 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 = "12775f35116965a7ab99b6b2617020889cab452598c2f51883247d05cf99a9ea"
)
const (
VerbHandAct = "hand-act"
VerbHandActs = "hand-acts"
@@ -65,18 +74,13 @@ func ParseActsByIDKey(key string) (string, bool) {
return v0, true
}
// DecodeActsByIDValue reads one value of the state acts under the form "<id>", refusing a field ActsByIDValue does not know and any text after the value.
func DecodeActsByIDValue(raw []byte) (ActsByIDValue, error) {
// DecodeActsByIDValue reads one value of the state acts under the form "<id>" as another part wrote it: a field ActsByIDValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodeActsByIDValue(raw []byte) (ActsByIDValue, int, error) {
var v ActsByIDValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// WarrantsByAskerAskKey is the key of one value of the state warrants under the form "<asker>.<ask>".
@@ -101,18 +105,13 @@ func ParseWarrantsByAskerAskKey(key string) (string, string, bool) {
return v0, v2, true
}
// DecodeWarrantsByAskerAskValue reads one value of the state warrants under the form "<asker>.<ask>", refusing a field WarrantsByAskerAskValue does not know and any text after the value.
func DecodeWarrantsByAskerAskValue(raw []byte) (WarrantsByAskerAskValue, error) {
// DecodeWarrantsByAskerAskValue reads one value of the state warrants under the form "<asker>.<ask>" as another part wrote it: a field WarrantsByAskerAskValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodeWarrantsByAskerAskValue(raw []byte) (WarrantsByAskerAskValue, int, error) {
var v WarrantsByAskerAskValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// Act is one act done by hand.
@@ -125,7 +124,9 @@ type Act struct {
Carried []string `json:"carried,omitempty"`
Cause string `json:"cause"`
Condition string `json:"condition,omitempty"`
ID string `json:"id"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
ID string `json:"id"`
// what the act was read to be from what it did
Kind string `json:"kind,omitempty"`
// which log holds it, set when it is read
@@ -200,7 +201,9 @@ type ActsByIDValue struct {
Carried []string `json:"carried,omitempty"`
Cause string `json:"cause"`
Condition string `json:"condition,omitempty"`
ID string `json:"id"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
ID string `json:"id"`
// what the act was read to be from what it did
Kind string `json:"kind,omitempty"`
// which log holds it, set when it is read
@@ -215,9 +218,58 @@ type ActsByIDValue struct {
// WarrantsByAskerAskValue is one value of the state warrants under the key <asker>.<ask>.
type WarrantsByAskerAskValue struct {
Ask string `json:"ask"`
Asker string `json:"asker"`
At *time.Time `json:"at,omitempty"`
By string `json:"by,omitempty"`
Option string `json:"option,omitempty"`
Ask string `json:"ask"`
Asker string `json:"asker"`
At *time.Time `json:"at,omitempty"`
By string `json:"by,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
Option string `json:"option,omitempty"`
}
// DecodeHandActAnswer reads a HandActAnswer 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 DecodeHandActAnswer(raw []byte) (HandActAnswer, int, error) {
var v HandActAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeHandActsAnswer reads a HandActsAnswer 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 DecodeHandActsAnswer(raw []byte) (HandActsAnswer, int, error) {
var v HandActsAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeWarrantedAnswer reads a WarrantedAnswer 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 DecodeWarrantedAnswer(raw []byte) (WarrantedAnswer, int, error) {
var v WarrantedAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeActRecordedEvent reads a ActRecordedEvent 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 DecodeActRecordedEvent(raw []byte) (ActRecordedEvent, int, error) {
var v ActRecordedEvent
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
}
@@ -4,15 +4,24 @@
package meshhealers
import (
"bytes"
"encoding/json"
"errors"
"time"
)
// Seat is the seat's name.
const Seat = "mesh-healers"
// 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 = "4970dc97cfa905889a3c496c5bcb539306ce1900fa4ac19d6010954051f7901a"
)
const (
VerbHealers = "healers"
VerbHeal = "heal"
@@ -76,18 +85,13 @@ func ParseAttemptsByAttemptKey(key string) (string, bool) {
return v0, true
}
// DecodeAttemptsByAttemptValue reads one value of the state attempts under the form "<attempt>", refusing a field AttemptsByAttemptValue does not know and any text after the value.
func DecodeAttemptsByAttemptValue(raw []byte) (AttemptsByAttemptValue, error) {
// DecodeAttemptsByAttemptValue reads one value of the state attempts under the form "<attempt>" as another part wrote it: a field AttemptsByAttemptValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodeAttemptsByAttemptValue(raw []byte) (AttemptsByAttemptValue, int, error) {
var v AttemptsByAttemptValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// WouldByWouldKey is the key of one value of the state would under the form "<would>".
@@ -107,18 +111,13 @@ func ParseWouldByWouldKey(key string) (string, bool) {
return v0, true
}
// DecodeWouldByWouldValue reads one value of the state would under the form "<would>", refusing a field WouldByWouldValue does not know and any text after the value.
func DecodeWouldByWouldValue(raw []byte) (WouldByWouldValue, error) {
// DecodeWouldByWouldValue reads one value of the state would under the form "<would>" as another part wrote it: a field WouldByWouldValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodeWouldByWouldValue(raw []byte) (WouldByWouldValue, int, error) {
var v WouldByWouldValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// HealersInput is what healers takes.
@@ -162,11 +161,13 @@ type HealerActedEvent struct {
By string `json:"by,omitempty"`
Condition string `json:"condition"`
Event string `json:"event"`
Healer string `json:"healer"`
Kind string `json:"kind,omitempty"`
Outcome string `json:"outcome"`
Said string `json:"said,omitempty"`
Show string `json:"show,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
Healer string `json:"healer"`
Kind string `json:"kind,omitempty"`
Outcome string `json:"outcome"`
Said string `json:"said,omitempty"`
Show string `json:"show,omitempty"`
}
// The values of HealerActedEvent's outcome.
@@ -185,9 +186,11 @@ type AttemptChangedEvent struct {
BudgetKey string `json:"budget-key,omitempty"`
Condition string `json:"condition,omitempty"`
Finished *time.Time `json:"finished,omitempty"`
Healer string `json:"healer,omitempty"`
Kind string `json:"kind,omitempty"`
Outcome string `json:"outcome,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
Healer string `json:"healer,omitempty"`
Kind string `json:"kind,omitempty"`
Outcome string `json:"outcome,omitempty"`
// true when the healer ends the attempt
Removed bool `json:"removed,omitempty"`
Said string `json:"said,omitempty"`
@@ -211,10 +214,12 @@ type AttemptsByAttemptValue struct {
BudgetKey string `json:"budget-key"`
Condition string `json:"condition"`
Finished *time.Time `json:"finished,omitempty"`
Healer string `json:"healer"`
Kind string `json:"kind"`
Outcome string `json:"outcome"`
Said string `json:"said,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
Healer string `json:"healer"`
Kind string `json:"kind"`
Outcome string `json:"outcome"`
Said string `json:"said,omitempty"`
}
// The values of AttemptsByAttemptValue's outcome.
@@ -230,7 +235,65 @@ type WouldByWouldValue struct {
Act string `json:"act"`
At time.Time `json:"at"`
Condition string `json:"condition"`
Healer string `json:"healer"`
Kind string `json:"kind,omitempty"`
Why string `json:"why,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
Healer string `json:"healer"`
Kind string `json:"kind,omitempty"`
Why string `json:"why,omitempty"`
}
// DecodeHealersAnswer reads a HealersAnswer 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 DecodeHealersAnswer(raw []byte) (HealersAnswer, int, error) {
var v HealersAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeHealAnswer reads a HealAnswer 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 DecodeHealAnswer(raw []byte) (HealAnswer, int, error) {
var v HealAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeDrillAnswer reads a DrillAnswer 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 DecodeDrillAnswer(raw []byte) (DrillAnswer, int, error) {
var v DrillAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeHealerActedEvent reads a HealerActedEvent 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 DecodeHealerActedEvent(raw []byte) (HealerActedEvent, int, error) {
var v HealerActedEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeAttemptChangedEvent reads a AttemptChangedEvent 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 DecodeAttemptChangedEvent(raw []byte) (AttemptChangedEvent, int, error) {
var v AttemptChangedEvent
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
}
@@ -3,11 +3,25 @@
// Package meshselfcheck is the contract of the seat "mesh-self-check", defined whole (seats/mesh-self-check/seat.json): The mesh checking itself (ADR 0564): probes run every five minutes, each failure a finding the seat's conditions raise.
package meshselfcheck
import "time"
import (
"encoding/json"
"time"
)
// Seat is the seat's name.
const Seat = "mesh-self-check"
// 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 = "5f1c3026e243ab14d7005851c952f42cfb40cfa79e22cea8f3c2f94a59e65f7f"
)
const (
VerbDoctor = "doctor"
VerbProbes = "probes"
@@ -90,14 +104,54 @@ type CheckedEventCounts struct {
// CheckedEvent is the body of the event checked.
type CheckedEvent struct {
At time.Time `json:"at"`
Controller string `json:"controller,omitempty"`
Counts *CheckedEventCounts `json:"counts,omitempty"`
IntervalSeconds int64 `json:"interval-seconds,omitempty"`
Probes []ProbeVerdict `json:"probes"`
Run string `json:"run"`
Started *time.Time `json:"started,omitempty"`
Took string `json:"took,omitempty"`
Unsaid int64 `json:"unsaid,omitempty"`
Why string `json:"why,omitempty"`
At time.Time `json:"at"`
Controller string `json:"controller,omitempty"`
Counts *CheckedEventCounts `json:"counts,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
IntervalSeconds int64 `json:"interval-seconds,omitempty"`
Probes []ProbeVerdict `json:"probes"`
Run string `json:"run"`
Started *time.Time `json:"started,omitempty"`
Took string `json:"took,omitempty"`
Unsaid int64 `json:"unsaid,omitempty"`
Why string `json:"why,omitempty"`
}
// DecodeDoctorAnswer reads a DoctorAnswer 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 DecodeDoctorAnswer(raw []byte) (DoctorAnswer, int, error) {
var v DoctorAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeProbesAnswer reads a ProbesAnswer 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 DecodeProbesAnswer(raw []byte) (ProbesAnswer, int, error) {
var v ProbesAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeCheckedEvent reads a CheckedEvent 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 DecodeCheckedEvent(raw []byte) (CheckedEvent, int, error) {
var v CheckedEvent
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
}
@@ -4,9 +4,7 @@
package meshwatchdogs
import (
"bytes"
"encoding/json"
"errors"
"strings"
"time"
)
@@ -14,6 +12,17 @@ import (
// Seat is the seat's name.
const Seat = "mesh-watchdogs"
// 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 = "aacf27b959d307b4603d4a4909f324b82430c882bfbeff86941dfa0143a53854"
)
const (
VerbSignals = "signals"
VerbStuck = "stuck"
@@ -88,18 +97,13 @@ func ParsePresenceByNodeKey(key string) (string, bool) {
return v0, true
}
// DecodePresenceByNodeValue reads one value of the state presence under the form "<node>", refusing a field PresenceByNodeValue does not know and any text after the value.
func DecodePresenceByNodeValue(raw []byte) (PresenceByNodeValue, error) {
// DecodePresenceByNodeValue reads one value of the state presence under the form "<node>" as another part wrote it: a field PresenceByNodeValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodePresenceByNodeValue(raw []byte) (PresenceByNodeValue, int, error) {
var v PresenceByNodeValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// PresenceByPartPartInstanceKey is the key of one value of the state presence under the form "part.<part>.<instance>".
@@ -130,18 +134,13 @@ func ParsePresenceByPartPartInstanceKey(key string) (string, string, bool) {
return v1, v3, true
}
// DecodePresenceByPartPartInstanceValue reads one value of the state presence under the form "part.<part>.<instance>", refusing a field PresenceByPartPartInstanceValue does not know and any text after the value.
func DecodePresenceByPartPartInstanceValue(raw []byte) (PresenceByPartPartInstanceValue, error) {
// DecodePresenceByPartPartInstanceValue reads one value of the state presence under the form "part.<part>.<instance>" as another part wrote it: a field PresenceByPartPartInstanceValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodePresenceByPartPartInstanceValue(raw []byte) (PresenceByPartPartInstanceValue, int, error) {
var v PresenceByPartPartInstanceValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// PulseByBucketKeyKey is the key of one value of the state pulse under the form "<bucket>.<key>".
@@ -166,18 +165,13 @@ func ParsePulseByBucketKeyKey(key string) (string, string, bool) {
return v0, v2, true
}
// DecodePulseByBucketKeyValue reads one value of the state pulse under the form "<bucket>.<key>", refusing a field PulseByBucketKeyValue does not know and any text after the value.
func DecodePulseByBucketKeyValue(raw []byte) (PulseByBucketKeyValue, error) {
// DecodePulseByBucketKeyValue reads one value of the state pulse under the form "<bucket>.<key>" as another part wrote it: a field PulseByBucketKeyValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodePulseByBucketKeyValue(raw []byte) (PulseByBucketKeyValue, int, error) {
var v PulseByBucketKeyValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// StuckByBucketKeyKey is the key of one value of the state stuck under the form "<bucket>.<key>".
@@ -202,18 +196,13 @@ func ParseStuckByBucketKeyKey(key string) (string, string, bool) {
return v0, v2, true
}
// DecodeStuckByBucketKeyValue reads one value of the state stuck under the form "<bucket>.<key>", refusing a field StuckByBucketKeyValue does not know and any text after the value.
func DecodeStuckByBucketKeyValue(raw []byte) (StuckByBucketKeyValue, error) {
// DecodeStuckByBucketKeyValue reads one value of the state stuck under the form "<bucket>.<key>" as another part wrote it: a field StuckByBucketKeyValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodeStuckByBucketKeyValue(raw []byte) (StuckByBucketKeyValue, int, error) {
var v StuckByBucketKeyValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// SignalsInput is what signals takes.
@@ -252,6 +241,8 @@ type PresenceAnswerKeysItem struct {
// PresenceAnswer is what presence answers.
type PresenceAnswer struct {
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// without machine: how many keys the state holds
Holds int64 `json:"holds,omitempty"`
// without machine: each key of the state presence, <node> or part.<part>.<instance>, with its value
@@ -297,6 +288,8 @@ type ResyncAnswer = map[string]any
// MachineAwayEvent is the body of the event machine-away.
type MachineAwayEvent struct {
At time.Time `json:"at"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// when the machine was last heard
LastHeard time.Time `json:"last-heard"`
// the machine whose presence changed
@@ -308,6 +301,8 @@ type MachineAwayEvent struct {
// MachineBackEvent is the body of the event machine-back.
type MachineBackEvent struct {
At time.Time `json:"at"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// when the machine was last heard
LastHeard time.Time `json:"last-heard"`
// the machine whose presence changed
@@ -318,19 +313,25 @@ type MachineBackEvent struct {
// PresenceByNodeValue is one value of the state presence under the key <node>.
type PresenceByNodeValue struct {
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
Online bool `json:"online"`
V int64 `json:"v,omitempty"`
}
// PresenceByPartPartInstanceValue is one value of the state presence under the key part.<part>.<instance>.
type PresenceByPartPartInstanceValue struct {
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
Online bool `json:"online"`
V int64 `json:"v,omitempty"`
}
// PulseByBucketKeyValue is one value of the state pulse under the key <bucket>.<key>.
type PulseByBucketKeyValue struct {
Bucket string `json:"bucket"`
Bucket string `json:"bucket"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
Key string `json:"key"`
Owes string `json:"owes,omitempty"`
Revision int64 `json:"revision"`
@@ -340,7 +341,9 @@ type PulseByBucketKeyValue struct {
// StuckByBucketKeyValue is one value of the state stuck under the key <bucket>.<key>.
type StuckByBucketKeyValue struct {
Bucket string `json:"bucket"`
Key string `json:"key"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
Key string `json:"key"`
// it has moved again
Moved bool `json:"moved,omitempty"`
Since time.Time `json:"since"`
@@ -348,3 +351,77 @@ type StuckByBucketKeyValue struct {
// what it waited for, in words
Waited string `json:"waited,omitempty"`
}
// DecodeSignalsAnswer reads a SignalsAnswer 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 DecodeSignalsAnswer(raw []byte) (SignalsAnswer, int, error) {
var v SignalsAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeStuckAnswer reads a StuckAnswer 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 DecodeStuckAnswer(raw []byte) (StuckAnswer, int, error) {
var v StuckAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodePresenceAnswer reads a PresenceAnswer 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 DecodePresenceAnswer(raw []byte) (PresenceAnswer, int, error) {
var v PresenceAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeDeadLettersAnswer reads a DeadLettersAnswer 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 DecodeDeadLettersAnswer(raw []byte) (DeadLettersAnswer, int, error) {
var v DeadLettersAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeResyncAnswer reads a ResyncAnswer 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 DecodeResyncAnswer(raw []byte) (ResyncAnswer, int, error) {
var v ResyncAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeMachineAwayEvent reads a MachineAwayEvent 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 DecodeMachineAwayEvent(raw []byte) (MachineAwayEvent, int, error) {
var v MachineAwayEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeMachineBackEvent reads a MachineBackEvent 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 DecodeMachineBackEvent(raw []byte) (MachineBackEvent, int, error) {
var v MachineBackEvent
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
}
+10
View File
@@ -95,6 +95,8 @@ export interface ConditionEvent {
"evidence"?: Evidence[];
"explanation"?: string;
"first"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"gaps"?: ConditionEventGapsItem[];
"headline"?: string;
/** scope.id.token */
@@ -151,6 +153,8 @@ export interface Finding {
/** newest first, at most 10 */
"evidence"?: Evidence[];
"explanation"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"headline"?: string;
/** the key's second part */
"id": string;
@@ -269,6 +273,8 @@ export interface FindingsAskedEvent {
"at": string;
/** who asked: the keeper, or the person or session that called resync */
"by": string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** to ask one observer; none asks all */
"module"?: string;
}
@@ -301,6 +307,8 @@ export interface ConditionsByKeyValue {
"evidence"?: Evidence[];
"explanation"?: string;
"first"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"gaps"?: ConditionsByKeyValueGapsItem[];
"headline"?: string;
/** scope.id.token */
@@ -341,6 +349,8 @@ export interface FindingsViewsByObserverNodeValueStated {
export interface FindingsViewsByObserverNodeValue {
/** the open asks */
"asks"?: string[];
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"node": string;
"observer": string;
/** the keys it cannot judge yet */
+6
View File
@@ -45,6 +45,8 @@ export interface Act {
"carried"?: string[];
"cause": string;
"condition"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"id": string;
/** what the act was read to be from what it did */
"kind"?: string;
@@ -114,6 +116,8 @@ export interface ActsByIDValue {
"carried"?: string[];
"cause": string;
"condition"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"id": string;
/** what the act was read to be from what it did */
"kind"?: string;
@@ -133,6 +137,8 @@ export interface WarrantsByAskerAskValue {
"asker": string;
"at"?: string;
"by"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"option"?: string;
}
+8
View File
@@ -83,6 +83,8 @@ export interface HealerActedEvent {
"by"?: string;
"condition": string;
"event": string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"healer": string;
"kind"?: string;
"outcome": "acting" | "acted" | "failed" | "escalated";
@@ -98,6 +100,8 @@ export interface AttemptChangedEvent {
"budget-key"?: string;
"condition"?: string;
"finished"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"healer"?: string;
"kind"?: string;
"outcome"?: "acting" | "acted" | "failed" | "escalated";
@@ -116,6 +120,8 @@ export interface AttemptsByAttemptValue {
"budget-key": string;
"condition": string;
"finished"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"healer": string;
"kind": string;
"outcome": "acting" | "acted" | "failed" | "escalated";
@@ -127,6 +133,8 @@ export interface WouldByWouldValue {
"act": string;
"at": string;
"condition": string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"healer": string;
"kind"?: string;
"why"?: string;
+2
View File
@@ -59,6 +59,8 @@ export interface CheckedEvent {
"at": string;
"controller"?: string;
"counts"?: CheckedEventCounts;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"interval-seconds"?: number;
"probes": ProbeVerdict[];
"run": string;
+14
View File
@@ -96,6 +96,8 @@ export interface PresenceAnswerKeysItem {
/** is what presence answers. */
export interface PresenceAnswer {
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** without machine: how many keys the state holds */
"holds"?: number;
/** without machine: each key of the state presence, <node> or part.<part>.<instance>, with its value */
@@ -141,6 +143,8 @@ export type ResyncAnswer = Record<string, unknown>;
/** is the body of the event machine-away. */
export interface MachineAwayEvent {
"at": string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** when the machine was last heard */
"last-heard": string;
/** the machine whose presence changed */
@@ -152,6 +156,8 @@ export interface MachineAwayEvent {
/** is the body of the event machine-back. */
export interface MachineBackEvent {
"at": string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** when the machine was last heard */
"last-heard": string;
/** the machine whose presence changed */
@@ -162,12 +168,16 @@ export interface MachineBackEvent {
/** is one value of the state presence under the key <node>. */
export interface PresenceByNodeValue {
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"online": boolean;
"v"?: number;
}
/** is one value of the state presence under the key part.<part>.<instance>. */
export interface PresenceByPartPartInstanceValue {
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"online": boolean;
"v"?: number;
}
@@ -175,6 +185,8 @@ export interface PresenceByPartPartInstanceValue {
/** is one value of the state pulse under the key <bucket>.<key>. */
export interface PulseByBucketKeyValue {
"bucket": string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"key": string;
"owes"?: string;
"revision": number;
@@ -184,6 +196,8 @@ export interface PulseByBucketKeyValue {
/** is one value of the state stuck under the key <bucket>.<key>. */
export interface StuckByBucketKeyValue {
"bucket": string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"key": string;
/** it has moved again */
"moved"?: boolean;
@@ -113,7 +113,7 @@ func DecodeNodeLogin(data []byte) (seat.NodeLoginsByNodeValue, error) {
if probe.V == nil || *probe.V != Version {
return seat.NodeLoginsByNodeValue{}, fmt.Errorf("%w: this reader reads %d", ErrUnknownVersion, Version)
}
l, err := seat.DecodeNodeLoginsByNodeValue(data)
l, _, err := seat.DecodeNodeLoginsByNodeValue(data)
if err != nil {
return l, fmt.Errorf("meshvaultclient: value does not fit its shape: %w", err)
}
@@ -104,7 +104,7 @@ func SignerPublicKey(k seat.SignersByKeyValue) (ed25519.PublicKey, error) {
// DecodeSignerKey reads the key `key` of `signers`, refused when it does not check.
func DecodeSignerKey(raw []byte) (seat.SignersByKeyValue, error) {
k, err := seat.DecodeSignersByKeyValue(raw)
k, _, err := seat.DecodeSignersByKeyValue(raw)
if err != nil {
return k, fmt.Errorf("meshvaultclient: signers %s: %w", "key", err)
}
@@ -117,7 +117,7 @@ func DecodeSignerKey(raw []byte) (seat.SignersByKeyValue, error) {
// DecodeSignerAuthority reads the key `authority` of `signers`: one authority certificate (a CA that signs leaves
// alone) whose fingerprint is the one named.
func DecodeSignerAuthority(raw []byte) (seat.SignersByAuthorityValue, error) {
a, err := seat.DecodeSignersByAuthorityValue(raw)
a, _, err := seat.DecodeSignersByAuthorityValue(raw)
if err != nil {
return a, fmt.Errorf("meshvaultclient: signers %s: %w", "authority", err)
}
@@ -3,11 +3,25 @@
// Package meshgrants is the contract of the seat "mesh-grants", defined whole (seats/mesh-grants/seat.json): Who may say what on the bus: the grants part composes each module's membership, its buckets, logs and streams, the bus's user list and grants (design 47 'The grants part'). An acting part of the step grant (ADR 0656 1): an entry whose grant waits for its new version is held on its running build within the bound, said by wait-held and wait-ended; a store passing 80 % of its cap is said by filling, and back below 70 % by room; grants-for answers the grants a candidate would compose (design 47 G 331, 441).
package meshgrants
import "time"
import (
"encoding/json"
"time"
)
// Seat is the seat's name.
const Seat = "mesh-grants"
// 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 = "b2f4006c04a64376f684122491eac6e2bccab805b53cb2fc34ea05db6f2ab965"
)
const (
VerbGrantsFor = "grants-for"
VerbWithheld = "withheld"
@@ -54,6 +68,8 @@ type Fill struct {
Bytes int64 `json:"bytes"`
// bytes
Cap int64 `json:"cap"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// the store
Store string `json:"store"`
}
@@ -76,7 +92,9 @@ type GrantsForModulesItem struct {
// GrantsFor is the grants a candidate would compose, per module, added and removed against the branch's newest.
type GrantsFor struct {
// why it could not be answered: the catalog half of the candidate is not held
Error string `json:"error,omitempty"`
Error string `json:"error,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
Modules []GrantsForModulesItem `json:"modules,omitempty"`
}
@@ -88,6 +106,8 @@ type Wait struct {
By string `json:"by,omitempty"`
// when the new version's build was done, as the builder's build.ended says; the bound's clock starts there (design 47 G 266)
ClockFrom time.Time `json:"clock-from"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// the entry's fingerprint, whose grant waits
Fp string `json:"fp,omitempty"`
// on wait-ended: ran or released
@@ -122,6 +142,8 @@ type WithheldModulesItem struct {
// Withheld is a node's withheld subjects, by module.
type Withheld struct {
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
Modules []WithheldModulesItem `json:"modules"`
Node string `json:"node"`
}
@@ -165,3 +187,68 @@ type FillingEvent = Fill
// RoomEvent is the body of the event room.
type RoomEvent = Fill
// DecodeGrantsForAnswer reads a GrantsForAnswer 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 DecodeGrantsForAnswer(raw []byte) (GrantsForAnswer, int, error) {
var v GrantsForAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeWithheldAnswer reads a WithheldAnswer 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 DecodeWithheldAnswer(raw []byte) (WithheldAnswer, int, error) {
var v WithheldAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeWaitHeldEvent reads a WaitHeldEvent 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 DecodeWaitHeldEvent(raw []byte) (WaitHeldEvent, int, error) {
var v WaitHeldEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeWaitEndedEvent reads a WaitEndedEvent 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 DecodeWaitEndedEvent(raw []byte) (WaitEndedEvent, int, error) {
var v WaitEndedEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeFillingEvent reads a FillingEvent 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 DecodeFillingEvent(raw []byte) (FillingEvent, int, error) {
var v FillingEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeRoomEvent reads a RoomEvent 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 DecodeRoomEvent(raw []byte) (RoomEvent, int, error) {
var v RoomEvent
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
}
@@ -4,9 +4,7 @@
package meshnodeenroller
import (
"bytes"
"encoding/json"
"errors"
"strings"
"time"
)
@@ -14,6 +12,17 @@ import (
// Seat is the seat's name.
const Seat = "mesh-node-enroller"
// 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 = "a6eedea7a2806712696e7b491a8a643a1dc054ab6ab1d97dce0de7f015c92243"
)
const (
VerbIssue = "issue"
VerbRedeem = "redeem"
@@ -87,18 +96,13 @@ func ParseEnrolmentsByNodeNodeKey(key string) (string, bool) {
return v1, true
}
// DecodeEnrolmentsByNodeNodeValue reads one value of the state enrolments under the form "node.<node>", refusing a field EnrolmentsByNodeNodeValue does not know and any text after the value.
func DecodeEnrolmentsByNodeNodeValue(raw []byte) (EnrolmentsByNodeNodeValue, error) {
// DecodeEnrolmentsByNodeNodeValue reads one value of the state enrolments under the form "node.<node>" as another part wrote it: a field EnrolmentsByNodeNodeValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodeEnrolmentsByNodeNodeValue(raw []byte) (EnrolmentsByNodeNodeValue, int, error) {
var v EnrolmentsByNodeNodeValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// EnrolmentsByAddressAddressKey is the key of one value of the state enrolments under the form "address.<address>".
@@ -122,26 +126,23 @@ func ParseEnrolmentsByAddressAddressKey(key string) (string, bool) {
return v1, true
}
// DecodeEnrolmentsByAddressAddressValue reads one value of the state enrolments under the form "address.<address>", refusing a field EnrolmentsByAddressAddressValue does not know and any text after the value.
func DecodeEnrolmentsByAddressAddressValue(raw []byte) (EnrolmentsByAddressAddressValue, error) {
// DecodeEnrolmentsByAddressAddressValue reads one value of the state enrolments under the form "address.<address>" as another part wrote it: a field EnrolmentsByAddressAddressValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodeEnrolmentsByAddressAddressValue(raw []byte) (EnrolmentsByAddressAddressValue, int, error) {
var v EnrolmentsByAddressAddressValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// Enrolment is one open enrolment.
type Enrolment struct {
Address string `json:"address"`
Ask string `json:"ask,omitempty"`
Caller string `json:"caller,omitempty"`
Expires *time.Time `json:"expires,omitempty"`
Address string `json:"address"`
Ask string `json:"ask,omitempty"`
Caller string `json:"caller,omitempty"`
Expires *time.Time `json:"expires,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
Issued *time.Time `json:"issued,omitempty"`
KeysDigest string `json:"keys-digest,omitempty"`
Node string `json:"node"`
@@ -193,6 +194,8 @@ type RedeemAnswer struct {
Account string `json:"account"`
// its certificate, PEM
Certificate string `json:"certificate"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// the login it dials as next
Login string `json:"login"`
// the node
@@ -267,8 +270,120 @@ type EnrolmentsByNodeNodeValue = Enrolment
// EnrolmentsByAddressAddressValue is one value of the state enrolments under the key address.<address>.
type EnrolmentsByAddressAddressValue struct {
Ask string `json:"ask,omitempty"`
Ask string `json:"ask,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
Issued *time.Time `json:"issued,omitempty"`
Node string `json:"node"`
V int64 `json:"v,omitempty"`
}
// DecodeIssueAnswer reads a IssueAnswer 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 DecodeIssueAnswer(raw []byte) (IssueAnswer, int, error) {
var v IssueAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeRedeemAnswer reads a RedeemAnswer 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 DecodeRedeemAnswer(raw []byte) (RedeemAnswer, int, error) {
var v RedeemAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeConfirmAnswer reads a ConfirmAnswer 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 DecodeConfirmAnswer(raw []byte) (ConfirmAnswer, int, error) {
var v ConfirmAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeRevokeAnswer reads a RevokeAnswer 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 DecodeRevokeAnswer(raw []byte) (RevokeAnswer, int, error) {
var v RevokeAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeTokensAnswer reads a TokensAnswer 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 DecodeTokensAnswer(raw []byte) (TokensAnswer, int, error) {
var v TokensAnswer
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
}
// DecodeEnrolmentIssuedEvent reads a EnrolmentIssuedEvent 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 DecodeEnrolmentIssuedEvent(raw []byte) (EnrolmentIssuedEvent, int, error) {
var v EnrolmentIssuedEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeNodeEnrolledEvent reads a NodeEnrolledEvent 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 DecodeNodeEnrolledEvent(raw []byte) (NodeEnrolledEvent, int, error) {
var v NodeEnrolledEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeEnrolmentRefusedEvent reads a EnrolmentRefusedEvent 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 DecodeEnrolmentRefusedEvent(raw []byte) (EnrolmentRefusedEvent, int, error) {
var v EnrolmentRefusedEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeEnrolmentRevokedEvent reads a EnrolmentRevokedEvent 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 DecodeEnrolmentRevokedEvent(raw []byte) (EnrolmentRevokedEvent, int, error) {
var v EnrolmentRevokedEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeEnrolmentExpiredEvent reads a EnrolmentExpiredEvent 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 DecodeEnrolmentExpiredEvent(raw []byte) (EnrolmentExpiredEvent, int, error) {
var v EnrolmentExpiredEvent
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
}
@@ -4,9 +4,7 @@
package meshvault
import (
"bytes"
"encoding/json"
"errors"
"strings"
"time"
)
@@ -14,6 +12,17 @@ import (
// Seat is the seat's name.
const Seat = "mesh-vault"
// 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 = "1b55f695820faf0b8d358617daeba7d5c8ed27ac41b7e9d024c83f28201ad0d0"
)
const (
VerbGet = "get"
VerbSecretAsk = "secret-ask"
@@ -126,18 +135,13 @@ func ParseSignersByKeyKey(key string) bool {
return true
}
// DecodeSignersByKeyValue reads one value of the state signers under the form "key", refusing a field SignersByKeyValue does not know and any text after the value.
func DecodeSignersByKeyValue(raw []byte) (SignersByKeyValue, error) {
// DecodeSignersByKeyValue reads one value of the state signers under the form "key" as another part wrote it: a field SignersByKeyValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodeSignersByKeyValue(raw []byte) (SignersByKeyValue, int, error) {
var v SignersByKeyValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// SignersByAuthorityKey is the key of one value of the state signers under the form "authority".
@@ -156,18 +160,13 @@ func ParseSignersByAuthorityKey(key string) bool {
return true
}
// DecodeSignersByAuthorityValue reads one value of the state signers under the form "authority", refusing a field SignersByAuthorityValue does not know and any text after the value.
func DecodeSignersByAuthorityValue(raw []byte) (SignersByAuthorityValue, error) {
// DecodeSignersByAuthorityValue reads one value of the state signers under the form "authority" as another part wrote it: a field SignersByAuthorityValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodeSignersByAuthorityValue(raw []byte) (SignersByAuthorityValue, int, error) {
var v SignersByAuthorityValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// NodeLoginsByNodeKey is the key of one value of the state node-logins under the form "<node>".
@@ -187,18 +186,13 @@ func ParseNodeLoginsByNodeKey(key string) (string, bool) {
return v0, true
}
// DecodeNodeLoginsByNodeValue reads one value of the state node-logins under the form "<node>", refusing a field NodeLoginsByNodeValue does not know and any text after the value.
func DecodeNodeLoginsByNodeValue(raw []byte) (NodeLoginsByNodeValue, error) {
// DecodeNodeLoginsByNodeValue reads one value of the state node-logins under the form "<node>" as another part wrote it: a field NodeLoginsByNodeValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodeNodeLoginsByNodeValue(raw []byte) (NodeLoginsByNodeValue, int, error) {
var v NodeLoginsByNodeValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// GetInput is what get takes.
@@ -363,6 +357,8 @@ type SignAnswer struct {
Certificate string `json:"certificate,omitempty"`
// sha256:<hex> of the bytes signed
Digest string `json:"digest"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// node-certificate or enrolment, as asked
Kind string `json:"kind"`
// the machine, for a node certificate
@@ -421,6 +417,8 @@ type EnrolmentTokenAnswer struct {
Dropped bool `json:"dropped,omitempty"`
// the fingerprint of the bus's certificate
Fingerprint string `json:"fingerprint,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// the node the token is for
Node string `json:"node"`
// the token sealed to the operator key, when asked sealed, relayed as it is
@@ -451,6 +449,8 @@ const (
type NodeAccountAnswer struct {
// the account sealed to the node's sealing key, in base64
Account string `json:"account,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// the login minted
Login string `json:"login,omitempty"`
// the joining node
@@ -504,6 +504,8 @@ type RetireInput struct {
// RetireAnswer is what retire answers.
type RetireAnswer struct {
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// the secret is gone
Retired bool `json:"retired"`
}
@@ -546,6 +548,8 @@ type SignedHolderEvent struct {
Caller string `json:"caller"`
// sha256:<hex> of the bytes signed
Digest string `json:"digest"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// node-certificate or enrolment
Kind string `json:"kind"`
// the machine, for a node certificate
@@ -560,6 +564,8 @@ type OwnRetiredHolderEvent struct {
Ask string `json:"ask,omitempty"`
// the caller the vault proved
Caller string `json:"caller"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// the module
Module string `json:"module"`
// the secret's name
@@ -571,6 +577,8 @@ type OwnRetiredHolderEvent struct {
// SignersByKeyValue is one value of the state signers under the key key.
type SignersByKeyValue struct {
Fingerprint string `json:"fingerprint"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// the signing key's public half, standard base64
Key string `json:"key"`
Made time.Time `json:"made"`
@@ -580,15 +588,19 @@ type SignersByKeyValue struct {
// SignersByAuthorityValue is one value of the state signers under the key authority.
type SignersByAuthorityValue struct {
// the authority certificate, PEM
Certificate string `json:"certificate"`
Fingerprint string `json:"fingerprint"`
Made time.Time `json:"made"`
V int64 `json:"v,omitempty"`
Certificate string `json:"certificate"`
Fingerprint string `json:"fingerprint"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
Made time.Time `json:"made"`
V int64 `json:"v,omitempty"`
}
// NodeLoginsByNodeValue is one value of the state node-logins under the key <node>.
type NodeLoginsByNodeValue struct {
Acts []string `json:"acts,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// the user list's revision that held both logins, from ready on
ListRevision int64 `json:"list-revision,omitempty"`
// the login in use
@@ -601,3 +613,185 @@ type NodeLoginsByNodeValue struct {
Stage string `json:"stage,omitempty"`
V int64 `json:"v,omitempty"`
}
// DecodeGetAnswer reads a GetAnswer 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 DecodeGetAnswer(raw []byte) (GetAnswer, int, error) {
var v GetAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeSecretAskAnswer reads a SecretAskAnswer 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 DecodeSecretAskAnswer(raw []byte) (SecretAskAnswer, int, error) {
var v SecretAskAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeIssuedAnswer reads a IssuedAnswer 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 DecodeIssuedAnswer(raw []byte) (IssuedAnswer, int, error) {
var v IssuedAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeRotateAnswer reads a RotateAnswer 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 DecodeRotateAnswer(raw []byte) (RotateAnswer, int, error) {
var v RotateAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeMoveInAnswer reads a MoveInAnswer 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 DecodeMoveInAnswer(raw []byte) (MoveInAnswer, int, error) {
var v MoveInAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeNodeKeyAnswer reads a NodeKeyAnswer 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 DecodeNodeKeyAnswer(raw []byte) (NodeKeyAnswer, int, error) {
var v NodeKeyAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeOwnAnswer reads a OwnAnswer 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 DecodeOwnAnswer(raw []byte) (OwnAnswer, int, error) {
var v OwnAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeIssueAccountAnswer reads a IssueAccountAnswer 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 DecodeIssueAccountAnswer(raw []byte) (IssueAccountAnswer, int, error) {
var v IssueAccountAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeSignAnswer reads a SignAnswer 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 DecodeSignAnswer(raw []byte) (SignAnswer, int, error) {
var v SignAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeEnrolmentTokenAnswer reads a EnrolmentTokenAnswer 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 DecodeEnrolmentTokenAnswer(raw []byte) (EnrolmentTokenAnswer, int, error) {
var v EnrolmentTokenAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeNodeAccountAnswer reads a NodeAccountAnswer 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 DecodeNodeAccountAnswer(raw []byte) (NodeAccountAnswer, int, error) {
var v NodeAccountAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeRotateNodeAnswer reads a RotateNodeAnswer 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 DecodeRotateNodeAnswer(raw []byte) (RotateNodeAnswer, int, error) {
var v RotateNodeAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeNodeAccountConfirmAnswer reads a NodeAccountConfirmAnswer 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 DecodeNodeAccountConfirmAnswer(raw []byte) (NodeAccountConfirmAnswer, int, error) {
var v NodeAccountConfirmAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeAbandonAnswer reads a AbandonAnswer 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 DecodeAbandonAnswer(raw []byte) (AbandonAnswer, int, error) {
var v AbandonAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeRetireAnswer reads a RetireAnswer 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 DecodeRetireAnswer(raw []byte) (RetireAnswer, int, error) {
var v RetireAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeLicencePutAnswer reads a LicencePutAnswer 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 DecodeLicencePutAnswer(raw []byte) (LicencePutAnswer, int, error) {
var v LicencePutAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeOwnPutAnswer reads a OwnPutAnswer 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 DecodeOwnPutAnswer(raw []byte) (OwnPutAnswer, int, error) {
var v OwnPutAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeSignedHolderEvent reads a SignedHolderEvent 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 DecodeSignedHolderEvent(raw []byte) (SignedHolderEvent, int, error) {
var v SignedHolderEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeOwnRetiredHolderEvent reads a OwnRetiredHolderEvent 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 DecodeOwnRetiredHolderEvent(raw []byte) (OwnRetiredHolderEvent, int, error) {
var v OwnRetiredHolderEvent
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
}
+8
View File
@@ -32,6 +32,8 @@ export interface Fill {
"bytes": number;
/** bytes */
"cap": number;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** the store */
"store": string;
}
@@ -53,6 +55,8 @@ export interface GrantsForModulesItem {
export interface GrantsFor {
/** why it could not be answered: the catalog half of the candidate is not held */
"error"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"modules"?: GrantsForModulesItem[];
}
@@ -64,6 +68,8 @@ export interface Wait {
"by"?: string;
/** when the new version's build was done, as the builder's build.ended says; the bound's clock starts there (design 47 G 266) */
"clock-from": string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** the entry's fingerprint, whose grant waits */
"fp"?: string;
/** on wait-ended: ran or released */
@@ -86,6 +92,8 @@ export interface WithheldModulesItem {
/** a node's withheld subjects, by module */
export interface Withheld {
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"modules": WithheldModulesItem[];
"node": string;
}
@@ -55,6 +55,8 @@ export interface Enrolment {
"ask"?: string;
"caller"?: string;
"expires"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"issued"?: string;
"keys-digest"?: string;
"node": string;
@@ -106,6 +108,8 @@ export interface RedeemAnswer {
"account": string;
/** its certificate, PEM */
"certificate": string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** the login it dials as next */
"login": string;
/** the node */
@@ -175,6 +179,8 @@ export type EnrolmentsByNodeNodeValue = Enrolment;
/** is one value of the state enrolments under the key address.<address>. */
export interface EnrolmentsByAddressAddressValue {
"ask"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"issued"?: string;
"node": string;
"v"?: number;
+18
View File
@@ -244,6 +244,8 @@ export interface SignAnswer {
"certificate"?: string;
/** sha256:<hex> of the bytes signed */
"digest": string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** node-certificate or enrolment, as asked */
"kind": string;
/** the machine, for a node certificate */
@@ -290,6 +292,8 @@ export interface EnrolmentTokenAnswer {
"dropped"?: boolean;
/** the fingerprint of the bus's certificate */
"fingerprint"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** the node the token is for */
"node": string;
/** the token sealed to the operator key, when asked sealed, relayed as it is */
@@ -314,6 +318,8 @@ export interface NodeAccountInput {
export interface NodeAccountAnswer {
/** the account sealed to the node's sealing key, in base64 */
"account"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** the login minted */
"login"?: string;
/** the joining node */
@@ -367,6 +373,8 @@ export interface RetireInput {
/** is what retire answers. */
export interface RetireAnswer {
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** the secret is gone */
"retired": boolean;
}
@@ -409,6 +417,8 @@ export interface SignedHolderEvent {
"caller": string;
/** sha256:<hex> of the bytes signed */
"digest": string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** node-certificate or enrolment */
"kind": string;
/** the machine, for a node certificate */
@@ -423,6 +433,8 @@ export interface OwnRetiredHolderEvent {
"ask"?: string;
/** the caller the vault proved */
"caller": string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** the module */
"module": string;
/** the secret's name */
@@ -434,6 +446,8 @@ export interface OwnRetiredHolderEvent {
/** is one value of the state signers under the key key. */
export interface SignersByKeyValue {
"fingerprint": string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** the signing key's public half, standard base64 */
"key": string;
"made": string;
@@ -445,6 +459,8 @@ export interface SignersByAuthorityValue {
/** the authority certificate, PEM */
"certificate": string;
"fingerprint": string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"made": string;
"v"?: number;
}
@@ -452,6 +468,8 @@ export interface SignersByAuthorityValue {
/** is one value of the state node-logins under the key <node>. */
export interface NodeLoginsByNodeValue {
"acts"?: string[];
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** the user list's revision that held both logins, from ready on */
"list-revision"?: number;
/** the login in use */
@@ -4,9 +4,7 @@
package operatorchannel
import (
"bytes"
"encoding/json"
"errors"
"strings"
"time"
)
@@ -14,6 +12,17 @@ import (
// Seat is the seat's name.
const Seat = "operator-channel"
// 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 = "5447f2572c926558eb1532038108cddeded16377f9d1dee5c0f1aafb856b3ce2"
)
const (
VerbOpen = "open"
VerbHistory = "history"
@@ -108,18 +117,13 @@ func ParseAsksByAskerIDKey(key string) (string, string, bool) {
return v0, v2, true
}
// DecodeAsksByAskerIDValue reads one value of the state asks under the form "<asker>.<id>", refusing a field AsksByAskerIDValue does not know and any text after the value.
func DecodeAsksByAskerIDValue(raw []byte) (AsksByAskerIDValue, error) {
// DecodeAsksByAskerIDValue reads one value of the state asks under the form "<asker>.<id>" as another part wrote it: a field AsksByAskerIDValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodeAsksByAskerIDValue(raw []byte) (AsksByAskerIDValue, int, error) {
var v AsksByAskerIDValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// Ask is a type of the contract.
@@ -346,6 +350,8 @@ type Warrant struct {
By *Person `json:"by,omitempty"`
// the module it came through
Channel string `json:"channel,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// its label
Label string `json:"label,omitempty"`
// its level
@@ -453,6 +459,8 @@ type AsksAnswer struct {
Asks []AsksAnswerAsksItem `json:"asks"`
// what the bound cut, and how to ask for more; empty when nothing was cut
Cut string `json:"cut,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// how many asks the arguments matched
Matched int64 `json:"matched,omitempty"`
}
@@ -478,6 +486,8 @@ type OfferedHolderEvent struct {
Asker string `json:"asker"`
// the channels it was offered on
Channels []string `json:"channels,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// its headline
Headline string `json:"headline,omitempty"`
// the ask's id
@@ -488,7 +498,9 @@ type OfferedHolderEvent struct {
type ClosedHolderEvent struct {
// its asker
Asker string `json:"asker"`
How string `json:"how"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
How string `json:"how"`
// the ask's id
ID string `json:"id"`
}
@@ -514,6 +526,8 @@ type AsksByAskerIDValue struct {
At string `json:"at,omitempty"`
// when it ends unanswered, RFC 3339
Expires string `json:"expires"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
// its headline
Headline string `json:"headline"`
// <asker>.<id>
@@ -526,3 +540,86 @@ type AsksByAskerIDValue struct {
State string `json:"state"`
Warrant *Warrant `json:"warrant,omitempty"`
}
// DecodeOpenAnswer reads a OpenAnswer 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 DecodeOpenAnswer(raw []byte) (OpenAnswer, int, error) {
var v OpenAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeHistoryAnswer reads a HistoryAnswer 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 DecodeHistoryAnswer(raw []byte) (HistoryAnswer, int, error) {
var v HistoryAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeNotifyAnswer reads a NotifyAnswer 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 DecodeNotifyAnswer(raw []byte) (NotifyAnswer, int, error) {
var v NotifyAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeTellAnswer reads a TellAnswer 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 DecodeTellAnswer(raw []byte) (TellAnswer, int, error) {
var v TellAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeAsksAnswer reads a AsksAnswer 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 DecodeAsksAnswer(raw []byte) (AsksAnswer, int, error) {
var v AsksAnswer
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeDecidedEvent reads a DecidedEvent 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 DecodeDecidedEvent(raw []byte) (DecidedEvent, int, error) {
var v DecidedEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeOfferedHolderEvent reads a OfferedHolderEvent 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 DecodeOfferedHolderEvent(raw []byte) (OfferedHolderEvent, int, error) {
var v OfferedHolderEvent
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
return v, formRead(raw), nil
}
// DecodeClosedHolderEvent reads a ClosedHolderEvent 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 DecodeClosedHolderEvent(raw []byte) (ClosedHolderEvent, int, error) {
var v ClosedHolderEvent
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
}
@@ -271,6 +271,8 @@ export interface Warrant {
"by"?: Person;
/** the module it came through */
"channel"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** its label */
"label"?: string;
/** its level */
@@ -362,6 +364,8 @@ export interface AsksAnswer {
"asks": AsksAnswerAsksItem[];
/** what the bound cut, and how to ask for more; empty when nothing was cut */
"cut"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** how many asks the arguments matched */
"matched"?: number;
}
@@ -387,6 +391,8 @@ export interface OfferedHolderEvent {
"asker": string;
/** the channels it was offered on */
"channels"?: string[];
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** its headline */
"headline"?: string;
/** the ask's id */
@@ -397,6 +403,8 @@ export interface OfferedHolderEvent {
export interface ClosedHolderEvent {
/** its asker */
"asker": string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"how": "answered" | "expired" | "cancelled" | "replaced" | "unlinked";
/** the ask's id */
"id": string;
@@ -414,6 +422,8 @@ export interface AsksByAskerIDValue {
"at"?: string;
/** when it ends unanswered, RFC 3339 */
"expires": string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** its headline */
"headline": string;
/** <asker>.<id> */
@@ -4,9 +4,7 @@
package meshprovisioner
import (
"bytes"
"encoding/json"
"errors"
"strings"
"time"
)
@@ -14,6 +12,17 @@ import (
// Seat is the seat's name.
const Seat = "mesh-provisioner"
// 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 = "878e1ffd0497bd99a1544b43596e8317c72417540badaef82999fe69e55202b6"
)
const (
VerbProvisioning = "provisioning"
)
@@ -50,18 +59,13 @@ func ParsePlansByNodeModuleKey(key string) (string, string, bool) {
return v0, v2, true
}
// DecodePlansByNodeModuleValue reads one value of the state plans under the form "<node>.<module>", refusing a field PlansByNodeModuleValue does not know and any text after the value.
func DecodePlansByNodeModuleValue(raw []byte) (PlansByNodeModuleValue, error) {
// DecodePlansByNodeModuleValue reads one value of the state plans under the form "<node>.<module>" as another part wrote it: a field PlansByNodeModuleValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodePlansByNodeModuleValue(raw []byte) (PlansByNodeModuleValue, int, error) {
var v PlansByNodeModuleValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// ProvisionsByNodeConsumerProvisionKey is the key of one value of the state provisions under the form "<node>.<consumer>.<provision>".
@@ -93,18 +97,13 @@ func ParseProvisionsByNodeConsumerProvisionKey(key string) (string, string, stri
return v0, v2, v4, true
}
// DecodeProvisionsByNodeConsumerProvisionValue reads one value of the state provisions under the form "<node>.<consumer>.<provision>", refusing a field ProvisionsByNodeConsumerProvisionValue does not know and any text after the value.
func DecodeProvisionsByNodeConsumerProvisionValue(raw []byte) (ProvisionsByNodeConsumerProvisionValue, error) {
// DecodeProvisionsByNodeConsumerProvisionValue reads one value of the state provisions under the form "<node>.<consumer>.<provision>" as another part wrote it: a field ProvisionsByNodeConsumerProvisionValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodeProvisionsByNodeConsumerProvisionValue(raw []byte) (ProvisionsByNodeConsumerProvisionValue, int, error) {
var v ProvisionsByNodeConsumerProvisionValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// ProvisionsByNodeConsumerProvisionLocalKey is the key of one value of the state provisions under the form "<node>.<consumer>.<provision>.<local>".
@@ -141,18 +140,13 @@ func ParseProvisionsByNodeConsumerProvisionLocalKey(key string) (string, string,
return v0, v2, v4, v6, true
}
// DecodeProvisionsByNodeConsumerProvisionLocalValue reads one value of the state provisions under the form "<node>.<consumer>.<provision>.<local>", refusing a field ProvisionsByNodeConsumerProvisionLocalValue does not know and any text after the value.
func DecodeProvisionsByNodeConsumerProvisionLocalValue(raw []byte) (ProvisionsByNodeConsumerProvisionLocalValue, error) {
// DecodeProvisionsByNodeConsumerProvisionLocalValue reads one value of the state provisions under the form "<node>.<consumer>.<provision>.<local>" as another part wrote it: a field ProvisionsByNodeConsumerProvisionLocalValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
func DecodeProvisionsByNodeConsumerProvisionLocalValue(raw []byte) (ProvisionsByNodeConsumerProvisionLocalValue, int, error) {
var v ProvisionsByNodeConsumerProvisionLocalValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
if err := json.Unmarshal(raw, &v); err != nil {
return v, 0, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
return v, formRead(raw), nil
}
// ProvisioningInput is what provisioning takes.
@@ -172,6 +166,8 @@ type ProvisioningAnswer = map[string]any
// PlansByNodeModuleValue is one value of the state plans under the key <node>.<module>.
type PlansByNodeModuleValue struct {
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
Module string `json:"module"`
Node string `json:"node"`
// the module's plan
@@ -230,7 +226,9 @@ type ProvisionsByNodeConsumerProvisionValue struct {
At time.Time `json:"at"`
Consumer ProvisionsByNodeConsumerProvisionValueConsumer `json:"consumer"`
DependsOn []string `json:"depends-on,omitempty"`
Local string `json:"local,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
Local string `json:"local,omitempty"`
// the plan's provision: the entry the key was composed from, at the consumer's wanted build or its newest (issue 1126)
Plan *ProvisionsByNodeConsumerProvisionValuePlan `json:"plan,omitempty"`
Provider ProvisionsByNodeConsumerProvisionValueProvider `json:"provider"`
@@ -302,7 +300,9 @@ type ProvisionsByNodeConsumerProvisionLocalValue struct {
At time.Time `json:"at"`
Consumer ProvisionsByNodeConsumerProvisionLocalValueConsumer `json:"consumer"`
DependsOn []string `json:"depends-on,omitempty"`
Local string `json:"local,omitempty"`
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
Form int64 `json:"form,omitempty"`
Local string `json:"local,omitempty"`
// the plan's provision: the entry the key was composed from, at the consumer's wanted build or its newest (issue 1126)
Plan *ProvisionsByNodeConsumerProvisionLocalValuePlan `json:"plan,omitempty"`
Provider ProvisionsByNodeConsumerProvisionLocalValueProvider `json:"provider"`
@@ -322,3 +322,23 @@ const (
ProvisionsByNodeConsumerProvisionLocalValueStateFailed = "failed"
ProvisionsByNodeConsumerProvisionLocalValueStateRetiring = "retiring"
)
// DecodeProvisioningAnswer reads a ProvisioningAnswer 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 DecodeProvisioningAnswer(raw []byte) (ProvisioningAnswer, int, error) {
var v ProvisioningAnswer
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
}
+6
View File
@@ -48,6 +48,8 @@ export type ProvisioningAnswer = Record<string, unknown>;
/** is one value of the state plans under the key <node>.<module>. */
export interface PlansByNodeModuleValue {
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"module": string;
"node": string;
/** the module's plan */
@@ -102,6 +104,8 @@ export interface ProvisionsByNodeConsumerProvisionValue {
"at": string;
"consumer": ProvisionsByNodeConsumerProvisionValueConsumer;
"depends-on"?: string[];
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"local"?: string;
/** the plan's provision: the entry the key was composed from, at the consumer's wanted build or its newest (issue 1126) */
"plan"?: ProvisionsByNodeConsumerProvisionValuePlan;
@@ -161,6 +165,8 @@ export interface ProvisionsByNodeConsumerProvisionLocalValue {
"at": string;
"consumer": ProvisionsByNodeConsumerProvisionLocalValueConsumer;
"depends-on"?: string[];
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"local"?: string;
/** the plan's provision: the entry the key was composed from, at the consumer's wanted build or its newest (issue 1126) */
"plan"?: ProvisionsByNodeConsumerProvisionLocalValuePlan;
+22
View File
@@ -122,6 +122,8 @@ export interface Held {
/** its own configuration, where no template fits */
"configuration"?: Record<string, unknown>;
"fill"?: Fill;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** its local name in the module's manifest */
"local-name": string;
/** the module asking it */
@@ -157,6 +159,8 @@ export interface Said {
/** its own configuration, where no template fits */
"configuration"?: Record<string, unknown>;
"fill"?: Fill;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** the settings held */
"held"?: Record<string, unknown>;
/** its local name in the module's manifest */
@@ -207,6 +211,8 @@ export interface ListAnswer {
"caps"?: ListAnswerCaps;
/** every entry */
"entries": Held[];
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
}
/** is what show takes. */
@@ -238,6 +244,8 @@ export interface CheckAnswerDifferencesItem {
export interface CheckAnswer {
/** every difference */
"differences": CheckAnswerDifferencesItem[];
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
}
/** is what orphans takes. */
@@ -248,6 +256,8 @@ export interface OrphansInput {
export interface OrphansAnswer {
/** every orphan */
"entries": Held[];
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
}
/** is what create takes. */
@@ -275,6 +285,8 @@ export type DropInput = Warranted;
export interface DropAnswer {
/** it is gone */
"dropped": boolean;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** the snapshot taken first */
"snapshot"?: string;
}
@@ -297,6 +309,8 @@ export interface SnapshotGetAnswer {
"digest"?: string;
/** why not: snapshot damaged, snapshot missing, snapshot protected or snapshot taken before milestone G; set alone */
"error"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** the entry's local name */
"local"?: string;
"module"?: string;
@@ -324,6 +338,8 @@ export interface SnapshotRestoreAnswer {
"busy"?: string;
/** why not; set alone */
"error"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
}
/** is what snapshot-restore-cancel takes. */
@@ -342,6 +358,8 @@ export interface SnapshotRestoreCancelAnswer {
"busy"?: string;
/** why not; set alone */
"error"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
}
/** is what snapshot-remove takes. */
@@ -362,6 +380,8 @@ export interface SnapshotRemoveAnswer {
"busy"?: string;
/** why not; set alone */
"error"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
}
/** is the body of the event created. */
@@ -396,6 +416,8 @@ export interface SnapshotRestoredEvent {
"act": string;
/** when failed */
"error"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"outcome": "done" | "failed";
"request": string;
}
+10
View File
@@ -78,6 +78,8 @@ export interface RenamesAnswerRenamesItem {
/** is what renames answers. */
export interface RenamesAnswer {
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** every open rename */
"renames": RenamesAnswerRenamesItem[];
}
@@ -86,6 +88,8 @@ export interface RenamesAnswer {
export interface RenamedHolderEvent {
/** when, RFC 3339 */
"at": string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** the old name */
"from": string;
/** the module */
@@ -98,6 +102,8 @@ export interface RenamedHolderEvent {
export interface RetiringHolderEvent {
/** the ask's id */
"ask"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** the value's or secret's name */
"key": string;
"kind": "value" | "secret";
@@ -111,6 +117,8 @@ export interface RetiringHolderEvent {
export interface RetiredHolderEvent {
/** the ask's id */
"ask"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** the module */
"module": string;
/** the name */
@@ -121,6 +129,8 @@ export interface RetiredHolderEvent {
/** is one value of the state resolved under the key <node>.<module>.<key>. */
export interface ResolvedByNodeModuleKeyValue {
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"key": string;
"module": string;
"node": string;
+18
View File
@@ -117,6 +117,8 @@ export interface AssignmentsEventWarrant {
export interface AssignmentsEvent {
/** for assignments-withdrawn, why it ended */
"ended"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** for assignments-changed, by node the revisions before and after and the modules added, removed or changed */
"nodes"?: Record<string, unknown>[];
"proposal": Proposal;
@@ -212,6 +214,8 @@ export interface Proposal {
"by": string;
"changes": ProposalChange[];
"export-digest"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"hand-back"?: boolean;
"id": string;
"must"?: string[];
@@ -280,6 +284,8 @@ export interface SeatHoldersHoldersItem {
/** one key of seat-holders */
export interface SeatHolders {
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"holders": SeatHoldersHoldersItem[];
"node"?: string;
/** the claim names no seat of the seat list */
@@ -378,6 +384,8 @@ export interface PlacementInput {
/** is what placement answers. */
export interface PlacementAnswer {
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** one per branch and build, the nodes that run the module from it */
"placements": ModulePlacement[];
}
@@ -403,6 +411,8 @@ export interface AssignmentsByNodeNodeValueModulesItem {
/** is one value of the state assignments under the key <node>.node. */
export interface AssignmentsByNodeNodeValue {
"decided": NodeDecided;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"holds"?: Holding[];
/** the modules placed, in the order the composition reads them */
"modules": AssignmentsByNodeNodeValueModulesItem[];
@@ -413,6 +423,8 @@ export interface AssignmentsByNodeNodeValue {
/** is one value of the state assignments under the key <node>.<module>. */
export interface AssignmentsByNodeModuleValue {
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"node": string;
"placed": PlacedModule;
/** the value it replaces while a write is under way */
@@ -429,6 +441,8 @@ export interface CandidatesByProposalNodeValue {
"added"?: Record<string, AddedModule>;
/** the node's assignments with the proposal laid over it; absent when the proposal takes its key away */
"assignments"?: Assignments;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"proposal": string;
/** the proposal changes this node's composition through another's key */
"reached"?: boolean;
@@ -437,11 +451,15 @@ export interface CandidatesByProposalNodeValue {
/** is one value of the state pulses under the key answer.<proposal>.<node>. */
export interface PulsesByAnswerProposalNodeValue {
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"v"?: number;
}
/** is one value of the state pulses under the key ask.<proposal>. */
export interface PulsesByAskProposalValue {
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"v"?: number;
}
+28
View File
@@ -155,6 +155,8 @@ export interface SnapshotKeptAnswer {
"busy"?: string;
/** why it was not taken; set alone */
"error"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
}
/** is what restore-kept takes. */
@@ -183,6 +185,8 @@ export interface RestoreKeptAnswer {
"busy"?: string;
/** why it was not taken; set alone */
"error"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
}
/** is what kept-points takes. */
@@ -196,6 +200,8 @@ export interface KeptPointsInput {
/** is what kept-points answers. */
export interface KeptPointsAnswer {
"asides": Aside[];
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"points": Point[];
"running"?: Running;
/** the asides whose record ended at removed that no running act holds: the live data of those names is gone and only the aside holds it; the module's health check fails while one is listed (design 47 G 554, 657, A-129) */
@@ -224,6 +230,8 @@ export interface RestoreAsideAnswer {
"busy"?: string;
/** why it was not taken; set alone */
"error"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
}
/** is what cancel takes. */
@@ -244,6 +252,8 @@ export interface CancelAnswer {
"busy"?: string;
/** why not, naming the step an act has begun; set alone */
"error"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
}
/** is what take takes. */
@@ -268,6 +278,8 @@ export interface TakeAnswer {
"busy"?: string;
/** why it was not taken; set alone */
"error"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
}
/** is what restore takes. */
@@ -296,6 +308,8 @@ export interface RestoreAnswer {
"busy"?: string;
/** why it was not taken; set alone */
"error"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
}
/** is what retry takes. */
@@ -318,6 +332,8 @@ export interface RetryAnswer {
"busy"?: string;
/** why it was not taken; set alone */
"error"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
}
/** is what aside takes. */
@@ -340,6 +356,8 @@ export interface AsideAnswer {
"busy"?: string;
/** why it was not taken; set alone */
"error"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
}
/** is what discard-aside takes. */
@@ -364,6 +382,8 @@ export interface DiscardAsideAnswer {
"busy"?: string;
/** why it was not taken; set alone */
"error"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
}
/** is what expire-points takes. */
@@ -382,6 +402,8 @@ export interface ExpirePointsAnswer {
"busy"?: string;
/** why it was not taken; set alone */
"error"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
}
/** is the body of the event ended. */
@@ -447,6 +469,8 @@ export interface SetAsideEvent {
"act": string;
/** when it was said, RFC 3339 */
"at": string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"id": string;
/** the bus names it was live under, one per bus object */
"names": string[];
@@ -459,6 +483,8 @@ export interface AsideDiscardedEvent {
"act": string;
/** when it was said, RFC 3339 */
"at": string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"id": string;
/** the bus names it was live under, one per bus object */
"names": string[];
@@ -484,6 +510,8 @@ export interface ExpiryEndedEvent {
"act": string;
/** when it was said, RFC 3339 */
"at": string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** the number of points the run removed, 0 included */
"removed": number;
}
+62
View File
@@ -193,6 +193,8 @@ export interface ActSaid {
"ask"?: string;
/** the caller as the runtime proved it */
"caller": string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** the node whose engine says it */
"node": string;
/** what the engine said of it */
@@ -207,6 +209,8 @@ export interface ActSaid {
export interface Acts {
/** the acts, newest first */
"acts": Act[];
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** the node */
"node": string;
}
@@ -223,6 +227,8 @@ export interface Adoption {
export interface Asked {
/** the ask's id: acts shows where it stands */
"asked": string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** the node */
"node": string;
/** what happens next, in words */
@@ -297,6 +303,8 @@ export interface Composed {
"digest": string;
/** the fingerprint of the want composed */
"fingerprint": string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** the module */
"module": string;
/** the node */
@@ -408,6 +416,8 @@ export type ManifestReadWord = "want:version";
export interface ManifestReadsChanged {
/** when it says it, RFC 3339 */
"at": string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** what its engine states it reads now */
"manifest-reads"?: string[];
/** the node */
@@ -552,6 +562,8 @@ export interface ProcessBuild {
export interface ProcessBuilds {
/** why they could not be read */
"error"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** the node */
"node": string;
/** every process the node-engine started, by module */
@@ -618,6 +630,8 @@ export interface Running {
"at": string;
/** the fingerprint of the build it runs; none with stopped */
"fingerprint"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** the health of the build that runs, as the node-engine's have holds it from the module's declared check (ADR 0240); a running with none, said by a node-engine of before design 47 G, reads as healthy (design 47 G 520). SeatsToPassOn reads none of it: an unhealthy holder still holds its seat */
"healthy"?: boolean | null;
/** the digest of that build's manifest, the indexer's manifest of it, read by digest from the catalog half */
@@ -634,6 +648,8 @@ export interface Running {
/** the answer of a read-only judgement */
export interface Said {
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** the node */
"node": string;
/** the engine's judgement or search, one line per directory or program */
@@ -665,6 +681,8 @@ export interface SeatListStatus {
export interface SeatList {
/** why the read failed, for seat-list-again */
"error"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** the one line the engine says of it; empty when nothing waits */
"health": string;
"status": SeatListStatus;
@@ -718,6 +736,8 @@ export interface Wait {
"bound"?: string;
/** the time the bound counts from (design 47 G 266, 269, 498) */
"clock-from"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** the node waited on: the build node for a kept build; the subject's <node> is the node that says it */
"node"?: string;
/** what it waits on */
@@ -779,6 +799,8 @@ export interface RootFreeInput {
/** is what root-free answers. */
export interface RootFreeAnswer {
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** this machine's verdict */
"machines": RootVerdict[];
}
@@ -819,6 +841,8 @@ export interface PackagesAnswerKey {
/** is what packages answers. */
export interface PackagesAnswer {
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** the node's key as the bus holds it; absent when the engine wrote none */
"key"?: PackagesAnswerKey;
/** why the key could not be read */
@@ -958,6 +982,8 @@ export interface CompositionAnswer {
"composition": Revision;
/** every resource that differs from what runs, when asked */
"diff"?: Record<string, unknown>[];
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** what the module's have key says now; absent when it says nothing */
"have"?: CompositionAnswerHave;
/** the move from what runs to the composition read */
@@ -996,6 +1022,8 @@ export interface CompositionDiffInput {
/** is what composition-diff answers. */
export interface CompositionDiffAnswer {
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** the module */
"module": string;
/** the node */
@@ -1031,6 +1059,8 @@ export interface ComposeAnswerPass {
/** is what compose answers. */
export interface ComposeAnswer {
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** how the pass went */
"pass": ComposeAnswerPass;
/** the module whose apply was tried again */
@@ -1053,6 +1083,8 @@ export interface ComposeCandidateAnswer {
"candidate": string;
/** when asked with input and a call token: how many chunks of at most 512 KiB carry the composition input, sent on the chunk subject of the call, each acknowledged by the caller (design 47 G A-237b) */
"chunks"?: number;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** when asked without a call token: the composition input it composed from, inline, up to what one answer carries (the checker's form, kept until G removes the checker, G-6 section 321) */
"input"?: Record<string, unknown>;
/** every module placed on the node, sorted by name */
@@ -1076,6 +1108,8 @@ export interface ManifestReadsInput {
/** is what manifest-reads answers. */
export interface ManifestReadsAnswer {
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** the reader capabilities its engine states: the manifest words, forms and seat names it reads; empty for an engine built before it said them, read as the baseline */
"manifest-reads"?: string[];
/** the node */
@@ -1107,6 +1141,8 @@ export interface ApplyOrderAnswerOrderItem {
/** is what apply-order answers. */
export interface ApplyOrderAnswer {
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** one row per unapplied changed want, in the order it will be applied */
"order": ApplyOrderAnswerOrderItem[];
}
@@ -1153,6 +1189,8 @@ export interface FirstViewsAnswer {
"entries": FirstViewsAnswerEntriesItem[];
/** one status per owner and state followed, as mesh-sdk's views runtime keeps it */
"first-views": Record<string, unknown>[];
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** the wants the node-engine keeps (design 47 G 683, 698) */
"wants": FirstViewsAnswerWantsItem[];
}
@@ -1187,6 +1225,8 @@ export interface FirstViewAgainAnswerAsked {
export interface FirstViewAgainAnswer {
/** the hand ask written */
"asked": FirstViewAgainAnswerAsked;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** the verb that reads the status, first-views */
"read": string;
}
@@ -1217,6 +1257,8 @@ export interface EntryAgainAnswerAsked {
export interface EntryAgainAnswer {
/** the hand ask written */
"asked": EntryAgainAnswerAsked;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** the verb that reads the status, first-views */
"read": string;
}
@@ -1236,6 +1278,8 @@ export interface ConvergedInput {
/** is what converged answers. */
export interface ConvergedAnswer {
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** the kind of the firewall found, for an adopted node */
"found"?: string;
/** the links of this node that face outside, as the engine classifies them for its filter render (ADR 0140); an allowance with no interface never opens one */
@@ -1280,6 +1324,8 @@ export interface HaveByNodeModuleValue {
/** the digest of the composition the node runs */
"composed"?: string;
"detail"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
/** the fingerprint held */
"fp"?: string;
"handed"?: AccountsHanded;
@@ -1314,6 +1360,8 @@ export interface HaveByNodeNodeValue {
"composes"?: string;
"composes-why"?: string;
"filters"?: Record<string, unknown>[];
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"profile"?: Record<string, unknown>;
"record"?: NodeRecord;
"sealed"?: string[];
@@ -1329,6 +1377,8 @@ export interface ComposedByNodeModuleFingerprintValue {
"data"?: boolean;
/** the files the provisioner fills */
"filled_files"?: string[];
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"fp": string;
"module": string;
"node": string;
@@ -1349,6 +1399,8 @@ export interface ComposedByNodeNodeValue {
"data"?: boolean;
/** the files the provisioner fills */
"filled_files"?: string[];
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"node": string;
"own"?: NodeOwn;
/** the declaration resources, each saying its module */
@@ -1359,6 +1411,8 @@ export interface ComposedByNodeNodeValue {
/** is one value of the state data under the key <node>.<module>. */
export interface DataByNodeModuleValue {
"digest": string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"items": PlacedDataItem[];
"module": string;
"node": string;
@@ -1373,6 +1427,8 @@ export interface PackagesByNodeValuePackagesItem {
/** is one value of the state packages under the key <node>. */
export interface PackagesByNodeValue {
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"node": string;
"packages": PackagesByNodeValuePackagesItem[];
}
@@ -1383,6 +1439,8 @@ export interface HealthByNodeValue {
"at": string;
"contract"?: number;
"fallback"?: LoginFallback;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"found"?: NodeDirectory[];
"network"?: NetworkHealth;
"node": string;
@@ -1400,6 +1458,8 @@ export interface FindingsByKeyValue {
/** newest first, at most 10 */
"evidence"?: FindingEvidence[];
"explanation"?: string;
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"headline"?: string;
/** scope.id.token */
"key": string;
@@ -1426,6 +1486,8 @@ export interface FindingsByKeyValue {
/** is one value of the state bounds under the key <what>.<id>. */
export interface BoundsByWhatIDValue {
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
"form"?: number;
"module"?: string;
/** when the wait began, RFC 3339 */
"since": string;