mesh/merge-gate head 1cc588ebc060 merged into trunk 1203f96a24c8 — pass: builds mesh-host → ace, g14, novox, shanks; no bus step; every machine composes wi…
mesh/repo-check head 1cc588ebc060 merged into trunk 1203f96a24c8 — pass: its merge-check.sh passed
mesh/delivery delivered
The provisioner (ADR 0349 §5) needs each file it places to say whether it is owned, a seed or managed, and the node-engine needs to know which paths it fills. The words map onto today's forms (drift written back, create-once, into), so no write changes; the reader accepts the fields and states OwnershipContract before any controller sends them. Issue 667. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
45 lines
2.1 KiB
Go
45 lines
2.1 KiB
Go
package validate
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// **The validator a controller imports is the host's**: a declaration the host takes passes, and one
|
|
// it refuses is refused with the host's own words, every problem at once.
|
|
func TestTheValidatorIsTheHosts(t *testing.T) {
|
|
good := `{"declaration": 1, "resources": [{"id": "d", "type": "directory", "path": "/var/lib/x", "mode": "0755"}]}`
|
|
if problems := Declaration([]byte(good)); problems != nil {
|
|
t.Fatalf("a declaration the host takes was refused: %v", problems)
|
|
}
|
|
// And one carrying the lease epoch and sequence the controller sends it under (novox/hq to-be 45
|
|
// §6): a controller validating with this package may send them.
|
|
ordered := `{"declaration": 1, "epoch": 57, "sequence": 3, "resources": [{"id": "d", "type": "directory", "path": "/var/lib/x", "mode": "0755"}]}`
|
|
if problems := Declaration([]byte(ordered)); problems != nil {
|
|
t.Fatalf("a declaration carrying its order was refused: %v", problems)
|
|
}
|
|
// And one carrying a file's owner-at-runtime and the files the provisioner fills (novox/hq ADR 0349 §5): the
|
|
// reader takes them before any controller sends them.
|
|
owned := `{"declaration": 1, "filled_files": ["/etc/x"], "resources": [{"id": "f", "type": "file", "path": "/etc/x", "content": "a", "owner-at-runtime": "owned"}]}`
|
|
if problems := Declaration([]byte(owned)); problems != nil {
|
|
t.Fatalf("a declaration saying who owns a file at runtime was refused: %v", problems)
|
|
}
|
|
for _, bad := range []string{
|
|
`{"declaration": 1, "filled_files": ["/etc/none"], "resources": [{"id": "f", "type": "file", "path": "/etc/x", "content": "a", "owner-at-runtime": "owned"}]}`,
|
|
`{"declaration": 1, "resources": []}`,
|
|
`{"declaration": 99, "resources": [{"id": "d", "type": "directory", "path": "/x"}]}`,
|
|
`{"declaration": 1, "resources": [{"id": "d", "type": "nothing-the-host-knows"}]}`,
|
|
`not json`,
|
|
} {
|
|
problems := Declaration([]byte(bad))
|
|
if len(problems) == 0 {
|
|
t.Errorf("a declaration the host refuses was passed: %s", bad)
|
|
}
|
|
for _, p := range problems {
|
|
if strings.TrimSpace(p) == "" {
|
|
t.Errorf("a problem said nothing, for %s", bad)
|
|
}
|
|
}
|
|
}
|
|
}
|