Raise the declaration's Version to 2 for drain-bound; manifests state the Version read and written
Version is the declaration's form: drain-bound raises it by one, and a node-engine refuses only a higher one, so it still takes what a composer of version 1 writes. A manifest says declaration-reads (the node-engine's) and declaration-writes (the composer's), so the delivery plan can order the writer of a Version after every engine that reads it. Builds: design 47 H2 §813 (12), H-A-388 (2), H-A-358
This commit is contained in:
@@ -823,6 +823,13 @@ type Manifest struct {
|
||||
// no module): the bus and the provisioner and its client say it.
|
||||
CoreCredentials bool `json:"core-credentials,omitempty"`
|
||||
|
||||
// DeclarationReads is the declaration Version (declaration.Version) the node-engine this module is reads, and
|
||||
// DeclarationWrites the one the composer this module is writes (design 47 H2 §813 (12), H-A-388): the edge the delivery
|
||||
// plan derives orders the writer of a Version after every node's engine that reads it. Said by the module; zero for
|
||||
// one that is neither.
|
||||
DeclarationReads int `json:"declaration-reads,omitempty"`
|
||||
DeclarationWrites int `json:"declaration-writes,omitempty"`
|
||||
|
||||
// SecretsOwner is who the files holding this module's secrets belong to on the machine —
|
||||
// `uid:gid`, or a name — when its process is not root.
|
||||
//
|
||||
|
||||
@@ -67,7 +67,9 @@ func TestOwnManifestUsesNoWordTheRunningControllerRefuses(t *testing.T) {
|
||||
}
|
||||
for _, want := range []string{"word:tool-runner", "word:core-credentials", "word:bus-state", "word:bus-state.storage",
|
||||
// The reference form a registry seat answers (ADR 0605 §9), and the seats the registry milestone adds.
|
||||
ReadForm + ReferenceFormSeat, ReadForm + ReferenceFormSeatReach, "seat:go-package-registry", "seat:container-image-registry", "seat:oci-artifact-registry"} {
|
||||
ReadForm + ReferenceFormSeat, ReadForm + ReferenceFormSeatReach, "seat:go-package-registry", "seat:container-image-registry", "seat:oci-artifact-registry",
|
||||
// H-A-388: the declaration Version a node-engine reads and a composer writes, the delivery plan's edge.
|
||||
"word:declaration-reads", "word:declaration-writes"} {
|
||||
if !slices.Contains(added, want) {
|
||||
t.Errorf("%s is in the baseline, or not read: added since it are %v", want, added)
|
||||
}
|
||||
|
||||
@@ -26,9 +26,10 @@ import (
|
||||
"git.novox.be/novox/mesh-sdk/go/seal"
|
||||
)
|
||||
|
||||
// Version is the vocabulary this host speaks. A declaration naming any other version is
|
||||
// refused: an older host handed a newer vocabulary must not quietly do half of it.
|
||||
const Version = 1
|
||||
// Version is the vocabulary this host speaks, the declaration's form. A declaration naming a higher version is
|
||||
// refused: an older host handed a newer vocabulary must not quietly do half of it. A lower one is a part of this
|
||||
// vocabulary and is read. Version 2 carries a process's drain-bound (design 47 H2 §813 (12), H-A-358, H-A-388).
|
||||
const Version = 2
|
||||
|
||||
// Type names a kind of resource. Every addition widens what a compromised control plane can
|
||||
// express, so the list is a security artefact and grows deliberately.
|
||||
@@ -2361,7 +2362,7 @@ func parse(raw []byte, allowActions bool) (*Declaration, error) {
|
||||
return nil, &RefusalError{Problems: []string{"not a declaration: " + err.Error()}}
|
||||
}
|
||||
|
||||
if env.Version != Version {
|
||||
if env.Version < 1 || env.Version > Version {
|
||||
// Everything below assumes the vocabulary, so there is nothing further to say.
|
||||
return nil, &RefusalError{Problems: []string{fmt.Sprintf(
|
||||
"declaration version %d; this host speaks version %d. Refused whole rather than "+
|
||||
|
||||
@@ -2,6 +2,7 @@ package declaration
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
@@ -92,9 +93,22 @@ func testAnUnknownVersionIsRefusedWhole(t *testing.T) {
|
||||
{"id":"a","type":"directory","path":"/etc/mesh"}
|
||||
]}`)
|
||||
joined := strings.Join(refusal.Problems, "\n")
|
||||
if !strings.Contains(joined, "99") || !strings.Contains(joined, "version 1") {
|
||||
if !strings.Contains(joined, "99") || !strings.Contains(joined, "version 2") {
|
||||
t.Errorf("the version mismatch was not stated plainly: %v", refusal.Problems)
|
||||
}
|
||||
// Design 47 H2 §813 (12), H-A-388: Version is the declaration's form, raised to 2 by drain-bound; a lower one is a
|
||||
// part of this vocabulary and is read, so a node-engine that reads 2 takes what a composer of 1 still writes.
|
||||
for _, v := range []int{1, Version} {
|
||||
if _, err := Parse([]byte(fmt.Sprintf(`{"declaration":%d,"resources":[{"id":"a","type":"directory","path":"/etc/mesh"}]}`, v))); err != nil {
|
||||
t.Errorf("a declaration of version %d was refused: %v", v, err)
|
||||
}
|
||||
}
|
||||
if Version != 2 {
|
||||
t.Errorf("the declaration's Version is %d, want 2 (H-A-388)", Version)
|
||||
}
|
||||
if r := refusalFor(t, `{"declaration":0,"resources":[]}`); !strings.Contains(strings.Join(r.Problems, " "), "version 0") {
|
||||
t.Errorf("a declaration of version 0 was refused as %v", r.Problems)
|
||||
}
|
||||
// Nothing else is reported, because everything else assumes a vocabulary this host does
|
||||
// not have — a list of complaints derived from the wrong grammar is noise.
|
||||
if len(refusal.Problems) != 1 {
|
||||
|
||||
Reference in New Issue
Block a user