The delivery SDK's enginereads, findings and heard leave for the clients of their seats (ADR 0634 sections 1 and 2, issue 1966)

Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i
This commit is contained in:
2026-11-05 19:22:05 +01:00
parent 828b5b1d38
commit 276e5e2aef
7 changed files with 994 additions and 1 deletions
@@ -0,0 +1,40 @@
package enginereads
import (
"strings"
"testing"
)
// The answer and the event are judged as the contract lays them out and its reader checks: the layout's version, a node
// that is a name, no empty capability, a time, and an event's why one of the two.
func TestTheAnswerAndTheEventAreJudged(t *testing.T) {
const at = "2026-11-05T12:00:00Z"
for name, c := range map[string]struct{ body, bad string }{
"whole": {`{"v":1,"node":"ace","manifest-reads":["mesh-config.resolved"],"stated-at":"` + at + `"}`, ""},
"old layout": {`{"v":2,"node":"ace","stated-at":"` + at + `"}`, "version"},
"bad node": {`{"v":1,"node":"a.b","stated-at":"` + at + `"}`, "no node"},
"empty read": {`{"v":1,"node":"ace","manifest-reads":[" "],"stated-at":"` + at + `"}`, "empty reader"},
"no time": {`{"v":1,"node":"ace","stated-at":"yesterday"}`, "RFC 3339"},
} {
_, _, err := DecodeAnswer([]byte(c.body))
if (c.bad == "") != (err == nil) || (err != nil && !strings.Contains(err.Error(), c.bad)) {
t.Errorf("answer %s: %v, want %q", name, err, c.bad)
}
}
for name, c := range map[string]struct{ body, bad string }{
"whole": {`{"v":1,"node":"ace","why":"started","manifest-reads":["a.b"],"at":"` + at + `"}`, ""},
"returned": {`{"v":1,"node":"ace","why":"returned","at":"` + at + `"}`, ""},
"old layout": {`{"v":2,"node":"ace","why":"started","at":"` + at + `"}`, "version"},
"no node": {`{"v":1,"node":"","why":"started","at":"` + at + `"}`, "no node"},
"another why": {`{"v":1,"node":"ace","why":"bored","at":"` + at + `"}`, "bored"},
"no time": {`{"v":1,"node":"ace","why":"started","at":"yesterday"}`, "RFC 3339"},
} {
_, err := DecodeChanged([]byte(c.body))
if (c.bad == "") != (err == nil) || (err != nil && !strings.Contains(err.Error(), c.bad)) {
t.Errorf("event %s: %v, want %q", name, err, c.bad)
}
}
if Verb != "manifest-reads" || Event != "manifest-reads-changed" || Consumes != "node-engine.manifest-reads-changed" || Invoke != "seat:node-engine.manifest-reads" {
t.Errorf("the names are %s %s %s %s", Verb, Event, Consumes, Invoke)
}
}