T1c verb-timeout-console: mesh_call waits the timeout its verb's definition names and says it
The console's surface holds the runner's seat definitions; a seat verb's call waits its `timeout`, and a timeout's text names the bound waited, not a fixed 30s. Builds: design 47 H §760, H-A-43 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
This commit is contained in:
@@ -927,10 +927,23 @@ func schemaWithoutNode(raw json.RawMessage) map[string]any {
|
||||
}
|
||||
|
||||
// answerText is a discovery verb's answer as MCP content: JSON, indented.
|
||||
// withinOf is how long a call of the target waits: the `timeout` its seat verb's definition names (design 47 H §760), else the
|
||||
// runner's own bound, RequestTimeout.
|
||||
func (s *Surface) withinOf(t target) time.Duration {
|
||||
if t.Seat && s.Definitions != nil {
|
||||
for _, v := range s.Definitions()[t.Tool.Module].Verbs {
|
||||
if v.Name == t.Tool.Name && v.Timeout != nil {
|
||||
return time.Duration(*v.Timeout) * time.Second
|
||||
}
|
||||
}
|
||||
}
|
||||
return bus.RequestTimeout
|
||||
}
|
||||
|
||||
// callFailed is why a call failed, as mesh_call says it: a marked tool or verb that reaches no responder names `withheld`
|
||||
// and the grants part's read (design 46 7-approval-mark §6), and a target known only from an earlier round says so.
|
||||
func (s *Surface) callFailed(t target, err error) string {
|
||||
why := whyItFailed(t.Address, err)
|
||||
why := whyItFailedWithin(t.Address, err, s.withinOf(t))
|
||||
if ok, _ := s.markedTool(t); ok && errors.Is(err, bus.ErrNoResponders) {
|
||||
// A marked subject withheld from a machine whose tool runner does not honour the mark (§6).
|
||||
why += "; it needs the operator's approval, so it may be withheld where the machine's tool runner does not state " +
|
||||
@@ -1147,7 +1160,7 @@ func (s *Surface) discover(ctx context.Context, name string, args map[string]any
|
||||
}
|
||||
var got bus.Answered
|
||||
if t.Seat {
|
||||
got, err = s.conn.Ask(t.Key, callArgs, "")
|
||||
got, err = s.conn.AskWithin(t.Key, callArgs, "", s.withinOf(t))
|
||||
} else {
|
||||
got, err = callTool(s.conn, t.Key, callArgs, nil, x.Listing)
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/nats-io/nats.go"
|
||||
|
||||
@@ -120,6 +121,11 @@ var (
|
||||
|
||||
// whyItFailed says why a call failed, so the remedy is in the words.
|
||||
func whyItFailed(key string, err error) string {
|
||||
return whyItFailedWithin(key, err, bus.RequestTimeout)
|
||||
}
|
||||
|
||||
// whyItFailedWithin is whyItFailed for a call that waited within, the bound its verb's definition names or the runner's own.
|
||||
func whyItFailedWithin(key string, err error, within time.Duration) string {
|
||||
if err == nil {
|
||||
err = errors.New("failed")
|
||||
}
|
||||
@@ -139,7 +145,7 @@ func whyItFailed(key string, err error) string {
|
||||
case timedOut.MatchString(msg):
|
||||
// **A timeout is not a failure** (novox/hq issue 265). Something took the call, so it may
|
||||
// still be running and may already have done what was asked: a push said this while it pushed.
|
||||
said := key + " did not answer within " + bus.RequestTimeout.String() + ". That is not a failure: " +
|
||||
said := key + " did not answer within " + within.String() + ". That is not a failure: " +
|
||||
"something is serving it, so it may still be running and may already have done what was " +
|
||||
"asked — check before repeating a call that changes the mesh."
|
||||
return said
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"encoding/json"
|
||||
"git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
|
||||
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
||||
"git.novox.be/novox/mesh-sdk/go/seatdef"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -65,6 +66,9 @@ type Surface struct {
|
||||
Record func(args map[string]any) error
|
||||
// Approvals is this machine's approval gate, read by mesh_approvals and mesh_describe; nil when the runner has none.
|
||||
Approvals Approvals
|
||||
// Definitions is the seat definitions this runner holds, by seat, which name a verb's `timeout` (design 47 H §760); nil when it
|
||||
// holds none, and a call then waits the runner's own bound.
|
||||
Definitions func() map[string]seatdef.Definition
|
||||
}
|
||||
|
||||
// MethodSeats is the console's JSON-RPC method beside MCP's that answers every seat's verbs and holders, in the shape
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"git.novox.be/novox/mesh-sdk/go/seatdef"
|
||||
"git.novox.be/novox/mesh-sdk/go/stateobjects"
|
||||
"github.com/nats-io/nats.go"
|
||||
"github.com/nats-io/nats.go/jetstream"
|
||||
@@ -74,6 +75,27 @@ func TestARefusalIsSaidOnlyForTheBussOwn(t *testing.T) {
|
||||
// the grammar's example, the handshake's instructions and a timeout's remedy named the controller's verbs.
|
||||
func TestATimeoutIsNotAFailure(t *testing.T) {
|
||||
got := whyItFailed("seat:mesh-delivery.deliveries", errors.New("timeout"))
|
||||
// Design 47 H §760: mesh_call waits the `timeout` the verb's definition names and a timeout says that bound; a verb naming none,
|
||||
// a module's tool and a surface holding no definitions wait and say the runner's own 30s.
|
||||
forty := 40
|
||||
s := &Surface{Definitions: func() map[string]seatdef.Definition {
|
||||
return map[string]seatdef.Definition{"mesh-broker": {Verbs: []seatdef.Verb{{Name: "rates", Timeout: &forty}, {Name: "plain"}}}}
|
||||
}}
|
||||
for _, row := range []struct {
|
||||
t target
|
||||
want string
|
||||
}{
|
||||
{target{Address: "mesh-broker.rates", Seat: true, Tool: Tool{Module: "mesh-broker", Name: "rates"}}, "within 40s"},
|
||||
{target{Address: "mesh-broker.plain", Seat: true, Tool: Tool{Module: "mesh-broker", Name: "plain"}}, "within 30s"},
|
||||
{target{Address: "mesh-broker.rates", Tool: Tool{Module: "mesh-broker", Name: "rates"}}, "within 30s"},
|
||||
} {
|
||||
if said := s.callFailed(row.t, errors.New("timeout")); !strings.Contains(said, row.want) {
|
||||
t.Errorf("%s: a timeout says %q, want it to say %q", row.t.Address, said, row.want)
|
||||
}
|
||||
}
|
||||
if said := (&Surface{}).callFailed(target{Seat: true, Tool: Tool{Module: "mesh-broker", Name: "rates"}}, errors.New("timeout")); !strings.Contains(said, "within 30s") {
|
||||
t.Errorf("a surface that holds no definitions says %q, want 30s", said)
|
||||
}
|
||||
for _, want := range []string{"not a failure", "may already have done"} {
|
||||
if !strings.Contains(got, want) {
|
||||
t.Errorf("a seat's timeout does not say %q: %s", want, got)
|
||||
|
||||
Reference in New Issue
Block a user