From 3327f8679da6513155d86d05a239afc8cc2a1b78 Mon Sep 17 00:00:00 2001 From: jochen Date: Thu, 12 Nov 2026 10:22:48 +0100 Subject: [PATCH] A3h item 2a: Conn.Accept sends a seat's holder an accepted kind MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A process publishes on mesh.seat..accept.., its module the caller, as Emit publishes an event, so the gate's channel over a connection can ask and cancel through the seat operator-channel. Builds: design 47 G §677, §700; lead answers A-272, A-273 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h --- go/process/emit.go | 7 +++++++ go/process/emit_integration_test.go | 14 +++++++++++--- go/process/fixture_integration_test.go | 3 ++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/go/process/emit.go b/go/process/emit.go index a489afcf..1def5e8c 100644 --- a/go/process/emit.go +++ b/go/process/emit.go @@ -29,6 +29,13 @@ func (c *Conn) EmitSeat(seat, event string, body any, opts ...stdio.EmitOptions) return c.emitOn("mesh.seat."+seat+".event."+event, body, opts) } +// Accept sends the seat's holder an accepted kind (design 47 G §677, lead answer A-273): one call, publishing on +// mesh.seat..accept.., the caller being this process's module, with the same envelope, headers and +// message id as Emit. The grants part grants every user of a seat the publish of its accept subjects that name it. +func (c *Conn) Accept(seat, kind string, body any, opts ...stdio.EmitOptions) error { + return c.emitOn("mesh.seat."+seat+".accept."+kind+"."+c.account.Module, body, opts) +} + // emitOn publishes body on subject with the SDK's envelope. func (c *Conn) emitOn(subject string, body any, opts []stdio.EmitOptions) error { data, err := json.Marshal(body) diff --git a/go/process/emit_integration_test.go b/go/process/emit_integration_test.go index 46dc2036..7044d100 100644 --- a/go/process/emit_integration_test.go +++ b/go/process/emit_integration_test.go @@ -19,7 +19,7 @@ func TestEmitTwiceWithTheSameIDIsKeptToOneWithTheSDKsHeaders(t *testing.T) { account.Node = "novox" _, adminJetStream := adminJS(t, url) stream, err := adminJetStream.CreateStream(ctxFor(t), jetstream.StreamConfig{ - Name: "MAIL_EVENTS", Subjects: []string{"mesh.mod.mesh-mail.event.>", "mesh.seat.mail-sender.event.>"}, Duplicates: time.Minute, + Name: "MAIL_EVENTS", Subjects: []string{"mesh.mod.mesh-mail.event.>", "mesh.seat.mail-sender.event.>", "mesh.seat.mail-sender.accept.>"}, Duplicates: time.Minute, }) if err != nil { t.Fatalf("the admin could not make the events stream: %v", err) @@ -45,12 +45,20 @@ func TestEmitTwiceWithTheSameIDIsKeptToOneWithTheSDKsHeaders(t *testing.T) { t.Fatalf("the seat's event: %v, %v", m, err) } + // An accepted kind goes on mesh.seat..accept.., the caller this process's module (A-273). + if err := conn.Accept("mail-sender", "send", map[string]any{"send": "s2"}, stdio.EmitOptions{MessageID: "accept-s2"}); err != nil { + t.Fatalf("Accept: %v", err) + } + if m, err := stream.GetLastMsgForSubject(ctxFor(t), "mesh.seat.mail-sender.accept.send.mesh-mail"); err != nil || m.Header.Get("x-event-id") != "accept-s2" || m.Header.Get("x-source") != "mesh-mail" { + t.Fatalf("the accepted kind: %v, %v", m, err) + } + info, err := stream.Info(ctxFor(t)) if err != nil { t.Fatal(err) } - if info.State.Msgs != 2 { - t.Fatalf("the stream holds %d messages, want 2: one of the doubled publish, one of the seat's event", info.State.Msgs) + if info.State.Msgs != 3 { + t.Fatalf("the stream holds %d messages, want 3: one of the doubled publish, one of the seat's event, one accepted", info.State.Msgs) } msg, err := stream.GetMsg(ctxFor(t), 1) diff --git a/go/process/fixture_integration_test.go b/go/process/fixture_integration_test.go index ff69c644..99fde63f 100644 --- a/go/process/fixture_integration_test.go +++ b/go/process/fixture_integration_test.go @@ -39,7 +39,8 @@ var sendGrants = []string{ "mesh.mod.mesh-mail.event.mail.send.failed", "mesh.mod.mesh-mail.event.mail.send.sent", "mesh.mod.mesh-mail.event.states", - "mesh.seat.mail-sender.event.sent", // a held seat's event, said through Conn.EmitSeat (design 47 G A-10) + "mesh.seat.mail-sender.event.sent", // a held seat's event, said through Conn.EmitSeat (design 47 G A-10) + "mesh.seat.mail-sender.accept.send.mesh-mail", // a kind accepted by a seat, sent through Conn.Accept (A-273) "mesh.seat.operator-channel.call.tell.*.novox~mesh-mail~send", "mesh.seat.operator-channel.call.tell.novox~mesh-mail~send", "mesh.seat.operator-channel.tool.tell",