From bed9b61d5a39dd01ceae270c195c0629c1c6c80e Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 16:09:35 +0100 Subject: [PATCH 1/2] mesh-grants: the marks subtest calls on the caller's granted token and waits for its refusals MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The subtest "a runtime denied the marks is delivered no call on a marked subject" published the caller-named call on mesh.mod.shell.call.execute.asker~a, a token the composer never grants (buscompose.CallerToken gives a~asker for the user a.asker), so the server refused it every time; the test passed only because it read the refusals with a non-blocking select right after Flush, before the client's error callback had run. Under load the callback won the race and the pipeline's integration step failed (main.12, 15:50). The call now uses CallerToken, and a probe on another caller's token is published last: the server refuses in order, so waiting for the probe's refusal waits on every refusal asserted. Builds: design 47 H §746 (the pipeline's integration step), G A-203 (AM-D4) --- .../mesh-grants/composed_integration_test.go | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/modules/mesh-grants/cmd/mesh-grants/composed_integration_test.go b/modules/mesh-grants/cmd/mesh-grants/composed_integration_test.go index fb847a1f..d0e3ce52 100644 --- a/modules/mesh-grants/cmd/mesh-grants/composed_integration_test.go +++ b/modules/mesh-grants/cmd/mesh-grants/composed_integration_test.go @@ -647,19 +647,32 @@ func aRuntimeDeniedTheMarksHearsNoMarkedCall(t *testing.T) { t.Fatal(err) } asker, askerRefused := bus.dial("a.asker") - // The caller-named subject is process.Call's first: mesh.mod..call... - for _, subject := range []string{"mesh.mod.shell.tool.execute", "mesh.mod.shell.call.execute.asker~a", "mesh.mod.shell.tool.read"} { + // The caller-named subject is process.Call's first: mesh.mod..call.., the token the + // composer grants (buscompose.CallerToken: `a~asker` for the user a.asker). + for _, subject := range []string{"mesh.mod.shell.tool.execute", "mesh.mod.shell.call.execute." + buscompose.CallerToken("a.asker"), "mesh.mod.shell.tool.read"} { if err := asker.Publish(subject, []byte(`{}`)); err != nil { t.Fatal(err) } } + // The server says a refused publish asynchronously, in the order of the publishes: a probe the asker may not publish + // (another caller's token) is refused after every refusal of the calls above, so waiting for it waits on what is asserted. + const probe = "mesh.mod.shell.call.execute.a~someone" + if err := asker.Publish(probe, []byte(`{}`)); err != nil { + t.Fatal(err) + } if err := asker.Flush(); err != nil { t.Fatal(err) } - select { - case e := <-askerRefused: - t.Fatalf("the asker may not call: %s", e) - default: + for probed := false; !probed; { + select { + case e := <-askerRefused: + if !strings.Contains(e, `"`+probe+`"`) { + t.Fatalf("the asker may not call: %s", e) + } + probed = true + case <-time.After(5 * time.Second): + t.Fatal("the probe's refusal never came, so the calls' refusals are not known") + } } select { case m := <-heard: From ac95e5628cf0b38de5ef54083e703f3cc38b5bfb Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 16:11:14 +0100 Subject: [PATCH 2/2] mesh-grants: the test's stand-in nats_streams skips a consumer gone between its listing and its read MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Under load (8 copies side by side) TestTheGrantsPartWhole panicked at integration_test.go:151 at abb7cfcf too: st.Consumer's error was dropped and a consumer deleted after ConsumerNames listed it gave a nil one. Builds: design 47 H §746 (the pipeline's integration step) --- modules/mesh-grants/cmd/mesh-grants/integration_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/mesh-grants/cmd/mesh-grants/integration_test.go b/modules/mesh-grants/cmd/mesh-grants/integration_test.go index a7d41915..b64f7cdf 100644 --- a/modules/mesh-grants/cmd/mesh-grants/integration_test.go +++ b/modules/mesh-grants/cmd/mesh-grants/integration_test.go @@ -147,7 +147,10 @@ func TestTheGrantsPartWhole(t *testing.T) { consumers := []any{} names := st.ConsumerNames(ctx) for name := range names.Name() { - c, _ := st.Consumer(ctx, name) + c, err := st.Consumer(ctx, name) + if err != nil { + continue // deleted between the listing and its read: the bus module's tool lists what it can read + } cfg := c.CachedInfo().Config consumers = append(consumers, map[string]any{"name": name, "filters": cfg.FilterSubjects, "max_deliver": cfg.MaxDeliver}) }