Read the kinds a module's membership names

This commit is contained in:
jochen
2026-10-09 13:58:27 +02:00
committed by jschoubben
parent 3d0c8b02b2
commit d7be28a1a9
+34
View File
@@ -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}))