From 7a6174bb3ed32741e11f9c6d2f8e63075db20bb1 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 13 Nov 2026 23:19:04 +0100 Subject: [PATCH] Reach an old objects entry by the store grants creates for it, not by a membership field (A-380) Builds: design 47 G A-380 (corrects A-379) Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h --- node-tools/internal/bus/bindings.go | 18 +++++++++++++----- node-tools/internal/bus/bindings_test.go | 5 ++--- node-tools/internal/bus/bus.go | 3 --- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/node-tools/internal/bus/bindings.go b/node-tools/internal/bus/bindings.go index 1a14a8c..4a13023 100644 --- a/node-tools/internal/bus/bindings.go +++ b/node-tools/internal/bus/bindings.go @@ -62,18 +62,22 @@ func (c *Conn) Bindings(module string) []membership.BusBinding { // A-16, A-27). func (c *Conn) JetStream() (jetstream.JetStream, error) { return jetstream.New(c.nc) } -// objectBucketOf is the bus name of the module's object store of a local name: its binding's when it has one, else the -// store its membership's old `objects` section names under the name grants created for it, `_` (design 47 G -// lead answers A-379); a name neither names is refused as the binding refuses it. +// objectBucketOf is the bus name of the module's object store of a local name: its binding's when it has one, else, for a +// name no binding of any type holds, the store grants creates for a module's old `objects` entry, `_` +// (catalogue.ObjectsBucket; design 47 G lead answers A-380): the bus's rights decide whether it is reached. A name bound +// with another storage type is refused as the binding refuses it. func (c *Conn) objectBucketOf(module, local string) (membership.BusBinding, error) { b, err := c.Binding(module, local, catalogue.StorageObjectStore) if err == nil { return b, nil } if m := c.Membership(module); m != nil { - if store := strings.TrimPrefix(m.Objects[local], "OBJ_"); store != "" { - return membership.BusBinding{Local: local, Storage: catalogue.StorageObjectStore, ObjectStore: store}, nil + for _, held := range m.Bindings { + if held.Local == local { + return b, err + } } + return membership.BusBinding{Local: local, Storage: catalogue.StorageObjectStore, ObjectStore: catalogue.ObjectsBucket(module, local)}, nil } return b, err } @@ -89,6 +93,10 @@ func (c *Conn) objectStore(ctx context.Context, module, local string) (jetstream } obs, err := js.ObjectStore(ctx, b.ObjectStore) if errors.Is(err, jetstream.ErrBucketNotFound) || errors.Is(err, jetstream.ErrStreamNotFound) { + if b.Template == "" { + return nil, b, fmt.Errorf("%s was bound no object-store called %q, and the store %s grants creates for an old `objects` entry of that name is not on the bus", + module, local, b.ObjectStore) + } return nil, b, fmt.Errorf("%s's objects %q are bound and their store %s is not on the bus", module, local, b.ObjectStore) } return obs, b, err diff --git a/node-tools/internal/bus/bindings_test.go b/node-tools/internal/bus/bindings_test.go index 0a100dd..6521fb5 100644 --- a/node-tools/internal/bus/bindings_test.go +++ b/node-tools/internal/bus/bindings_test.go @@ -50,7 +50,6 @@ func TestABundleReachesItsOwnBoundObjectsAndStreamsOnly(t *testing.T) { {Local: "events", Storage: catalogue.StorageStream, Template: catalogue.TemplateEvents, Stream: "m_events", Subject: "mesh.state.m.events"}, } - m.Objects = map[string]string{"old": "m_old"} // an old `objects` section grants created (design 47 G A-379) other := mt.MembershipOf("other", "anchor", false, nil) mesh.Issue(t, m) mesh.Issue(t, other) @@ -96,7 +95,7 @@ func TestABundleReachesItsOwnBoundObjectsAndStreamsOnly(t *testing.T) { if listed, err := conn.ObjectsList("m", buscalls.ObjectsRequest{Objects: "files"}); err != nil || len(listed.Objects) != 1 { t.Fatalf("listed %+v, %v", listed, err) } - // A-379: an old `objects` section the membership names is reached by its bus name, with no binding of that name. + // A-380: an old `objects` entry is reached by the store grants creates for it, `_`, with no binding of that name. if _, err := conn.ObjectsPut("m", buscalls.ObjectsPutRequest{Objects: "old", Name: "r", Data: []byte("old section")}); err != nil { t.Fatalf("put into the old objects section: %v", err) } @@ -132,7 +131,7 @@ func TestABundleReachesItsOwnBoundObjectsAndStreamsOnly(t *testing.T) { name, module, refusal string call func(module string) error }{ - {"a local name not bound", "m", `bound no object-store called "photos"`, func(module string) error { + {"a local name not bound", "m", `bound no object-store called "photos", and the store m_photos grants creates`, func(module string) error { _, err := conn.ObjectsGet(module, buscalls.ObjectsNameRequest{Objects: "photos", Name: "a"}) return err }}, diff --git a/node-tools/internal/bus/bus.go b/node-tools/internal/bus/bus.go index 28853d2..b0c0c04 100644 --- a/node-tools/internal/bus/bus.go +++ b/node-tools/internal/bus/bus.go @@ -64,9 +64,6 @@ type Membership struct { Tools string `json:"tools"` // State is every bucket the module's code may reach, by the name it uses (novox/hq ADR 0201). State []StateIssued `json:"state,omitempty"` - // Objects maps the name of each old `objects` section of the module to its object store (mesh-sdk membership.Objects, - // design 47 G ยง619), reached when no binding names it (bindings.go objectBucketOf, A-379). - Objects map[string]string `json:"objects,omitempty"` // Logs is every log the module keeps, by its local name (novox/hq ADR 0297): its own alone. Logs []LogIssued `json:"logs,omitempty"` // SeatTraffic is what the module's code may submit, say, take, ask, answer and read on seats that name