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
This commit is contained in:
2026-11-13 23:19:04 +01:00
parent faa1064214
commit 7a6174bb3e
3 changed files with 15 additions and 11 deletions
+13 -5
View File
@@ -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, `<module>_<name>` (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, `<module>_<name>`
// (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
+2 -3
View File
@@ -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, `<module>_<name>`, 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
}},
-3
View File
@@ -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