Main reverted G's half merge (#189, reverted by8afc3ebin #191) and then took the reader release's S1-S5, which copied G's code. G's form holds where they differ (process_bus.go, seats.go, state.go and their tests); the release's kept names stay so main's callers keep building: SeatViewPrefix beside SeatReadPrefix, and QueueInvoke's empty strings on not-ok (with its test TestQueueInvoke). The tree differs from G's headf30dee54only by those and the release's two tests (objects cap option, seat states and stream kinds). Builds: design 47 G (the milestone's sdk part, as atf30dee54) Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
38 lines
1.4 KiB
Go
38 lines
1.4 KiB
Go
package stdio
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// Design 47 G §576: the words are read once, an unknown-call answer reads as none, and a word not stated fails naming it
|
|
// and the node (from MESH_NODE).
|
|
func subACapabilityWordIsReadOnceAndNamedWhenNotStated(t *testing.T) {
|
|
t.Setenv("MESH_NODE", "ace")
|
|
asked := 0
|
|
var c capabilityWords
|
|
ask := func() (json.RawMessage, error) { asked++; return json.RawMessage(`{"words":["put-sessions"]}`), nil }
|
|
if err := c.require(CapPutSessions, ask); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
err := c.require(CapFindingCalls, ask)
|
|
if err == nil || !strings.Contains(err.Error(), CapFindingCalls) || !strings.Contains(err.Error(), "ace") || asked != 1 {
|
|
t.Errorf("a word not stated: %v after %d asks", err, asked)
|
|
}
|
|
var old capabilityWords
|
|
unknown := func() (json.RawMessage, error) {
|
|
asked++
|
|
return nil, &refused{message: "no mesh/capabilities", code: CodeNoMethod}
|
|
}
|
|
if err := old.require(CapPutSessions, unknown); err == nil || !strings.Contains(err.Error(), CapPutSessions) {
|
|
t.Errorf("a tool runner of before G stated %v", err)
|
|
}
|
|
var failing capabilityWords
|
|
if err := failing.require(CapPutSessions, func() (json.RawMessage, error) { return nil, errors.New("pipe closed") }); err == nil ||
|
|
!strings.Contains(err.Error(), "pipe closed") || failing.read {
|
|
t.Errorf("a failed read: %v, kept %v", err, failing.read)
|
|
}
|
|
}
|