From 3837f86eb6d439773320827f89c1325e3a296fc1 Mon Sep 17 00:00:00 2001 From: jochen Date: Thu, 8 Oct 2026 16:37:36 +0200 Subject: [PATCH] Read the kinds a module's membership names --- go/seat.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/go/seat.go b/go/seat.go index 7d44806..aa2f144 100644 --- a/go/seat.go +++ b/go/seat.go @@ -83,6 +83,40 @@ func SeatRecord(bucket, key string) (*StateEntry, error) { return &e, json.Unmarshal(raw, &e) } +// KindHeld is one kind of a kinded bench and who holds it, with what it promises (novox/hq ADR 0259 ยง5). +type KindHeld struct { + Seat string `json:"seat"` + Kind string `json:"kind"` + Module string `json:"module"` + Node string `json:"node"` + Capabilities []string `json:"capabilities,omitempty"` +} + +// Promises says whether this kind's claim declares a capability. +func (k KindHeld) Promises(capability string) bool { + for _, c := range k.Capabilities { + if c == capability { + return true + } + } + return false +} + +// SeatKinds is every kind of the kinded benches this module uses or watches, as the controller issued +// them in its membership: the one account of which channel is which, never a channel's own word. +func SeatKinds() ([]KindHeld, error) { + c, err := live() + if err != nil { + return nil, err + } + raw, err := c.ask("mesh/seat.kinds", map[string]any{}, seatTimeout) + if err != nil { + return nil, err + } + var out []KindHeld + return out, json.Unmarshal(raw, &out) +} + // Create writes a key only when it has none, and returns the revision; a key that has one is refused. func (s KeptState) Create(key string, value any) (uint64, error) { return s.revisionOf(s.ask("create", map[string]any{"key": key, "value": value}))