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:
2026-11-20 02:37:41 +01:00
parent 618d8953ed
commit 5d88eecea9
5 changed files with 49 additions and 3 deletions
+1
View File
@@ -127,6 +127,7 @@ func main() {
} }
who := node + "." + cred.Module who := node + "." + cred.Module
surface := console.NewSurface(conn, source, who) surface := console.NewSurface(conn, source, who)
surface.Definitions = definitionsOf(seatList)
surface.Approvals = gateTools{Gate: gate, state: approvalsState{conn: conn, module: cred.Module}} surface.Approvals = gateTools{Gate: gate, state: approvalsState{conn: conn, module: cred.Module}}
up, err = console.Serve(surface, listen) up, err = console.Serve(surface, listen)
if err != nil { if err != nil {
+15 -2
View File
@@ -927,10 +927,23 @@ func schemaWithoutNode(raw json.RawMessage) map[string]any {
} }
// answerText is a discovery verb's answer as MCP content: JSON, indented. // 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` // 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. // 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 { 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) { 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). // 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 " + 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 var got bus.Answered
if t.Seat { if t.Seat {
got, err = s.conn.Ask(t.Key, callArgs, "") got, err = s.conn.AskWithin(t.Key, callArgs, "", s.withinOf(t))
} else { } else {
got, err = callTool(s.conn, t.Key, callArgs, nil, x.Listing) got, err = callTool(s.conn, t.Key, callArgs, nil, x.Listing)
} }
+7 -1
View File
@@ -6,6 +6,7 @@ import (
"fmt" "fmt"
"regexp" "regexp"
"strings" "strings"
"time"
"github.com/nats-io/nats.go" "github.com/nats-io/nats.go"
@@ -120,6 +121,11 @@ var (
// whyItFailed says why a call failed, so the remedy is in the words. // whyItFailed says why a call failed, so the remedy is in the words.
func whyItFailed(key string, err error) string { 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 { if err == nil {
err = errors.New("failed") err = errors.New("failed")
} }
@@ -139,7 +145,7 @@ func whyItFailed(key string, err error) string {
case timedOut.MatchString(msg): case timedOut.MatchString(msg):
// **A timeout is not a failure** (novox/hq issue 265). Something took the call, so it may // **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. // 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 " + "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." "asked — check before repeating a call that changes the mesh."
return said return said
+4
View File
@@ -8,6 +8,7 @@ import (
"encoding/json" "encoding/json"
"git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner" "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
"git.novox.be/novox/mesh-sdk/go/catalogue" "git.novox.be/novox/mesh-sdk/go/catalogue"
"git.novox.be/novox/mesh-sdk/go/seatdef"
"os" "os"
"strings" "strings"
"sync" "sync"
@@ -65,6 +66,9 @@ type Surface struct {
Record func(args map[string]any) error 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 is this machine's approval gate, read by mesh_approvals and mesh_describe; nil when the runner has none.
Approvals Approvals 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 // 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" "strings"
"testing" "testing"
"git.novox.be/novox/mesh-sdk/go/seatdef"
"git.novox.be/novox/mesh-sdk/go/stateobjects" "git.novox.be/novox/mesh-sdk/go/stateobjects"
"github.com/nats-io/nats.go" "github.com/nats-io/nats.go"
"github.com/nats-io/nats.go/jetstream" "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. // the grammar's example, the handshake's instructions and a timeout's remedy named the controller's verbs.
func TestATimeoutIsNotAFailure(t *testing.T) { func TestATimeoutIsNotAFailure(t *testing.T) {
got := whyItFailed("seat:mesh-delivery.deliveries", errors.New("timeout")) 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"} { for _, want := range []string{"not a failure", "may already have done"} {
if !strings.Contains(got, want) { if !strings.Contains(got, want) {
t.Errorf("a seat's timeout does not say %q: %s", want, got) t.Errorf("a seat's timeout does not say %q: %s", want, got)