From 5d88eecea9157047036959e1905ab1e076f583ed Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 02:37:41 +0100 Subject: [PATCH] T1c verb-timeout-console: mesh_call waits the timeout its verb's definition names and says it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- node-tools/cmd/node-tools/main.go | 1 + node-tools/internal/console/address.go | 17 ++++++++++++++-- node-tools/internal/console/client.go | 8 +++++++- node-tools/internal/console/mcp.go | 4 ++++ node-tools/internal/console/refusal_test.go | 22 +++++++++++++++++++++ 5 files changed, 49 insertions(+), 3 deletions(-) diff --git a/node-tools/cmd/node-tools/main.go b/node-tools/cmd/node-tools/main.go index 154455c..7e072b3 100644 --- a/node-tools/cmd/node-tools/main.go +++ b/node-tools/cmd/node-tools/main.go @@ -127,6 +127,7 @@ func main() { } who := node + "." + cred.Module surface := console.NewSurface(conn, source, who) + surface.Definitions = definitionsOf(seatList) surface.Approvals = gateTools{Gate: gate, state: approvalsState{conn: conn, module: cred.Module}} up, err = console.Serve(surface, listen) if err != nil { diff --git a/node-tools/internal/console/address.go b/node-tools/internal/console/address.go index 706f38c..dcf7ee3 100644 --- a/node-tools/internal/console/address.go +++ b/node-tools/internal/console/address.go @@ -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) } diff --git a/node-tools/internal/console/client.go b/node-tools/internal/console/client.go index dc1ef15..69d25df 100644 --- a/node-tools/internal/console/client.go +++ b/node-tools/internal/console/client.go @@ -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 diff --git a/node-tools/internal/console/mcp.go b/node-tools/internal/console/mcp.go index 57e4e8b..99f2a27 100644 --- a/node-tools/internal/console/mcp.go +++ b/node-tools/internal/console/mcp.go @@ -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 diff --git a/node-tools/internal/console/refusal_test.go b/node-tools/internal/console/refusal_test.go index 5d2111f..6316836 100644 --- a/node-tools/internal/console/refusal_test.go +++ b/node-tools/internal/console/refusal_test.go @@ -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)