dialogreply

package
v0.0.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package dialogreply is the leeway-coded wire form of the file-dialog reply payload published on `fs.dialog.{op}` replies.

Vocabulary:

  • vdd.MembDialogApproved — narrow boolean (kept narrow vs. elevating to a shared `approved` term — see the fsbroker vdd file's rationale).
  • vdd.MembDialogHandleSubject — narrow string; the NATS subject prefix the caller's caps are scoped to on approval.
  • vdd.MembReason — shared, populated on denial and broker-side errors.

The Go-level [fsbroker.DialogReply] keeps its existing shape (Granted/HandleSubjectPrefix/Reason); this struct is the codec-side projection only. Conversion lives in `fsbroker.MarshalDialogReply` / `UnmarshalDialogReply`. New plain columns (FactId/At) are stamped at marshal time inside those helpers; the broker's existing API is unchanged.

Index

Constants

This section is empty.

Variables

View Source
var DialogReplyActiveFields = 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
})

DialogReplyActiveFields is the column-index subset this kind populates in the runtime.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.

View Source
var DialogReplyActiveSections = []int{1, 9, 12}

DialogReplyActiveSections 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.

View Source
var PackageProps = packageprops.Props{
	WASMWASI:         packageprops.WASMBlocked,
	WASMJS:           packageprops.WASMBlocked,
	WASMFreestanding: packageprops.WASMBlocked,
}

PackageProps records this package's curated properties (ADR-0080). Seeded by `wasmsurvey props generate`; curate by hand, then `wasmsurvey props verify`.

Functions

func DialogReplyBuildEntities

func DialogReplyBuildEntities[
	BoolAttr DialogReplyBoolAttrI,
	BoolSec DialogReplyBoolSecI[BoolAttr, Ent],
	StringArrayAttr DialogReplyStringArrayAttrI,
	StringArraySec DialogReplyStringArraySecI[StringArrayAttr, Ent],
	TextArrayAttr DialogReplyTextArrayAttrI,
	TextArraySec DialogReplyTextArraySecI[TextArrayAttr, Ent],
	Ent any,
	DML DialogReplyEntityI[
		BoolAttr, BoolSec,
		StringArrayAttr, StringArraySec,
		TextArrayAttr, TextArraySec,
		Ent,
	],
](dml DML, c *DialogReplyColumns) (err error)

DialogReplyBuildEntities 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 DialogReplyFillFromArrow

func DialogReplyFillFromArrow[
	BoolAttrs DialogReplyBoolAttrsReadI,
	BoolMembs DialogReplyBoolMembsReadI,
	StringArrayAttrs DialogReplyStringArrayAttrsReadI,
	StringArrayMembs DialogReplyStringArrayMembsReadI,
	TextArrayAttrs DialogReplyTextArrayAttrsReadI,
	TextArrayMembs DialogReplyTextArrayMembsReadI,
](
	c *DialogReplyColumns,
	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)

DialogReplyFillFromArrow 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 DialogReply

type DialogReply 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 user's accept/cancel decision (false also
	// covers broker-side errors with Reason populated).
	Approved bool `lw:"dialogApproved,bool"`

	// HandleSubjectPrefix is the NATS subject prefix the caller's
	// caps cover on approval. Empty on denial.
	HandleSubjectPrefix string `lw:"dialogHandleSubject,stringArray"`

	// Reason is the rationale (denial reason or broker error). Empty
	// on a successful approval.
	Reason string `lw:"reason,textArray"`
	// contains filtered or unexported fields
}

DialogReply is the flat wire form of a file-dialog reply.

type DialogReplyBoolAttrI

type DialogReplyBoolAttrI interface {
	dmlruntime.InAttributeMembershipLowCardRefPI
	EndAttributeP()
}

DialogReplyBoolAttrI 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 DialogReplyBoolAttrsReadI

type DialogReplyBoolAttrsReadI interface {
	GetAttrValueValue(entityIdx raruntime.EntityIdx, attrIdx raruntime.AttributeIdx) bool
	GetNumberOfAttributes(entityIdx raruntime.EntityIdx) int64
}

DialogReplyBoolAttrsReadI is the Attributes-side view of the bool section.

type DialogReplyBoolMembsReadI

type DialogReplyBoolMembsReadI interface {
	GetMembValueLowCardRef(entityIdx raruntime.EntityIdx, attrIdx raruntime.AttributeIdx) iter.Seq[uint64]
}

DialogReplyBoolMembsReadI is the Memberships-side view of the bool section.

type DialogReplyBoolSecI

type DialogReplyBoolSecI[Attr any, Ent any] interface {
	BeginAttribute(value bool) Attr
	EndSection() Ent
}

DialogReplyBoolSecI is the Section-side view: opens an attribute and closes the section. Attr and Ent are bound at the call site by inference.

type DialogReplyCodec

type DialogReplyCodec struct{}

DialogReplyCodec is the buscodec.CodecI bridge for DialogReply. 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 (*DialogReplyCodec) ContentType

func (inst *DialogReplyCodec) ContentType() (ct string)

func (*DialogReplyCodec) Decode

func (inst *DialogReplyCodec) Decode(b []byte, v any) (err error)

func (*DialogReplyCodec) Encode

func (inst *DialogReplyCodec) Encode(v any) (b []byte, err error)

func (*DialogReplyCodec) Name

func (inst *DialogReplyCodec) Name() (n string)

type DialogReplyColumns

type DialogReplyColumns struct {
	FactId     []uint64
	NaturalKey [][]byte
	At         []time.Time

	Approved            []bool
	HandleSubjectPrefix []string
	Reason              []string
}

DialogReplyColumns is the SoA storage for batches of DialogReply rows. All slices grow in lockstep — Len returns the row count.

func (*DialogReplyColumns) Append

func (c *DialogReplyColumns) Append(row DialogReply)

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 (*DialogReplyColumns) Len

func (c *DialogReplyColumns) Len() int

Len returns the number of rows currently in the batch.

func (*DialogReplyColumns) Marshal

func (c *DialogReplyColumns) 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 DialogReplyBuildEntities — the per-row chain lives there and works against any leeway-DML class that structurally satisfies DialogReplyEntityI.

func (*DialogReplyColumns) Row

func (c *DialogReplyColumns) Row(i int) (row DialogReply)

Row reconstructs entity i as an AoS DialogReply record. Inverse of Append: slice / pointer fields are shared by reference (no defensive copy); scalar fields and Option[T] are copied.

func (*DialogReplyColumns) Unmarshal

func (c *DialogReplyColumns) Unmarshal(rec arrow.Record) (err error)

Unmarshal appends one row to c per entity in rec, projecting the runtime.facts columns through factsschema/ra. Thin wrapper around DialogReplyFillFromArrow — the per-row decode lives there.

type DialogReplyEntityI

type DialogReplyEntityI[
	BoolAttr DialogReplyBoolAttrI,
	BoolSec DialogReplyBoolSecI[BoolAttr, Ent],
	StringArrayAttr DialogReplyStringArrayAttrI,
	StringArraySec DialogReplyStringArraySecI[StringArrayAttr, Ent],
	TextArrayAttr DialogReplyTextArrayAttrI,
	TextArraySec DialogReplyTextArraySecI[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)
}

DialogReplyEntityI lists exactly the entity-level methods DialogReply uses. Type parameters compose the per-section Attr + Sec interfaces; Ent is the entity type itself (return type of BeginEntity / SetId / SetTimestamp / SetLifecycle — usually the DML pointer).

type DialogReplyStringArrayAttrI

type DialogReplyStringArrayAttrI interface {
	dmlruntime.InAttributeMembershipLowCardRefPI
	EndAttributeP()
}

DialogReplyStringArrayAttrI 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 DialogReplyStringArrayAttrsReadI

type DialogReplyStringArrayAttrsReadI interface {
	GetAttrValueSingleOrDefault(entityIdx raruntime.EntityIdx, attrIdx raruntime.AttributeIdx) string
	GetNumberOfAttributes(entityIdx raruntime.EntityIdx) int64
}

DialogReplyStringArrayAttrsReadI is the Attributes-side view of the stringArray section.

type DialogReplyStringArrayMembsReadI

type DialogReplyStringArrayMembsReadI interface {
	GetMembValueLowCardRef(entityIdx raruntime.EntityIdx, attrIdx raruntime.AttributeIdx) iter.Seq[uint64]
}

DialogReplyStringArrayMembsReadI is the Memberships-side view of the stringArray section.

type DialogReplyStringArraySecI

type DialogReplyStringArraySecI[Attr any, Ent any] interface {
	BeginAttributeSingle(value string) Attr
	EndSection() Ent
}

DialogReplyStringArraySecI is the Section-side view: opens an attribute and closes the section. Attr and Ent are bound at the call site by inference.

type DialogReplyTextArrayAttrI

type DialogReplyTextArrayAttrI interface {
	dmlruntime.InAttributeMembershipLowCardRefPI
	EndAttributeP()
}

DialogReplyTextArrayAttrI 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 DialogReplyTextArrayAttrsReadI

type DialogReplyTextArrayAttrsReadI interface {
	GetAttrValueSingleOrDefault(entityIdx raruntime.EntityIdx, attrIdx raruntime.AttributeIdx) string
	GetNumberOfAttributes(entityIdx raruntime.EntityIdx) int64
}

DialogReplyTextArrayAttrsReadI is the Attributes-side view of the textArray section.

type DialogReplyTextArrayMembsReadI

type DialogReplyTextArrayMembsReadI interface {
	GetMembValueLowCardRef(entityIdx raruntime.EntityIdx, attrIdx raruntime.AttributeIdx) iter.Seq[uint64]
}

DialogReplyTextArrayMembsReadI is the Memberships-side view of the textArray section.

type DialogReplyTextArraySecI

type DialogReplyTextArraySecI[Attr any, Ent any] interface {
	BeginAttributeSingle(value string) Attr
	EndSection() Ent
}

DialogReplyTextArraySecI is the Section-side view: opens an attribute and closes the section. Attr and Ent are bound at the call site by inference.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL