From 71f8e548aa609ebe42482f033d54389bbff66851 Mon Sep 17 00:00:00 2001 From: jochen Date: Tue, 10 Nov 2026 16:38:39 +0100 Subject: [PATCH] O-5: C-S6: stateobjects.Sender and Receive, a reply or an event over the message limit sent as the reference of an object in the sender's store of sent objects (milestone 47/G, issue 1966, ADR 0666 section 16) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Builds: design 47 G §59, §407 Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ --- go/stateobjects/fakes_test.go | 4 + go/stateobjects/send.go | 93 ++++++++++++++++++++++ go/stateobjects/send_test.go | 68 ++++++++++++++++ go/stateobjects/values_integration_test.go | 20 +++++ 4 files changed, 185 insertions(+) create mode 100644 go/stateobjects/send.go create mode 100644 go/stateobjects/send_test.go diff --git a/go/stateobjects/fakes_test.go b/go/stateobjects/fakes_test.go index b0a6a534..60c454da 100644 --- a/go/stateobjects/fakes_test.go +++ b/go/stateobjects/fakes_test.go @@ -192,6 +192,7 @@ func (m *memory) serve(method string, raw json.RawMessage) (any, error) { Revision uint64 `json:"revision"` Name string `json:"name"` Data []byte `json:"data"` + Object string `json:"object"` } _ = json.Unmarshal(raw, &p) switch method { @@ -214,6 +215,9 @@ func (m *memory) serve(method string, raw json.RawMessage) (any, error) { case buscalls.ObjectsGet: d, err := m.Object(p.Name) return buscalls.ObjectData{Info: buscalls.ObjectInfo{Name: p.Name}, Data: d}, err + case buscalls.ObjectsSentGet: + d, err := m.Object(p.Object) + return buscalls.ObjectData{Info: buscalls.ObjectInfo{Name: p.Object}, Data: d}, err case buscalls.ObjectsDelete: return buscalls.Done{}, memObjects{m}.Delete(p.Name) case buscalls.ObjectsList: diff --git a/go/stateobjects/send.go b/go/stateobjects/send.go new file mode 100644 index 00000000..6420a2ed --- /dev/null +++ b/go/stateobjects/send.go @@ -0,0 +1,93 @@ +package stateobjects + +import ( + "encoding/json" + "fmt" + + stdio "git.novox.be/novox/mesh-sdk/go" + "git.novox.be/novox/mesh-sdk/go/buscalls" +) + +// MessageLimit is the most a message of the bus carries when the sender does not know its connection's own +// (`nc.MaxPayload()`), and MessageHeaderRoom what the headers and the subject take of it. +const ( + MessageLimit = 1 << 20 + MessageHeaderRoom = 8 << 10 +) + +// Sender sends the body of a verb's reply or an event: a body over the per-message limit is put in the sender's store of +// sent objects and its reference is sent instead (ADR 0666 §16). The store is the bus module's `_sent-objects`, +// granted to the sender alone and read by the callers its seat definition names and the consumers that declare the event; +// a sent object lives as long as that store's age, which is transport and not kept data. +type Sender struct { + // Objects is the sender's store of sent objects, and Store its name as a reader asks for it. + Objects Objects + Store string + // Limit is the connection's largest message; zero is MessageLimit. + Limit int +} + +// Send is what to send for body: the body itself when it fits, else the reference of the object it was put in as +// `