Copy the kept call's ask id from its request header into the call's _meta as mesh/ask

Every tool call and seat verb the tool runner serves hands the bundle the ask id the kept call set
in the header x-ask (stdio.AskHeader) under _meta mesh/ask (stdio.MetaAsk), beside mesh/call; a call
whose header carries none names none.

Builds: design 47 H2 §775, H-A-351
This commit is contained in:
2026-11-21 23:14:53 +01:00
parent f7269d9812
commit 2365e41811
9 changed files with 87 additions and 27 deletions
+9 -4
View File
@@ -20,6 +20,7 @@ import (
"encoding/json"
"errors"
"fmt"
stdio "git.novox.be/novox/mesh-sdk/go"
"git.novox.be/novox/mesh-sdk/go/membership"
"log"
"regexp"
@@ -626,7 +627,7 @@ type reply struct {
// answerOn answers one subject with one handler, and says which machine answered (ADR 0159).
func (c *Conn) answerOn(subject, queue string, h Handler) (func(), error) {
return c.answerCalledOn(subject, queue, func(_ string, body json.RawMessage) (any, error) { return h(body) })
return c.answerCalledOn(subject, queue, func(_, _ string, body json.RawMessage) (any, error) { return h(body) })
}
// answerCalledOn answers one subject, handing the handler the caller the subject a call arrived on names:
@@ -636,7 +637,11 @@ func (c *Conn) answerCalledOn(subject, queue string, h CalledHandler) (func(), e
cb := func(msg *nats.Msg) {
go func() {
var r reply
result, err := h(callerOn(subject, msg.Subject), json.RawMessage(msg.Data))
ask := ""
if msg.Header != nil {
ask = msg.Header.Get(stdio.AskHeader)
}
result, err := h(callerOn(subject, msg.Subject), ask, json.RawMessage(msg.Data))
// A call the runner's drain cut at its stop is answered nothing: its caller sees a transport fault (design 47 H2
// §813 (12)).
var unanswered interface{ Unanswered() bool }
@@ -695,7 +700,7 @@ func nullable(v any) any {
// HandleSubject answers a subject outright: a seat's verb where the mesh issued it.
func (c *Conn) HandleSubject(subject string, h Handler) (func(), error) {
return c.HandleSubjectCalled(subject, func(_ string, body json.RawMessage) (any, error) { return h(body) })
return c.HandleSubjectCalled(subject, func(_, _ string, body json.RawMessage) (any, error) { return h(body) })
}
// HandleSubjectCalled answers a tool subject and its caller-named counterpart (novox/hq issue 365): a call on
@@ -733,7 +738,7 @@ func (c *Conn) answerBoth(subject, queue string, h CalledHandler) (func(), error
// Handle serves `<module>.<tool>` where the mesh issued that module, and follows its membership:
// when a new one arrives, it serves where it now says and stops where it no longer does.
func (c *Conn) Handle(key string, h Handler) (func(), error) {
return c.HandleCalled(key, func(_ string, body json.RawMessage) (any, error) { return h(body) })
return c.HandleCalled(key, func(_, _ string, body json.RawMessage) (any, error) { return h(body) })
}
// HandleCalled is Handle telling the handler who called: the bus user a caller-named subject names, or "" for