Documentation
¶
Overview ¶
Package fieldaccept is the ONE accepted-field-types table: for each built-in operator slot that reads a field's value, the field types it accepts and the coded refusal it raises for any other type.
Both sides read it. The runtime constructors in internal/processing (window application, the features, the regression build, the tier-1 test constructors, the numeric aggregators' registry wrapper) refuse with Refusal / Check, and predict (internal/descriptor) reports the very same *errors.CodedError at the same slot, so the two agree on code, message, details and count by construction. The manifest's accepts_types for a tabled slot is TypeNames (or, where noted, a subset of it), so the declaration cannot drift from the rule either.
Every row refuses with a code that says what it means: PULSE_FIELD_TYPE_UNSUPPORTED for "this slot does not read that type", PULSE_TEST_FIELD_NOT_NUMERIC / _FIELD2_ for a tier-1 test's field. A few constructors (the set_* refusals of the aggregator / attribute / grouper / filterer families) keep their own message, which names only the operators the instance offers, but raise the row's code; predict reports that code once per slot from here, and the root acceptance gate holds each row equal to its constructor over every field type.
The decimal rule runs before any row: a decimal128 field on a built-in aggregator with no decimal arm (outside DecimalAggregators) is PULSE_AGG_NOT_MEANINGFUL_FOR_DECIMAL.
It is a leaf: it imports only the public errors / encoding / types packages (and the stdlib-only internal/paramread, for a lenient params probe), never internal/processing or internal/service, so internal/descriptor may import it without breaking TestPredictNoExecutionImports.
Only built-in operators are tabled. An extension operator declares its accepted types through its registration's capability (accepts_types) and is never looked up here: Lookup misses for it, and every helper answers "no rule" (accept).
A vector field (vec_f32 / vec_f64) is never refused here: every slot that reads one value refuses a vector with PULSE_VECTOR_FIELD_NOT_SCALAR through the field-reference walk, first, and a second type refusal would only repeat it. TypeNames never lists a vector type for a tabled slot.
Index ¶
- Constants
- func Accepts(op string, slot Slot, ft encoding.FieldType) bool
- func Check(op string, slot Slot, field string, schema *encoding.Schema) *errors.CodedError
- func CheckExtensionRegression(op string, accepts []encoding.FieldType, slot Slot, field string, ...) *errors.CodedError
- func CovariateParam(raw []byte) string
- func CovariateRefusal(op, field, splitBy, covariate string, schema *encoding.Schema) *errors.CodedError
- func CovariateTests() []string
- func CovariateUnsupportedRefusal(path, op string) *errors.CodedError
- func DecimalAggregators() []string
- func ExpectedRefusal(op, rows, cols string, expected map[string]float64, schema *encoding.Schema) *errors.CodedError
- func ExtensionRegressionAccepts(accepts []encoding.FieldType, ft encoding.FieldType) bool
- func ExtensionRegressionTypeNames(accepts []encoding.FieldType) []string
- func HasDecimalArm(op string) bool
- func HasRequiredSlots(op types.TestType, post bool) bool
- func Levels(f *encoding.Field) []string
- func Operators() []string
- func OperatorsRaising(code errors.Code) []string
- func P0Refusal(op, splitBy string, p0 float64) *errors.CodedError
- func PackedBoolLevels() []string
- func ReferenceRefusal(op, splitBy, reference string, schema *encoding.Schema) *errors.CodedError
- func Refusal(op string, slot Slot, field string, ft encoding.FieldType) *errors.CodedError
- func RequiredSlotsRefusal(op types.TestType, post bool, s TestSlots) *errors.CodedError
- func SortedLabels(expected map[string]float64) []string
- func SuccessLevelRefusal(op, field, success string, schema *encoding.Schema) *errors.CodedError
- func TakesCovariate(op types.TestType) bool
- func TakesReference(op types.TestType) bool
- func TypeNames(op string, slot Slot) []string
- type Rule
- type Slot
- type TestSlots
Constants ¶
const ( CovariateReasonUnsupported = "unsupported_test" CovariateReasonWithoutSplitBy = "without_split_by" CovariateReasonNotNumeric = "not_numeric" CovariateReasonIsField = "is_field" )
The Details["reason"] values of PULSE_TEST_COVARIATE_INVALID.
const ( PackedBoolFalse = "0" PackedBoolTrue = "1" )
The two levels a packed_bool reads as: GROUP_CATEGORY's bucket keys, FILTER_INCLUDE's values and TEST_PROP_Z's success literals. There are no true / false aliases.
const ( ExpectedReasonWithCols = "with_cols" ExpectedReasonTooFew = "too_few_labels" ExpectedReasonEmptyLabel = "empty_label" ExpectedReasonNotPositive = "not_positive" ExpectedReasonSum = "sum_not_one" ExpectedReasonNotALevel = "not_a_level" )
The Details["reason"] values of PULSE_TEST_EXPECTED_INVALID.
const ( P0ReasonRange = "out_of_range" P0ReasonWithSplitBy = "with_split_by" )
The Details["reason"] values of PULSE_TEST_P0_INVALID.
const ( ReferenceReasonWithoutSplitBy = "without_split_by" ReferenceReasonNotALevel = "not_a_level" )
The Details["reason"] values of PULSE_TEST_REFERENCE_INVALID.
const CovariateKey = "covariate"
CovariateKey is the params key of the two-group mean and proportion tests' covariate adjustment (CUPED, U48).
const ExpectedSumTolerance = 1e-9
ExpectedSumTolerance is how far params.expected's proportions may sum from 1: a fit is never renormalised, so a share list that does not add up is a typo, not a rounding difference.
Variables ¶
This section is empty.
Functions ¶
func Accepts ¶
Accepts reports whether op's slot accepts ft: the decimal rule first (a decimal128 field on a built-in aggregator with no decimal arm), then the slot's row. An untabled slot and a vector type (the field-reference walk's refusal) answer true.
func Check ¶
Check is Refusal for a field named in a request: nil when the schema has no such field (an unknown name is the field-reference walk's refusal; a derived column carries no schema type) or the slot accepts it.
func CheckExtensionRegression ¶
func CheckExtensionRegression(op string, accepts []encoding.FieldType, slot Slot, field string, schema *encoding.Schema) *errors.CodedError
CheckExtensionRegression is Check for a registered extension REG_* model op's target or predictor slot (ExtensionRegressionAccepts): nil when the schema lacks the field or the slot accepts it, else PULSE_FIELD_TYPE_UNSUPPORTED in the table's shape, under op's name. The runtime adapter and predict raise the same error.
func CovariateParam ¶
CovariateParam returns the raw Params blob's "covariate" value; "" when params are absent, malformed or carry none (a lenient probe — the test's constructor decodes and records it).
func CovariateRefusal ¶
func CovariateRefusal(op, field, splitBy, covariate string, schema *encoding.Schema) *errors.CodedError
CovariateRefusal is the covariate-taking tests' params.covariate rule: an empty covariate is absent (no adjustment); a set one needs split_by (the adjustment compares two groups), must not be the test's own field, and on a schema field must be numeric (the tier-1 test value set: no categorical index, no set bitmask). An unknown name is the field-reference walk's refusal and a vector the vector rule's, both earlier; a derived column is not type-judged. Predict and the runtime constructors both raise it (PULSE_TEST_COVARIATE_INVALID), after params.reference. Nil when usable.
func CovariateTests ¶
func CovariateTests() []string
CovariateTests returns the test types that read params.covariate, sorted.
func CovariateUnsupportedRefusal ¶
func CovariateUnsupportedRefusal(path, op string) *errors.CodedError
CovariateUnsupportedRefusal is the refusal of params.covariate on a test that does not read it (op at slot path, e.g. "tests[1]" or "post_tests[0]"): the params allowlist raises it in place of the generic unknown-key refusal, on predict and every runtime funnel alike, so a covariate is never silently ignored.
func DecimalAggregators ¶
func DecimalAggregators() []string
DecimalAggregators returns the built-in aggregators with a decimal128 implementation, sorted.
func ExpectedRefusal ¶
func ExpectedRefusal(op, rows, cols string, expected map[string]float64, schema *encoding.Schema) *errors.CodedError
ExpectedRefusal is TEST_CHISQ's goodness-of-fit params rule: with params.expected set (a non-nil map) the test reads rows alone, so cols must be empty; the map needs at least two labels, none empty, every proportion a finite number above 0, summing to 1 within ExpectedSumTolerance; and on a packed_bool rows field every label is a level ("0" / "1") — any other label can never be observed. A categorical's labels are not judged against its dictionary: a label the data never shows is a legitimate observed 0. Predict and the runtime constructor both raise it (PULSE_TEST_EXPECTED_INVALID), after the rows requirement and before the axis type check. Nil when the params are usable.
func ExtensionRegressionAccepts ¶
ExtensionRegressionAccepts reports whether a registered extension REG_* model's target / predictor slot accepts ft: the built-in regressions' rule when accepts is empty, else exactly the listed types. A vector type answers true (the field-reference walk refuses it), as Accepts does.
func ExtensionRegressionTypeNames ¶
ExtensionRegressionTypeNames lists the field types a registered extension REG_* model's target and predictors accept (ExtensionRegressionAccepts), sorted byte-wise like TypeNames; vector types are never listed.
func HasDecimalArm ¶
HasDecimalArm reports whether the built-in aggregator op has a decimal128 implementation.
func HasRequiredSlots ¶
HasRequiredSlots reports whether built-in test op (a post-test when post) has a tabled required-slot rule.
func Levels ¶
Levels returns the declared levels of a level-set field (the categoricalValue class): a categorical's dictionary labels in dictionary order, or a packed_bool's PackedBoolLevels. Nil for any other field, or a categorical with no dictionary. FEAT_ONE_HOT builds its output columns from it on both sides (runtime and predict's post-feature schema), so the column set is a function of the schema.
func OperatorsRaising ¶
OperatorsRaising returns every tabled operator with a slot whose refusal carries code, sorted — the owner list of that code.
func P0Refusal ¶
func P0Refusal(op, splitBy string, p0 float64) *errors.CodedError
P0Refusal is TEST_PROP_Z's one-proportion params rule: p0 must lie strictly between 0 and 1 (at 0 or 1 the null standard error is 0), and is refused beside split_by — a two-proportion test has no hypothesised rate, and ignoring it would hide the mistake. Predict and the runtime constructor both raise it (PULSE_TEST_P0_INVALID).
func PackedBoolLevels ¶
func PackedBoolLevels() []string
PackedBoolLevels returns the two packed_bool levels, false first.
func ReferenceRefusal ¶
func ReferenceRefusal(op, splitBy, reference string, schema *encoding.Schema) *errors.CodedError
ReferenceRefusal is the two-group tests' params.reference rule: an empty reference is absent (alphabetical order, nothing to judge); a set one needs split_by (the one-sample / one-proportion forms have no second group to read against), and on a schema field must be one of its levels — "0" / "1" on a packed_bool, a dictionary entry on a categorical. A split_by the schema does not hold (a derived column) is not judged here: the runtime's Finalize refuses an unobserved reference (PULSE_TEST_REFERENCE_MISSING). Predict and the runtime constructors both raise it (PULSE_TEST_REFERENCE_INVALID), after the field and split_by type refusals. Nil when usable.
func Refusal ¶
Refusal is the coded refusal for a field named field, of type ft, in op's slot — nil when the slot accepts it (Accepts). Message, code and details are the same on every side that raises it.
func RequiredSlotsRefusal ¶
RequiredSlotsRefusal is a built-in test constructor's missing-slot refusal — PROCESSING_CONFIG with the constructor's message, at its first rule with an empty slot — or nil when every required slot is named (or op has no tabled rule). The constructors raise it and predict reports the same coded error, so a missing field / field2 / split_by / subject_field reads alike on both sides.
func SortedLabels ¶
SortedLabels returns expected's labels sorted byte-wise: the order a goodness-of-fit result lists its categories in, and the order the proportions are summed in (so the sum is a function of the set).
func SuccessLevelRefusal ¶
func SuccessLevelRefusal(op, field, success string, schema *encoding.Schema) *errors.CodedError
SuccessLevelRefusal is TEST_PROP_Z's success-literal rule: on a packed_bool outcome success must be exactly "0" or "1"; on a categorical one, exactly an entry of its dictionary — a typo (or "true") would count no success and report a confident zero rate. Nil when success is a level, or the outcome is not a schema field (a derived column), a dictionary-less categorical, or another type (the accepted-types table's refusal). Both forms, two-group and p0, are judged alike. Over a shard archive the schema is the canonical one, its dictionaries the union of every shard's (ReferenceRefusal's split_by rule reads the same). Predict and the runtime constructor both raise it, after the outcome and split type checks.
func TakesCovariate ¶
TakesCovariate reports whether the tier-1 test type op reads params.covariate.
func TakesReference ¶
TakesReference reports whether test type op reads params.reference.
func TypeNames ¶
TypeNames returns the names of every registered field type op's slot accepts, sorted byte-wise (the manifest's accepts_types order); nil for an untabled slot. Vector types are never listed. The slice is shared (capacity clipped, so an append copies): callers must not modify it in place.
Types ¶
type Rule ¶
type Rule struct {
// Accepts reports whether the slot accepts a field of type ft.
Accepts func(ft encoding.FieldType) bool
// Code is the refusal's code for any other (non-vector) type.
Code errors.Code
}
Rule is one tabled slot: the accepted types and the refusal code.
type Slot ¶
type Slot string
Slot names the request position a field is judged in.
const ( // SlotField is the operator's primary `field`. SlotField Slot = "field" // SlotField2 is a paired / bivariate test's `field2`. SlotField2 Slot = "field2" // SlotTarget is a regression's `target`. SlotTarget Slot = "target" // SlotPredictor is one entry of a regression's `predictors`. SlotPredictor Slot = "predictor" // SlotSplitBy is a test's `split_by` grouping column. SlotSplitBy Slot = "split_by" // SlotSubject is TEST_ANOVA_RM's and ATTR_PREVIOUS_STATE's // `subject_field`. SlotSubject Slot = "subject_field" // SlotOrder is ATTR_PREVIOUS_STATE's `order_field`. SlotOrder Slot = "order_field" // SlotRows / SlotCols are a contingency test's `rows` / `cols`. SlotRows Slot = "rows" SlotCols Slot = "cols" // SlotStratify is FEAT_TRAIN_TEST_SPLIT's `params.stratify`. SlotStratify Slot = "stratify" // SlotPrediction is a model-error aggregator's // `params.prediction_field`. SlotPrediction Slot = "prediction_field" // SlotNumerator / SlotDenominator are AGG_RATIO's // `params.numerator_field` / `params.denominator_field`. SlotNumerator Slot = "numerator_field" SlotDenominator Slot = "denominator_field" // SlotOutcome is AGG_AUC's `params.outcome` (the binary outcome // scored against the score in `field`). SlotOutcome Slot = "outcome" // SlotBase is WIN_LIFT's `params.base` (the column the field's share // is compared with). SlotBase Slot = "base" )