vectors

package
v1.0.0-alpha.13 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package vectors is the one resolution of Request.Vectors: it turns each types.VectorSpec into its ordered member list against a schema, refusing malformed specs and unsupported member types with the PULSE_VECTOR_* codes.

It is NO-EXECUTE: it reads only the schema, never a record, and imports nothing but the standard library, errors, encoding, types and the parse-only internal/exprident (an expression's vector references). Predict (internal/descriptor), the runtime (internal/service, via the descriptor's field-reference pass) and projection (internal/processing.NeededFields) all call it, so the three cannot disagree about what a vector contains.

Resolution rules (the contract):

  • Vector names are non-empty, unique per request and never a schema field's name (an expression binds a named vector as an identifier beside the fields: PULSE_VECTOR_NAME_COLLISION; details.native when the field is a native vector field).
  • A native vector field (vec_f32 / vec_f64) is a vector with no spec: Resolve appends one Resolved per native field after the spec-backed ones, and a fields entry / glob / pattern naming one expands to its element members ("f[k]", 1-based) — see native.go.
  • Exactly one of Fields and Pattern is set.
  • A Fields entry without a glob metacharacter (`*`, `?`, `[`) is a literal member and keeps its position (caller order is axis order); a glob entry expands in place to every matching schema field, in schema order (path.Match semantics, whole-name). Pattern is a Go regular expression (unanchored) whose matches are taken in schema order.
  • A member repeated after expansion is refused; so is an empty resolution.
  • Members are integer (u4/u8/u16/u32/u64) or float (f32/f64) fields; packed_bool needs Coerce "binary"; categorical, set_*, date, datetime and decimal128 are refused naming the field.
  • Labels, when set, carry one entry per resolved member.
  • Kind, when set, is one of types.AllVectorKinds (unknown_kind); scale_min / scale_max are set only under kind "scale" (scale_bounds_without_scale_kind), together (scale_bounds_partial) and finite with min < max (scale_bounds_invalid).

Checks run spec by spec in request order; within one spec in the order: name, duplicate name, field-name collision, fields/pattern shape, coerce, kind and scale bounds, expansion (unknown literal, bad glob / regex, duplicate member), empty, member types, labels. The first failure is returned.

Index

Constants

View Source
const (
	// MahalanobisD2 is the default: the squared distance D².
	MahalanobisD2 = "d2"
	// MahalanobisP is the χ² upper tail of D² on p degrees of freedom.
	MahalanobisP = "p"
)

ATTR_MAHALANOBIS params.output values.

View Source
const (
	// FactorScoreRegression is the default: Thurstone's regression
	// scores, weights R⁻¹·S (S = LΦ, the structure).
	FactorScoreRegression = "regression"
	// FactorScoreBartlett is Bartlett's weighted least-squares scores,
	// weights U⁻²L(LᵀU⁻²L)⁻¹ (U² the uniquenesses).
	FactorScoreBartlett = "bartlett"
)

ATTR_FACTOR_SCORE params.method values.

View Source
const (
	// ReferenceValues: a literal array, one value per member in member
	// order.
	ReferenceValues = "values"
	// ReferenceLabelMap: an object of label → value, matched by label.
	ReferenceLabelMap = "label_map"
	// ReferenceTableKey: {table, key} — one registered profile.
	ReferenceTableKey = "table_key"
	// ReferenceTableKeyField: {table, key_field} — each row's own
	// profile, keyed by its key_field value (a categorical label, or an
	// unsigned integer's base-10 form).
	ReferenceTableKeyField = "table_key_field"
	// ReferenceCentroid: {centroid: {filter?, by?}} — the per-element
	// weighted mean of the filtered rows the centroid filter admits
	// (a pre-pass); with by, one centroid per by value, each row read
	// against its own key's.
	ReferenceCentroid = "centroid"
	// ReferencePopulation: {population: name} — a bound vector fit's
	// stored mean (a request / registered population or an in-batch
	// Compose vector fit), aligned by label.
	ReferencePopulation = "population"
	// ReferenceRecord: {record: {cohort?, keys}} — one stored record of
	// a cohort (the request's own when cohort is omitted), resolved by
	// a point lookup over the cohort's sidecar index before the
	// processor builds; its member columns are the reference.
	ReferenceRecord = "record"
)

The params.reference forms.

View Source
const (
	// KMeansDefaultMaxIter is params.max_iter's default: the Lloyd
	// iteration cap per start.
	KMeansDefaultMaxIter = 100
	// KMeansDefaultNInit is params.n_init's default: the number of
	// seeded k-means++ starts; the lowest within-SS wins.
	KMeansDefaultNInit = 10
	// KMeansDefaultSeed is the seed params.seed 0 (or absent) stands
	// for — fixed, never time-derived.
	KMeansDefaultSeed int64 = 20251011
)

GROUP_KMEANS params defaults.

View Source
const (
	PCAOnCorrelation = "correlation"
	PCAOnCovariance  = "covariance"
)

MAT_PCA params.on values.

View Source
const (
	RotationNone    = "none"
	RotationVarimax = "varimax"
	RotationPromax  = "promax"
	RotationOblimin = "oblimin"
	// RotationQuartimax is GPArotation::quartimax (orthogonal).
	RotationQuartimax = "quartimax"
	// RotationGeomin is GPArotation::geominQ (oblique, params.epsilon).
	RotationGeomin = "geomin"
	// RotationGeominOrthogonal is GPArotation::geominT (orthogonal,
	// params.epsilon).
	RotationGeominOrthogonal = "geomin_orthogonal"
	// RotationEntropy is GPArotation::entropy, minimum entropy
	// (orthogonal).
	RotationEntropy = "entropy"
)

Rotation criteria of the shared rotation engine (internal/processing/matrix_rotate.go). RotationNone is the explicit "no rotation" spelling of a params.rotation knob. Each criterion is orthogonal or oblique exactly as its R reference (stats::varimax / promax, GPArotation's wrapper of the same name); RotationOblique is the one classifier.

View Source
const (
	// FactorExtractionMinres is the minimum-residual fit (psych
	// fm = "minres"), the default.
	FactorExtractionMinres = "minres"
	// FactorExtractionPrincipalAxis is iterated principal axes (psych
	// fm = "pa").
	FactorExtractionPrincipalAxis = "principal_axis"
	// FactorExtractionML is Jöreskog's maximum-likelihood fit over the
	// uniquenesses (stats::factanal, psych fm = "ml"); it adds the
	// likelihood chi-square and the fit indices.
	FactorExtractionML = "ml"
)

MAT_FACTOR extraction methods (params.extraction). Each starts from the squared multiple correlations; the solvers live in internal/processing/matrix_factor.go and matrix_factor_ml.go.

View Source
const (
	// PCAComponentsFixed keeps exactly K components (an integer
	// params.components, 1 ≤ K ≤ p).
	PCAComponentsFixed = "fixed"
	// PCAComponentsKaiser keeps the components whose eigenvalue
	// exceeds 1 (params.components "kaiser"; the default on a
	// correlation, refused on a covariance, whose eigenvalues are in
	// the members' units).
	PCAComponentsKaiser = "kaiser"
	// PCAComponentsVariance keeps the fewest leading components whose
	// cumulative explained-variance share reaches Share
	// (params.components {"variance": share}, 0 < share ≤ 1).
	PCAComponentsVariance = "variance"
)

MAT_PCA retention rules (PCAComponents.Rule).

View Source
const (
	MissingListwise = "listwise"
	MissingPairwise = "pairwise"
)

Missing-data modes (params.missing).

View Source
const (
	CorrelationPearson  = "pearson"
	CorrelationSpearman = "spearman"
	CorrelationKendall  = "kendall"
)

Correlation methods (MAT_CORRELATION params.method).

View Source
const (
	// BucketBasisUngrouped: no Request.Groups — one result per spec.
	BucketBasisUngrouped = "ungrouped"
	// BucketBasisDictionary: GROUP_CATEGORY over a categorical field or
	// GROUP_SET_PER_ELEMENT over a set field — its dictionary size.
	BucketBasisDictionary = "dictionary"
	// BucketBasisBoolean: GROUP_CATEGORY over packed_bool — keys "0"
	// and "1".
	BucketBasisBoolean = "boolean"
	// BucketBasisInclude: Group.Include restricts the keys — its
	// distinct values (those the field can produce, when that is known).
	BucketBasisInclude = "include"
	// BucketBasisQuantileBins: GROUP_QUANTILE — its bin count
	// (Interval, default 4).
	BucketBasisQuantileBins = "quantile_bins"
	// BucketBasisClusters: GROUP_KMEANS — its cluster count params.k.
	BucketBasisClusters = "clusters"
	// BucketBasisUnknown: the grouper's keys depend on the data (ranges,
	// dates, numeric categories, set compositions) — no estimate.
	BucketBasisUnknown = "unknown"
	// BucketBasisProduct: two or more groupers, every one sized — the
	// product of their bounds (an upper bound on the observed
	// combinations).
	BucketBasisProduct = "product"
)

How a bucket estimate was derived (MatrixPredict.bucket_basis).

View Source
const (
	// ReferenceReasonTableUnknown: no table is registered under the name.
	ReferenceReasonTableUnknown = "table_unknown"
	// ReferenceReasonTableNotLiteral: a ref() table argument is not a
	// string literal, so its labels cannot be known before a row.
	ReferenceReasonTableNotLiteral = "table_not_literal"
	// ReferenceReasonKeyUnknown: the table has no profile under the key.
	ReferenceReasonKeyUnknown = "key_unknown"
	// ReferenceReasonLabelsDiffer: the reference's labels are not the
	// compared vector's label set.
	ReferenceReasonLabelsDiffer = "labels_differ"
	// ReferenceReasonUnlabeledPartner: a ref() is compared with a vector
	// that carries no labels (a literal array, an arbitrary expression),
	// so nothing can align it by label.
	ReferenceReasonUnlabeledPartner = "unlabeled_partner"
)

The PULSE_VECTOR_REFERENCE_UNKNOWN / _MISMATCH details.reason values.

View Source
const (
	SuggestAggregation = "AGG_VEC_MEAN"
	SuggestGrouper     = "GROUP_KMEANS"
)

Suggestions FieldNotScalar names in details.suggest: the vector operator that replaces a scalar aggregation or grouper slot.

View Source
const (
	// ScaleStatMean is the default: the mean of the valid items.
	ScaleStatMean = "mean"
	// ScaleStatSum is the PRORATED sum: the valid-item mean × the item
	// count (there is no raw sum — a skipped item never reads as 0).
	ScaleStatSum = "sum"
)

ATTR_SCALE_SCORE params.stat values.

View Source
const (
	// HotellingVariancePooled is the default: one covariance shared by
	// both samples (exact F).
	HotellingVariancePooled = "pooled"
	// HotellingVarianceUnequal is the Krishnamoorthy–Yu modified Nel–Van
	// der Merwe approximation (two-sample only; fractional df2).
	HotellingVarianceUnequal = "unequal"
)

TEST_HOTELLING_T2 params.variance values.

View Source
const (
	// MardiaSkewness is the default: the multivariate-skewness χ².
	MardiaSkewness = "skewness"
	// MardiaKurtosis is the multivariate-kurtosis z.
	MardiaKurtosis = "kurtosis"
)

TEST_MARDIA params.statistic values: the headline Statistic / DF / PValue. Both figures always ride Details.

View Source
const ControlAll = "all"

ControlAll is MAT_PARTIAL_CORRELATION's default params.control.

View Source
const DistanceDefaultMetric = "euclidean"

DistanceDefaultMetric is MAT_DISTANCE's params.metric default. The accepted names are the linalg/metric registry's MAT_DISTANCE consumer list (metric.Accepted(metric.ConsumerMatDistance)): there is no local metric list.

View Source
const FactorDefaultConfLevel = 0.9

FactorDefaultConfLevel is MAT_FACTOR's default params.conf_level, the coverage of the ml RMSEA interval: psych::fa's alpha = 0.1, a 90% interval.

View Source
const FactorDefaultKappa = 4

FactorDefaultKappa is MAT_FACTOR's default promax power (stats::promax m = 4).

View Source
const FactorsKaiser = "kaiser"

FactorsKaiser is MAT_FACTOR's params.factors "kaiser" (the default): as many factors as the correlation has eigenvalues above 1.

View Source
const FitOnFiltered = "filtered"

FitOnFiltered is params.fit_on's default: fit on every filtered row.

View Source
const GeominDefaultEpsilon = 0.01

GeominDefaultEpsilon is params.epsilon's default: GPArotation's geominQ / geominT delta = 0.01.

View Source
const InferenceDefaultAlpha = 0.05

InferenceDefaultAlpha is params.alpha's default: 95% intervals.

View Source
const ReferenceReasonLengthDiffers = "length_differs"

ReferenceReasonLengthDiffers is the PULSE_VECTOR_REFERENCE_MISMATCH reason of a literal reference whose length is not the member count.

View Source
const ReferenceReasonPopulationUnknown = "population_unknown"

ReferenceReasonPopulationUnknown is the PULSE_VECTOR_REFERENCE_UNKNOWN reason of a {population} reference naming no bound vector fit.

View Source
const ReferenceReasonRecordMembersAbsent = "record_members_absent"

ReferenceReasonRecordMembersAbsent is the PULSE_VECTOR_REFERENCE_MISMATCH reason of a {record} reference whose cohort lacks a member column (or holds it as a type no vector member may be).

View Source
const ReliabilityMinItems = 2

ReliabilityMinItems is the fewest members MAT_RELIABILITY takes: alpha compares at least two items.

View Source
const RepairNearest = "nearest"

RepairNearest is params.repair "nearest": a non-PSD input matrix is replaced by its nearest correlation matrix (Higham 2002, alternating projections with Dykstra's correction), scaled back to the input's diagonal, with a PULSE_MATRIX_NOT_PSD warning carrying the Frobenius adjustment.

Variables

View Source
var BuiltinArity = map[string][2]int{
	"dot": {2, 2}, "dist": {2, 2}, "cosine": {2, 2},
	"vnormalize": {2, 2}, "pow": {2, 2},
	"jaccard": {2, 2}, "dice": {2, 2}, "hamming": {2, 2}, "overlap": {2, 2},
	"ref": {2, 2},
}

BuiltinArity is each reserved built-in's [min, max] argument count; a reserved name absent here takes exactly one.

View Source
var PairLengthFuncs = map[string]bool{"dot": true, "dist": true, "cosine": true}

PairLengthFuncs are the pair built-ins whose two vector arguments must have equal length.

View Source
var VectorResultBuiltins = map[string]bool{
	"vcenter": true, "vzscore": true, "vnormalize": true, "ref": true,
}

VectorResultBuiltins names the built-ins that return a vector.

Functions

func AggregationColumns

func AggregationColumns(req *types.Request, schema func() *encoding.Schema, kinds AggregationKinds) func(i int) ([]string, bool)

AggregationColumns is the column lister a series overlay host hands seriesfield (seriesfield.Columns): for aggregation i of req.Aggregations, the Response.Data columns it writes — AggregationOutputColumns over the schema schema returns (called at most once, and only for an expanding slot; nil: none). With no schema an expanding slot's columns are still known when it carries its element labels inline (fields + params.labels — the prepared slot AggregationSlotRewrite hands the runtime, whose labels are the columns' element labels); otherwise known is false. A slot that does not expand writes its label (known). Predict and the runtime build it the same way, so an element column resolves identically.

func AggregationExpands

func AggregationExpands(a *types.Aggregation, kinds AggregationKinds) bool

AggregationExpands reports whether a is an array-valued vector aggregation (a built-in, or an extension declared VectorInput and ArrayValued — kinds) whose params set expand (a params blob that does not decode never expands — the resolver refuses it).

func AggregationInputMembers

func AggregationInputMembers(req *types.Request, schema *encoding.Schema) (members []string, ok bool)

AggregationInputMembers returns the union of every field req's aggregation slots read through inline fields (a named vector's members ride Members(req)), and whether every one resolved — projection decodes wide otherwise.

func AggregationOutputColumns

func AggregationOutputColumns(req *types.Request, a *types.Aggregation, schema *encoding.Schema, kinds AggregationKinds) ([]string, bool)

AggregationOutputColumns returns the Response.Data columns slot a of req emits over schema: its label (types.AggregationLabelOf unless Label is set), or — on an expanding vector aggregation (AggregationExpands under kinds) — one ExpandedColumn per member in member order, the label itself absent. The second result is false when an expanding slot's members do not resolve (the resolver refuses the request); the label is returned then. Predict (return planning, chain stage columns, the per-slot columns) and the field-reference walk share it, so they name the columns the runtime writes.

func AggregationSlotRewrite

func AggregationSlotRewrite(a *types.Aggregation, in AggregationInput) *types.Aggregation

AggregationSlotRewrite is the slot a vector aggregator's factory receives: a copy with Label the default label when empty (computed from the slot as written), Vector cleared, Fields = the resolved literal members and params.labels = the resolved display labels — so a named vector's labels survive the literal-member rewrite. An extension's slot keeps every other params key (the operator's own). The caller's slot is never mutated.

func AlignFit

func AlignFit(key, slot, fit string, fitLabels, labels []string) ([]int, *errors.CodedError)

AlignFit aligns a bound vector fit's labels (fitLabels, the fit named fit) to a slot's member labels: perm[i] is the index, in fitLabels, of labels[i]. Unequal label sets are PULSE_VECTOR_REFERENCE_MISMATCH reason labels_differ (the reference Match rule) naming the fit under details.fit and the slot under details[key] (key "attribute" or "matrix"), the message prefixed with slot.

func AnyAggregationVectorInput

func AnyAggregationVectorInput(req *types.Request) bool

AnyAggregationVectorInput reports whether any aggregation slot of req sets vector or fields (allocation-free).

func ArrayValuedCrosstabRefusal

func ArrayValuedCrosstabRefusal(spec *types.CrosstabSpec, kinds AggregationKinds) *errors.CodedError

ArrayValuedCrosstabRefusal is the crosstab gate for an array-valued aggregator (AggregationKinds.IsArrayValued — a built-in or a declared ArrayValued extension) as the cell or a margin aggregation: PROCESSING_CONFIG {aggregation, slot, reason: "array_valued"}, whatever normalize says — a cell holds one number. The one exception is a slot selecting one element (SelectsElement: a built-in AGG_VEC_* with params.element), which is a scalar. kinds is the instance's view; nil when no slot is array-valued. processing.validateCrosstabSpec (both arms) and predict call it, so they refuse identically.

func AttributeFit

func AttributeFit(typ types.AttributeType, a *types.Attribute) string

AttributeFit returns a's params.fit — the bound vector fit a fitted attribute (or a fitted-metric comparison) scores against — when a's route typ is a vector-input attribute; "" when absent, empty, for any other type, or when the params do not decode (those are refused elsewhere). The field-reference walk judges the name against the bound fits (internal/model.CheckVectorFit).

func AttributeFitLabels

func AttributeFitLabels(typ types.AttributeType, a *types.Attribute, members Resolved, schema *encoding.Schema) ([]string, bool)

AttributeFitLabels returns the labels a fitted attribute slot (route typ, resolved members) aligns a bound vector fit to — the labels the engine's bind aligns: a fitted attribute's FittedLabels, a comparison slot's ComparisonParams labels — and false when they do not resolve (that refusal is the slot resolution's) or typ reads no fit.

func AttributeFitOn

func AttributeFitOn(typ types.AttributeType, a *types.Attribute) []*types.Filterer

AttributeFitOn returns a's decoded params.fit_on filterers when a's route typ is a vector-input attribute (nil for "filtered", a non-vector type, or params that do not decode — those are refused elsewhere), and — a comparison slot — its centroid reference's filter after them (ComparisonCentroidFilter). Projection, the field-reference walk and the two-pass planner read it to learn which columns the pre-pass predicates read.

func AttributeInputMembers

func AttributeInputMembers(req *types.Request, schema *encoding.Schema) (members []string, ok bool)

AttributeInputMembers returns the union of every field req's attributes read through inline fields (a named vector's members ride Members(req)) plus every comparison slot's params.reference key_field (ComparisonKeyField — a row whose key column did not decode would read as a missing profile), and whether every one resolved — projection decodes wide otherwise.

func ChainStageSchema

func ChainStageSchema(req *types.Request, in *encoding.Schema, kinds AggregationKinds) (*encoding.Schema, *errors.CodedError)

ChainStageSchema is the one synthesised schema a later ProcessChain stage reads the stage req's output rows through — the runtime's processing.ChainOutputSchema and predict's synthChainSchema both build it here, so the next stage's field references, defaults and gate see the same columns on both sides. in is the schema req itself executes over (its INPUT: the cohort's or joined schema for stage 0, else the one synthesised from the stage before it); kinds is the instance's aggregation view.

Layout, in order:

  • One categorical_u32 field per Group entry, named by its key column (GroupKeyField — the Data row key the stage writes), with an empty Dictionary the runtime fills as rows materialise; a repeated key is listed once.
  • One f64 field per aggregation output column (AggregationOutputColumns): the label, or — on an expanding vector aggregation — one "<label>[<element label>]" column per member in member order, the label itself absent (the row writer writes no array). An element column is an ordinary nullable f64 column there: an element no row answered (NaN) is a null.

A non-expanding array-valued or non-scalar aggregation never feeds a later stage (mergegate.StageArrayValuedRefusal), so its label is listed but never read.

The error is the first aggregation column colliding with an earlier column (a group key or another aggregation's column): PROCESSING_CONFIG {column, aggregation_index, aggregation}. The schema is still complete (the colliding column listed once) so a caller that only reports — predict — keeps judging the next stage.

func CodeFieldTypes

func CodeFieldTypes(schema *encoding.Schema, codes map[string]encoding.FieldType) func(field string) (encoding.FieldType, bool)

CodeFieldTypes is the field-type lookup a code judgement reads over schema plus the code columns a chain stage inherited: a code column answers the type it is a code of, every other schema field its own type. Nil for a nil schema.

func ComparisonCentroid

func ComparisonCentroid(typ types.AttributeType, a *types.Attribute) bool

ComparisonCentroid reports whether comparison slot a (route typ) compares with a centroid — a reference the pre-pass folds, so the slot is two-pass for either operator and any metric (ComparisonTwoPass).

func ComparisonCentroidFilter

func ComparisonCentroidFilter(typ types.AttributeType, a *types.Attribute) []*types.Filterer

ComparisonCentroidFilter returns a centroid reference's decoded filter (nil when absent, for any other reference, or when it does not decode — refused elsewhere). AttributeFitOn folds it in beside fit_on: both are pre-pass predicates over the attribute-step record.

func ComparisonConsumer

func ComparisonConsumer(t types.AttributeType) (metric.Consumer, metric.Form, types.AttributeType)

ComparisonConsumer returns the registry consumer comparison type t resolves its metric as, the form it asks for, and the operator that serves the other direction.

func ComparisonFitted

func ComparisonFitted(typ types.AttributeType, a *types.Attribute, specs []types.VectorSpec, schema *encoding.Schema) bool

ComparisonFitted reports whether attribute a (route typ) is an ATTR_VEC_DISTANCE slot over a fitted metric (std_euclidean, mahalanobis) — the per-attribute two-pass predicate. The metric is params.metric, else the kind default of the vector a names in specs (before Processor.prepare's rewrite writes it out); params that do not decode report false (refused elsewhere).

func ComparisonKeyField

func ComparisonKeyField(typ types.AttributeType, a *types.Attribute) string

ComparisonKeyField returns the column a comparison slot's params.reference keys each row by — a {table, key_field}'s key_field or a centroid's by — ("" for any other slot or reference form, or params that do not decode). Projection and the two-pass planner read it: the column must decode beside the members.

func ComparisonKeyFieldAccepts

func ComparisonKeyFieldAccepts(ft encoding.FieldType) bool

ComparisonKeyFieldAccepts reports whether ft may be a key_field.

func ComparisonKeyFieldInteger

func ComparisonKeyFieldInteger(ft encoding.FieldType) bool

ComparisonKeyFieldInteger reports whether ft is an unsigned-integer key_field, matched by its value's canonical base-10 string.

func ComparisonKeyFieldTypes

func ComparisonKeyFieldTypes() []string

ComparisonKeyFieldTypes names the field types a {table, key_field} reference accepts: the categorical rungs (the label is the profile key) and the unsigned integers (the value's canonical base-10 form — no sign, no leading zero — is the key). Floats, dates, datetimes, packed_bool, decimal128 and set_* are refused.

func ComparisonPopulation

func ComparisonPopulation(typ types.AttributeType, a *types.Attribute) string

ComparisonPopulation returns the bound vector fit a comparison slot's {population} reference names ("" for any other slot or form).

func ComparisonReferenceIssues

func ComparisonReferenceIssues(req *types.Request, schema *encoding.Schema, resolved []Resolved, tables ReferenceTables) []*errors.CodedError

ComparisonReferenceIssues returns, in request order, the table issue (ComparisonTableIssue) of every comparison attribute slot (ATTR_PROFILE_SIMILARITY, ATTR_VEC_DISTANCE) whose members and params judge — a slot that does not is the field-reference pass's to refuse. resolved are the request's named vectors over schema.

func ComparisonSlotParams

func ComparisonSlotParams(a *types.Attribute, members Resolved, schema *encoding.Schema) (json.RawMessage, bool)

ComparisonSlotParams resolves attribute a's (a comparison slot) params against its members and returns them canonical (CanonicalParams); ok is false when they do not judge (the field-reference pass has refused that request).

func ComparisonTwoPass

func ComparisonTwoPass(typ types.AttributeType, a *types.Attribute, specs []types.VectorSpec, schema *encoding.Schema) bool

ComparisonTwoPass is the per-slot two-pass predicate of the comparison pair: a centroid reference (folded by the pre-pass, either operator, any metric), or an ATTR_VEC_DISTANCE over a fitted metric (ComparisonFitted) that is not bound to a prebuilt fit (FitBound). Every routing site — processing attrRequiresTwoPassIn, predict's attrTwoPass, both fused-crosstab facts — reads it.

func ComparisonTypes

func ComparisonTypes() []types.AttributeType

ComparisonTypes returns the reference-comparison attribute types, in AllAttributeTypes order.

func CorrelationMethods

func CorrelationMethods() []string

CorrelationMethods returns the params.method values, default first.

func DistanceBetweenTypes

func DistanceBetweenTypes() []types.GroupType

DistanceBetweenTypes returns the built-in groupers MAT_DISTANCE's params.between accepts, in AllGroupTypes order: every built-in. The date family (GROUP_DATE, GROUP_DATE_RANGES) reads its zone like a top-level grouper — the zone pass walks the between as the slot "matrices[i].params.between" (internal/descriptor.ResolveZones) and ZonedRequest writes an inherited zone into its `tz`. A registered extension grouper is accepted too (ResolveMatricesRouted's ext).

func ElementLabel

func ElementLabel(field string, e int) string

ElementLabel is the default display label of element e (0-based) of native vector field field when the schema declares none: "field_<e+1>".

func ElementMarginClass

func ElementMarginClass(a *types.Aggregation, kinds AggregationKinds) (types.MarginReducibility, bool)

ElementMarginClass is the crosstab margin class of an element-selecting slot (SelectsElement): its scalar twin's — the selected element of AGG_VEC_MEAN is a weighted mean of one column (mean-reducible), of AGG_VEC_SUM a sum (summable). ok is false for any other slot, which keeps its type's class — an AGG_VEC_SD element included: a standard deviation recomputes its margin over the raw rows, like AGG_STDDEV (the type's MarginRecompute). Both crosstab arms' fusion facts and predict's normalize advisory read it.

func ElementMember

func ElementMember(field string, e int) string

ElementMember is the member name of element e (0-based) of native vector field field: "field[e+1]".

func EmitsInputValueAggregationTypes

func EmitsInputValueAggregationTypes() []types.AggregationType

EmitsInputValueAggregationTypes returns the built-in aggregation types whose one number is one of the INPUT field's own encoded values — a value picked from the column, not a figure computed over it: AGG_MODE (the modal value). Over a numeric field that value is a magnitude; over a categorical_* field it is the dictionary INDEX and over a packed_bool field the 0/1 truth value (IsCodeInputType) — a code, so an overlay scoring it would compare codes as magnitudes. AGG_MODE_COUNT (a count), AGG_FREQUENCY (a count of a value matched by label) and AGG_DISTINCT_COUNT (a cardinality) are figures, not picks. processing's TestEmitsInputValueAggregationTypes_MatchRowValues holds the list to what every built-in writes.

func EngineMatrixParams

func EngineMatrixParams() []string

EngineMatrixParams are the params keys the engine owns on every matrix operator, extension ones included: the missing-data mode, the listwise heavy-drop threshold and params.fit (the bound vector fit the slot emits from — resolveFit). An extension operator never sees them (decodeExtensionParams strips them) and may not declare them.

func EstimateBuckets

func EstimateBuckets(groups []*types.Group, schema *encoding.Schema) (buckets int64, basis string, known bool)

EstimateBuckets is the schema-only upper bound on the number of matrix buckets — the grouped Response.Data rows a request can emit — and how it was derived; known is false when the keys depend on the data. One grouper reports its own bound and basis; two or more report the PRODUCT of every grouper's bound (saturating at math.MaxInt64) with basis BucketBasisProduct, and are unknown when ANY grouper is — the composite keys a multi-grouper run mints are a subset of that cartesian product. It is an upper bound: a key no row carries (or that a filter removes, or a combination never observed) yields no bucket, so a run emits AT MOST this many results per spec. Unclamped by the record count (callers clamp). Header + schema only — importable from internal/descriptor.

func ExpandedColumn

func ExpandedColumn(label, element string) string

ExpandedColumn is the Response.Data column an expanded vector aggregation writes element by element: "<label>[<element label>]".

func ExprLengthIssue

func ExprLengthIssue(src string, lenOf func(string) (int, bool)) *errors.CodedError

ExprLengthIssue is the first PairIssue of src in the runtime build's walk order (post-order), nil when there is none or src does not parse.

func ExprRefCall

func ExprRefCall(n exprast.Node) *exprast.CallNode

ExprRefCall returns n as a call of the ref() built-in with at least its two arguments (the runtime build appends a third), else nil.

func ExprRefKey

func ExprRefKey(c *exprast.CallNode) (string, bool)

ExprRefKey returns a ref() call's key argument when it is a string literal.

func ExprRefSlot

func ExprRefSlot(slot *exprast.Node) *exprast.Node

ExprRefSlot follows slot down the first argument of label-preserving transforms to the ref() call at the bottom; nil when the chain ends anywhere else.

func ExprRefTable

func ExprRefTable(c *exprast.CallNode) (string, bool)

ExprRefTable returns a ref() call's table argument when it is a string literal.

func ExprReferenceIssues

func ExprReferenceIssues(src string, s RefScope) []*errors.CodedError

ExprReferenceIssues returns every reference issue in src, in walk order (post-order: a ref() call's own check before the pair that reads it). Nil when src calls no ref() or does not parse (its compile reports that).

func ExprStaticIssue

func ExprStaticIssue(src, what string, lenOf func(string) (int, bool)) *errors.CodedError

ExprStaticIssue is src's first static built-in issue at site what, lenOf answering the member count of a bare vector name (nil: no named vectors) — nil when there is none or src does not parse.

func ExprVectorLen

func ExprVectorLen(resolved []Resolved, schema *encoding.Schema) func(string) (int, bool)

ExprVectorLen is the LenOf of an expression over schema with the named vectors resolved (Resolve's result): a name binds a vector when Find knows it and it is not a scalar schema field (a scalar field shadows a same-named vector, as at bind time); its length is the member count.

func FactorExtractions

func FactorExtractions() []string

FactorExtractions returns MAT_FACTOR's params.extraction values, default first.

func FactorIdentified

func FactorIdentified(p, k int) bool

FactorIdentified reports whether k common factors are identified on p members: the model's degrees of freedom p(p − 1)/2 − p·k + k(k − 1)/2 = ((p − k)² − (p + k))/2 are not negative.

func FactorRotations

func FactorRotations() []string

FactorRotations returns MAT_FACTOR's (and ATTR_FACTOR_SCORE's) params.rotation values, default first: every criterion.

func FactorScoreMethods

func FactorScoreMethods() []string

FactorScoreMethods returns params.method's values, default first.

func FieldNotScalar

func FieldNotScalar(f *encoding.Field, dim int, slot, suggest string, extra map[string]any) *errors.CodedError

FieldNotScalar is the PULSE_VECTOR_FIELD_NOT_SCALAR refusal of vector field f (dim dim) read as a single value at slot (a request path such as "aggregations[0] (AGG_SUM) field"). suggest, when non-empty, names the vector operator replacing the slot (SuggestAggregation, SuggestGrouper). extra details are merged in.

func FitBound

func FitBound(typ types.AttributeType, a *types.Attribute) bool

FitBound reports whether attribute a (route typ) is a fitted slot bound to a prebuilt vector fit: a FittedAttributeTypes type or an ATTR_VEC_DISTANCE whose params.fit names a fit (AttributeFit). Such a slot holds its whole fit before the scan, so it is ROW-LOCAL — no pre-pass, streamable beside groupers / features / matrices, and (for the FittedAttributeTypes) mergeable — where the same slot with fit_on takes the two-pass drive. The one per-slot predicate every routing site reads (processing attrRequiresTwoPassIn, predict's attrTwoPass, the fused-crosstab facts, mergegate). A comparison slot whose reference is a centroid is never bound: its pre-pass remains.

func FittedAttributeTypes

func FittedAttributeTypes() []types.AttributeType

FittedAttributeTypes returns the vector-input attribute types that fit before they score (two-pass, params.fit_on), in AllAttributeTypes order: every VectorAttributeTypes entry but the row-local ATTR_SCALE_SCORE and the comparison pair (ATTR_VEC_DISTANCE fits per slot, by its metric: ComparisonFitted).

func FittedLabels

func FittedLabels(at string, typ types.AttributeType, raw json.RawMessage, members Resolved) ([]string, *errors.CodedError)

FittedLabels judges a fitted attribute slot's params.labels against its resolved members (vector the named vector, "" for inline fields) and returns the labels a bound vector fit aligns to: params.labels (inline fields only, one unique non-empty label per member), else the members' labels (a named vector's own, the member names for inline fields). Comparison slots judge theirs in ComparisonParams.

func FittedSlotParams

func FittedSlotParams(a *types.Attribute, members Resolved) (json.RawMessage, bool)

FittedSlotParams returns a fitted (non-comparison) attribute slot's params with params.labels written out as members' labels, for the literal-member rewrite (Processor.prepare): the rewrite clears the named vector, and the slot's labels are what a bound vector fit (params.fit) aligns to and what a captured one (a Compose vector fit over this slot) is stored under. ok is false — keep the params as written — when the slot names no vector or its params do not decode.

func GroupInputMembers

func GroupInputMembers(req *types.Request, schema *encoding.Schema) (members []string, ok bool)

GroupInputMembers returns the union of every field req's grouper slots read through inline fields (a named vector's members ride Members(req)), and whether every one resolved — projection decodes wide otherwise.

func GroupKeyField

func GroupKeyField(typ types.GroupType, g *types.Group) string

GroupKeyField is the column a grouper slot whose route is typ writes its bucket key under (the Data row key, the crosstab axis field): the slot's Field for every grouper except a vector-input one, whose key column is "<TYPE>_<vector>" or "<TYPE>_<first fields entry as written>".

func HasAggregationVectorInput

func HasAggregationVectorInput(a *types.Aggregation) bool

HasAggregationVectorInput reports whether a sets any vector-input slot.

func HasAttributeVectorInput

func HasAttributeVectorInput(a *types.Attribute) bool

HasAttributeVectorInput reports whether a sets any vector-input slot.

func HasGroupVectorInput

func HasGroupVectorInput(g *types.Group) bool

HasGroupVectorInput reports whether g sets any vector-input slot.

func HasVectorInput

func HasVectorInput(t *types.Test) bool

HasVectorInput reports whether t sets any vector-input slot.

func InferenceTypes

func InferenceTypes() []types.MatrixType

InferenceTypes are the matrix operators that take params.inference.

func InvalidNormalizeMode

func InvalidNormalizeMode(mode string, cause error) *errors.CodedError

InvalidNormalizeMode is the coded refusal of a vnormalize mode other than "l1" / "l2" (case-sensitive): PROCESSING_CONFIG {function, mode, valid}, cause attached.

func IsCodeInputType

func IsCodeInputType(ft encoding.FieldType) bool

IsCodeInputType reports whether a value picked from a field of type ft is a code rather than a magnitude: a categorical_* field's value is its dictionary index, a packed_bool field's its 0/1 truth value.

func IsComparisonAttribute

func IsComparisonAttribute(t types.AttributeType) bool

IsComparisonAttribute reports whether t is a reference-comparison attribute type.

func IsDateBetween

func IsDateBetween(t types.GroupType) bool

IsDateBetween reports whether t is a date-family grouper, the only between types that accept a `tz`.

func IsDecomposition

func IsDecomposition(t types.MatrixType) bool

IsDecomposition reports whether t is a decomposition operator (see Matrix.Decomposition): MAT_PARTIAL_CORRELATION, MAT_PCA (it eigen-decomposes its correlation or covariance), MAT_COLLINEARITY (it inverts and eigen-decomposes the predictors' correlation), MAT_FACTOR (it factors the correlation), and MAT_RELIABILITY, whose McDonald's omega factors the inter-item correlation (there the guard's refusal nulls omega with a warning instead of failing the matrix: alpha needs no PSD input).

func IsFittedAttribute

func IsFittedAttribute(t types.AttributeType) bool

IsFittedAttribute reports whether t is a built-in fitted vector attribute type (FittedAttributeTypes).

func IsNativeVector

func IsNativeVector(name string, schema *encoding.Schema) bool

IsNativeVector reports whether name is a native vector field of schema.

func IsRankMethod

func IsRankMethod(method string) bool

IsRankMethod reports whether method is a rank correlation (spearman or kendall): buffered, not mergeable, frequency weights only.

func IsVectorAggregation

func IsVectorAggregation(t types.AggregationType) bool

IsVectorAggregation reports whether t is a built-in vector aggregation type.

func IsVectorAttribute

func IsVectorAttribute(t types.AttributeType) bool

IsVectorAttribute reports whether t is a built-in vector-input attribute type.

func IsVectorGroup

func IsVectorGroup(t types.GroupType) bool

IsVectorGroup reports whether t is a built-in vector-input group type.

func IsVectorTest

func IsVectorTest(t types.TestType) bool

IsVectorTest reports whether t is a built-in vector-input test type.

func KMeansK

func KMeansK(g *types.Group) (int, bool)

KMeansK returns g's params.k when it decodes (EstimateBuckets' bound), false otherwise.

func KindDefault

func KindDefault(c metric.Consumer, k types.VectorKind, f metric.Form, admit func(metric.Metric) bool) (metric.Metric, bool)

KindDefault returns the metric consumer c defaults to for a vector of kind k in form f (metric.DefaultFor; admit nil admits every metric): the kind's table default when c accepts it, else the first metric c accepts that suits the kind. False with no kind or no suitable metric.

func KindIn

func KindIn(specs []types.VectorSpec, schema *encoding.Schema, name string) types.VectorKind

KindIn returns the declared kind of the vector named name: a Request.Vectors spec's kind, else — a native vector field of schema named directly (vec_f32 / vec_f64) — the kind its VECTORS section declares; "" when neither declares one. A spec and a native field never share a name (PULSE_VECTOR_NAME_COLLISION), so the order is immaterial.

func KindOf

func KindOf(specs []types.VectorSpec, name string) types.VectorKind

KindOf returns the declared kind of the vector named name in specs ("" when it declares none or no spec has that name).

func LengthIssues

func LengthIssues(req *types.Request, schema *encoding.Schema, resolved []Resolved) []*errors.CodedError

LengthIssues returns, per request expression (ExprSlots, request order), its first static length refusal (ExprLengthIssue) against the request's named vectors resolved over schema — the predict twin of the runtime build, which refuses the first.

func LengthMismatch

func LengthMismatch(fn string, left, right int, cause error) *errors.CodedError

LengthMismatch is the coded refusal of an unequal-length pair: PROCESSING_VECTOR_LENGTH_MISMATCH, details {function, left, right}.

func LevelVectorParams

func LevelVectorParams(at string, t *types.Test) *errors.CodedError

LevelVectorParams judges a slot that compares a member set across the levels of split_by (TEST_MANOVA, TEST_BOX_M): split_by is required (reason split_by_required) and params carry only missing (checkTestMissing's rule); unknown keys are refused. at is the slot path. Predict and the runtime factories both call it.

func MardiaParams

func MardiaParams(at string, t *types.Test) (string, *errors.CodedError)

MardiaParams judges a TEST_MARDIA slot and returns its headline statistic: one sample, so split_by is refused (reason split_by_not_accepted); params carry statistic ("skewness" default, or "kurtosis") and missing (checkTestMissing's rule); unknown keys are refused. Predict and the runtime factory both call it.

func MatrixMembers

func MatrixMembers(req *types.Request, schema *encoding.Schema) (members []string, ok bool)

MatrixMembers returns the union of every field req's matrix specs read beyond Request.Vectors — an inline spec's fields and a MAT_PARTIAL_CORRELATION params.control entry (a control outside the members joins the fold) — and whether every one resolved (projection decodes wide otherwise).

func MatrixMetricConsumer

func MatrixMetricConsumer(t types.MatrixType) (metric.Consumer, metric.Form, bool)

MatrixMetricConsumer returns the registry consumer a matrix type resolves its params.metric as, and the form it asks for; false for a type that takes no metric.

func MaxIdentifiedFactors

func MaxIdentifiedFactors(p int) int

MaxIdentifiedFactors is the largest k FactorIdentified admits on p members (0 below 3 members, where not even one factor is).

func MemberSourceFields

func MemberSourceFields(members []string, schema *encoding.Schema) []string

MemberSourceFields maps a resolved member-name list to the schema fields it reads (element members to their vector field), distinct, in first-use order. A name that is no element member is kept as is.

func MemberTypeAllowed

func MemberTypeAllowed(ft encoding.FieldType, coerce types.VectorCoerce) bool

MemberTypeAllowed reports whether a field of type ft may be a vector member under coerce: integer and float types always; packed_bool only under VectorCoerceBinary; nothing else.

func Members

func Members(req *types.Request, schema *encoding.Schema) (members []string, ok bool)

Members returns the union of every member req's vectors resolve to against schema, in vector then member order, and whether every vector resolved. Projection calls it: a vector that fails to resolve is refused before any record is read, so ok == false only tells the caller to decode wide rather than guess.

func MetricUnsuitedIssues

func MetricUnsuitedIssues(req *types.Request, schema *encoding.Schema) []*errors.CodedError

MetricUnsuitedIssues returns one PULSE_VECTOR_METRIC_UNSUITED issue per explicit poor-fit pair in req (metric.Metric.PoorFitFor: cosine on scale / measure, the Euclidean family on composition), in request order: every metric-taking matrix slot reading a kind-declared vector by name, every comparison attribute (ATTR_PROFILE_SIMILARITY, ATTR_VEC_DISTANCE) doing the same, then every expression call of a metric built-in (exprbuiltins.Metric) whose argument IS a kind-declared vector — the filterers' FILTER_EXPRESSION, each attribute's ATTR_FORMULA and its params.fit_on filterers, the slots exprReferenced scans. A wrapped argument (cosine(vcenter(v), …)) is a transform of the vector, not the vector, and is not judged. A defaulted metric is never a poor fit (KindDefault), and a vector without a kind raises nothing. The caller decides the channel: a warning, or under strict an error. A native vector field of schema named directly carries its schema kind.

func MissingModes

func MissingModes() []string

MissingModes returns the params.missing values, default first.

func NativeKindsMatter

func NativeKindsMatter(req *types.Request) bool

NativeKindsMatter reports whether req names, in a slot MetricUnsuitedIssues judges, a vector no Request.Vectors spec defines — a name only a native vector field's schema kind can decide. A caller holding no schema yet (the runtime's pre-dispatch strict refusal and post-dispatch warnings) opens the cohort's schema for the issue list only then; with false, MetricUnsuitedIssues(req, nil) is the full list.

func NonScalarAggregationTypes

func NonScalarAggregationTypes() []types.AggregationType

NonScalarAggregationTypes returns the built-in aggregation types whose Response.Data value is not one number — every built-in whose RichAggregator lift replaces the float64 (a moment struct, a label list, a per-label count map, one figure per vector member): the map-valued (types.AggregationType.MapValued), the array-valued (ArrayValued) and the two label-list set folds. Their float64 is a scalar FALLBACK (popcount, running mean, max-bin count) that never reaches the row. processing's TestNonScalarAggregationTypes_MatchRowValues holds the list to what each built-in actually writes.

func Normalize

func Normalize(req *types.Request, schema *encoding.Schema) *types.Request

Normalize returns req with every vector rewritten to its RESOLVED form — `fields` = the member list, `pattern` cleared, everything else kept — so Hash() on the result is a function of the resolved members: a pattern and the equivalent explicit field list hash identically. The request is shallow-copied (the caller's request never changes); req itself is returned when it has no vectors or a vector fails to resolve (that request is refused anyway). Request.Hash() alone is schema-free and hashes vectors as written; hash the normalized request wherever a schema is in hand and resolved-member identity is wanted.

func ObliqueRotations

func ObliqueRotations() []string

ObliqueRotations returns the oblique criteria, in FactorRotations order: what MAT_PCA's refusal names.

func PCAOnValues

func PCAOnValues() []string

PCAOnValues returns the params.on values, default first.

func PCARotations

func PCARotations() []string

PCARotations returns MAT_PCA's (and ATTR_PC_SCORE's) params.rotation values, default first: the orthogonal criteria of FactorRotations — a component is uncorrelated by construction, so an oblique criterion is refused (rotation_oblique_unsupported).

func ParseElementMember

func ParseElementMember(name string, schema *encoding.Schema) (field string, element int, ok bool)

ParseElementMember parses an element member name ("f[k]", k canonical base-10 in 1..dim of native vector field f of schema) into its field and 0-based element. ok is false for anything else.

func PopulationAlign

func PopulationAlign(at, name string, fitLabels, labels []string) ([]int, *errors.CodedError)

PopulationAlign aligns a {population} reference's bound fit (its labels fitLabels) to the slot's labels by the fit rule (AlignFit): perm[i] is the fit's index of labels[i]; unequal label sets are PULSE_VECTOR_REFERENCE_MISMATCH labels_differ naming the population.

func PopulationRefusal

func PopulationRefusal(at, name string, ce *errors.CodedError) *errors.CodedError

PopulationRefusal locates a {population} reference's lookup refusal (the runtime's model.Set.LookupVector or predict's model.CheckVectorFit) on slot at: an unbound name is PULSE_VECTOR_REFERENCE_UNKNOWN reason population_unknown (the bound vector fits under details.valid); any other refusal (a name bound as a regression: PULSE_MODEL_KIND_MISMATCH) keeps its code. Both carry details.attribute, details.population and details.slot.

func RecordMembersAbsent

func RecordMembersAbsent(at, cohort string, missing []string) *errors.CodedError

RecordMembersAbsent is the PULSE_VECTOR_REFERENCE_MISMATCH refusal of a {record} reference on slot at whose cohort holds no usable column for the members listed in missing (absent, or a type no vector member may be: categorical, date, set, …).

func ReferenceIssues

func ReferenceIssues(req *types.Request, schema *encoding.Schema, resolved []Resolved, tables ReferenceTables) []*errors.CodedError

ReferenceIssues returns every reference issue of req's comparison attributes' table references (ComparisonReferenceIssues) and of its expressions (ExprSlots), each with details.slot, against tables and the request's named vectors resolved over schema (a vector named like a schema field is shadowed by the field, as at bind time). The predict twin of the runtime build's refusal: the build raises the first issue of the first slot it binds.

func ReferenceMismatch

func ReferenceMismatch(reference, vector string, refLabels, labels, missing, extra []string) *errors.CodedError

ReferenceMismatch is the PULSE_VECTOR_REFERENCE_MISMATCH refusal (reason labels_differ) of a reference labelled refLabels compared with a vector labelled labels: missing are the vector's labels the reference lacks, extra the reference's labels the vector lacks. reference names the source (a table name, or "" for an inline reference); vector the compared named vector ("" when unnamed).

func Referenced

func Referenced(req *types.Request) map[string]bool

Referenced returns the vector names req's operator slots reference: every Request.Matrices spec's `vector`, every tier-1 test's `vector` / `vector2`, every attribute's `vector`, every grouper slot's `vector` (groups and both crosstab axes), every aggregation slot's `vector` (aggregations, the crosstab cell and its margin aggregations), and every Request.Vectors name an expression reads as a free identifier — an ATTR_FORMULA expression, a FILTER_EXPRESSION filterer's expression (Request.Filterers and a vector attribute's params.fit_on) and so a total() argument inside either (internal/exprident.Free, the walk the expression program binds by). It is the one reference set, so the unreferenced-vector warning and every consumer read one answer.

func ReferencedNatives

func ReferencedNatives(req *types.Request, schema *encoding.Schema) []string

ReferencedNatives returns, in schema order, the native vector fields of schema req names directly in a vector slot (the slots Referenced reads). Projection decodes them; an expression's reference to a native field is an ordinary field identifier there.

func ResolveAggregations

func ResolveAggregations(req *types.Request, schema *encoding.Schema, kinds AggregationKinds) (map[*types.Aggregation]AggregationInput, *errors.CodedError)

ResolveAggregations resolves every aggregation slot's vector input (AggregationSlots order) against schema (Request.Vectors first, like ResolveAttributes). kinds is the instance's view: its Route (a hidden type routes to an unknown name) and its extension declarations — an extension declared VectorInput resolves like a built-in vector aggregator, any other registered extension refuses a vector input. The result is keyed by the slot's *types.Aggregation and holds only the slots that resolved a vector input; the first refusal is returned. Like Resolve it reads only the schema.

func ResolveGroups

func ResolveGroups(req *types.Request, schema *encoding.Schema, route func(types.GroupType) types.GroupType, ext func(string) bool) (map[*types.Group]GroupInput, *errors.CodedError)

ResolveGroups resolves every grouper slot's vector input (GroupSlots order) against schema (Request.Vectors first, like ResolveTests). route maps a group type to the built-in it executes as — the instance's view, where a hidden type routes to an unknown name; nil is the identity. ext reports whether a routed type that is not a built-in is a registered extension grouper (its member set is then judged); nil means none is. The result is keyed by the slot's *types.Group and holds only the slots that resolved a vector input; the first refusal is returned. Like Resolve it reads only the schema.

func ResolveKindMetric

func ResolveKindMetric(c metric.Consumer, explicit string, k types.VectorKind, f metric.Form) (m metric.Metric, defaulted bool, cerr *errors.CodedError)

ResolveKindMetric resolves an operator's metric for consumer c in form f: an explicit name through the registry (metric.ResolveFor — PULSE_VECTOR_METRIC_UNKNOWN), else the kind default (defaulted true), else PULSE_VECTOR_METRIC_REQUIRED (no kind, or no metric suits it).

func RotationOblique

func RotationOblique(name string) bool

RotationOblique reports whether the named criterion is oblique (its factors may correlate: Φ ≠ I, auxiliary.factor_correlation). The one classifier: the accepted lists, MAT_PCA's refusal, the auxiliary keys and the engine all read it.

func RotationTakesEpsilon

func RotationTakesEpsilon(name string) bool

RotationTakesEpsilon reports whether the named criterion reads params.epsilon (the geomin pair).

func ScalarRefusal

func ScalarRefusal(schema *encoding.Schema, name, slot, suggest string, extra map[string]any) *errors.CodedError

ScalarRefusal is FieldNotScalar for name when it is a vector field of schema, else nil.

func ScaleScoreSlotParams

func ScaleScoreSlotParams(a *types.Attribute, members Resolved) (json.RawMessage, bool)

ScaleScoreSlotParams resolves attribute a's (an ATTR_SCALE_SCORE slot) params against its members and returns them canonical (CanonicalParams); ok is false when they do not judge (the field-reference pass has refused that request).

func ScaleStats

func ScaleStats() []string

ScaleStats returns params.stat's values, default first.

func SecondVectorTypes

func SecondVectorTypes() []types.TestType

SecondVectorTypes returns the built-in test types that also read a second member set from Vector2 / Fields2.

func SelectsElement

func SelectsElement(a *types.Aggregation, kinds AggregationKinds) bool

SelectsElement reports whether a is a built-in vector aggregation (routed under kinds; never an extension, whose params.element is its own key) whose params decode and set element: a crosstab slot reading ONE member as a scalar. Shape faults (an unknown element, element outside a crosstab) are the resolver's; this reads only the params.

func SourceFieldsOf

func SourceFieldsOf(refs []MemberRef) []string

SourceFieldsOf is SourceFields over a member-location list.

func SpecBetween

func SpecBetween(spec types.MatrixSpec) (types.Group, bool)

SpecBetween decodes a MAT_DISTANCE spec's params.between as written (lenient: unknown keys are not judged here); false on any other type or when it does not decode.

func SpecMethod

func SpecMethod(spec types.MatrixSpec) string

SpecMethod is spec's correlation method as the resolver reads it — params.method on MAT_CORRELATION (CorrelationPearson when absent), "" on every other type. Lenient: a params object that does not decode yields the default (the resolver refuses it elsewhere).

func SphericityParams

func SphericityParams(at string, t *types.Test) *errors.CodedError

SphericityParams judges a TEST_BARTLETT_SPHERICITY slot: one sample, so split_by is refused (reason split_by_not_accepted), and params carry only missing. Predict and the runtime factory both call it.

func StaticIssues

func StaticIssues(req *types.Request, schema *encoding.Schema, resolved []Resolved) []*errors.CodedError

StaticIssues returns, per request expression (ExprSlots, request order), its first static built-in issue against the request's named vectors resolved over schema — the predict twin of the runtime build, which refuses the first. Each slot is judged at the site the build compiles it as: an ATTR_FORMULA as "formula", its total() arguments first (each as "formula total() argument"; skipped when totalcall refuses the formula — that refusal comes first), every filter expression as "filter".

func TakesSecondVector

func TakesSecondVector(t types.TestType) bool

TakesSecondVector reports whether t reads a second member set.

func TestInputMembers

func TestInputMembers(req *types.Request, schema *encoding.Schema) (members []string, ok bool)

TestInputMembers returns the union of every field req's tier-1 tests read through inline fields / fields2 (a named vector's members ride Members(req)), and whether every one resolved — projection decodes wide otherwise.

func Unreferenced

func Unreferenced(req *types.Request) []string

Unreferenced returns, in request order, the names of req's vectors no operator slot references (each is a PULSE_VECTOR_UNREFERENCED warning).

func UnreferencedWarning

func UnreferencedWarning(name string) *errors.CodedError

UnreferencedWarning builds the PULSE_VECTOR_UNREFERENCED warning for vector name.

func VectorAggregationTypes

func VectorAggregationTypes() []types.AggregationType

VectorAggregationTypes returns the built-in aggregation types that read their columns from Vector / Fields, in AllAggregationTypes order.

func VectorAttributeLabel

func VectorAttributeLabel(typ types.AttributeType, a *types.Attribute) (string, bool)

VectorAttributeLabel is the default output label of a vector-input attribute whose route is typ: "<TYPE>_<vector>", or "<TYPE>_<first fields entry as written>" for inline fields, and on ATTR_PC_SCORE a "_PC<component>" suffix (when params.component decodes) and on ATTR_FACTOR_SCORE a "_F<factor>" suffix (when params.factor decodes) so two components or factors of one vector never share a label. ok is false for any other type (the caller's own label rule applies).

func VectorAttributeTypes

func VectorAttributeTypes() []types.AttributeType

VectorAttributeTypes returns the built-in attribute types that read their columns from Vector / Fields, in AllAttributeTypes order.

func VectorField

func VectorField(schema *encoding.Schema, name string) (f *encoding.Field, dim int, ok bool)

VectorField returns the schema field name names when it is a native vector field, with its dim; ok is false for any other (or unknown) name and for a nil schema.

func VectorGroupTypes

func VectorGroupTypes() []types.GroupType

VectorGroupTypes returns the built-in group types that read their columns from Vector / Fields, in AllGroupTypes order.

func VectorResultRefusal

func VectorResultRefusal(what string) *errors.CodedError

VectorResultRefusal refuses a vector as an expression's top-level result: the vector built-ins compose inside an expression, but an attribute value, a filter verdict and a total() term are scalars. what names the site ("formula", "filter", "formula total() argument").

func VectorTestTypes

func VectorTestTypes() []types.TestType

VectorTestTypes returns the built-in test types that read their columns from Vector / Fields, in AllTestTypes order.

Types

type AggregationInput

type AggregationInput struct {
	// Slot is the slot path ("aggregations[0]", "crosstab.cell", ...).
	Slot string
	// Members is the member set (axis order) with its display labels:
	// the named vector's, else params.labels, else the member names.
	Members Resolved
	// Expand is params.expand: the value is written as one column per
	// member (ExpandedColumn) instead of an array.
	Expand bool
	// Extension marks an extension vector aggregator's slot: its params
	// are the operator's, so AggregationSlotRewrite keeps every other
	// key.
	Extension bool
	// HasElement marks a slot whose params.element selects one member;
	// Element is that member's index in Members.
	HasElement bool
	Element    int
}

AggregationInput is one aggregation slot's vector input after resolution. The zero value (Has false) reads no vector.

func (AggregationInput) Has

func (in AggregationInput) Has() bool

Has reports whether the slot resolved a vector input.

type AggregationKinds

type AggregationKinds struct {
	Route     func(types.AggregationType) types.AggregationType
	Extension func(name string) ExtensionAggregation
}

AggregationKinds is one instance's view of the aggregation types the vector rules judge. Route maps a type to the name it executes as (a hidden type routes to "", an unknown name); nil is the identity. Extension reports a routed, non-built-in name's extension declaration; nil means no extension is registered. The zero value is the built-in view. Predict (from the extensions snapshot) and the runtime (from the extension registry) build one each, over the same declarations, so they classify a slot identically.

func (AggregationKinds) ChainCodeColumns

func (k AggregationKinds) ChainCodeColumns(stages []*types.Request, idx int, stage0 *encoding.Schema, next func(req *types.Request, in *encoding.Schema) *encoding.Schema) map[string]encoding.FieldType

ChainCodeColumns returns the code columns of chain stage idx's INPUT: nil for stage 0 (it reads stage0, whose fields carry their own types); for idx >= 1 the columns stage idx-1 writes as a code, judged against that stage's own input (CodeFieldTypes of its schema and the code columns it inherited), so code-ness propagates through every stage. stages are the chain's requests as executed (smart defaults resolved), index-aligned; stage0 the schema stage 0 executes over (nil: no judgement); next the side's synthesised-schema builder for a stage's output over that stage's input schema (nil result: no judgement past it).

func (AggregationKinds) EmitsInputValue

func (k AggregationKinds) EmitsInputValue(t types.AggregationType) bool

EmitsInputValue reports whether t's value is one of its input field's own encoded values: a built-in in EmitsInputValueAggregationTypes or an extension declared EmitsInputValue. Declared metadata only.

func (AggregationKinds) IsArrayValued

func (k AggregationKinds) IsArrayValued(t types.AggregationType) bool

IsArrayValued reports whether t's value is one figure per member: types.AggregationType.ArrayValued or an extension declared ArrayValued. Every consumer that needs one number refuses it.

func (AggregationKinds) IsCode

IsCode reports whether t over an input field of type input writes a code, not a magnitude, into its Response.Data row: EmitsInputValue over an IsCodeInputType field. It depends on the input field's schema type, so predict judges it from the request plus the schema (no records), as the runtime does.

func (AggregationKinds) IsNonScalar

func (k AggregationKinds) IsNonScalar(t types.AggregationType) bool

IsNonScalar reports whether t's value in a Response.Data row is not one number, so a consumer that reads one number per host row (an overlay's scored aggregation) has nothing to read: IsArrayValued, a built-in in NonScalarAggregationTypes, or an extension declared NonScalar. Declared metadata only — predict judges it from the request alone, as the runtime does.

func (AggregationKinds) IsVector

IsVector reports whether t reads a vector input: a built-in vector aggregator (VectorAggregationTypes) or an extension declared VectorInput.

func (AggregationKinds) Routed

Routed returns the name t executes as.

func (AggregationKinds) StageCodeColumns

func (k AggregationKinds) StageCodeColumns(req *types.Request, inputType func(field string) (encoding.FieldType, bool)) map[string]encoding.FieldType

StageCodeColumns returns the output columns of the chain stage req that carry a categorical code, each mapped to the field type it is a code of: an aggregation k.IsCode over its input field's type as inputType reports it (nil: none), keyed by its output label (types.AggregationLabelOf, the column the stage writes). Nil when none does.

type AggregationSlot

type AggregationSlot struct {
	Path string
	Agg  *types.Aggregation
}

AggregationSlot is one aggregation slot of a request with its path.

func AggregationSlots

func AggregationSlots(req *types.Request) []AggregationSlot

AggregationSlots lists req's aggregation slots in walk order: aggregations, then the crosstab cell, then its margin aggregations.

type AttributeInput

type AttributeInput struct {
	// Members is the member set (axis order).
	Members Resolved
	// FitOn is the decoded params.fit_on filterer list; nil fits on every
	// filtered row ("filtered").
	FitOn []*types.Filterer
}

AttributeInput is one attribute slot's vector input after resolution. The zero value (Has false) is an attribute that reads no vector.

func ResolveAttributes

func ResolveAttributes(req *types.Request, schema *encoding.Schema, route func(types.AttributeType) types.AttributeType, ext func(string) bool) ([]AttributeInput, *errors.CodedError)

ResolveAttributes resolves every attribute's vector input against schema (Request.Vectors first, like ResolveTests). route maps an attribute type to the built-in it executes as — the instance's view, where a hidden type routes to an unknown name; nil is the identity. ext reports whether a routed type that is not a built-in is a registered extension attribute (its member set is then judged); nil means none is. The result is index-aligned with req.Attributes (the zero AttributeInput for an attribute that reads no vector); the first refusal is returned. Like Resolve it reads only the schema.

func (AttributeInput) Has

func (in AttributeInput) Has() bool

Has reports whether the slot resolved a vector input.

type AttributeMetricDefault

type AttributeMetricDefault struct {
	// Index is the slot's position in Request.Attributes.
	Index int
	// Vector and Kind are the vector the slot reads and its kind.
	Vector string
	Kind   types.VectorKind
	// Metric is the filled metric; TableDefault the kind's own default
	// in the slot's form (they differ when the operator does not accept
	// the table default).
	Metric, TableDefault string
	// Params are the slot's params with "metric" set.
	Params json.RawMessage
}

AttributeMetricDefault is one kind-filled metric on a comparison attribute slot.

func AttributeMetricDefaults

func AttributeMetricDefaults(req *types.Request, schema *encoding.Schema) []AttributeMetricDefault

AttributeMetricDefaults returns, in request order, the metric each comparison attribute slot (ATTR_PROFILE_SIMILARITY, ATTR_VEC_DISTANCE) defaults to: one reading a kind-declared vector by `vector` whose params are a JSON object naming no metric (absent or null). The fill is ResolveKindMetric's own default, so the slot executes the metric reported whether or not the fill is applied. Inline `fields` carry no kind and are never filled; malformed params are left for decode to refuse. A native vector field named directly is read with its schema kind (KindIn).

type ComparisonBinding

type ComparisonBinding struct {
	Static []float64
	Table  ReferenceTable
	Perm   []int
}

ComparisonBinding is a comparison slot's reference against the instance's tables: Static the reference in member order for every static form; for {table, key_field}, Table and Perm (Perm[i] the table index of member i) read each row's profile.

func ComparisonTableIssue

func ComparisonTableIssue(at string, cfg ComparisonConfig, tables ReferenceTables) (ComparisonBinding, *errors.CodedError)

ComparisonTableIssue judges cfg's table reference against tables: PULSE_VECTOR_REFERENCE_UNKNOWN (table_unknown, key_unknown) or PULSE_VECTOR_REFERENCE_MISMATCH (labels_differ) naming the slot at. A literal or label-map reference raises none. On success the binding holds what the rows read (Static is nil in the predict view, whose tables carry no values).

type ComparisonConfig

type ComparisonConfig struct {
	// Type is ATTR_PROFILE_SIMILARITY or ATTR_VEC_DISTANCE.
	Type types.AttributeType
	// Metric is the resolved metric; Defaulted reports it came from the
	// vector's kind.
	Metric    metric.Metric
	Defaulted bool
	// MinValid is the fewest complete member pairs a row needs (default
	// 1).
	MinValid int
	// Labels are the element labels the reference aligns to: params.labels,
	// else the named vector's labels (the member names for inline fields).
	Labels []string
	// Vector is the named vector compared ("" for inline fields).
	Vector string
	// Reference is the decoded params.reference.
	Reference ComparisonReference
	// FitOn is the decoded params.fit_on (a fitted metric only); nil
	// fits on every filtered row. FitOnRaw is it as written.
	FitOn    []*types.Filterer
	FitOnRaw json.RawMessage
	// Fit names the bound vector fit a fitted metric reads instead of
	// fitting ("" folds this request's own fit); it aligns to Labels.
	Fit string
}

ComparisonConfig is a comparison attribute's params judged against its resolved members.

func ComparisonParams

func ComparisonParams(at string, typ types.AttributeType, raw json.RawMessage, members Resolved, schema *encoding.Schema) (ComparisonConfig, *errors.CodedError)

ComparisonParams judges comparison type typ's params against members (the resolved vector or inline fields) and schema (key_field must be a categorical or unsigned-integer source column, ComparisonKeyFieldAccepts; nil skips that check): metric, min_valid, reference, labels and — ATTR_VEC_DISTANCE beside a fitted metric — fit_on / missing. Unknown keys are refused. The table checks are ComparisonTableIssue's. Predict (the field-reference walk) and the runtime (Processor.prepare, the factory) both call it.

func (ComparisonConfig) CanonicalParams

func (cfg ComparisonConfig) CanonicalParams() json.RawMessage

CanonicalParams is cfg as the params of an inline-fields slot over members: the metric written out (a kind default survives the rewrite to literal fields), min_valid, the labels the reference aligns to, the reference (a literal or label map in member order; a table, centroid, population or record form as written), fit_on as written and the bound fit's name. Processor.prepare hands it to the factory beside the literal member list; ComparisonParams over those members decodes it back to cfg.

func (ComparisonConfig) Fitted

func (cfg ComparisonConfig) Fitted() bool

Fitted reports whether the metric reads a fit pass (std_euclidean, mahalanobis).

type ComparisonReference

type ComparisonReference struct {
	// Form is one of ReferenceValues, ReferenceLabelMap,
	// ReferenceTableKey, ReferenceTableKeyField.
	Form string
	// Values is the reference in member order (ReferenceValues and
	// ReferenceLabelMap); nil for a table form.
	Values []float64
	// Table, Key and KeyField are the table forms' operands.
	Table, Key, KeyField string
	// Filter is a centroid's decoded filter (nil: every filtered row),
	// FilterRaw it as written; By the column a per-key centroid reads.
	Filter    []*types.Filterer
	FilterRaw json.RawMessage
	By        string
	// Population names the bound vector fit a {population} form reads.
	Population string
	// Cohort and Keys are a {record} form's operands: the cohort the
	// record is looked up in (nil: the request's own) and the ordered
	// key tuple of its sidecar index.
	Cohort *types.Cohort
	Keys   []types.LookupKey
}

ComparisonReference is a decoded params.reference.

func ComparisonRecord

func ComparisonRecord(typ types.AttributeType, a *types.Attribute) (ComparisonReference, bool)

ComparisonRecord returns comparison slot a's (route typ) decoded {record} reference; ok is false for any other slot or form, or a record operand that does not decode (refused elsewhere). The Service reads it to resolve every slot's stored record before the processor builds.

func (ComparisonReference) KeyColumn

func (r ComparisonReference) KeyColumn() string

KeyColumn is the column a per-row reference keys on: the table form's key_field, or a centroid's by ("" for every static form).

func (ComparisonReference) RecordKey

func (r ComparisonReference) RecordKey() string

RecordKey is the key a {record} reference's resolved record binds under on the request's model.Set (model.Set.LookupRecord): the cohort as written (absent when omitted) and the keys in order, canonical JSON. The Service (which resolves) and the engine (which binds) both derive it from the decoded reference.

func (ComparisonReference) Static

func (r ComparisonReference) Static() bool

Static reports whether the reference is the same for every row (every form but ReferenceTableKeyField and a centroid with by).

type ExprSlot

type ExprSlot struct {
	// Path is the request path ("filterers[0].expression", ...).
	Path string
	// Src is the expression.
	Src string
}

ExprSlot is one request expression the reference / kind checks read.

func ExprSlots

func ExprSlots(req *types.Request) []ExprSlot

ExprSlots returns every request expression an expression-bound vector or reference can appear in, in request order: each FILTER_EXPRESSION filterer, then per attribute its ATTR_FORMULA expression and its params.fit_on (and centroid reference filter) FILTER_EXPRESSION filterers.

type ExtensionAggregation

type ExtensionAggregation struct {
	Registered, VectorInput, ArrayValued, NonScalar, EmitsInputValue bool
}

ExtensionAggregation is what an instance declares about one aggregation type its extensions register: Registered (the name is an extension aggregator), VectorInput (it reads vector / fields), ArrayValued (its value is one figure per member), NonScalar (its value is not one number — pulse.AggregatorRegistration.NonScalar) and EmitsInputValue (its value is one of its input field's own encoded values — pulse.AggregatorRegistration.EmitsInputValue).

type FactorCount

type FactorCount struct {
	K int
}

FactorCount is MAT_FACTOR's resolved params.factors: K > 0 is a fixed count; K == 0 is the Kaiser rule, decided on the data.

func (FactorCount) Kaiser

func (f FactorCount) Kaiser() bool

Kaiser reports the data-driven Kaiser rule.

type FactorScoreConfig

type FactorScoreConfig struct {
	// Factor is the 1-based factor scored (required).
	Factor int
	// Method is FactorScoreRegression (default) or FactorScoreBartlett.
	Method string
	// Factors, Extraction, Rotation ("" for none), Kappa, Gamma and
	// Epsilon are the inline fit's MAT_FACTOR knobs, decoded by
	// MAT_FACTOR's rule (factors "kaiser" by default, extraction
	// "minres"; every rotation, oblique ones included).
	Factors    FactorCount
	Extraction string
	Rotation   string
	Kappa      float64
	Gamma      float64
	Epsilon    float64
	// FitOn is the fit_on filterer list; nil fits on every filtered row.
	FitOn []*types.Filterer
	// Fit / Labels: as MahalanobisConfig's.
	Fit    string
	Labels []string
}

FactorScoreConfig is ATTR_FACTOR_SCORE's decoded params.

func FactorScoreParams

func FactorScoreParams(at string, raw json.RawMessage) (FactorScoreConfig, *errors.CodedError)

FactorScoreParams decodes ATTR_FACTOR_SCORE's params: factor (an integer ≥ 1, required), method ("regression" default, or "bartlett"), MAT_FACTOR's factors / extraction / rotation / kappa / gamma / epsilon (the same rule and defaults; no repair — the fit is listwise), fit_on and missing (FittedCommon). A fixed factors below factor is refused; the bounds against the member count are CheckMembers. Unknown keys are refused. at is the slot path. Predict and the runtime factory both call it.

func (FactorScoreConfig) CheckMembers

func (cfg FactorScoreConfig) CheckMembers(at string, p int) *errors.CodedError

CheckMembers refuses a factor (or a fixed factors count) beyond the p members: a p-member battery has at most p factors. Whether k factors are identified on p members (MAT_FACTOR's (p − k)² ≥ p + k) is the fit's call, as on MAT_FACTOR.

type FittedCommon

type FittedCommon struct {
	// FitOn is "filtered" (default) or an inline Filterer array.
	FitOn json.RawMessage `json:"fit_on"`
	// Fit names a bound vector fit to score against instead of fitting
	// (mutually exclusive with FitOn).
	Fit *string `json:"fit"`
	// Missing is "listwise" (the only mode).
	Missing *string `json:"missing"`
}

FittedCommon is the params every fitted vector attribute shares; an operator's params struct embeds it beside its own keys, so one strict decode refuses every unknown key.

type GroupInput

type GroupInput struct {
	// Slot is the slot path ("groups[0]", "crosstab.rows[1]", ...).
	Slot string
	// Members is the member set (axis order).
	Members Resolved
	// KMeans is GROUP_KMEANS's decoded params (zero on an extension).
	KMeans KMeansConfig
	// Extension reports the slot is a registered extension grouper: its
	// members are resolved, its params and key column its own.
	Extension bool
}

GroupInput is one grouper slot's vector input after resolution. The zero value (Has false) is a grouper that reads no vector.

func (GroupInput) Has

func (in GroupInput) Has() bool

Has reports whether the slot resolved a vector input.

type GroupSlot

type GroupSlot struct {
	Path  string
	Group *types.Group
}

GroupSlot is one grouper slot of a request with its path.

func GroupSlots

func GroupSlots(req *types.Request) []GroupSlot

GroupSlots lists req's grouper slots in walk order: groups, then the crosstab rows, then the crosstab columns.

type HotellingConfig

type HotellingConfig struct {
	// Mu is the hypothesized mean (one-sample) or mean difference
	// (paired) vector, length p (default zeros); nil on the two-sample
	// form, which tests equal means.
	Mu []float64
	// Variance is HotellingVariancePooled (default) or
	// HotellingVarianceUnequal (two-sample only).
	Variance string
}

HotellingConfig is TEST_HOTELLING_T2's decoded params.

func HotellingParams

func HotellingParams(at string, raw json.RawMessage, p int, form HotellingForm) (HotellingConfig, *errors.CodedError)

HotellingParams decodes TEST_HOTELLING_T2's params against its member count p and form: params.mu, a length-p array (default zeros; judged but ignored on the two-sample form), params.variance ("pooled" default, "unequal" refused off the two-sample form) and params.missing (checkTestMissing's rule). Unknown keys are refused. at is the slot path. Predict and the runtime factory both call it.

type HotellingForm

type HotellingForm string

HotellingForm is a TEST_HOTELLING_T2 slot's form, read off its spec.

const (
	HotellingOneSample HotellingForm = "one_sample"
	HotellingTwoSample HotellingForm = "two_sample"
	HotellingPaired    HotellingForm = "paired"
)

TEST_HOTELLING_T2 forms (TestResult.Variant prefixes).

func HotellingFormOf

func HotellingFormOf(t *types.Test) HotellingForm

HotellingFormOf reads t's form: paired when a second set is present, two-sample when split_by is set, one-sample otherwise. (The resolver refuses a second set with split_by before params are judged.)

type KMeansConfig

type KMeansConfig struct {
	// K is the cluster count (≥ 2).
	K int
	// Seed is the PRNG seed; params.seed 0 resolves to KMeansDefaultSeed.
	Seed int64
	// MaxIter is the Lloyd iteration cap per start (≥ 1).
	MaxIter int
	// NInit is the number of k-means++ starts (≥ 1).
	NInit int
	// Standardize z-scores every member over the clustered rows first.
	Standardize bool
}

KMeansConfig is GROUP_KMEANS's decoded params.

func KMeansParams

func KMeansParams(at string, raw json.RawMessage) (KMeansConfig, *errors.CodedError)

KMeansParams decodes GROUP_KMEANS's params: k (required, an integer ≥ 2), seed (int64; 0 = the fixed default), max_iter (≥ 1, default 100), n_init (≥ 1, default 10), standardize (default true) and missing ("listwise" only). fit is accepted and left to internal/groupfit. Unknown keys are refused. at is the slot path. Predict and the runtime factory both call it.

type LengthScope

type LengthScope struct {
	// LenOf is the member count of the vector a bare identifier binds,
	// false when the name binds no vector.
	LenOf func(name string) (int, bool)
	// contains filtered or unexported fields
}

LengthScope answers the static length of a pair argument in one expression.

func NewLengthScope

func NewLengthScope(src string, lenOf func(string) (int, bool)) LengthScope

NewLengthScope is the scope of src: lenOf, with src's let bindings shadowing it.

func (LengthScope) PairIssue

func (s LengthScope) PairIssue(c *exprast.CallNode) *errors.CodedError

PairIssue is the length refusal of call c, nil unless c is a two-argument pair built-in whose arguments have known, unequal lengths.

type MahalanobisConfig

type MahalanobisConfig struct {
	// Output is MahalanobisD2 (default) or MahalanobisP.
	Output string
	// FitOn is the fit_on filterer list; nil fits on every filtered row.
	FitOn []*types.Filterer
	// Fit names the bound vector fit scored against ("" folds this
	// request's own fit); Labels are the labels it aligns to
	// (params.labels as written; nil: the members').
	Fit    string
	Labels []string
}

MahalanobisConfig is ATTR_MAHALANOBIS's decoded params.

func MahalanobisParams

func MahalanobisParams(at string, raw json.RawMessage) (MahalanobisConfig, *errors.CodedError)

MahalanobisParams decodes ATTR_MAHALANOBIS's params: output ("d2" default, or "p"), fit_on and missing (FittedCommon). Unknown keys are refused. at is the slot path. Predict and the runtime factory both call it.

type Matrix

type Matrix struct {
	// Index is the spec's position in Request.Matrices.
	Index int
	// Name is the result name (MatrixSpec.EffectiveName).
	Name string
	// Type is the operator.
	Type types.MatrixType
	// Members are the axis members, with their labels and coercion.
	Members Resolved
	// ExplicitLabels reports whether the members carry caller-supplied
	// display labels (otherwise Members.Labels are the member names and
	// the result omits them).
	ExplicitLabels bool
	// Encoding is the effective Values layout.
	Encoding types.MatrixEncoding
	// Streamable and Mergeable are the spec-level answers
	// (types.MatrixSpec.Streamable / Mergeable — the type folded with
	// its params), copied at resolution so the engine, predict and the
	// routing gates read one rule. A non-streamable matrix is BUFFERED:
	// its slot keeps the admitted rows for a finalizer that needs them
	// all (a rank method).
	Streamable bool
	Mergeable  bool
	// DDOF is MAT_COVARIANCE's delta degrees of freedom (default 1).
	DDOF int
	// Pairwise reports params.missing "pairwise": each pair is computed
	// over the rows where both members are present. False is the
	// default "listwise": a row with any member null is dropped.
	Pairwise bool
	// MaxDropShare is params.max_drop_share (listwise only; no
	// default): when the share of filter-passing rows listwise drops
	// exceeds it, the result carries PULSE_MATRIX_LISTWISE_HEAVY_DROP.
	// Nil when unset.
	MaxDropShare *float64
	// Method is MAT_CORRELATION's params.method — CorrelationPearson
	// (the default), CorrelationSpearman or CorrelationKendall; "" on
	// every other type. A rank method is buffered and not mergeable
	// (Streamable / Mergeable false).
	Method string
	// TopPairs is MAT_CORRELATION's params.summary.top_pairs: the
	// number of strongest off-diagonal pairs the result lists under
	// vectors.top_pairs. 0 (the default) emits no summary.
	TopPairs int
	// Controls is MAT_PARTIAL_CORRELATION's params.control named list,
	// in the caller's order: nil is "all" (each pair controls for every
	// other member). A control may be a member (it leaves the output
	// axis) or any other numeric field (it joins the fold: Extra).
	Controls []string
	// Extra are the control fields outside the members, in params
	// order: the slot folds them after the members (Columns), so they
	// join the co-moment and the missing-data mode.
	Extra []string
	// Output are the output axis positions in Columns — the members
	// that are not controls, in axis order. Nil means every member
	// (Columns is then exactly the members).
	Output []int
	// Repair is a decomposition operator's params.repair: "" (refuse a
	// non-PSD input with PULSE_MATRIX_NOT_PSD) or RepairNearest.
	Repair string
	// Reverse are MAT_RELIABILITY's reverse-keyed items as member
	// positions, ascending (params.reverse, de-duplicated by name): the
	// slot folds x' = ScaleMin + ScaleMax − x for each before the
	// co-moment. Nil when nothing is reversed.
	Reverse []int
	// HasScale reports a declared battery-wide params.scale_min /
	// scale_max (both or neither; required with a reverse list) — or,
	// with neither, the kind "scale" vector's declared bounds: every
	// present member value must lie in [ScaleMin, ScaleMax], or the run
	// is refused with PROCESSING_CONFIG — never clamped, never inferred
	// from the data.
	HasScale           bool
	ScaleMin, ScaleMax float64

	// On is MAT_PCA's params.on: PCAOnCorrelation (the default) or
	// PCAOnCovariance; "" on every other type.
	On string
	// Components is MAT_PCA's retention rule (params.components).
	Components PCAComponents
	// Rotation is MAT_PCA's / MAT_FACTOR's params.rotation: "" (none,
	// the default) or a criterion — PCARotations on MAT_PCA (orthogonal
	// only), FactorRotations on MAT_FACTOR.
	Rotation string
	// Factors is MAT_FACTOR's params.factors: a fixed K or the Kaiser
	// rule (the default).
	Factors FactorCount
	// Extraction is MAT_FACTOR's params.extraction:
	// FactorExtractionMinres (the default), FactorExtractionPrincipalAxis
	// or FactorExtractionML; "" on every other type.
	Extraction string
	// Kappa is MAT_FACTOR's promax power (params.kappa, default
	// FactorDefaultKappa; promax only) and Gamma its oblimin γ
	// (params.gamma, default 0; oblimin only).
	Kappa, Gamma float64
	// Epsilon is the geomin criteria's ε (params.epsilon, default
	// GeominDefaultEpsilon; RotationGeomin / RotationGeominOrthogonal
	// only, on MAT_PCA and MAT_FACTOR), 0 otherwise.
	Epsilon float64
	// ConfLevel is MAT_FACTOR's params.conf_level: the coverage of the
	// ml RMSEA interval (rmsea_lower / rmsea_upper), FactorDefaultConfLevel
	// unless set; extraction ml only, 0 on every other type.
	ConfLevel float64
	// Center is MAT_COLLINEARITY's params.center: false (the default)
	// runs Belsley's diagnostics on the scaled, UNCENTERED predictors
	// with an intercept column; true on the scaled, centered ones (the
	// predictors' correlation, no intercept).
	Center bool
	// Between is MAT_DISTANCE's resolved params.between grouper: a copy
	// ready for the grouper factory — a GROUP_KMEANS slot's members
	// moved into Fields (a named vector resolved), Vector cleared. Nil
	// on every other type. The engine sets its Weight from the slot's
	// stamped weight (GROUP_KMEANS only: the other groupers' keys do not
	// read a weight).
	Between *types.Group
	// Metric is MAT_DISTANCE's params.metric, a linalg/metric registry
	// name the MAT_DISTANCE consumer accepts (DistanceDefaultMetric by
	// default); "" on every other type.
	Metric string
	// MinValid is MAT_DISTANCE's params.min_valid: the fewest complete
	// member pairs (coordinates defined on both centroids) a distance
	// needs; below it the cell is null. 1 by default; 0 on every other
	// type.
	MinValid int
	// Standardize is MAT_DISTANCE's params.standardize: z-score every
	// member over the bucketed rows before the centroids are compared.
	Standardize bool

	// Inference is params.inference on MAT_CORRELATION (every method)
	// and MAT_PARTIAL_CORRELATION: the result carries per-pair
	// auxiliary.p, auxiliary.ci_lower and auxiliary.ci_upper. False
	// (the default) builds none of them.
	Inference bool
	// Alpha is params.alpha, the two-sided level of the inference
	// confidence intervals (coverage 1 − Alpha): InferenceDefaultAlpha
	// under Inference, 0 otherwise.
	Alpha float64
	// Extension reports an embedder-registered MAT_* operator
	// (MatrixResolve.Extension). Its params are opaque to Pulse: the
	// engine-owned missing / max_drop_share are decoded onto Pairwise /
	// MaxDropShare exactly as for a built-in and stripped, and the
	// remaining keys ride ExtParams (nil when none is left) to the
	// operator's factory and Finalize. Streamable / Mergeable are its
	// DECLARED tier (a co-moment operator merges through the blocked
	// merge; a buffered one keeps rows and runs serially).
	Extension bool
	// ExtParams is an extension operator's params object without the
	// engine-owned keys; nil on a built-in.
	ExtParams json.RawMessage
	// ExtAuxiliary is an extension operator's declared auxiliary keys
	// (its registration's OutputKeys.Auxiliary), AuxiliaryKeys' answer.
	ExtAuxiliary []string
	// Fit is params.fit: the bound vector fit (a Compose `fits` entry of
	// kind vector) the slot emits from instead of folding its rows —
	// aligned to Columns' labels (FitLabels) by label, its own weight
	// basis governing. "" folds the filtered rows (the default).
	Fit string
	// contains filtered or unexported fields
}

Matrix is one Request.Matrices spec after resolution: its effective name, its operator, its members (the vector it names, or its inline fields resolved by the vector rules) and its decoded parameters.

func ResolveMatrices

func ResolveMatrices(req *types.Request, schema *encoding.Schema, known func(types.MatrixType) bool) ([]Matrix, *errors.CodedError)

ResolveMatrices resolves req.Matrices against schema: first req.Vectors (Resolve — its refusal wins), then every matrix spec in request order. known reports whether a matrix type is offered (an instance-hidden type is unknown); nil admits exactly types.AllMatrixTypes(). The first refusal is returned:

  • an unknown type, a spec setting both or neither of `vector` and `fields`, an unknown `encoding`, a result name used twice, or a malformed / out-of-range `params` — SERVICE_VALIDATION naming `matrix` (the slot path) and `reason`;
  • a `vector` no Request.Vectors entry defines — PULSE_VECTOR_UNKNOWN (`vector`, `slot`, `defined`);
  • inline `fields` — the vector rules (ResolveSpec at "matrices[i].fields").

The result is index-aligned with req.Matrices. Like Resolve it reads only the schema.

func ResolveMatricesRouted

func ResolveMatricesRouted(req *types.Request, schema *encoding.Schema, known func(types.MatrixType) bool, route func(types.GroupType) types.GroupType, ext func(string) bool) ([]Matrix, *errors.CodedError)

ResolveMatricesRouted is ResolveMatrices with route mapping a MAT_DISTANCE params.between grouper type to the built-in it executes as — the instance's view, where a hidden type routes to an unknown name (ResolveGroups' route); nil is the identity. ext reports whether a routed between type that is not a built-in is a registered extension grouper (ResolveGroups' ext: it is then accepted, its member set judged); nil means none is.

func ResolveMatricesWith

func ResolveMatricesWith(req *types.Request, schema *encoding.Schema, o MatrixResolve) ([]Matrix, *errors.CodedError)

ResolveMatricesWith is ResolveMatricesRouted plus the extension MAT_* operators o.Extension reports: such a type resolves like a built-in — shape, encoding, name, members by the vector rules, the engine-owned missing / max_drop_share — with its other params kept opaque (Matrix.ExtParams), its declared tier as Streamable / Mergeable, and a member whose column type its non-empty Accepts does not list refused with PULSE_VECTOR_MEMBER_TYPE.

func (Matrix) AccumulatorBytes

func (m Matrix) AccumulatorBytes() int64

AccumulatorBytes estimates the payload bytes of one co-moment state over the matrix's folded columns (Columns: the members plus any outside control): 40 + 8·(p + p(p+1)/2) listwise, 40 + 72·p(p+1)/2 pairwise. The engine holds one such state per populated merge block (linalg.MergeBlockSize rows) until finalize, so a run's matrix state is this times its block count. Go headers and map overhead are not counted.

func (Matrix) AuxiliaryKeys

func (m Matrix) AuxiliaryKeys() (keys []string, known bool)

AuxiliaryKeys lists the matrices[*].auxiliary keys m's finalizer emits under its params, in a fixed order — the ONE list the predict size model (matrixAuxiliaryNodes) and the runtime's per-spec auxiliary compute gate (processing.ComputePlan) read, so predict sizes and the computed auxiliaries cannot drift. The multiplicity twins (p_adjusted, significant_adjusted) are written later by the service fold and are not listed. known is false for an operator this list does not model (every built-in is modelled): a caller then assumes it may emit any key.

  • n: params.missing pairwise, every operator but MAT_DISTANCE.
  • p, ci_lower, ci_upper: params.inference (MAT_CORRELATION / MAT_PARTIAL_CORRELATION).
  • MAT_PCA: eigenvectors; unrotated under a rotation.
  • MAT_FACTOR: unrotated under a rotation; factor_correlation under an oblique one.
  • MAT_COLLINEARITY: variance_decomposition.
  • MAT_DISTANCE: centroids; centroids_standardized under standardize; pooled_covariance under a fitted inverse-covariance metric.

func (Matrix) Columns

func (m Matrix) Columns() []string

Columns returns the fields the slot folds, in fold order: the members, then any control outside them (Extra). Every co-moment index (N, PairN, the warnings' member names) is a Columns index.

func (Matrix) Decomposition

func (m Matrix) Decomposition() bool

Decomposition reports whether the matrix's operator decomposes (or inverts) its input matrix, so a non-PSD input is a FATAL PULSE_MATRIX_NOT_PSD unless params.repair is "nearest" — the shared guard (processing.guardPSD). Every other operator keeps the detection-only warning.

func (Matrix) FitLabels

func (m Matrix) FitLabels() []string

FitLabels are the labels a bound vector fit aligns to, in Columns order: each member's display label (its name when it carries none), then each control outside the members (MAT_PARTIAL_CORRELATION) by name. A vector fit captured from a matrix battery is stored under the same labels.

func (Matrix) FragmentRowBytes

func (m Matrix) FragmentRowBytes() int64

FragmentRowBytes is one row a non-head merge fragment buffers (a shard archive row whose shard starts inside its merge block, kept for the finalize to replay): the folded columns plus the weight, 8 bytes each. Slice headers are not counted.

func (Matrix) OutputIndices

func (m Matrix) OutputIndices() []int

OutputIndices returns the output axis as Columns positions: Output, or every member when Output is nil.

func (Matrix) OutputMembers

func (m Matrix) OutputMembers() (members, labels []string)

OutputMembers returns the result's axis keys (OutputIndices' fields) and their labels.

func (Matrix) PSDRisk

func (m Matrix) PSDRisk() bool

PSDRisk reports whether the matrix can come back NOT positive semidefinite — the only shapes the engine runs its PULSE_MATRIX_NOT_PSD check on, so a false here is a guarantee the warning never fires. Listwise matrices are Gram matrices over one row set and always PSD. Under pairwise each cell rests on its own rows, and the risk is decided PER TYPE — a type this switch does not name carries none (an operator that assembles a pairwise matrix and can come back non-PSD must add its own case):

  • MAT_COVARIANCE at p ≥ 2 — a variance and a covariance over different rows need not satisfy |C_ij| ≤ √(V_i·V_j);
  • MAT_CORRELATION at p ≥ 3 — a 2 × 2 correlation is clamped to [−1, 1] with a unit diagonal, which is always PSD, but three pairwise r's need not be mutually consistent;
  • MAT_PARTIAL_CORRELATION at p ≥ 3 folded columns (members plus outside controls) — its input is the pairwise correlation over every column. A decomposition operator (Decomposition): there the risk is a FATAL PULSE_MATRIX_NOT_PSD, or the repair warning under params.repair "nearest", never the detection-only warning;
  • MAT_RELIABILITY at p ≥ 3 — omega factors the pairwise inter-item correlation (a decomposition operator); there an unrepaired non-PSD input nulls omega with a PULSE_MATRIX_NOT_PSD warning (alpha needs no PSD input and still computes);
  • MAT_PCA — a decomposition operator over the pairwise correlation at p ≥ 3 (params.on "correlation") or the pairwise covariance at p ≥ 2 ("covariance", the MAT_COVARIANCE rule); the risk is the fatal refusal or the repair warning;
  • MAT_COLLINEARITY at p ≥ 3 — a decomposition operator over the pairwise correlation (VIF inverts it; Belsley's diagnostics decompose it, or the uncentered moment matrix rebuilt from it, which is PSD whenever it is); the risk is the fatal refusal or the repair warning;
  • MAT_FACTOR at p ≥ 3 — a decomposition operator over the pairwise correlation; the risk is the fatal refusal or the repair warning.

func (Matrix) RowBytes

func (m Matrix) RowBytes() int64

RowBytes is the bytes a BUFFERED matrix (not Streamable — a rank method) keeps per admitted row until finalize: the p member values and the row weight, 8·(p + 1). 0 on a streamable matrix, which keeps no rows. The row store is shared by every bucket of a grouped run (each row lands in its own bucket's store), so a run's buffer is this times the admitted rows, at most the record count.

func (Matrix) ScaleKey

func (m Matrix) ScaleKey() ScaleKey

ScaleKey is the matrix's declared range and reverse positions as the shared ScaleKey (meaningful only when HasScale).

func (Matrix) StateCount

func (m Matrix) StateCount(schema *encoding.Schema) int64

StateCount is the co-moment states the matrix holds per merge block: 1, or on MAT_DISTANCE its base state plus one per between bucket when the bucket count is known from the schema (EstimateBuckets over params.between; 1 otherwise, the per-bucket states then uncounted).

type MatrixExtension

type MatrixExtension struct {
	Streamable bool
	Accepts    []encoding.FieldType
	Auxiliary  []string
}

MatrixExtension is what resolution needs to know about an embedder-registered MAT_* operator: its declared tier, the member column types it reads (empty: the built-in member types the vector rules admit) and its declared auxiliary keys.

type MatrixResolve

type MatrixResolve struct {
	Known      func(types.MatrixType) bool
	Route      func(types.GroupType) types.GroupType
	BetweenExt func(string) bool
	Extension  func(types.MatrixType) (MatrixExtension, bool)
}

MatrixResolve parameterises ResolveMatricesWith: Known, Route and BetweenExt are ResolveMatricesRouted's known / route / ext; Extension reports a registered (and offered) extension MAT_* operator, which resolves even when Known refuses it. Nil Extension registers none.

type MemberRef

type MemberRef struct {
	Field   string
	Element int
}

MemberRef locates one member's value on a record: scalar column Field (Element < 0), or element Element (0-based) of native vector field Field.

func (MemberRef) Native

func (m MemberRef) Native() bool

Native reports whether the member is an element of a native vector.

type MetricDefault

type MetricDefault struct {
	// Index is the slot's position in Request.Matrices.
	Index int
	// Vector and Kind are the vector the slot reads and its kind.
	Vector string
	Kind   types.VectorKind
	// Consumer is the registry consumer the slot resolves as.
	Consumer metric.Consumer
	// Metric is the filled metric; TableDefault the kind's own default
	// in the slot's form (they differ when the consumer does not accept
	// the table default).
	Metric, TableDefault string
	// Params are the slot's params with "metric" set.
	Params json.RawMessage
}

MetricDefault is one kind-filled metric on a matrix slot.

func MatrixMetricDefaults

func MatrixMetricDefaults(req *types.Request, schema *encoding.Schema) []MetricDefault

MatrixMetricDefaults returns, in request order, the metric each matrix slot defaults to: a metric-taking type (MatrixMetricConsumer) reading a kind-declared vector by `vector` whose params are a JSON object naming no metric (absent or null). Inline `fields` carry no kind and are never filled; malformed params are left for decode to refuse. A native vector field named directly is read with its schema kind (KindIn). Under MAT_DISTANCE's standardize a non-negative-domain metric (aitchison, hellinger) is not admitted — z-scored centroids are signed — so the next suitable one is filled.

type NativeVector

type NativeVector struct {
	// Field is the vec field's name (the vector's Name).
	Field string
	// FieldIndex is the field's LOGICAL position in Schema.Fields.
	FieldIndex int
	// Dim is the element count.
	Dim int
	// Type is vec_f32 or vec_f64.
	Type encoding.FieldType
	// HasLabels reports element labels declared in the schema (Labels
	// are then those, not the "f_<i>" defaults).
	HasLabels bool
}

NativeVector marks a Resolved that IS one native vector field.

type PCAComponents

type PCAComponents struct {
	Rule  string
	K     int
	Share float64
}

PCAComponents is MAT_PCA's resolved params.components.

type PCScoreConfig

type PCScoreConfig struct {
	// Component is the 1-based component scored (required).
	Component int
	// On is PCAOnCorrelation (default) or PCAOnCovariance.
	On string
	// Rotation is "" (none) or a PCARotations criterion; Epsilon its
	// geomin ε (0 unless RotationGeominOrthogonal).
	Rotation string
	Epsilon  float64
	// Components is the k leading components rotated within (required
	// with a rotation, refused without one); 0 when unrotated.
	Components int
	// FitOn is the fit_on filterer list; nil fits on every filtered row.
	FitOn []*types.Filterer
	// Fit / Labels: as MahalanobisConfig's.
	Fit    string
	Labels []string
}

PCScoreConfig is ATTR_PC_SCORE's decoded params.

func PCScoreParams

func PCScoreParams(at string, raw json.RawMessage) (PCScoreConfig, *errors.CodedError)

PCScoreParams decodes ATTR_PC_SCORE's params: component (an integer ≥ 1, required), on ("correlation" default, or "covariance"), rotation ("none" default, or an orthogonal criterion — MAT_PCA's rule, decodeRotation), epsilon (geomin_orthogonal only), components (an integer ≥ component, required with a rotation and refused without one), fit_on and missing (FittedCommon). Unknown keys are refused; the bounds against the member count are CheckMembers. at is the slot path. Predict and the runtime factory both call it.

func (PCScoreConfig) CheckMembers

func (cfg PCScoreConfig) CheckMembers(at string, p int) *errors.CodedError

CheckMembers refuses a component (or a rotated k) beyond the p members: there are only p components.

type RefAlignment

type RefAlignment struct {
	// Slot holds the ref() call (possibly under label-preserving
	// transforms of the pair argument).
	Slot *exprast.Node
	// Call is the ref() call; Table its table.
	Call  *exprast.CallNode
	Table string
	// Perm reorders the table's profile into the other side's label
	// order: element i is the profile's value at Perm[i].
	Perm []int
}

RefAlignment is how one ref() argument of a pair call is aligned.

type RefScope

type RefScope struct {
	// LabelsOf returns the labels of the named vector an identifier
	// binds (false when the identifier is not a bound named vector: a
	// schema field of that name shadows the vector, as it does when the
	// expression is bound).
	LabelsOf func(name string) ([]string, bool)
	// Tables are the instance's reference-vector tables.
	Tables ReferenceTables
	// contains filtered or unexported fields
}

RefScope is what an expression's references are judged against.

func (RefScope) AlignPair

func (s RefScope) AlignPair(c *exprast.CallNode) ([]RefAlignment, []*errors.CodedError)

AlignPair judges one call of a pair built-in (dot, dist, cosine; any other node returns nothing): every ref() argument whose table is a registered literal gets its alignment to the other argument, or the issue that refuses it. A ref() whose own call fails CheckRefCall is left to that check.

func (RefScope) CheckRefCall

func (s RefScope) CheckRefCall(c *exprast.CallNode) *errors.CodedError

CheckRefCall judges one ref() call on its own: a literal registered table and, when the key is a literal, a registered key. nil when it passes.

func (RefScope) WithLets

func (s RefScope) WithLets(src string) RefScope

WithLets returns s shadowing every let-bound name src declares.

type ReferenceTable

type ReferenceTable struct {
	// Labels are the element labels, in the order each profile lists its
	// values.
	Labels []string
	// Keys are the profile keys, sorted.
	Keys []string
	// Profiles maps a key to its values, index-aligned with Labels. Nil
	// in the predict view, which carries Labels and Keys only.
	Profiles map[string][]float64
}

ReferenceTable is one registered reference-vector table.

func (ReferenceTable) HasKey

func (t ReferenceTable) HasKey(key string) bool

HasKey reports whether the table has a profile under key.

func (ReferenceTable) KeyUnknown

func (t ReferenceTable) KeyUnknown(name, key string) *errors.CodedError

KeyUnknown is the PULSE_VECTOR_REFERENCE_UNKNOWN refusal (reason key_unknown) of key in table name.

func (ReferenceTable) Match

func (t ReferenceTable) Match(name, vector string, labels []string) ([]int, *errors.CodedError)

Match aligns the table's labels to labels, the labels of the vector the reference is compared with (named vector in details; "" when the compared side is not a named vector): perm[i] is the index, in the table, of labels[i]. The two label sets must be equal — same size, no label on one side only — else PULSE_VECTOR_REFERENCE_MISMATCH reason labels_differ with the labels only the vector has ("missing" from the table) and only the table has ("extra").

func (ReferenceTable) Profile

func (t ReferenceTable) Profile(key string, perm []int) ([]float64, bool)

Profile returns key's values reordered by perm (perm[i] indexes the table; nil keeps the table's own order) in a new slice; false when the table has no such profile or carries no values (the predict view).

type ReferenceTables

type ReferenceTables map[string]ReferenceTable

ReferenceTables are the instance's reference-vector tables by name.

func NewReferenceTables

func NewReferenceTables(in map[string]types.ReferenceVectorTable) ReferenceTables

NewReferenceTables copies the registered tables into the engine's read-only form (sorted keys; the embedder's maps and slices are not retained). Nil for none.

func (ReferenceTables) Names

func (ts ReferenceTables) Names() []string

Names returns the registered table names, sorted.

func (ReferenceTables) Table

Table returns the table registered as name, or the PULSE_VECTOR_REFERENCE_UNKNOWN refusal (reason table_unknown, the registered names under "valid").

type Resolved

type Resolved struct {
	// Name is the vector's request-scoped name.
	Name string
	// Members are the member field names in axis order.
	Members []string
	// Labels are the display labels, one per member: the spec's own, or
	// the member names when the spec sets none.
	Labels []string
	// Coerce is the spec's coercion ("" when none).
	Coerce types.VectorCoerce
	// Kind is the spec's declared kind ("" when none).
	Kind types.VectorKind
	// HasScale reports declared scale bounds (kind "scale" only):
	// ScaleMin < ScaleMax, both finite.
	HasScale           bool
	ScaleMin, ScaleMax float64
	// Native is set when the vector IS one native vector field named
	// directly (no Request.Vectors entry): its metadata is the schema's.
	Native *NativeVector
	// Refs locates each member (index-aligned with Members) when any
	// member is an element of a native vector field; nil when every
	// member is a scalar column (Ref reads Members then).
	Refs []MemberRef
}

Resolved is one vector after resolution.

func Find

func Find(resolved []Resolved, name string) (Resolved, bool)

Find returns the resolved vector named name.

func Natives

func Natives(schema *encoding.Schema) []Resolved

Natives returns one Resolved per native vector field of schema, in schema order (nil when it has none): Name = the field, Members its element members, Labels the schema labels (else the "f_<i>" defaults), Kind / scale range from the schema, Native set.

func Resolve

func Resolve(specs []types.VectorSpec, schema *encoding.Schema) ([]Resolved, *errors.CodedError)

Resolve resolves every spec in specs against schema, in order. It returns the resolved vectors — index-aligned with specs, followed by the schema's native vector fields (Natives), so every by-name lookup (Find) accepts a native field named directly — or the first refusal. A nil / empty specs over a vector-free schema resolves to nil, nil.

func ResolveSpec

func ResolveSpec(at string, spec types.VectorSpec, schema *encoding.Schema) (Resolved, *errors.CodedError)

ResolveSpec resolves one spec against schema. at is the spec's path in the request ("vectors[0]", or an operator slot's inline-fields path) and lands in every refusal's details under "vector". Duplicate NAMES are Resolve's concern, not this function's.

func (Resolved) Ref

func (r Resolved) Ref(i int) MemberRef

Ref returns member i's location: Refs[i] when the vector reads a native element anywhere, else the scalar column Members[i].

func (Resolved) SourceFields

func (r Resolved) SourceFields() []string

SourceFields returns the distinct schema fields r's members read, in first-use order: a scalar member's column, a native element's vector field. Projection decodes these (an element member names no column).

type ScaleKey

type ScaleKey struct {
	// Lo and Hi are the declared range, Lo < Hi, both finite.
	Lo, Hi float64
	// Reverse are the reverse-keyed member positions, ascending.
	Reverse []int
}

ScaleKey is a rating battery's declared scale range [Lo, Hi] and its reverse-keyed member positions — the one definition MAT_RELIABILITY and ATTR_SCALE_SCORE share. The range is DECLARED (params or a kind "scale" vector's bounds), never inferred from the data, and a value outside it is never clamped: MAT_RELIABILITY refuses the run, ATTR_SCALE_SCORE reads the value as missing and counts it.

func (ScaleKey) ApplyReverse

func (k ScaleKey) ApplyReverse(x []float64)

ApplyReverse flips each reverse-keyed present member of x in place: x' = Lo + Hi − x. A NaN stays NaN.

func (ScaleKey) FirstOutOfRange

func (k ScaleKey) FirstOutOfRange(x []float64) int

FirstOutOfRange returns the first position of x holding a present value outside [Lo, Hi], or −1.

func (ScaleKey) OutOfRange

func (k ScaleKey) OutOfRange(v float64) bool

OutOfRange reports whether the present value v lies outside [Lo, Hi] (NaN — a missing value — never does).

type ScaleScoreConfig

type ScaleScoreConfig struct {
	// Stat is ScaleStatMean (default) or ScaleStatSum.
	Stat string
	// MinValid is the fewest valid (present, in-range) items a row
	// needs for a score; below it the score is null. Default: every
	// item.
	MinValid int
	// HasScale reports a declared range (params, else the kind "scale"
	// vector's bounds); Key carries it and the reverse positions.
	HasScale bool
	Key      ScaleKey
}

ScaleScoreConfig is ATTR_SCALE_SCORE's params judged against its resolved members.

func ScaleScoreParams

func ScaleScoreParams(at string, raw json.RawMessage, members Resolved) (ScaleScoreConfig, *errors.CodedError)

ScaleScoreParams judges ATTR_SCALE_SCORE's params against members (the resolved vector or inline fields): stat ("mean" default, or "sum"), min_valid (an integer in [1, item count], default the item count), scale_min / scale_max (both or neither, finite, min < max; without them the kind "scale" vector's declared bounds stand in) and reverse (member LABELS, each once; needs a range from either source — the range is never inferred from the data). Unknown keys are refused. Refusals are SERVICE_VALIDATION naming the slot at. Predict (the field-reference walk) and the runtime (Processor.prepare) both call it.

func (ScaleScoreConfig) CanonicalParams

func (cfg ScaleScoreConfig) CanonicalParams(members []string) json.RawMessage

CanonicalParams is cfg as the params of an inline-fields slot over members (labels = member names): every default written out, the declared range explicit (so a kind "scale" vector's bounds survive the rewrite to literal fields) and reverse spelled by member NAME. Processor.prepare hands it to the factory beside the literal member list; ScaleScoreParams over those members decodes it back to cfg.

type TestInput

type TestInput struct {
	// Members is the first member set (axis order).
	Members Resolved
	// Members2 is the second member set; HasSecond reports it is set.
	Members2  Resolved
	HasSecond bool
}

TestInput is one test slot's vector input after resolution. The zero value (Has false) is a test that reads no vector.

func ResolveTests

func ResolveTests(req *types.Request, schema *encoding.Schema, route func(types.TestType) types.TestType, ext func(string) bool) ([]TestInput, *errors.CodedError)

ResolveTests resolves every tier-1 test's vector input against schema (Request.Vectors first, like ResolveMatrices) and judges every post-test's. route maps a test type to the built-in it executes as — the instance's view, where a hidden type routes to an unknown name; nil is the identity. ext reports whether a routed type that is not a built-in is a registered extension test (its member sets are then judged); nil means none is. The result is index-aligned with req.Tests (the zero TestInput for a test that reads no vector); the first refusal is returned. Like Resolve it reads only the schema.

func (TestInput) Has

func (in TestInput) Has() bool

Has reports whether the slot resolved a vector input.

func (TestInput) P

func (in TestInput) P() int

P is the member count of the first set.

type VecAggParams

type VecAggParams struct {
	// Labels is params.labels: one display label per member (inline
	// fields only).
	Labels []string `json:"labels,omitempty"`
	// Expand replaces the array value with one scalar column per member,
	// named ExpandedColumn(label, element label). Each is an ordinary
	// nullable f64 output column (Sort, a window, a post-test, a series
	// overlay's params.field and a later chain stage read it); the bare
	// label stays refused.
	Expand bool `json:"expand,omitempty"`
	// Element is params.element: the display label of the ONE member a
	// crosstab cell or margin aggregation reads (SelectsElement). The
	// slot is then a scalar over that member alone — its figure, floor
	// and components are the selected element's — so the crosstab
	// array_valued refusal does not apply. Built-in vector aggregators
	// only (for an extension the key is the operator's own); refused
	// outside a crosstab slot (element_outside_crosstab), beside expand
	// (element_with_expand), naming no member label (element_unknown)
	// or a label two members share (element_ambiguous).
	Element *string `json:"element,omitempty"`
}

VecAggParams is a vector aggregator's decoded params.

func DecodeExtensionVecAggParams

func DecodeExtensionVecAggParams(at string, typ types.AggregationType, raw json.RawMessage) (VecAggParams, *errors.CodedError)

DecodeExtensionVecAggParams decodes the engine's keys of an extension vector aggregator's params — `labels` and `expand` — leniently: every other key is the operator's own and is left alone. A reserved key of the wrong JSON type is bad_params. at is the slot path.

func DecodeVecAggParams

func DecodeVecAggParams(at string, typ types.AggregationType, raw json.RawMessage) (VecAggParams, *errors.CodedError)

DecodeVecAggParams decodes a vector aggregator's params strictly (unknown keys refused, bad_params). at is the slot path.

Jump to

Keyboard shortcuts

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