launchreply

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package launchreply is the leeway-coded wire form of the app-launch reply payload. Sibling to keelson/runtime/codec/launchrequest (ADR-0135 §SD1). Refusals travel as a reply with a Reason, never as a silent drop or a bare timeout.

Vocabulary:

  • vdd.MembTileKey — shared; the opened window's key. The window host writes the same value as TileKey on the app-lifecycle "started" row, so a launch reply joins its lifecycle row on one column.
  • vdd.MembReason — shared; empty on success, the refusal or failure rationale otherwise (unknown app, kind mismatch, oversize, malformed envelope, …).

Index

Constants

This section is empty.

Variables

View Source
var LaunchReplyActiveFields = sync.OnceValue(func() []int {
	active := map[string]bool{"textArray": true, "u64Array": 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
})

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

View Source
var LaunchReplyActiveSections = []int{12, 18}

LaunchReplyActiveSections 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 LaunchReplyAddSections

func LaunchReplyAddSections[
	U64ArrayAttr LaunchReplyU64ArrayAttrI,
	U64ArraySec LaunchReplyU64ArraySecI[U64ArrayAttr, Ent],
	TextArrayAttr LaunchReplyTextArrayAttrI,
	TextArraySec LaunchReplyTextArraySecI[TextArrayAttr, Ent],
	Ent any,
	DML LaunchReplyEntityI[
		U64ArrayAttr, U64ArraySec,
		TextArrayAttr, TextArraySec,
		Ent,
	],
](dml DML, row LaunchReply) (err error)

LaunchReplyAddSections 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 LaunchReplyBuildEntities

func LaunchReplyBuildEntities[
	U64ArrayAttr LaunchReplyU64ArrayAttrI,
	U64ArraySec LaunchReplyU64ArraySecI[U64ArrayAttr, Ent],
	TextArrayAttr LaunchReplyTextArrayAttrI,
	TextArraySec LaunchReplyTextArraySecI[TextArrayAttr, Ent],
	Ent any,
	DML LaunchReplyEntityI[
		U64ArrayAttr, U64ArraySec,
		TextArrayAttr, TextArraySec,
		Ent,
	],
](dml DML, c *LaunchReplyColumns) (err error)

LaunchReplyBuildEntities 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 LaunchReplyFillFromArrow

func LaunchReplyFillFromArrow[
	U64ArrayAttrs LaunchReplyU64ArrayAttrsReadI,
	U64ArrayMembs LaunchReplyU64ArrayMembsReadI,
	TextArrayAttrs LaunchReplyTextArrayAttrsReadI,
	TextArrayMembs LaunchReplyTextArrayMembsReadI,
](
	c *LaunchReplyColumns,
	n int,
	idCol *array.Uint64,
	nkCol *array.Binary,
	tsCol *array.Timestamp,
	u64ArrayAttrs U64ArrayAttrs,
	u64ArrayMembs U64ArrayMembs,
	textArrayAttrs TextArrayAttrs,
	textArrayMembs TextArrayMembs,
) (err error)

LaunchReplyFillFromArrow 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 LaunchReply

type LaunchReply 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"`

	// WindowKey is the key of the window the open created. Zero when
	// the open was refused. Shares the `tileKey` vocabulary term with
	// the app-lifecycle rows (the host records the same value there),
	// so launches join their lifecycle row directly.
	WindowKey uint64 `lw:"tileKey,u64Array"`

	// Reason carries the refusal or failure rationale. Empty on
	// success.
	Reason string `lw:"reason,textArray"`
	// contains filtered or unexported fields
}

LaunchReply is the flat wire form of an app-launch reply.

func LaunchReplyReadRow

func LaunchReplyReadRow[
	U64ArrayAttrs LaunchReplyU64ArrayAttrsReadI,
	U64ArrayMembs LaunchReplyU64ArrayMembsReadI,
	TextArrayAttrs LaunchReplyTextArrayAttrsReadI,
	TextArrayMembs LaunchReplyTextArrayMembsReadI,
](
	i int,
	u64ArrayAttrs U64ArrayAttrs,
	u64ArrayMembs U64ArrayMembs,
	textArrayAttrs TextArrayAttrs,
	textArrayMembs TextArrayMembs,
) (row LaunchReply, present bool, err error)

LaunchReplyReadRow reads row i as one optional LaunchReply 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 LaunchReplyCodec

type LaunchReplyCodec struct{}

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

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

func (*LaunchReplyCodec) Decode

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

func (*LaunchReplyCodec) Encode

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

func (*LaunchReplyCodec) Name

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

type LaunchReplyColumns

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

	WindowKey []uint64
	Reason    []string
}

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

func (*LaunchReplyColumns) Append

func (c *LaunchReplyColumns) Append(row LaunchReply)

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

func (c *LaunchReplyColumns) Len() int

Len returns the number of rows currently in the batch.

func (*LaunchReplyColumns) Marshal

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

func (*LaunchReplyColumns) Row

func (c *LaunchReplyColumns) Row(i int) (row LaunchReply)

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

func (*LaunchReplyColumns) Unmarshal

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

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

type LaunchReplyEntityI

type LaunchReplyEntityI[
	U64ArrayAttr LaunchReplyU64ArrayAttrI,
	U64ArraySec LaunchReplyU64ArraySecI[U64ArrayAttr, Ent],
	TextArrayAttr LaunchReplyTextArrayAttrI,
	TextArraySec LaunchReplyTextArraySecI[TextArrayAttr, Ent],
	Ent any,
] interface {
	BeginEntity() Ent
	SetId(id uint64, naturalKey []byte) Ent
	SetTimestamp(ts time.Time) Ent
	GetSectionU64Array() U64ArraySec
	GetSectionTextArray() TextArraySec
	CommitEntity() (err error)
}

LaunchReplyEntityI is the entity-builder surface LaunchReplyAddSections 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 LaunchReplyTextArrayAttrI

type LaunchReplyTextArrayAttrI interface {
	dmlruntime.InAttributeMembershipLowCardRefPI
	EndAttributeP()
}

LaunchReplyTextArrayAttrI 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 LaunchReplyTextArrayAttrsReadI

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

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

type LaunchReplyTextArrayMembsReadI

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

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

type LaunchReplyTextArraySecI

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

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

type LaunchReplyU64ArrayAttrI

type LaunchReplyU64ArrayAttrI interface {
	dmlruntime.InAttributeMembershipLowCardRefPI
	EndAttributeP()
}

LaunchReplyU64ArrayAttrI is the InAttr-side view of the u64Array section. P-variants only — every method returns void so no F-bounded `[Self]` parameter is needed.

type LaunchReplyU64ArrayAttrsReadI

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

LaunchReplyU64ArrayAttrsReadI is the Attributes-side view of the u64Array section.

type LaunchReplyU64ArrayMembsReadI

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

LaunchReplyU64ArrayMembsReadI is the Memberships-side view of the u64Array section.

type LaunchReplyU64ArraySecI

type LaunchReplyU64ArraySecI[Attr any, Ent any] interface {
	BeginAttributeSingle(value uint64) Attr
	EndSection() Ent
}

LaunchReplyU64ArraySecI 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