Documentation
¶
Overview ¶
Package prevstate is the one ATTR_PREVIOUS_STATE slot rule: which slot keys it reads (field, subject_field, order_field), which it refuses, and the field types each accepts. The runtime factory (internal/processing) and predict (internal/descriptor) both call Check, so the two raise the same code, message and details by construction; the field-reference walk (internal/descriptor, run on both sides before any operator is built) calls FieldRefs and ForeignSlotRefusal. KeySchema is the internal dictionary-inheritance view both sides read, so the output column resolves through its state field's dictionary on every label-resolving consumer.
It is a leaf: it imports only the public errors / encoding / types packages and internal/fieldaccept, never internal/processing or internal/service, so internal/descriptor may import it without breaking TestPredictNoExecutionImports.
Index ¶
- func BeforeFilters(t types.AttributeType) bool
- func BeforeFiltersLabels(attrs []*types.Attribute, route func(types.AttributeType) types.AttributeType) []string
- func Check(attr *types.Attribute, schema *encoding.Schema) *errors.CodedError
- func ForeignSlotRefusal(attr *types.Attribute, route types.AttributeType) *errors.CodedError
- func KeySchema(attrs []*types.Attribute, schema *encoding.Schema) *encoding.Schema
- func Label(attr *types.Attribute) string
- type Ref
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BeforeFilters ¶
func BeforeFilters(t types.AttributeType) bool
BeforeFilters is the per-operator "computed before filters" property: an attribute of type t runs over the whole decoded cohort BEFORE the filter pass (after the pre-filter features), so a filter keeps each subject's first in-window record with its true previous state and an expression filter may read the output column. Only ATTR_PREVIOUS_STATE carries it; every other attribute (an extension's included) runs over the filter-passing records. The runtime's buffered pipeline and the field-reference walk (predict and runtime alike) both read it here.
func BeforeFiltersLabels ¶
func BeforeFiltersLabels(attrs []*types.Attribute, route func(types.AttributeType) types.AttributeType) []string
BeforeFiltersLabels returns the output column of every attrs slot whose type route reports BeforeFilters, in declared order; nil when none. route maps a slot's type to the operator it runs as (predict's instance route; the identity at runtime).
func Check ¶
Check is the slot's configuration rule, first refusal first:
- field, subject_field and order_field are each required (PROCESSING_CONFIG);
- target, predictors and expression belong to other attribute types and would be silently ignored here (PROCESSING_CONFIG);
- each named schema field's type is judged by the accepted-types table (PULSE_FIELD_TYPE_UNSUPPORTED): field a categorical_* or packed_bool (a coded unsigned integer is refused with a pointer at re-importing it as a categorical), subject_field any scalar but a set_*, order_field a date or datetime.
A name the schema does not carry (unknown, or a derived column) is the field-reference walk's refusal, and a vector field its PULSE_VECTOR_FIELD_NOT_SCALAR, so neither is judged here. A nil schema judges only rules 1-2.
func ForeignSlotRefusal ¶
func ForeignSlotRefusal(attr *types.Attribute, route types.AttributeType) *errors.CodedError
ForeignSlotRefusal refuses subject_field / order_field on any attribute route other than ATTR_PREVIOUS_STATE: every other attribute would ignore them silently. Nil when neither is set, or route is ATTR_PREVIOUS_STATE.
func KeySchema ¶
KeySchema is the dictionary-inheritance hook: schema with one virtual field per ATTR_PREVIOUS_STATE output column of attrs, typed as the slot's state field and carrying its dictionary (its packed_bool type for a packed_bool state), nullable — the output values ARE the source field's codes (dictionary indices, or 0 / 1), so every label-resolving consumer reads the output column as it reads the source field: GROUP_CATEGORY keys, Group.Include, crosstab axes, req.Labels validation and predict's dictionary-derived axis bounds. A previous-state × state crosstab then carries the same labels on both axes.
The virtual fields are appended after the cohort's fields (every existing field index stays put) and have no physical presence: the result is a NAME-LOOKUP view, never a decode, stride or write schema. A slot whose state field the schema does not carry (or carries with another type — Check refuses it), or whose label already names a schema field, contributes nothing. schema itself is returned — the same pointer — when no slot contributes, so a request without the attribute is byte-identical. Internal: only this attribute declares an inherited dictionary (an extension attribute cannot).
Types ¶
type Ref ¶
type Ref struct {
Slot fieldaccept.Slot
Name string
}
Ref is one field the slot reads: the slot key and the field it names.