Documentation
¶
Overview ¶
Package grantreply is the leeway-coded wire form of the capability-grant reply payload. Sibling to keelson/runtime/codec/grantrequest; both opened the broker request/reply DTO cohort.
Vocabulary:
- vdd.MembGrantApproved — narrow, the policy decision (false ⇒ denied).
- vdd.MembGrantId — narrow, the broker-local grant identifier on approval. Empty string on denial.
- vdd.MembReason — shared, rationale either way (policy text on approval; error or denial reason on rejection).
Wire shape vs the legacy capbroker.GrantReply JSON form:
- `Granted` → `Approved` (the wire vocabulary names it `grantApproved`; the Go field follows). Same boolean semantics.
- New `FactId uint64` plain `id` and `At time.Time` plain `ts`.
Index ¶
- Variables
- func GrantReplyAddSections[BoolAttr GrantReplyBoolAttrI, BoolSec GrantReplyBoolSecI[BoolAttr, Ent], ...](dml DML, row GrantReply) (err error)
- func GrantReplyBuildEntities[BoolAttr GrantReplyBoolAttrI, BoolSec GrantReplyBoolSecI[BoolAttr, Ent], ...](dml DML, c *GrantReplyColumns) (err error)
- func GrantReplyEmitSectionBool[BoolAttr GrantReplyBoolAttrI, BoolSec GrantReplyBoolSecI[BoolAttr, Ent], ...](boolSec BoolSec, row GrantReply) (err error)
- func GrantReplyEmitSectionStringArray[StringArrayAttr GrantReplyStringArrayAttrI, ...](stringArraySec StringArraySec, row GrantReply) (err error)
- func GrantReplyEmitSectionTextArray[TextArrayAttr GrantReplyTextArrayAttrI, ...](textArraySec TextArraySec, row GrantReply) (err error)
- func GrantReplyFillFromArrow[BoolAttrs GrantReplyBoolAttrsReadI, BoolMembs GrantReplyBoolMembsReadI, ...](c *GrantReplyColumns, n int, idCol *array.Uint64, nkCol *array.Binary, ...) (err error)
- type GrantReply
- type GrantReplyBoolAttrI
- type GrantReplyBoolAttrsReadI
- type GrantReplyBoolMembsReadI
- type GrantReplyBoolSecI
- type GrantReplyCodec
- type GrantReplyColumns
- type GrantReplyEntityI
- type GrantReplyStringArrayAttrI
- type GrantReplyStringArrayAttrsReadI
- type GrantReplyStringArrayMembsReadI
- type GrantReplyStringArraySecI
- type GrantReplyTextArrayAttrI
- type GrantReplyTextArrayAttrsReadI
- type GrantReplyTextArrayMembsReadI
- type GrantReplyTextArraySecI
Constants ¶
This section is empty.
Variables ¶
var GrantReplyActiveFields = sync.OnceValue(func() []int { active := map[string]bool{"bool": true, "stringArray": true, "textArray": true} schema := cbdml.CreateSchemaFacts() out := make([]int, 0, 4+len(active)*8) for i, f := range schema.Fields() { name := f.Name switch { case strings.HasPrefix(name, "id:"), strings.HasPrefix(name, "ts:"), strings.HasPrefix(name, "lc:"): out = append(out, i) case strings.HasPrefix(name, "tv:"): rest := name[3:] colon := strings.IndexByte(rest, ':') if colon < 0 { continue } if active[rest[:colon]] { out = append(out, i) } } } return out })
GrantReplyActiveFields is the column-index subset this kind populates in the boxer.facts Arrow schema. Lazily computed once via sync.OnceValue: scans cbdml.CreateSchemaFacts()'s tv:<section>:... field names against this kind's active sections plus the three plain prefixes (id:, ts:, lc:). Driven through RecordBuilder. SetActiveFields to skip per-row emit walks for unused columns.
var GrantReplyActiveSections = []int{1, 9, 12}
GrantReplyActiveSections is the dml_cbor section-index subset this kind populates. Passed to InEntityFacts.SetActiveSections so the builder skips beginSection list-slot work for inactive sections.
var PackageProps = packageprops.Props{ WASMWASI: packageprops.WASMBlocked, WASMJS: packageprops.WASMBlocked, WASMFreestanding: packageprops.WASMBlocked, }
PackageProps records this package's curated properties (ADR-0080). Seeded by `boxer code analysis golang wasmsurvey props generate`; curate by hand. The same group's `props verify` reconciles it.
Functions ¶
func GrantReplyAddSections ¶ added in v0.0.17
func GrantReplyAddSections[ BoolAttr GrantReplyBoolAttrI, BoolSec GrantReplyBoolSecI[BoolAttr, Ent], StringArrayAttr GrantReplyStringArrayAttrI, StringArraySec GrantReplyStringArraySecI[StringArrayAttr, Ent], TextArrayAttr GrantReplyTextArrayAttrI, TextArraySec GrantReplyTextArraySecI[TextArrayAttr, Ent], Ent any, DML GrantReplyEntityI[ BoolAttr, BoolSec, StringArrayAttr, StringArraySec, TextArrayAttr, TextArraySec, Ent, ], ](dml DML, row GrantReply) (err error)
GrantReplyAddSections contributes this kind's tagged sections to the OPEN entity on dml — the BuildEntities body without the entity frame. The caller owns BeginEntity / plain setters / CommitEntity.
func GrantReplyBuildEntities ¶
func GrantReplyBuildEntities[ BoolAttr GrantReplyBoolAttrI, BoolSec GrantReplyBoolSecI[BoolAttr, Ent], StringArrayAttr GrantReplyStringArrayAttrI, StringArraySec GrantReplyStringArraySecI[StringArrayAttr, Ent], TextArrayAttr GrantReplyTextArrayAttrI, TextArraySec GrantReplyTextArraySecI[TextArrayAttr, Ent], Ent any, DML GrantReplyEntityI[ BoolAttr, BoolSec, StringArrayAttr, StringArraySec, TextArrayAttr, TextArraySec, Ent, ], ](dml DML, c *GrantReplyColumns) (err error)
GrantReplyBuildEntities walks c row-by-row, drives dml's entity / section chain, and returns once every row has been committed. The dml argument's concrete type binds every type parameter via Go's type inference at the call site.
func GrantReplyEmitSectionBool ¶ added in v0.0.20
func GrantReplyEmitSectionBool[ BoolAttr GrantReplyBoolAttrI, BoolSec GrantReplyBoolSecI[BoolAttr, Ent], Ent any, ](boolSec BoolSec, row GrantReply) (err error)
GrantReplyEmitSectionBool writes this kind's bool attributes into an ALREADY-OPEN section frame, and does not close it. The caller owns the frame: one kind's AddSections, or a builder deferring the close until every component that shares the section has written.
func GrantReplyEmitSectionStringArray ¶ added in v0.0.20
func GrantReplyEmitSectionStringArray[ StringArrayAttr GrantReplyStringArrayAttrI, StringArraySec GrantReplyStringArraySecI[StringArrayAttr, Ent], Ent any, ](stringArraySec StringArraySec, row GrantReply) (err error)
GrantReplyEmitSectionStringArray writes this kind's stringArray attributes into an ALREADY-OPEN section frame, and does not close it. The caller owns the frame: one kind's AddSections, or a builder deferring the close until every component that shares the section has written.
func GrantReplyEmitSectionTextArray ¶ added in v0.0.20
func GrantReplyEmitSectionTextArray[ TextArrayAttr GrantReplyTextArrayAttrI, TextArraySec GrantReplyTextArraySecI[TextArrayAttr, Ent], Ent any, ](textArraySec TextArraySec, row GrantReply) (err error)
GrantReplyEmitSectionTextArray writes this kind's textArray attributes into an ALREADY-OPEN section frame, and does not close it. The caller owns the frame: one kind's AddSections, or a builder deferring the close until every component that shares the section has written.
func GrantReplyFillFromArrow ¶
func GrantReplyFillFromArrow[ BoolAttrs GrantReplyBoolAttrsReadI, BoolMembs GrantReplyBoolMembsReadI, StringArrayAttrs GrantReplyStringArrayAttrsReadI, StringArrayMembs GrantReplyStringArrayMembsReadI, TextArrayAttrs GrantReplyTextArrayAttrsReadI, TextArrayMembs GrantReplyTextArrayMembsReadI, ]( c *GrantReplyColumns, n int, idCol *array.Uint64, nkCol *array.Binary, tsCol *array.Timestamp, boolAttrs BoolAttrs, boolMembs BoolMembs, stringArrayAttrs StringArrayAttrs, stringArrayMembs StringArrayMembs, textArrayAttrs TextArrayAttrs, textArrayMembs TextArrayMembs, ) (err error)
GrantReplyFillFromArrow walks rec row-by-row and appends each entity's plain + tagged-section values into c. Plain columns enter as concrete Arrow accessors; per-section Attrs + Membs bind through type-parameter interfaces.
Types ¶
type GrantReply ¶
type GrantReply struct {
// FactId is the per-row event id.
FactId uint64 `lw:",id"`
// NaturalKey is the entity natural key; the facts SetId is 2-arg.
// These bus DTOs carry no separate key, so it stays the nil default.
NaturalKey []byte `lw:",naturalKey"`
// At is the event timestamp. time.Time matches the facts
// SetTimestamp signature directly (strict 1:1); the leeway wire
// truncates to u32 seconds, while the bus preserves full nanos.
At time.Time `lw:",ts"`
// Approved carries the policy decision.
Approved bool `lw:"grantApproved,bool"`
// GrantId is the broker-local identifier on approval (decimal
// uint64-as-string). Empty on denial.
GrantId string `lw:"grantId,stringArray"`
// Reason is the rationale (policy text on approval; error
// message on denial). Shares the cross-DTO `reason` vocabulary
// entry.
Reason string `lw:"reason,textArray"`
// contains filtered or unexported fields
}
GrantReply is the wire form of a capability-grant reply. The Go-level [capbroker.GrantReply] keeps its existing shape (Granted/GrantId/Reason); this struct is the codec-side projection only.
func GrantReplyReadRow ¶ added in v0.0.17
func GrantReplyReadRow[ BoolAttrs GrantReplyBoolAttrsReadI, BoolMembs GrantReplyBoolMembsReadI, StringArrayAttrs GrantReplyStringArrayAttrsReadI, StringArrayMembs GrantReplyStringArrayMembsReadI, TextArrayAttrs GrantReplyTextArrayAttrsReadI, TextArrayMembs GrantReplyTextArrayMembsReadI, ]( i int, boolAttrs BoolAttrs, boolMembs BoolMembs, stringArrayAttrs StringArrayAttrs, stringArrayMembs StringArrayMembs, textArrayAttrs TextArrayAttrs, textArrayMembs TextArrayMembs, ) (row GrantReply, present bool, err error)
GrantReplyReadRow reads row i as one optional GrantReply component: presence- gated (a row carrying none of the kind's memberships yields present=false), membership-matched. A slot carrying more attributes than this kind's shape admits is an error, for every shape including containers. Plain- bound fields stay zero — the caller owns the envelope. The Attrs/Membs readers bind by type inference at the call site, as with FillFromArrow.
type GrantReplyBoolAttrI ¶
type GrantReplyBoolAttrI interface {
dmlruntime.InAttributeMembershipLowCardRefPI
EndAttributeP()
}
GrantReplyBoolAttrI is the InAttr-side view of the bool section. P-variants only — every method returns void so no F-bounded `[Self]` parameter is needed.
type GrantReplyBoolAttrsReadI ¶
type GrantReplyBoolAttrsReadI interface {
GetAttrValueValue(entityIdx raruntime.EntityIdx, attrIdx raruntime.AttributeIdx) bool
GetNumberOfAttributes(entityIdx raruntime.EntityIdx) int64
}
GrantReplyBoolAttrsReadI is the Attributes-side view of the bool section.
type GrantReplyBoolMembsReadI ¶
type GrantReplyBoolMembsReadI interface {
GetMembValueLowCardRef(entityIdx raruntime.EntityIdx, attrIdx raruntime.AttributeIdx) iter.Seq[uint64]
}
GrantReplyBoolMembsReadI is the Memberships-side view of the bool section.
type GrantReplyBoolSecI ¶
type GrantReplyBoolSecI[Attr any, Ent any] interface { BeginAttribute(value bool) Attr EndSection() Ent }
GrantReplyBoolSecI is the Section-side view: opens an attribute and closes the section. Attr and Ent are bound at the call site by inference.
type GrantReplyCodec ¶
type GrantReplyCodec struct{}
GrantReplyCodec is the buscodec.CodecI bridge for GrantReply. Encodes one row through dml_cbor; decodes via cborarrow.Convert + ra-Unmarshal + Row(0). Auto-registered in init() so callers using buscodec.Encode / Decode route through here instead of the CBOR fallback.
func (*GrantReplyCodec) ContentType ¶
func (inst *GrantReplyCodec) ContentType() (ct string)
func (*GrantReplyCodec) Name ¶
func (inst *GrantReplyCodec) Name() (n string)
type GrantReplyColumns ¶
type GrantReplyColumns struct {
FactId []uint64
NaturalKey [][]byte
At []time.Time
Approved []bool
GrantId []string
Reason []string
}
GrantReplyColumns is the SoA storage for batches of GrantReply rows. All slices grow in lockstep — Len returns the row count.
func (*GrantReplyColumns) Append ¶
func (c *GrantReplyColumns) Append(row GrantReply)
Append pushes one AoS record into the SoA buffers.
Aliasing: slice and pointer fields (`[]T`, `*roaring.Bitmap`) are stored by reference, not copied. Callers must not mutate row.<F> after Append unless they want Marshal to read the mutation. Scalar fields (T, Option[T]) are copied by value.
func (*GrantReplyColumns) Len ¶
func (c *GrantReplyColumns) Len() int
Len returns the number of rows currently in the batch.
func (*GrantReplyColumns) Marshal ¶
func (c *GrantReplyColumns) Marshal(w io.Writer) (err error)
Marshal writes the SoA buffer to w as the sparse-CBOR wire format produced through factsschema/dml_cbor. Thin wrapper around GrantReplyBuildEntities — the per-row chain lives there and works against any leeway-DML class that structurally satisfies GrantReplyEntityI.
func (*GrantReplyColumns) Row ¶
func (c *GrantReplyColumns) Row(i int) (row GrantReply)
Row reconstructs entity i as an AoS GrantReply record. Inverse of Append: slice / pointer fields are shared by reference (no defensive copy); scalar fields and Option[T] are copied.
type GrantReplyEntityI ¶
type GrantReplyEntityI[ BoolAttr GrantReplyBoolAttrI, BoolSec GrantReplyBoolSecI[BoolAttr, Ent], StringArrayAttr GrantReplyStringArrayAttrI, StringArraySec GrantReplyStringArraySecI[StringArrayAttr, Ent], TextArrayAttr GrantReplyTextArrayAttrI, TextArraySec GrantReplyTextArraySecI[TextArrayAttr, Ent], Ent any, ] interface { BeginEntity() Ent SetId(id uint64, naturalKey []byte) Ent SetTimestamp(ts time.Time) Ent GetSectionBool() BoolSec GetSectionStringArray() StringArraySec GetSectionTextArray() TextArraySec CommitEntity() (err error) }
GrantReplyEntityI is the entity-builder surface GrantReplyAddSections drives. It always lists the per-section getters; the entity-frame methods (BeginEntity / plain setters / CommitEntity) are added only for the full codec's BuildEntities. AddSections stacks sections onto a frame the caller already owns, so it needs none of them — which lets a store drive it with a builder whose frame control is unexported (ADR-0100 SD6). Ent is the builder pointer.
type GrantReplyStringArrayAttrI ¶
type GrantReplyStringArrayAttrI interface {
dmlruntime.InAttributeMembershipLowCardRefPI
EndAttributeP()
}
GrantReplyStringArrayAttrI is the InAttr-side view of the stringArray section. P-variants only — every method returns void so no F-bounded `[Self]` parameter is needed.
type GrantReplyStringArrayAttrsReadI ¶
type GrantReplyStringArrayAttrsReadI interface {
GetAttrValueSingle(entityIdx raruntime.EntityIdx, attrIdx raruntime.AttributeIdx) (string, error)
GetNumberOfAttributes(entityIdx raruntime.EntityIdx) int64
}
GrantReplyStringArrayAttrsReadI is the Attributes-side view of the stringArray section.
type GrantReplyStringArrayMembsReadI ¶
type GrantReplyStringArrayMembsReadI interface {
GetMembValueLowCardRef(entityIdx raruntime.EntityIdx, attrIdx raruntime.AttributeIdx) iter.Seq[uint64]
}
GrantReplyStringArrayMembsReadI is the Memberships-side view of the stringArray section.
type GrantReplyStringArraySecI ¶
type GrantReplyStringArraySecI[Attr any, Ent any] interface { BeginAttributeSingle(value string) Attr EndSection() Ent }
GrantReplyStringArraySecI is the Section-side view: opens an attribute and closes the section. Attr and Ent are bound at the call site by inference.
type GrantReplyTextArrayAttrI ¶
type GrantReplyTextArrayAttrI interface {
dmlruntime.InAttributeMembershipLowCardRefPI
EndAttributeP()
}
GrantReplyTextArrayAttrI is the InAttr-side view of the textArray section. P-variants only — every method returns void so no F-bounded `[Self]` parameter is needed.
type GrantReplyTextArrayAttrsReadI ¶
type GrantReplyTextArrayAttrsReadI interface {
GetAttrValueSingle(entityIdx raruntime.EntityIdx, attrIdx raruntime.AttributeIdx) (string, error)
GetNumberOfAttributes(entityIdx raruntime.EntityIdx) int64
}
GrantReplyTextArrayAttrsReadI is the Attributes-side view of the textArray section.
type GrantReplyTextArrayMembsReadI ¶
type GrantReplyTextArrayMembsReadI interface {
GetMembValueLowCardRef(entityIdx raruntime.EntityIdx, attrIdx raruntime.AttributeIdx) iter.Seq[uint64]
}
GrantReplyTextArrayMembsReadI is the Memberships-side view of the textArray section.
type GrantReplyTextArraySecI ¶
type GrantReplyTextArraySecI[Attr any, Ent any] interface { BeginAttributeSingle(value string) Attr EndSection() Ent }
GrantReplyTextArraySecI is the Section-side view: opens an attribute and closes the section. Attr and Ent are bound at the call site by inference.