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:
2026-11-22 00:19:52 +01:00
parent 484e2bba3c
commit 134b111e3f
4 changed files with 30 additions and 6 deletions
+5 -4
View File
@@ -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 "+
+15 -1
View File
@@ -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 {