node-tools: a tool call names its caller, and the module is told it from the subject (hq issue 365)
mesh/merge-gate pass: builds mesh-tools, node-tools → ace, g14, novox, shanks; no bus step; every machine composes with the change as it did without (4 of …
mesh/repo-check pass: THE CHANGE ALTERS ITS OWN CHECK (merge-check.sh): main's version judged it; the change's judges the pull requests after it merges; it…
mesh/delivery-group group fix/365-a-tool-call-names-its-caller delivering: 0 of 4 delivered
mesh/delivery superseded: a newer head of the same pull request

Each tool and seat verb is also served on its caller-named subject, kind call
with the caller's bus user last, which the controller grants each user with its
own name alone; the runtime hands the module that caller in the call's _meta,
never from the body. Calls through the runtime (the console and modules'
invokes) ask the caller-named subject first and the old one only when the first
reached nobody: nothing serves it yet, or the bus refused it because the grant
is not delivered yet, which ends the call at once rather than after 30 s. The
old subjects stay served and say no caller for one release (hq issue 464).
This commit is contained in:
2026-10-11 05:19:08 +02:00
parent 6a6ed725c0
commit ab0f888d67
9 changed files with 642 additions and 13 deletions
+58
View File
@@ -0,0 +1,58 @@
package bus
import "testing"
// A call names its caller under the `call` kind, the caller's bus user its last token (novox/hq issue 365).
func TestACallerNamedSubjectIsTheToolsAddressUnderCallWithTheCallerLast(t *testing.T) {
for subject, want := range map[string]string{
"mesh.mod.ledger.tool.who": "mesh.mod.ledger.call.who.shanks~node-tools",
"mesh.mod.ledger.tool.who.anchor": "mesh.mod.ledger.call.who.anchor.shanks~node-tools",
"mesh.seat.issue-tracker.tool.open": "mesh.seat.issue-tracker.call.open.shanks~node-tools",
"mesh.seat.node-desk.tool.who.anchor": "mesh.seat.node-desk.call.who.anchor.shanks~node-tools",
"mesh.mod.ledger.event.opened": "",
"mesh.seat.intake.accept.ask.x": "",
"mesh.mod.ledger.tool.>": "",
"mesh.mod.*.tool.who": "mesh.mod.*.call.who.shanks~node-tools",
"mesh.node.anchor.ask.report": "",
"mesh.seat.operator-channel.proof.x.y": "",
} {
if subject == "mesh.mod.*.tool.who" {
continue // a wildcard is never asked on
}
if got := CalledSubject(subject, "shanks.node-tools"); got != want {
t.Errorf("%s → %q, want %q", subject, got, want)
}
}
for _, user := range []string{"", "a b", "x.*", "x.>", "a~b", "a..b"} {
if got := CalledSubject("mesh.mod.ledger.tool.who", user); got != "" {
t.Errorf("a caller %q that is not a bus user was named: %s", user, got)
}
}
}
// The caller is read back from the subject a call arrived on, and only under the pattern that names one.
func TestTheCallerIsTheLastTokenOfTheSubjectTheCallArrivedOn(t *testing.T) {
pattern := calledPattern("mesh.mod.ledger.tool.who.anchor")
if pattern != "mesh.mod.ledger.call.who.anchor.*" {
t.Fatalf("pattern %q", pattern)
}
for subject, want := range map[string]string{
"mesh.mod.ledger.call.who.anchor.shanks~node-tools": "shanks.node-tools",
"mesh.mod.ledger.call.who.anchor.controller": "controller",
"mesh.mod.ledger.call.who.anchor.person~jochen": "person.jochen",
"mesh.mod.ledger.call.who.anchor.a~~b": "",
"mesh.mod.ledger.call.what.anchor.controller": "",
} {
if got := callerOn(pattern, subject); got != want {
t.Errorf("%s → %q, want %q", subject, got, want)
}
}
if got := callerOn("mesh.mod.ledger.tool.who.anchor", "mesh.mod.ledger.tool.who.anchor"); got != "" {
t.Errorf("a call on the subject that names no caller was handed %q", got)
}
for _, user := range []string{"controller", "shanks.node-tools", "person.jochen", "node.ace"} {
if back := UserOfToken(CallerToken(user)); back != user {
t.Errorf("%s → %s → %s", user, CallerToken(user), back)
}
}
}