mesh/delivery merged: source.main moved to novox/mesh-sdk@27da949140c6
mesh/check being carried to 8afc3ebdf371 on 93e0a7b50d90 | from 27da949140c6
The group feat/47-G-join11 merged 3 of 17 members on 2026-11-13; G's mesh-sdk alone on main breaks 25 trunk
modules. The operator chose to put the order right: a reader release first, then G whole. This restores main
to 8fbba810 exactly.
Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
54 lines
2.2 KiB
Go
54 lines
2.2 KiB
Go
package catalogue
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// A module declares the state it keeps and the state it reads (novox/hq ADR 0201), a bucket by its
|
|
// bare name or with the owner's options.
|
|
func TestAManifestMaySayWhatStateItKeepsAndReads(t *testing.T) {
|
|
m, err := decodeForTest([]byte(`{"module":"claude-code","version":"1",` +
|
|
`"state":["servers",{"name":"seen","history":5,"ttl-seconds":3600}],` +
|
|
`"reads":["licence-manager.bindings"]}`))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(m.State) != 2 || m.State[0].Name != "servers" || m.State[1].History != 5 || m.State[1].TTLSeconds != 3600 {
|
|
t.Fatalf("state not read: %+v", m.State)
|
|
}
|
|
if len(m.Reads) != 1 || m.Reads[0] != "licence-manager.bindings" {
|
|
t.Fatalf("reads not read: %v", m.Reads)
|
|
}
|
|
// Written back as it came in: the short form where nothing else is said.
|
|
out, _ := json.Marshal(m.State)
|
|
if string(out) != `["servers",{"name":"seen","history":5,"ttl-seconds":3600}]` {
|
|
t.Fatalf("written back as %s", out)
|
|
}
|
|
}
|
|
|
|
// 1154/AC1: a state entry may say key-ttl; it is read, written back, and a bare name or an entry without it reads as before.
|
|
// G-sdk-contracts 4: read-only likewise, and given twice it is refused.
|
|
func TestAStateMayHaveKeysThatExpireOneByOne(t *testing.T) {
|
|
m, err := decodeForTest([]byte(`{"module":"mesh-delivery-watchman","version":"1",` +
|
|
`"state":[{"name":"pulse","key-ttl":true},"stuck",{"name":"seen","history":5},{"name":"spent","read-only":true}]}`))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !m.State[0].KeyTTL || m.State[1].KeyTTL || m.State[2].KeyTTL {
|
|
t.Fatalf("key-ttl not read as said: %+v", m.State)
|
|
}
|
|
if !m.State[3].ReadOnly || m.State[0].ReadOnly || m.State[1].ReadOnly {
|
|
t.Fatalf("read-only not read as said: %+v", m.State)
|
|
}
|
|
out, _ := json.Marshal(m.State)
|
|
if string(out) != `[{"name":"pulse","key-ttl":true},"stuck",{"name":"seen","history":5},{"name":"spent","read-only":true}]` {
|
|
t.Fatalf("written back as %s", out)
|
|
}
|
|
if _, err := decodeForTest([]byte(`{"module":"nats","version":"1","state":[{"name":"spent","read-only":true,"read-only":false}]}`)); err == nil ||
|
|
!strings.Contains(err.Error(), "the field state[0].read-only is given twice") {
|
|
t.Fatalf("read-only given twice: %v", err)
|
|
}
|
|
}
|