Payload JSON Schema
Pulse publishes a single machine-readable JSON Schema (draft 2020-12)
describing every public payload — the request envelopes and the universal
--json output envelope. Use it to validate requests before sending them,
to generate client types, or to drive editor autocompletion.
Where to get it
The schema is reachable three ways, all backed by the same generator
(BuildPayloadSchema in internal/descriptor):
| Surface | How |
|---|---|
| Docs URL | https://frankbardon.github.io/pulse/payload-schema.json — the file’s own $id. |
| CLI | pulse schema prints it to stdout (offline; no cohort needed). |
| MCP resource | Read pulse://schema (MIME application/json) alongside pulse_manifest. |
| Go library | p.PayloadSchema() returns the schema of instance p as raw JSON. |
The CLI and MCP surfaces emit byte-identical output to the published file.
On this page, “byte-identical” beside an additive key means identical to the output of the same request before the key existed: a request that omits the key neither gains a field nor changes its hash.
Per-instance schema
The root $comment carries the describing instance’s feature-set digest,
"feature_set_digest: fs1:…" — the same value as the manifest’s
feature_set_digest and p.FeatureSetDigest(), so both self-descriptions
can be cached under one key. $id never changes.
p.PayloadSchema() describes only what instance p offers. Without a
feature profile or extensions it is the published file byte for byte.
Every extension operator the instance registers (and its profile keeps)
joins its category’s operator-type enum beside the built-ins —
AggregationType, AttributeType, FiltererType, GroupType,
WindowType, FeatureType, TestType, MatrixType,
RegressionType, OverlayKind and PostFitType (extension-only, so
empty without a registration) — so a request
naming one validates against the instance’s own schema. An instance
built with a feature profile gets a narrower document:
- the operator, overlay-kind and regression enums list only the enabled names;
- a capability-gated slot the instance hides (the
gatedSlotstable ininternal/descriptor/request_slots.go:crosstab,joins,overlays,vectors,matrices,weight,models,params,union,output, a Compose root’ssweep/fits/optimize/ …) is not a property of its root (a hiddenvectorstakesVectorSpec,VectorCoerce,VectorKindandVectorStandardizewith it; hiddenmatricestakesMatrixSpec, theResponse.matricesandResponseComponents.matricesslots andMatrixResult/MatrixComponentswith it —MatrixValuesstays, shared with the regressionvcov/correlation); withoutcapability:weightingno per-slotweightis a property either (soSlotWeightandWeightSpecare absent), and withoutcapability:multiplicitynomultiplicityblock is a property of any root or slot (soMultiplicity,RegressionMultiplicity,MultiplicityMethodandMultiplicityFamilyare absent); withoutcapability:regression_holdoutneitherRegressionSpec.holdoutnorRegressionResult.holdoutis a property (soRegressionHoldoutis absent); withoutcapability:regression_orderRegressionSpec.orderis not a property (soRegressionOrderandOrderGapsare absent); - a root whose capability is not offered is absent —
ComposedRequest/ComposedResponse(compose),ChainRequest/ChainResponse(process-chain),FacetRequest/FacetResult(facet),SampleRequest(sample),LookupRequest/LookupResult(lookup),RecommendRequest/RecommendResult(recommend),ExplainRequest/ExplainResult(explain),MaterializePredictResult(materialize); on an instance that offers explain,ExplainRequestdrops the slots of every hidden root (composed/composed_response,chain/chain_response,facet/facet_result,sample); - every def reachable only through an omitted part is dropped, so the
document stays a valid draft 2020-12 schema with no dangling
$ref.
Request, Response and Envelope are always present. pulse schema
serves the CLI’s default instance; the pulse://schema MCP resource
serves the mounted instance’s schema (p.PayloadSchema()).
Structure
The document is a $defs bundle. The root oneOf lists the entry points:
- Requests —
#/$defs/Request(process / predict),ComposedRequest(compose),ChainRequest(process-chain),FacetRequest,SampleRequest,LookupRequest(point lookup),RecommendRequest(recommend),ExplainRequest(explain: one request root, or one result root with its request companion, or anoperatorname alone, plusdetail). - Results —
#/$defs/Response,ComposedResponse,ChainResponse,FacetResult(itswarningsare coded{code, message, details}entries, theResponse.warningsshape),LookupResult,RecommendResult(its draftrequestis an open object: a"<placeholder>"may sit whereRequesttakes a number;steps— theRecommendStepplan{tool, request, placeholders, why}— is deprecated, markeddeprecated: true, and always absent: recommend drafts no multi-request plan),ExplainResult(itsfindings[].numbersvalues are["number", "null"],verdictthe closedVerdictenum;warningsrelays predict’s coded warnings; operator mode addsvalidation, theOperatorValidationrecord{references, gap, weight_refusal, certification}),MaterializePredictResult(Pulse.PredictMaterialize/pulse api materialize --predict/pulse_materialize {predict: true}:valid, the sourceschema_info, the outputcolumns—{name, type, nullable, description, from, derived}plus a truncateddictionaryand a decimalprecision/scale— thederived_columnsnames and the data-dependentrisks{column, path, code, check}; the three lists are[], nevernull). A bootstrapRegressionResultechoesbootstrap_requested/bootstrap_succeeded; a delete-a-group jackknife (RegressionSpec.jackknife_groups/jackknife_by, both additiveomitempty) echoes its replicate count asjackknife_groups, absent on leave-one-out. ARegressionResultcarries the fit’s own coded diagnostics inwarnings(additiveomitempty,#/$defs/ResponseWarningentries — an extension regression’s, e.g.PROCESSING_REGRESSION_DIAGNOSTIC), each also lifted onto the response’swarnings. EachComposedResponse.responses[i]echoes its slot’s finallabel(absent on a standaloneResponse). - Advisory —
#/$defs/Advisory, one entry of a predict result’sadvisories({code, message, details}): a coded, non-blocking note that the analysis may not fit the data. Never a warning. The same shape ridesRegressionResult.advisories(additiveomitempty, in thestandardandminimalpresets): anl1/elasticnetfit withoutresamplecarriesPULSE_ADVISORY_PENALIZED_INFERENCE_UNDEFINEDbeside itsstd_errors,p_values,ci_lowerandci_upper, which arenullon every key (the data pick the predictors, so no analytical inference is valid); predict raises the identical advisory andOptions.SuppressAdvisoriesdrops it from both. Predict’slimit_findings({limit, configured, estimated, grade, details}— on Process, Compose, chain and facet predict;detailslocates a Compose slot asrequestor a chain stage asstage) is a predict result field, not part of this schema. So is predict’spost_window({windows_first, window_labels, attributes: [{index, label, depends_on, window_reads}]}— on Process predict and per Compose slot, additiveomitempty, absent without a window): the post-window plan, which attributes run after the windows, by index. So isunresolved_scalars([{path, expression, reads}]— on Process predict and Compose predict, additiveomitempty): every scalar-expression slot predict could not compute because it callscoef(),sweep_axis(),lookup(),range_label()or an embedder function — an optimize bound, or aWIN_DISTRIBUTED_LAGdecay / shape / scale / max_lag orWIN_EWMAalpha / decay window param (windows[0].params.decay, underrequests[i]./fits[i].request.in a batch), or an embedder extension operator’s number param its registration declares expression-capable (aggregations[0].params.scale; the manifest marks itexpression). A window param,AGG_CONSTANTexpror expression-capable extension param whose only such reads arecoef()/sweep_axis()/response()of the request’s (or facet’s) own loadedmodels/populationsentry — and an optimize bound or start reading only its block’s ownmodels— is not listed: predict folds it to the runtime’s value and range-checks it (a Composefitsentry stays listed). Those params take a number or an expression string; a slot’sparamsobject stays open in this schema. - Envelope —
#/$defs/Envelope, the universal--jsonwrapper. Itsdataslot is intentionally open: it carries whatever the operation returned (aResponse, the manifest, a predict result, an inspect result, …). To validate a wrapped result strictly, validate the unwrappeddatavalue against its own def (e.g.#/$defs/Response).
Example — validate a request body with any draft-2020-12 validator:
pulse schema > payload-schema.json
# then point your validator at payload-schema.json#/$defs/Request
How it stays in sync
The schema is generated, never hand-maintained, so it cannot silently drift from the engine:
- Reflection over the Go payload structs — a new or renamed field changes the output.
- Registry-injected enums — the operator, matrix, overlay-kind
and regression discriminants draw their value lists from the same
types.All*Types()/AllOverlayKinds()/AllRegressionTypes()registries the engine executes against (an instance adds its extensions;PostFitTypehas no built-in value), so registering a new operator changes the schema. Other closed vocabularies with a registry list (MultiplicityMethod,ReturnPreset,SweepMode,CovarianceType, …) are enums too. - Hand-tuned strict unions for the two shapes reflection cannot
express:
OverlayRef(at most one arm populated; thematrix {name}arm names aRequest.Matricesspec for the matrix-result overlay host) andOverlayPayload(shape-discriminatedscalar/series/matrix, plus namedpartsthat never nest).
A golden test (TestPayloadSchemaGolden) pins the output and an
enum-parity test (TestPayloadSchema_EnumsMatchRegistry) fails CI on
drift; the schema’s format_version is held equal to the envelope’s
(TestPayloadSchema_VersionMatchesEnvelope). Regenerate after an
intentional payload change with:
go test ./descriptor/ -run TestPayloadSchemaGolden -update
v1 boundaries
The schema is faithful but not maximally strict in two places, by design:
- Operator
params(thejson.RawMessageslot on aggregations, groupers, overlays, etc.) is an open object here. The per-operator allowlist is the manifest’s param list for the operator: predict and every runtime arm refuse an undeclared key (PULSE_REQUEST_UNKNOWN_FIELD), and the operator’s skill documents each param. - Small closed mode enums (
OverlayScope,OverlayShape,CrosstabNormalize,CrosstabShape,LabelMode,MarginAxis) are typed as plain strings rather thanenums — they have no registry helper, and a hardcoded list would drift silently.
One shape reads oddly against the rest and is deliberate rather than an
oversight: MarginAggregationFigure.present (on the crosstab’s auxiliary
margin figures — row_margin_aggregations / column_margin_aggregations
/ grand_total_aggregations) is required, so a false is on the wire,
while its sibling value is optional and open. A margin slot that
admitted no record has no defined aggregate; emitting 0 there would be
indistinguishable from a genuine zero, so the figure carries no value
at all and present is what says so. Dropping present when false would
put that statement back into an absence — exactly what it exists to
avoid. Every other field of every response sub-shape stays omitempty.
Cross-slot validation rules that depend on more than one field (e.g. a
crosstab requires at least one row grouper, mutually exclusive with
top-level groups; every crosstab.margin_aggregations entry needs
a type and a label distinct from every other entry’s and from the cell’s)
are enforced by predict (pulse api predict) at request time, not by
the schema.
crosstab.columns is optional (not in the schema’s required list):
absent, null or [] runs the crosstab with ONE implicit column, key
["Total"], column_header {fields: ["_total"], types: ["TOTAL"]},
holding every record whose row key resolved — a Total column with no
constant field behind it.
crosstab.cell is optional too: a crosstab names its cell aggregation
either as cell or as several measures in cells (an array of
Aggregation, mutually exclusive with cell — predict refuses both, or
neither, since the schema cannot say “exactly one”). Each measure
becomes a stub row under every row key: row_header gains the
_measure / MEASURE position, matrix.cell_labels[i] names row i’s
measure, and the per-measure column margins and grand total move to
matrix.measures[] (CrosstabMeasureMargins) and
components.crosstab.measures[] (CrosstabMeasureComponents). All three
result slots are optional and absent on a single-cell crosstab.
Time-zone slots
Four optional string slots name a time zone:
time_zoneonRequestandFacetRequest— the request-level zone.ComposedRequestandChainRequestcarry none of their own (each innerRequestdoes);SampleRequesthas none.tzon everyGroup(so alsocrosstab.rows[]/crosstab.columns[]),Filterer,AttributeandFeatureentry — the per-slot override. It is a slot key besidetype/field, never a key insideparams.time_zone_field(request) andtz_field(slot), on the same objects — a per-row zone: the name of a categorical cohort field whose values are IANA zone names, so each row is read in its own zone.
All are typed as plain strings. The schema does not encode the zone
name set or which operators accept tz; these rules are enforced by
predict and at run time instead:
- a name must be exactly
UTCor an IANAArea/Locationzone (Europe/Berlin,Etc/GMT-5) — anything else isPULSE_TIMEZONE_UNKNOWN; tzandtz_fieldare accepted only on operators whose manifest entry carries"zone": "capable", never on adatefield, and never both on one slot — otherwisePROCESSING_CONFIG;- a zone field must be a
categorical_*cohort field (absent:SERVICE_VALIDATION; another type:PROCESSING_CONFIG) whose every dictionary entry is a valid zone name (elsePULSE_TIMEZONE_UNKNOWNwithdetails.dictionary_index); - precedence is slot
tz→ slottz_field→time_zone_field→time_zone→ the cohort’s default zone field (echoedsource: "cohort") → the engine’sDefaultTimeZone→UTC; a resolved zone on adatetimefield reads each instant on its local calendar day, and a non-UTC zone (or any zone field) reaching a derived field (absent from the schema) is refused withPROCESSING_CONFIG.
The resolved zone per slot is echoed by predict as
data.time_zones[] — {slot, operator, field_type, tz, tz_field, source} (source: "field" or "cohort" with tz: null for a per-row
zone) —
which is a predict result field, not part of this schema. See
skills/request-envelope.md (Time zones).
Request params
params on Request is an additive, optional object of named
constants every expression of that request reads, read-only, as
params.<name> (or params["<name>"]): ATTR_FORMULA,
FILTER_EXPRESSION, a total() argument, a regression holdout,
OVERLAY_FORMULA and every scalar-expression param (an expression-valued
window param, AGG_CONSTANT expr, an extension’s expression-capable
param). Gated by capability:params:
an instance whose feature profile omits it has no params property and
refuses the key as an unknown field.
The schema types it as an object whose property names match
^[A-Za-z_][A-Za-z0-9_]*$ and whose values are a number, a string, a
boolean, or an array of numbers, of strings or of booleans. Rules the
schema cannot say, enforced by predict and at run time alike,
before any record is read:
- a value is never
null, and a list holds ONE kind — otherwisePULSE_PARAMS_INVALID(details.reason:null_value,invalid_name,mixed_list,unsupported_value); - numbers are kept as their JSON text: an integer binds as an integer
(
int64, oruint64above it), so a large id compares exactly; any other number binds as a float. A list of numbers binds as the one integer or float array type every element fits; - reading a name the object does not declare is
PULSE_PARAMS_UNDECLARED; readingparams.<name>whereparamsis also a name the request reads (a schema field, feature output, attribute label or vector calledparams) isPULSE_PARAMS_FIELD_COLLISION. A bareparamsalways reads that name.
ComposedRequest and ChainRequest carry a params of their own,
same schema and gate: every sub-request inherits it — each Compose
slot (sweep- and banner-expanded ones included), each Compose fits
request, each chain stage — merged during normalization with a key the
sub-request declares itself winning. The top-level block is validated
once, before any sub-request (PULSE_PARAMS_INVALID, even when every
sub-request overrides the bad name). The normalized request
(--echo-request, pulse api predict-compose / predict-chain)
shows the merged params on every sub-request. A Compose-level
OVERLAY_FORMULA reads the batch’s top-level params; an undeclared
read there is PULSE_PARAMS_UNDECLARED.
FacetRequest carries a params of its own too, same schema, rules and
gate: its filterers’ FILTER_EXPRESSIONs (base and additive scope
alike) read it as a Request’s filterers read theirs, so a facet over
the filter an analysis applies (wave == params.wave) takes the same
block. pulse api facet, pulse api predict-facet and the
pulse_facet_schema tool accept it; a facet template can pass a
variable as "params": {"wave": {"$var": "wave"}}.
A Compose sweep axis may carry target: "params.<name>" (SweepAxis,
same gate): each sweep slot’s request then takes the axis value as
params.<name> (declared, or overriding the body’s and the batch’s
value). FilterToFileRequest (a library-only Go root, not a payload
root) carries a params of its own with the same rules.
Union slots
union on Request — and, with the same rules, on ChainRequest
(stage 0’s source), FacetRequest, SampleRequest and LookupRequest
(a lookup over a union scans: it reads no sidecar index) —
(#/$defs/UnionMember {cohort, label}, both required) reads several
labelled cohorts as ONE record stream in place of cohort; union_source_field (a string, default _source) names
the virtual categorical source field the union adds — one dictionary
entry per label, in declared order, so groups: [{field: "_source"}]
splits by member. Both are additive: format_version stays "1.1" and
a request without them is byte-identical. Rules the schema cannot say,
judged by predict and the runtime alike before any member is read:
cohort and union together is PULSE_UNION_COHORT_CONFLICT; a member
without a cohort filename PULSE_UNION_MEMBER_INVALID; an empty or
repeated label PULSE_UNION_LABEL_INVALID (details.reason empty /
duplicate); union_source_field without a union, or naming a field
a member carries, PULSE_UNION_SOURCE_FIELD_INVALID (details.reason
without_union / collision); more than 65,535 members — or shards,
once each shard-archive member is flattened —
PULSE_UNION_MEMBER_LIMIT. Member schemas merge by the shard-archive
rules (set fields widen; names, types, vector dims, categorical widths,
nullability and the default zone field must agree; dictionaries union
within their width): a pair an archive refuses is
PULSE_UNION_SCHEMA_MISMATCH, carrying the archive refusal’s details
(details.dimension where it names one) plus archive_code, member
and label. A union key on a join (its right side) is
PULSE_UNION_JOIN_RIGHT; one inside a union member is
PULSE_UNION_NESTED. Predict reads each member’s header and schema
only and reports record_count (the members’ total) and union
([{label, cohort, record_count, shards}]).
Which surfaces execute a union. Process and its stream
(--stream, ProcessStream), every Compose slot (serial and
parallel), a ProcessChain’s stage 0 (the chain root’s union; later
stages read the stage before), FacetSchema, Sample (the request form —
SampleWithRequest, MCP pulse_sample), Materialize (the source field
is written as a column, derived columns are described “derived from
union”), Lookup (always a scan of the members in declared order; no
sidecar index is read or written) and a join’s LEFT side (the union is
the request’s own cohort; the join’s right names one cohort). Every
predict root (Predict, PredictCompose, PredictChain, PredictFacet,
PredictMaterialize) sizes a union the same way, header and schema only.
Refused. A union on a join’s RIGHT side
(PULSE_UNION_JOIN_RIGHT) and a nested union — a member, or a member’s
cohort, carrying its own union (PULSE_UNION_NESTED) — are refused
when the request is decoded, located by details.path like any
unknown key. A single-source predict handed a union (the library
descriptor-level predict over one reader) is PULSE_UNION_UNSUPPORTED.
Feature gate. Both keys ride capability:union on every root: an
instance whose feature profile omits it has no union /
union_source_field property and no UnionMember def, refuses either
key (union_source_field alone included) as PULSE_REQUEST_UNKNOWN_FIELD,
lists no PULSE_UNION_* code, and reads a union key on a join as a
plain unknown key.
Materialize output slot
output on Request (#/$defs/MaterializeOutput) lays out the cohort
Pulse.Materialize writes: columns — a list of
#/$defs/MaterializeOutputColumn {from, as, description, nullable, type, precision, scale, on_cast_error, recode, bucket}, from required — XOR exclude (field / derived-column names) — plus the
container keys shards (#/$defs/MaterializeShards {max_records}: a
shard archive of max_records-row shards; max_records ≤ 0 is
PULSE_MATERIALIZE_OUTPUT_INVALID), elide_constants (store a
column constant over the written rows once) and groups
(#/$defs/MaterializeGroup {key, members} over written names; absent
inherits the source’s parent groups whose members are written
unchanged, [] writes none). It is
additive: format_version stays "1.1" and omitting it writes the
cohort Materialize always wrote, byte for byte. It is MATERIALIZE-ONLY:
every other operation that takes a Request (process, compose, chain,
predict, their streaming, CLI and MCP surfaces) refuses it with
PULSE_MATERIALIZE_OUTPUT_ONLY (details.slot: "output"). Gated by
capability:materialize_output: an instance whose feature profile
omits it has no output property and refuses the key as an unknown
field everywhere. Rules the schema cannot say, enforced before any
record is read: columns and exclude together, an empty columns
list, an exclude dropping every column or an entry without from is
PULSE_MATERIALIZE_OUTPUT_INVALID; a name that is neither a source
field nor a derived column is PULSE_MATERIALIZE_OUTPUT_UNKNOWN_COLUMN;
two columns under one name after as is
PULSE_MATERIALIZE_OUTPUT_DUPLICATE; a type its column cannot cast
to is PULSE_MATERIALIZE_CAST_UNSUPPORTED, an unknown type, a bad
precision / scale or a misused on_cast_error ("fail" /
"null") PULSE_MATERIALIZE_OUTPUT_INVALID. recode
(#/$defs/MaterializeRecode {map, order}; a map value is a label or
null) rewrites a categorical’s dictionary before type reads it: a
map key its source dictionary lacks is
PULSE_MATERIALIZE_RECODE_UNKNOWN_LABEL (details.label); a recode of a
non-categorical, a null on a non-nullable column, or an order that
is not exactly the recoded labels once each is
PULSE_MATERIALIZE_OUTPUT_INVALID. bucket
(#/$defs/MaterializeBucket {ranges, range_table}, each range a
#/$defs/MaterializeBucketRange {label, start, end} whose bounds are a
number, an ISO date string or null) writes a numeric or date-family
column as the categorical_* of its range labels; its refusals are the
shared range codes (PULSE_RANGE_SOURCE_AMBIGUOUS,
PULSE_RANGE_TABLE_UNKNOWN, PULSE_RANGE_TABLE_KIND_MISMATCH,
PULSE_RANGE_EMPTY / _INVALID / _DUPLICATE_LABEL / _OVERLAP) plus
PULSE_MATERIALIZE_OUTPUT_INVALID for an unbucketable column, and a
value outside every range fails like a cast. A null in a nullable: false column fails the run with PULSE_MATERIALIZE_OUTPUT_NULL, a
stored value its cast cannot represent with
PULSE_MATERIALIZE_CAST_FAILED (or, on_cast_error: "null", a null and
a PULSE_MATERIALIZE_CAST_NULLED warning). See
Materializing Derived Columns.
Multiplicity slots
Multiple-comparison correction adds one additive block shape,
#/$defs/Multiplicity {method, family, alpha} (every key optional;
a request that names no block hashes identically). It rides
as multiplicity on Request, Test (tests[] and post_tests[]),
OverlaySpec (request and facet overlays), MatrixSpec (matrices[]),
ComposeOverlaySpec, FitComparisonSpec (compare[]) and
ComposedRequest; a RegressionSpec
(regressions[]) carries #/$defs/RegressionMultiplicity, the same
three keys plus coefficients (an array of coefficient names). A
member regression’s RegressionResult gains the additive p_adjusted
(number map, null for an undefined p), significant_adjusted (boolean
map) and multiplicity (AppliedMultiplicity) beside p_values. method is the closed enum
MultiplicityMethod (none, bonferroni, holm, bh, by) and
family the closed enum MultiplicityFamily (layer, row, column,
request, compose, matrix, and the echo-only margins — the family
a regression’s marginal effects form on their own, which a block naming
it is refused);
both are full vocabularies on every instance (not features). alpha is a
number in (0, 1).
Each key falls through on its own: slot → request (a Compose slot: then
the ComposedRequest) → the engine’s DefaultMultiplicity → none, and an
omitted family takes the surface default (request for tests and
regressions, layer for overlays, matrix for a matrix spec). A
regression joins only through its own block — an inherited one never
reaches it — and REG_BAYES_LINEAR refuses any method but none. {"method": "none"} is the explicit opt-out. What the
schema cannot say is enforced identically by predict and the
runtime (PULSE_MULTIPLICITY_INVALID): the families each surface offers
(row / column only on a MATRIX-payload overlay kind, compose only
inside Compose, never request on a Compose overlay or anything but
layer / row / column on a facet overlay, matrix only — with
request — on a matrix spec), no alpha on a test’s own block, no
explicit correction on the Tukey HSD post-test, and no block on a matrix
operator without p-values (only MAT_CORRELATION /
MAT_PARTIAL_CORRELATION, MAT_SEM and an extension operator declaring
PValues take one; on the first two it implies params.inference, and
an explicit params.inference: false beside it is refused). Members
of one request or compose family that resolve to different methods
are refused PULSE_MULTIPLICITY_CONFLICT.
On a grouped request (groups set) every tests[] entry runs once per
composite group key, and tests[] in the response is flat: one
TestResult per (test x group), test-major, the groups in the final
data row order. Each carries the additive omitempty group_key (an
array — the bucket’s per-grouper key tuple, one element for one grouper;
the MatrixResult.group_key shape), so entry k belongs to request
tests[k / groups]. A group whose data the test refuses has null
statistic and p_value (reject_null false) and a response warning
under the refusal’s code naming its group_key. An ungrouped response
carries no group_key and is byte-identical; format_version stays
"1.1".
With two or more groupers every post_tests[] entry likewise runs once
per partition of the result rows — the rows sharing the leading group
key columns, every key but the last by default, or the leading prefix
its params.partition_by names ([] = one run over every row) — and
post_tests[] is flat: post-tests x partitions, test-major, partitions
in first-appearance data order, each result’s group_key the
partition key (one element per partition column). Every post-test of a
request partitions alike (PULSE_TEST_PARTITION_INVALID otherwise), so
entry k belongs to request post_tests[k / partitions]. One grouper,
partition_by: [] and a crosstab host never partition: one result per
post-test, no group_key, byte-identical.
When a correction runs, each corrected TestResult (in tests[] and
post_tests[]) gains three additive omitempty keys BESIDE its raw
p_value / reject_null, which never change: p_adjusted (number, or
null when the raw p is undefined — such a p is left out of the family
size), significant_adjusted (p_adjusted < the test’s own alpha;
absent when p_adjusted is null) and multiplicity
(#/$defs/AppliedMultiplicity {method, family, alpha, m, excluded},
m the number of defined p-values corrected together, excluded
(integer, omitempty) the family’s members left out of m because their
p is undefined — a sparse group or partition; absent when 0, and summed
over the families of a row / column echo like m). Every
(test x group) and (post-test x partition) result joins its slot’s
family, so a request family pools them all. Each test contributes
one headline p; the Tukey HSD post-test never joins a family. No block,
or a method resolving to none, emits none of them — the response is
byte-identical. On an instance that hides capability:multiplicity the
three keys and AppliedMultiplicity are absent from the schema too.
An inferential overlay layer is corrected the same way, its adjusted
figures riding the layer’s own additive slots — the base payload (the
matrix cells, scalar, each summary’s p_value / statistic) never
changes. Where they land follows where the kind carries its p-values:
an OverlaySummary (the layer’s, for the χ² / KS kinds whose p is
summary.p_value; each SERIES entry’s, for OVERLAY_CHISQ_ROW /
_COL, and for OVERLAY_T_VS_REF / OVERLAY_Z_VS_REF whose p is the
entry’s statistic; each tested period’s, for the *_VS_PRIOR tests
whose p is the entry’s p_value — the first period has none and is no
family member) gains p_adjusted and significant_adjusted; a
MATRIX payload whose cells are p-values (the pairwise, Fisher and
*_CELL kinds) gains two parallel MatrixPayloads, payload.p_adjusted
and payload.significant_adjusted, on identical headers, keys and
[row][column] coordinates (a panel kind’s cell vector maps element for
element: []number|null and []boolean|null); a base cell that is
absent stays absent, an undefined adjusted p is null and its
significance cell absent. The layer gains a multiplicity echo
(AppliedMultiplicity), present only when a correction ran.
significant_adjusted compares against the resolved
multiplicity.alpha (default 0.05). A layer family never mixes
layers; a request-family layer pools with the request’s tests and
post-tests, so its echo’s m is the pooled count. A row (column)
family is one family per row (column) index of the layer’s own MATRIX
payload — purely coordinate-based, never crossing rows (columns) or
layers — and every element of a panel cell joins its cell’s row
(column); its echo adds m_per (array of integers, omitempty), each
family’s size index-aligned with the matrix rows (columns), 0 for an
index with no defined p-value, and m is their sum. A facet overlay
(FacetResult.overlays[]) is corrected per layer with the same slots
and the engine’s DefaultMultiplicity applying. These keys ride
capability:multiplicity like the test outputs.
A matrix spec under params.inference (set, or implied by its own
block) is corrected over its DISTINCT pairs: the off-diagonal upper
triangle of each square_symmetric result (m = k(k − 1)/2 for k
members — the diagonal and the mirrored lower triangle are not separate
hypotheses), every cell of a rectangular one. The result’s open
auxiliary map gains p_adjusted and significant_adjusted, two
MatrixValues of auxiliary.p’s kind, encoding and keys (mirrored into
both triangles under full, diagonal null; significant_adjusted is
1 when p_adjusted < the block’s alpha, else 0, null beside a
null p_adjusted), and the MatrixResult gains a multiplicity echo
(AppliedMultiplicity). auxiliary.p never changes. Family matrix
(the default) is one family per result — per spec and per group
bucket; request pools every bucket of the spec with the request’s
other request-family members. An inherited block reaches only a spec
already under params.inference or an extension operator declaring
PValues; MAT_SEM joins through its own block only, one hypothesis
per estimate row with a defined p_value. The echo key rides
capability:multiplicity.
Overlay payload parts
OverlayPayload.parts (additive, omitempty) carries a multi-output
overlay kind’s named secondary payloads BESIDE its primary: one spec
still produces one layer, and the primary (shape + its arm) stays where
every renderer already reads it.
{"shape": "matrix", "matrix": {"…": "residuals"},
"parts": {"expected": {"shape": "matrix", "matrix": {"…": "…"}},
"p": {"shape": "matrix", "matrix": {"…": "…"}}}}
- Each part is a plain
scalar|series|matrixpayload under the same shape rule as the primary. Parts never nest: the schema’s per-part definition has nopartskey, and the engine refuses a handler that builds one (PROCESSING_INTERNAL). - Part names are fixed per kind and listed in the kind’s skill.
- A single-output kind may still write an OPT-IN part: every
OVERLAY_PAIRWISE_*kind writeslettersonly underparams.letters— a matrix on the host coordinates whose present cellvalueis an object{"letter", "group", "higher", "above"}(types.PairwiseLetterCell;higher/aboveare letter arrays, empty, nevernull), not a number. - A coordinate-style matrix part whose columns are dimensions rather than
host keys (points × dimensions) keys them
["dim_1"],["dim_2"], … in dimension order. - A layer without parts — every single-output kind — writes no
partskey, so its bytes are unchanged;format_versionstays"1.1". returnaddresses one part asoverlays[*].payload.parts.<part>. A part name is a map key, so the path is Open: an excluded part is ABSENT (nevernull), an include naming no existing part raisesPULSE_RETURN_PATH_UNMATCHED, and excluding every part drops thepartskey.- Export: NDJSON, Arrow and Parquet write each layer as JSON, parts
included; Excel writes the primary on the layer’s sheet and drops the
parts under one
PULSE_OVERLAY_EXPORT_PARTS_DROPPEDwarning; CSV, TSV and SPSS drop whole layers underPULSE_OVERLAY_EXPORT_CSV_UNSUPPORTED.
Weight slots
Row weighting adds two optional slot shapes (a request that names no weight hashes identically):
weightonRequest— aWeightSpecobject{field, kind},kind∈probability(default when omitted) |frequency.ComposedRequestandChainRequestcarry none of their own (each innerRequestdoes);FacetRequestandSampleRequesthave none.weighton everyAggregation(so alsocrosstab.celland eachcrosstab.margin_aggregations[]entry),Test(tests[]andpost_tests[]),RegressionSpec,MatrixSpec,Attribute,OverlaySpecandGroup(groups[]and both crosstab axes) — the per-slotSlotWeightunion: a field-name string, aWeightSpecobject, ornull. Inferential slots (tests, regressions, reference-distribution attributes, the quantile grouper, inferential overlays) are refusedPULSE_WEIGHT_UNSUPPORTEDwhile a weight is in force, so on themnullis the way to run unweighted.
null is not absence. An absent per-slot weight inherits the
request’s weight, then the engine’s DefaultWeight; an explicit
null opts that one slot out, so it runs unweighted while the rest of
the request stays weighted. The schema says so with
oneOf [string, WeightSpec, null] on #/$defs/SlotWeight.
The field set a weight may name is not in the schema; predict
and the runtime enforce it identically: the field must be a cohort
column (a joined, prefixed name included — never a derived column) of
an unsigned-integer or float type, otherwise SERVICE_VALIDATION
(unknown field) or PROCESSING_CONFIG ({slot, field, type}). The
resolved weight per slot is echoed by predict as data.weights[] —
{slot, operator, field, kind, status, source}, omitted when nothing
names a weight — a predict result field, not part of this schema.
A weighted aggregation slot reports three optional floor fields on its
Response.components.aggregations[i] entry — sum_weights, n_eff
(probability weights only) and n_weight_invalid — each omitempty
and present only when a weight was applied to that slot, so an
unweighted response is unchanged. n and n_null keep their
value-presence meaning.
Which operators honour, skip or refuse a weight, the invalid-weight rules and the unweighted-base recipe: Row Weighting.
Vector slot
vectors on Request is an additive array of VectorSpec
{name, fields | pattern, labels?, coerce?, kind?, scale_min?, scale_max?, standardize?}
(format_version stays "1.1"; a request with no vectors is
byte-identical and hashes identically). coerce is the closed
VectorCoerce enum (binary); kind the closed VectorKind enum
(measure, scale, composition, binary) — what the values mean,
which fills a metric-taking operator’s default metric (reported in
predict’s defaults_applied, category metric) and flags an explicit
poorly fitting one (PULSE_VECTOR_METRIC_UNSUITED, a warning, an
error under strict). scale_min / scale_max are numbers, accepted
only beside kind: "scale", both or neither, min below max.
standardize is the closed VectorStandardize enum (zscore): the
members are z-scored with their population SD over the rows a
listwise co-moment MAT_* slot keeps (frequency weights respected), so
its covariance is their correlation; every other consumer (a test,
attribute, grouper or aggregation vector, an expression, MAT_DISTANCE,
missing: "pairwise", a rank method) is refused with
PULSE_VECTOR_INVALID (details.reason standardize_unsupported,
details.slot), and predict’s matrices[].standardize echoes it.
What the schema cannot say, predict and the runtime enforce
identically before any record is read: exactly one of fields /
pattern; literal fields entries keep the caller’s order while glob
entries and pattern (a Go regular expression) expand in schema order;
members must be integer or float columns (packed_bool only with
coerce: "binary"); labels count equals the member count; names and
members are unique — refusals carry the PULSE_VECTOR_* codes.
Predict echoes the resolved members as data.resolved_vectors
({name: [members]}, a predict result field, not part of this schema).
Request.Hash() hashes a vector as written (see
Request hashing).
Test vector inputs
Test carries four additive slots, the MatrixSpec mirror:
vector / fields (the member set) and vector2 / fields2 (a
paired second set). A vector-input test (TEST_HOTELLING_T2, TEST_MANOVA,
TEST_BOX_M, TEST_BARTLETT_SPHERICITY, TEST_MARDIA) sets
exactly one of vector (a vectors entry) and fields (inline
names and globs, the VectorSpec.fields rules) and no field; a
second set must resolve to the same member count and is accepted only
by a test that reads one (TEST_HOTELLING_T2’s paired form, which
refuses split_by beside it); every other test refuses all four.
TEST_MANOVA and TEST_BOX_M require split_by (details.reason
split_by_required); TEST_BARTLETT_SPHERICITY and TEST_MARDIA
refuse it (split_by_not_accepted). Missing
data is listwise only (params.missing other than "listwise" is
refused). Shape refusals are SERVICE_VALIDATION with
details.reason; an undefined vector is PULSE_VECTOR_UNKNOWN.
format_version stays "1.1"; a test without them is byte-identical.
Attribute vector inputs
Attribute carries two additive slots, the same mirror: vector /
fields. A vector-input attribute (the fitted ATTR_MAHALANOBIS,
ATTR_PC_SCORE, ATTR_FACTOR_SCORE, the row-local
ATTR_SCALE_SCORE, and the reference comparisons
ATTR_PROFILE_SIMILARITY / ATTR_VEC_DISTANCE) sets exactly one of
them and no field; every other attribute refuses both.
Members are source columns only. ATTR_SCALE_SCORE‘s params are
stat (mean | sum, prorated), min_valid, reverse (member
labels) and scale_min / scale_max (else the kind scale vector’s
bounds). The comparisons’ params are metric (similarity / distance
direction respectively; default from the vector’s kind), min_valid
(complete pairs, default 1), labels (inline fields only) and
reference — a literal array (member order), a label map
{label: value}, {table, key} or {table, key_field} over
Extensions.ReferenceVectors, matched by label, a centroid
{centroid: {filter, by}} (the weighted per-member mean of the filtered
rows filter admits, one per by value with each row compared with its
own — a pre-pass, so the slot is two-pass), {population: name} (a
bound vector fit’s stored mean, matched by label) or
{record: {cohort?, keys: [{field, value}]}} (one stored record,
point-looked-up through its cohort’s sidecar index before the run — the
request’s own cohort when cohort is omitted — read by member column
name); ATTR_VEC_DISTANCE
adds fit_on / missing beside its fitted metrics. A fitted attribute’s params share fit_on —
"filtered" (the default) or an inline array of Filterer objects
choosing the fit rows among the filtered ones (every filtered row is
still scored) — and missing ("listwise" only). The default label is
<TYPE>_<vector>, or <TYPE>_<first fields entry> (ATTR_PC_SCORE
appends _PC<component>, ATTR_FACTOR_SCORE _F<factor>). Shape refusals
are SERVICE_VALIDATION with details.attribute and details.reason;
an undefined vector is PULSE_VECTOR_UNKNOWN. A fit that is singular,
or has N* ≤ p, nulls every score and adds a PULSE_MATRIX_SINGULAR /
PULSE_MATRIX_INSUFFICIENT_N entry to Response.warnings (details
scope: "fit"); ATTR_FACTOR_SCORE also nulls every score with
PULSE_MATRIX_NOT_IDENTIFIED (an unidentified or Kaiser-short factor
count) or PULSE_MATRIX_HEYWOOD (Bartlett over a uniqueness ≤ 0), and
scores with a PULSE_MATRIX_HEYWOOD / PULSE_MATRIX_NOT_CONVERGED
entry otherwise. format_version stays "1.1"; an attribute without
them is byte-identical.
Attribute subject and order slots
Attribute carries two additive string slots read only by
ATTR_PREVIOUS_STATE: subject_field (the cohort field identifying
each record’s subject — any scalar type but a set_* or a vector) and
order_field (a date or datetime cohort field ordering each
subject’s records by instant). Both are required on that operator, name
source columns only (an earlier attribute or feature output is refused
SERVICE_VALIDATION), and are refused PROCESSING_CONFIG on every
other attribute type; a field of the wrong type is
PULSE_FIELD_TYPE_UNSUPPORTED (details.slot names the key). They are
slot keys, never params keys. format_version stays "1.1"; an
attribute without them is byte-identical.
Grouper vector inputs
Group carries the same two additive slots, vector / fields, on
groups and both crosstab axes. A vector-input grouper (GROUP_KMEANS)
sets exactly one of them and no field; every other grouper refuses
both. Members are source columns only. Its key column (the Data row key,
the crosstab axis field) is <TYPE>_<vector> or <TYPE>_<first fields entry>. Shape refusals are SERVICE_VALIDATION with details.group
and details.reason; an undefined vector is PULSE_VECTOR_UNKNOWN. A
best start stopped at params.max_iter adds a
PULSE_MATRIX_NOT_CONVERGED entry to Response.warnings (solver
kmeans_lloyd). Predict’s groups[i].row_buffer_bytes reports its point
store. format_version stays "1.1"; a grouper without them is
byte-identical.
Aggregation vector inputs
Aggregation carries the same two additive slots, vector / fields,
on aggregations, crosstab.cell and crosstab.margin_aggregations.
A vector aggregator (AGG_VEC_MEAN, AGG_VEC_SUM, AGG_VEC_SD) sets exactly one of
them and no field; every other aggregator (extensions included)
refuses both. Members are source columns only; params.labels (one per
member) is accepted with fields only. The default label is
<TYPE>_<vector> or <TYPE>_<first fields entry>. The value in
data is a JSON ARRAY, one figure per member in member order (a
non-finite element is null); its components entry adds labels,
element_n, element_sum and, weighted, element_sum_weights
(AGG_VEC_SD adds element_mean, element_m2 and, weighted,
element_sum_weights_sq; an element whose sample size is 1 or less is
null). Shape
refusals are SERVICE_VALIDATION with details.aggregation and
details.reason; an undefined vector is PULSE_VECTOR_UNKNOWN. An
array-valued aggregator is refused PROCESSING_CONFIG
(details.reason array_valued) as a crosstab cell or margin
aggregation (the manifest lists them in
crosstab.array_valued_aggregators), as a sort key, as
aggregations[0] under overlays and in a chain stage that feeds
another (unless it expands, below). A crosstab cell or margin
aggregation runs when its params.element names ONE member label
(built-in AGG_VEC_* only): the slot is a scalar over that member —
the cell (or auxiliary) is that element’s figure, its floor counts the
rows that answered the member (so a record reaches an auxiliary margin
only if its selected member reached a cell), its components are
one-entry arrays, and it margins and fuses like its scalar twin;
element outside a crosstab, beside expand, unknown or shared is
SERVICE_VALIDATION (element_*). format_version stays "1.1"; an aggregation without them is
byte-identical.
params.expand: true on a vector aggregator replaces the array with one
scalar column per member, <label>[<element label>] in member order
(grouped: per row); the label column is absent. Every execution mode
writes the same keys. PredictResult.aggregations[i].columns lists them
(omitted on every other slot, whose one column is its label), the
return column check and PredictChain’s stage_schemas use them, and
duplicate element labels are refused (SERVICE_VALIDATION, reason
expand_duplicate_labels). Each column is an ordinary nullable f64
column: a sort key, a window’s field / order_by / partition_by,
a post-test field and a series overlay’s params.field (request,
Compose or whole-chain host) read it, and so does a later chain stage —
the synthesised schema carries each as an f64 field (an element no row
answered is NaN — null on the wire — and orders last / is skipped like a
null, and a later chain stage reads it as a null; an overlay reads it as
a missing host value), while the bare array label
stays refused there PROCESSING_CONFIG (array_valued) — so is an
overlay scoring it by default as aggregations[0]. A return path
names one with a quoted segment (data[*]."<label>[<element label>]")
and all of them with a prefix glob (data[*].<label>*).
field is optional on Aggregation, Group and Attribute (a vector
aggregator or grouper reads vector / fields, ATTR_FORMULA an
expression); the Go wire form still writes it.
Matrix slots
matrices on Request is an additive array of MatrixSpec
{name, type, vector | fields, params, weight, encoding, multiplicity, for_each} and matrices on Response the matching array of
MatrixResult {name, type, group_key?, group_header?, primary, auxiliary, vectors, scalars, warnings, multiplicity?, error?}, one per
spec in request order (format_version stays "1.1"; a matrix-free
request and response are byte-identical). type is the
registry-backed MatrixType enum (MAT_COVARIANCE, MAT_CORRELATION,
MAT_PARTIAL_CORRELATION, MAT_PCA, MAT_FACTOR, MAT_COLLINEARITY,
MAT_RELIABILITY, MAT_DISTANCE, MAT_SEM, plus an instance’s
extension MAT_* operators); encoding is full (default), upper or
records. Every matrix is a dedicated MatrixValues {kind, encoding, row_keys, column_keys, labels?, values} — not the crosstab
MatrixPayload — whose values rows hold p cells (full) or p − r
cells from the diagonal (upper). kind is square_symmetric or
rectangular (a loadings or estimates table, say: MAT_PCA’s p × k
loadings keyed by member and PC1 … PCk), and a rectangular matrix is
always written full. Under encoding: "records" every matrix (primary
and each auxiliary, rectangular ones too) is instead {kind, encoding, columns, rows, labels?}: columns the column keys, rows one object
per row in row order, {"key": <row key>, <column>: number | null, ...} (plus an operator’s own row fields, such as MAT_SEM’s estimate
lval, op, rval, parameter and free); the schema’s
MatrixValues is the oneOf of the two forms.
params stays an open object in the schema — its keys are the
operator’s manifest param list — and each operator’s skill
(skills/op-mat-<name>.md) documents its params and defaults, the
auxiliary / vectors / scalars keys it writes and the
PULSE_MATRIX_* warnings it raises. MAT_CORRELATION and
MAT_PARTIAL_CORRELATION take params.inference (bool) and
params.alpha (0 < alpha < 1, default 0.05): on, auxiliary gains
p, ci_lower and ci_upper, square twins of primary (same axis
and encoding, diagonal null); off or absent, the response is
byte-identical. Under params.missing: "pairwise", auxiliary.n is a
MatrixValues of the same shape and encoding holding each pair’s row
count. Undefined cells and scalars (no mass, too few rows, a
determinant of a matrix that is not positive definite) are null, keys
kept. What the schema cannot say, predict and the runtime enforce
identically before any record is read: exactly one of vector /
fields; a vector a vectors entry defines (else
PULSE_VECTOR_UNKNOWN); inline fields follow the vector rules;
result names are unique; params are the operator’s own. warnings
are {code, message, details} entries; a refusal of the slot’s data
(a singular or non-positive-definite input an operator cannot repair)
fails that slot alone (see Failed slots). components.matrices carries one
MatrixComponents per result, in the same order: {name, type, group_key?, n, n_null, n_listwise_dropped, min_pair_n?, max_pair_n?, sum_weights?, n_eff?, n_weight_invalid?, operator?} (pairwise and
weighted keys only when they apply; MAT_RELIABILITY’s operator
carries the omega fit’s iterations / converged; MAT_DISTANCE’s
metric, standardize, buckets and n_null_key — the rows its
between grouper placed in no bucket). Contract:
.claude/reference/matrix-and-vectors.md.
Regression coefficient covariance
RegressionSpec takes an additive vcov boolean (default false) and
RegressionResult two additive omitempty MatrixValues slots,
vcov and correlation, present only when the spec set vcov: true
(format_version stays "1.1"; a fit without it is byte-identical).
Both are square_symmetric, full, with row_keys = column_keys =
(intercept) then the predictors in spec order. vcov is the
coefficient covariance — REG_OLS σ̂²·(XᵀX)⁻¹ (ridge: the sandwich),
REG_GLM φ·(XᵀWX)⁻¹ at the converged working weights (φ = 1 for
binomial / poisson; gamma’s estimate, the Pearson χ² over its df),
whose square-rooted diagonal is exactly std_errors; REG_BAYES_LINEAR
the POSTERIOR covariance b_n/(a_n−1)·Λ_n⁻¹ (null cells when
a_n ≤ 1), whose diagonal is std_errors²·a_n/(a_n−1). A weighted fit
reads the inference size N* (Σw frequency, n_eff probability), as its
standard errors do. correlation is vcov scaled to a unit diagonal
(R’s cov2cor); an entry with a zero or undefined variance is null.
Beside a classical vcov whose dispersion is estimated — unpenalized
REG_OLS (σ̂² = RSS/df) and REG_GLM gamma (the Pearson χ²/df) —
RegressionResult carries the additive omitempty number dispersion,
so vcov / dispersion is (XᵀWX)⁻¹ (null when the residual df is ≤ 0;
absent on binomial / poisson, whose φ is 1, and on every robust,
resampled, penalized or Bayesian fit). The influence figures over a
bound fit read it.
Every plain REG_OLS / REG_GLM fit carries the additive omitempty
numbers two_log_lik (twice the maximised log-likelihood, R’s
logLik()) and aic (−two_log_lik + 2·k, k logLik‘s df: σ counted
on OLS, the dispersion on gamma, an estimated θ on negative binomial),
absent under a probability weight, a penalty, a binding OLS bound and on
REG_BAYES_LINEAR; null when infinite (a non-count poisson /
binomial response). A REG_GLM negative_binomial fit (NB2, Var = μ +
μ²/θ) adds two more additive omitempty numbers: theta — θ̂, the
maximum-likelihood estimate (MASS glm.nb), or the spec’s fixed theta
(an additive omitempty RegressionSpec number, > 0) — and
theta_std_err (θ̂’s standard error 1/√I(θ̂), present only when θ was
estimated; null when the information is not positive). Its vcov is (XᵀWX)⁻¹ at θ̂ with φ = 1 (MASS
summary.negbin), so no dispersion rides it — unless a fixed θ sets
the additive omitempty RegressionSpec string dispersion
(fixed | estimated) to estimated: then its vcov is
φ̂·(XᵀWX)⁻¹, φ̂ the Pearson χ²/df, carried as dispersion with df (R’s
summary.glm). Every other family leaves theta and theta_std_err
absent.
An additive omitempty RegressionSpec object margins ({type, terms, scale, binary}, REG_OLS / REG_GLM / REG_ORDINAL / an extension
model declaring Margins) adds the additive omitempty
object RegressionResult.margins (RegressionMarginsResult): type
(ame | mem), scale (response | link), terms (string array),
under binary: "contrast" the additive omitempty string
binary echo and string array contrasts (the 0/1 terms reported as
μ(1) − μ(0); absent under slope, the default, byte-identical),
the term-keyed number maps estimates, std_errors, statistics,
p_values, ci_lower, ci_upper, and at (mem only), the numbers
conf_level and df (present only for a Student t; null when ≤ 0),
the additive omitempty string inference ("resample"
when the regression’s resample made the standard errors the effects’
replicate spread — Wald z / percentile p, normal intervals, no df;
absent on the delta method, byte-identical),
and — gated on capability:multiplicity like the coefficient twins —
p_adjusted / significant_adjusted and a multiplicity
(AppliedMultiplicity, family: "margins") echo: under the
regression’s own block the terms form one family per regression, apart
from the coefficients’. An undefined figure is null,
key kept. A request without margins is byte-identical. On a
per-level fit (REG_ORDINAL, REG_MULTINOMIAL — every
fitted category on the response scale, the non-reference ones on the
link — or an extension model whose
extend.MarginsRegression lists outcomes) the block adds the additive
omitempty string array outcomes (the levels, in order) and every
map is keyed "<outcome>:<term>"; absent, the maps are keyed by term
(REG_OLS / REG_GLM bytes unchanged).
An additive omitempty RegressionSpec object collinearity
({basis, groups}, REG_OLS / REG_GLM; basis model |
predictors, groups an array of {name, predictors}) adds the
additive omitempty object RegressionResult.collinearity
(RegressionCollinearityResult): basis, terms (string array), the
term-keyed maps df (integers), vif and tolerance (numbers), and
gvif_scaled (numbers, present only when groups is set). An
undefined figure is null, key kept. A request without collinearity
is byte-identical.
Under resample it is the replicate covariance (jackknife
(g−1)/g·Σ(β₋ₖ−β̄)(β₋ₖ−β̄)ᵀ over its g delete groups, g = n on
leave-one-out; bootstrap the B−1 sample covariance of the
successful replicates), under selection the final refit’s covariance
keyed (intercept) + the selected predictors — so its diagonal is
std_errors² there too. Lasso / elastic net refuse vcov, with or
without a modifier, with PROCESSING_REGRESSION_VCOV_UNSUPPORTED
(details.reason penalty) in predict and at runtime alike. Both slots are in the standard preset (not
minimal) and every float in them is rounded by return.precision.
Extension regression results
An embedder-registered REG_<NS>_<NAME> model (pulse.Options.Extensions.Regressions)
returns its result in the built-in RegressionResult shape, plus two
additive omitempty slots the built-ins never fill (format_version
stays "1.1"; a built-in fit is byte-identical): statistics, the
per-coefficient test statistic (keyed like coefficients), and
outputs, an object of the model’s declared extras (its
registration’s OutputSchema keys). On an extension fit std_errors,
statistics and p_values each carry EVERY coefficient key; a figure
the model did not compute is null (key kept), so the coefficient
table stays rectangular. A model whose registration does not declare
PValues emits none: its p_values is null on every coefficient,
under resample too. Only a coefficient whose p-value is defined
joins a multiplicity family. ci_lower / ci_upper / conf_level
are the engine’s (below, Regression coefficient intervals): β ∓ q·SE
on every coefficient key, null where the standard error is, q the
Student-t on the model’s reported df, else (and under resample)
the normal; df is the reported one only on a t interval. A
non-finite float in outputs is null. The fit statistics a model may report
are r2, adj_r2, residual_std_err, df, deviance,
null_deviance, pseudo_r2, two_log_lik and aic
(extend.RegressionFit; the last two never under a
probability weight) and converged_iters. The built-in model
regressions (REG_MMM_HILL, REG_MMM_BAYES, REG_ORDINAL) answer in
the same shape; REG_ORDINAL names its thresholds "<level>|<next>"
beside the predictors (no intercept), leaves their p_values null,
and fills outputs link, levels, thresholds,
fitted_probabilities and, with params.brant, brant (with
params.nominal_test, nominal_test: {statistic, df, p_value, terms},
a failed partial fit’s figures null; absent under a probability weight).
REG_MMM_HILL with params.adstock appends decay:<channel> (and
peak:<channel>) after s:<channel>, adds outputs.condition_number
(null when the joint block does not invert) and, above 1e6, carries
PULSE_ADVISORY_MMM_ADSTOCK_ILL_CONDITIONED on advisories
(result-only; the standard errors stay).
n_obs, sum_weights / n_eff, p_adjusted, multiplicity and
error stay engine-owned. outputs is not on the components
machinery: neither disable_components / --no-components nor any
return preset strips it (it is in minimal and standard). The Go
RegressionResult.ReportedFigures (the fit statistics the model
reported, so a reported exact 0 ranks in a compose sweep) is
json:"-" and never reaches the wire. A sweep rank reads an
extension fit like a built-in: regressions.<name>.outputs.<key> ranks
on a declared output (an exact 0 included), a fit statistic the model
reported ranks, and one it did not report is missing — refused
PULSE_SWEEP_RANK_PATH (reason missing) when no slot reports it.
Under resample (always accepted on an extension model) the result
echoes resample (and bootstrap_requested / bootstrap_succeeded,
jackknife_groups) as a built-in’s does, and every coefficient’s
std_errors, statistics (the Wald z) and p_values carry the
replicate figures; under selection (a SupportsSelection model) it
echoes selection, criterion and selected_features.
On the request side RegressionSpec takes an additive params object
(omitempty; absent is byte-identical), the model’s own configuration.
Its keys are the registration’s declared Params — the manifest’s
extensions.regressions[].params entries not marked slot — and any
other key is refused PULSE_REQUEST_UNKNOWN_FIELD with details.path
regressions[i].params.<key>, identically at predict and at runtime; a
value not of its declared json_type, or a missing required param, is
PULSE_REQUEST_PARAM_INVALID at the same path (every extension
category’s params is checked this way). A
registration declaring no params leaves the object unchecked (predict
notes it PULSE_ADVISORY_EXTENSION_PARAMS_UNDECLARED). The built-ins
(REG_OLS, REG_GLM, REG_BAYES_LINEAR) take every knob as a typed
field and declare no params, so any params key on one is refused. The
manifest row lists the model’s output_schema (key, json_type,
description), the keys outputs may carry. Recipe:
docs/src/internals/extension-points.md (Regression model).
Regression robust covariance
RegressionSpec takes an additive covariance object {type, cluster, cluster2, order_by, entity, lags} and RegressionResult an additive omitempty
covariance echo {type, cluster, clusters, cluster2, clusters2, order_by, lags, entity, entities, periods} (format_version stays "1.1"). type is the
CovarianceType enum (classical, hc0, hc1, hc2, hc3,
cluster, hac, driscoll_kraay); lags is a non-negative integer or
"auto". entity (types hac and driscoll_kraay) names a
panel’s entity field: hac + entity is per-entity Newey–West,
driscoll_kraay sums the scores per order_by period; the echo then
adds periods (distinct order_by values) and, with an entity,
entity / entities. A plain hac echo carries none of the three.
cluster2 (type cluster) makes it two-way
(Cameron–Gelbach–Miller); the echo adds cluster2 / clusters2, an
OLS df is min(G₁, G₂) − 1, and a negative two-way variance leaves its
std_errors / p_values / interval entries null beside the negative
vcov diagonal. A one-way echo carries neither key. Absent or classical is
byte-identical to a request without the block and echoes nothing. Any
other type on REG_OLS or REG_GLM replaces the estimator behind
std_errors, p_values, ci_lower / ci_upper and vcov (so
√diag(vcov) is still exactly std_errors); under cluster, an OLS
df is the cluster count minus 1 (GLM stays Wald z). On
REG_BAYES_LINEAR it keeps the posterior-mean coefficients and
REPLACES the posterior covariance with Müller’s sandwich posterior:
std_errors, credible_intervals, ci_lower / ci_upper (normal, no
df) and vcov follow it. REG_MULTINOMIAL takes hc0, hc1 and
cluster (the score sandwich over its K − 1 blocks); an extension model
takes the types its registration declares (CovarianceTypes). Shape
faults are PROCESSING_CONFIG; a robust type beside a penalty,
resample or selection, or one the regression type does not compute,
is
PROCESSING_REGRESSION_VCOV_UNSUPPORTED (details.reason), in predict
and at runtime alike. The echo is in the standard preset.
Regression shrinkage controls
RegressionSpec.prior_precision (REG_BAYES_LINEAR) is
#/$defs/PriorPrecision, a oneOf of a non-negative number (the
scalar ε, Λ₀ = ε·I; absent or 0 = the default 1e-3) and an array of non-negative numbers (one per
coefficient, intercept first like prior_mu: Λ₀ = diag; 0 is a flat
prior). A wrong length or a negative entry is PROCESSING_CONFIG in
predict and at runtime. RegressionSpec.unpenalized is an additive
omitempty array of predictor names the penalty skips (glmnet
penalty.factor 0) on REG_OLS, REG_GLM and REG_MULTINOMIAL, any
penalty kind; no
penalty, or any other type, refuses it PROCESSING_CONFIG, predict
and runtime alike.
format_version stays "1.1"; neither is echoed on the result.
RegressionSpec.bounds (REG_OLS) is an additive omitempty object
#/$defs/RegressionBounds {nonnegative: [predictor names]}: those
slopes are constrained ≥ 0. A fit no bound binds is plain OLS byte for
byte; a binding fit keeps its coefficients (a held one exactly 0) and
R² and reports std_errors, p_values, ci_lower / ci_upper and
every vcov / correlation entry null (keys kept), with
PULSE_ADVISORY_CONSTRAINT_ACTIVE on advisories (result-only).
Refused PROCESSING_CONFIG with a penalty or selection, on another
type or for an unknown / repeated name; a robust covariance is
PROCESSING_REGRESSION_VCOV_UNSUPPORTED (details.reason bounds).
format_version stays "1.1"; the bounds are not echoed.
Regression coefficient intervals
RegressionSpec takes an additive conf_level float (0 < c < 1,
zero or absent = 0.95; out of range is PROCESSING_CONFIG in predict
and at runtime) and RegressionResult four additive omitempty
slots: ci_lower / ci_upper (maps keyed like coefficients, a key
present exactly when std_errors carries it), df and conf_level
(format_version stays "1.1"). Each bound is β ∓ q·SE: REG_OLS a
Student-t q on df = the residual N* − p − 1 (fractional under
probability weights), REG_GLM a Wald normal q (no df),
REG_BAYES_LINEAR the posterior t on df = 2·a_n — equal to
credible_intervals when conf_level is unset, since it then falls
back to credible_level —, a registered model a t q on the df it
reports (else a normal q, no df), and any fit under resample a normal q on
the resampled standard errors (no df). An undefined bound or df
(residual df ≤ 0) is null. All four are in the standard preset (not
minimal) and rounded by return.precision.
Regression holdout
RegressionSpec takes an additive holdout string — an expr-lang
boolean predicate over the fully built record (schema fields, feature
outputs, attribute labels, window labels and post-window attribute
labels; a window label only where the windows run over the record rows,
else PULSE_REGRESSION_WINDOW_UNAVAILABLE with details.slot
holdout). A row it calls true is held out of the fit and scored by
the fitted model afterwards, false is fitted, null joins neither.
RegressionResult gains the additive omitempty object holdout
(#/$defs/RegressionHoldout) {n, n_null, rmse, mae, r2}: n the
scored held-out rows (target, predictors and — weighted — a valid
positive weight present; a raw count), n_null the null-predicate
rows, the figures on the response scale (a REG_GLM‘s inverse link)
weighted by the slot weight, r2 = 1 − SSE/SST about the held-out
rows’ own mean — null (key kept) when the held-out targets do not
vary. A categorical-outcome fit (REG_ORDINAL, REG_MULTINOMIAL)
scores each held-out row’s probability vector p instead and
reports {n, n_null, log_loss, brier, accuracy} (REG_ORDINAL adds
rps), weighted means over the scored rows: log_loss = −ln p_y
(natural log; null when p_y is 0), brier = Σ_k (p_k − [y = k])²,
accuracy = the share whose most probable outcome (the first on a tie)
is y, rps = Σ_{k<K} (F_k − [y ≤ k])²/(K − 1) over the cumulative
probabilities F_k; rmse / mae / r2 are absent there, as the
categorical figures are on a numeric fit (every figure is an
omitempty key). A held-out row whose outcome the fit does not carry
is not scored. Absent holdout is byte-identical, a numeric fit’s
block is byte-identical, and format_version stays "1.1". A predicate that does not compile as a boolean or names an
unknown column is PULSE_FORMULA_COMPILE_ERROR; a type the instance
cannot score is PULSE_MODEL_SCORE_INVALID details.reason
no_scorer — both refused identically at predict and at runtime. No
scorable held-out row fails the slot alone
(PROCESSING_REGRESSION_INSUFFICIENT_DATA, details.reason
holdout_empty; PULSE_SLOT_FAILED). A holdout forces the buffered
path (predict streamable_reasons: "regression <TYPE> holdout requires the buffered path (the held-out rows are scored after the fit)"). The
block rides capability:regression_holdout, is kept by the standard
and minimal presets, is rounded by return.precision and never
appears under Response.components.
Regression order
RegressionSpec takes an additive omitempty object order
(#/$defs/RegressionOrder) {field, partition, gaps}: the engine sorts
the slot’s rows by field (an unsigned integer, date or datetime
field or derived column) — within each partition series (optional; a
categorical, unsigned integer, date, datetime or packed_bool
field), the series in ascending key order — before any fit, dropping a
row whose field or partition is null. Under gaps refuse
(#/$defs/OrderGaps, the default and only policy) the rows the fit
admits (target and every predictor present) must form contiguous
series: a repeated value inside one series (details.reason
duplicate) or a step that is not the cadence, the smallest positive
step over every series (reason gap), fails the slot alone with
PROCESSING_REGRESSION_ORDER (PULSE_SLOT_FAILED). The spec rules —
field required, a known gaps, partition ≠ field, the field
types — are PROCESSING_CONFIG {slot: "order", reason}, and a model
whose registration requires an order refuses a spec without one
(reason order_required), identically at predict and at runtime. An
order forces the buffered path (predict streamable false). It adds no
response field; absent is byte-identical and format_version stays
"1.1". The block rides capability:regression_order.
Multinomial regression
REG_MULTINOMIAL is a RegressionType enum value; the
payload adds two omitempty keys. RegressionSpec.reference (string)
names the baseline category, one of the target’s dictionary labels
(absent: the first fitted level); on any other regression it is
PROCESSING_CONFIG (details.requires: type REG_MULTINOMIAL).
RegressionResult.reference (string) echoes the reference a
multinomial fit read and RegressionResult.categories (array of
string) lists its fitted levels in dictionary order; both are absent on
every other regression. The per-coefficient maps (coefficients,
std_errors, p_values, ci_lower, ci_upper, p_adjusted,
significant_adjusted) and vcov’s row / column keys read
"<level>:<term>" per non-reference level ("<level>:(intercept)" for
the intercept). Absent is byte-identical and format_version stays
"1.1". A multinomial fit binds under a Compose fits entry, saves
(its model file lists feature categories) and loads through models;
ATTR_REG_PREDICT scores it one column per slot
(params.category: P(y = category), the default output;
params.output: class: the most probable category’s 0-based index in
categories; params.scale: link: the category’s log-odds against the
reference), and coef() reads its "<level>:<term>" keys. A holdout
reports its proper scores (Regression holdout). Under
resample / selection the result echoes them as a
built-in’s does (resample, bootstrap_requested /
bootstrap_succeeded, jackknife_groups, selection, criterion,
selected_features), the per-coefficient maps keep the
"<level>:<term>" keys, and a resampled fit adds statistics (the
Wald z on the replicate SE); every refit keeps the full fit’s
categories and reference. Under a penalty (the spec’s
penalty, alpha, l1_ratio and unpenalized keys, echoed as
penalty / alpha / l1_ratio) the fit is glmnet’s symmetric form:
reference is absent, the per-coefficient maps carry "<level>:<term>"
for EVERY level in categories, std_errors / p_values / ci_lower
/ ci_upper are null on every key (with
advisories[PULSE_ADVISORY_PENALIZED_INFERENCE_UNDEFINED]) unless
resample replaces them, and two_log_lik / aic / vcov are absent.
No key is added; format_version stays "1.1".
An additive omitempty boolean RegressionSpec.exponentiate
(REG_MULTINOMIAL and REG_ORDINAL only; any other type is
PROCESSING_CONFIG with details.slot: exponentiate and
details.requires: type REG_MULTINOMIAL or REG_ORDINAL, at predict and
at runtime alike) adds the additive omitempty object
RegressionResult.exponentiated (RegressionExponentiated): the
key-keyed number maps estimates (exp(β)), std_errors (the
delta-method exp(β)·SE), ci_lower / ci_upper (exp of each interval
bound), keyed like coefficients — every "<level>:<term>" key on a
multinomial fit (relative-risk ratios), the predictors only on an
ordinal fit (cumulative odds ratios; no threshold key). std_errors,
ci_lower and ci_upper carry exactly the keys their raw twins carry,
on whatever covariance the fit used (classical, robust, resampled); a
raw null stays null (a penalized multinomial fit: exp(β) beside
null figures). The raw maps never move. In the standard preset (not
minimal); every float is rounded by return.precision. Absent is
byte-identical and format_version stays "1.1".
An additive omitempty boolean RegressionSpec.term_tests (
REG_MULTINOMIAL only; any other type, or beside a penalty,
selection or resample, is PROCESSING_CONFIG with
details.slot: term_tests, at predict and at runtime alike) adds the
additive omitempty object RegressionResult.term_tests
(RegressionTermTests): terms (string array, the predictors), and the
term-keyed maps df (integers, K − 1), wald_chi2 / wald_p_values
(numbers; on the fit’s covariance) and the additive omitempty
lr_chi2 / lr_p_values (numbers; against the refit without the term,
absent under a probability weight). An undefined figure is null, key
kept. In the standard preset (not minimal); every float is rounded
by return.precision. Absent is byte-identical and format_version
stays "1.1".
Per-group aggregation components
groups on AggregationComponents is an additive omitempty array of
AggregationGroupComponents {group_key, n, n_null, sum_weights?, n_eff?, n_weight_invalid?, operator?} (format_version stays "1.1";
an ungrouped or crosstab response has no groups key and is
byte-identical). On a grouped, non-crosstab run each
components.aggregations[i] carries the cohort-wide floor (no
operator) and one groups entry per data row, in data order
(sort included), each equal to an ungrouped run over that bucket’s
records. What the schema cannot say: entry i describes data[i]; every
execution arm (buffered, streaming, parallel) emits the same figures, and
a stream carries them on its terminal chunk only. Contract:
.claude/reference/response-components.md (Per-group aggregation
components).
Grouper refit buckets
buckets on GrouperComponents is an additive omitempty array of
GrouperBucketComponents {group_key, total_n?, n_null?, operator?, error?} (format_version stays "1.1"; a response without a
params.fit: "within" grouper after the first position has no
buckets key and is byte-identical). What the schema cannot say: it is
present only on a "within" position after the first
(GROUP_QUANTILE, GROUP_KMEANS refitted inside each bucket of the
groupers before it) — predict’s groups[i].refit_buckets says so in
advance — with one entry per outer bucket, group_key the outer
segment, in the outer segments’ data order; each entry’s figures are
what a standalone run of the grouper over that segment reports, while
the slot’s own total_n / n_null / operator stay the whole-set
fit’s. A refit refused on its bucket’s data (GROUP_KMEANS k above
the bucket’s distinct tuples) carries error (a SlotError) and
n_null = the bucket’s records instead of figures: those records join
no bucket, and the run warns PULSE_SLOT_FAILED (see Failed slots). A
stream carries buckets on its terminal chunk only. A crosstab has no
grouper entries: a "within" row position’s row_key_components
bucket is read off that row’s refit instead. Contract:
.claude/reference/response-components.md (Grouper refit buckets).
Attribute components
attributes on ResponseComponents is an additive omitempty array of
AttributeComponents {label, type, n, n_null, operator?}
(format_version stays "1.1"; a response with no attribute slot whose
operator declares a ComponentSchema has no attributes key and is
byte-identical). What the schema cannot say: an entry exists only for a
slot whose operator declares a schema (ATTR_SCALE_SCORE, an extension
attribute registered with one) — manifest.components_schemas.attributes
lists them — so entries are keyed back by label (the effective output
label) and type, never by index into attributes; n / n_null
count the filter-passing rows whose output is present / null; entries
are cohort-wide (a grouped or crosstab run carries one per slot, never
per bucket) and carry no weighted floor keys. ATTR_SCALE_SCORE’s
operator holds n_out_of_range / n_rows_out_of_range only when a
range is declared. Contract: .claude/reference/response-components.md
(Attribute components).
Return slot
return on Request is an additive Return object
{preset?, include?, exclude?, precision?} (format_version stays
"1.1"; a request without one is byte-identical and hashes
identically). preset is the closed ReturnPreset enum (full,
standard, minimal); precision is significant digits, 1–17 (0 or
absent: unlimited). include / exclude are paths over this schema’s
Response JSON names at any depth — . between keys, [*] into every
array element, a trailing * on a map-key segment as a prefix glob
(tests[*].details.effect_*). A key holding ., [, ] or * (an
expanded vector element column) is a quoted segment,
data[*]."emb_mean[q3]": inside the quotes every byte is literal except
\" and \\, and only a segment that starts with " is quoted, so
every unquoted path and its plan digest are unchanged. What the schema cannot say, predict and
the runtime enforce identically before any record is read: resolution
runs preset, then include adds, then exclude removes (exclude wins);
include without a preset starts from an empty base; top-level
warnings, and every nested warnings whose parent is emitted, stay
unless excluded. A path this instance’s Response does not carry — a
hidden feature’s included — is PULSE_RETURN_PATH_UNKNOWN, as is a
data[*].<column> the request cannot produce (data under a join or a
crosstab, test details and operator component maps accept any key); an
unknown preset, a precision out of range or a malformed path is
PULSE_RETURN_INVALID. Predict echoes the resolved plan as
data.return ({preset, include, exclude, keep, precision?, identity, digest, unresolved_includes?}, a predict result field, not part of
this schema); equivalent spellings share a digest, and
unresolved_includes lists the open-path includes predict cannot
resolve without data. On every request, return block or not, predict
also reports data.sizes: each top-level section as {section, full_bytes, shaped_bytes, basis} (shaped_bytes equals full_bytes
with no return, 0 when excluded; a section whose size depends on the
data is omitted) — guidance only. Compose predict reports the same per
slot as slots[*].sizes (additive omitempty), headed by a label
section for the slot’s label echo; like sizes, a predict result
field, not part of this schema.
At runtime the plan is applied to the finished Response: an excluded
slot is absent on the wire — never null, required keys such as
metadata.total_rows or tests[*].p_value included — and zero (nil
when nillable) on the Go value. A shaped response carries returned
(ReturnedMarker {preset, digest, precision?} — preset is custom
for an explicit include / exclude without one; digest equals
predict’s); it is emitted only when the plan changes something and is
not itself a selectable path (naming it is PULSE_RETURN_INVALID). An
include through a map key or an open value that matched nothing in the
executed response adds a PULSE_RETURN_PATH_UNMATCHED entry to
warnings (details path) unless warnings is excluded.
precision is wire-only: the Go response keeps full float64, and on
the wire every float (data cells, tests, regressions, overlays, matrices
incl. top_pairs[*].r and scalars.determinant, component maps) is
strconv.FormatFloat(v, 'g', precision, 64) — so 3e-9 at 4 digits is
3e-09 and 123456.789 is 1.235e+05. NaN / ±Inf stay null; ints
are never touched. Exempt (written exact): integer-semantics floats —
on every request matrices[*].auxiliary.n and the integer matrix
scalars (precisionExempt in types/return_shape.go: df, dof,
dof_baseline, n_params, iterations, converged, bartlett_df,
components_retained, factors_retained), and, derived from the
request, the data column of a count aggregation (AGG_COUNT,
AGG_DISTINCT_COUNT, AGG_NULL_COUNT, AGG_MODE_COUNT,
AGG_FREQUENCY, AGG_SET_FREQUENCY, AGG_SET_CARDINALITY_SUM,
AGG_SET_DISTINCT_VALUES, an extension declaring CountSemantic), a
count crosstab cell under normalize
none (cells, margins, grand total, long-form column) and a count
auxiliary margin aggregation’s figures — plus decimal128 values, which
are decimal strings. The upper matrix encoding keeps its shape.
A shaped response is a projection: it is not schema-valid against
the full payload schema (required keys may be absent), so validate the
request and the plan, not the shaped output. A request without return
stays byte-identical. Agent-facing summary: skills/response-shaping.md;
library walkthrough: library/response-shaping.md.
Presets
The presets are defined once (internal/descriptor/return_resolve.go,
returnPresetPaths) and listed in the manifest as return_presets
([{name, paths, companions?}], in full / standard / minimal order) with each
preset’s paths expanded against the instance: a path a hidden
feature owns (e.g. matrices[*] without capability:matrices,
tests[*].p_adjusted without capability:multiplicity) is absent from
the listing and from the selection, never an error. A preset is an
include allowlist, so a caller’s include can always add a part back.
Nested *.warnings are not listed: each is kept wherever its parent is
emitted. companions lists a preset’s CONDITIONAL selections, each
<path> (with <key>): the map key at path is kept wherever its parent
map also holds a kept <key> (returnPresetCompanions). standard has
one, matrices[*].auxiliary.n (with p); predict’s return plan echoes
it as companions and its digest covers it. An include or exclude
covering the path removes it; excluding <key> drops it too. Every listed path must resolve against this schema
(TestReturnPathsMatchSchema).
| Slot | minimal (primary result) | standard |
|---|---|---|
label (the Compose slot echo) | yes | yes |
data, warnings | yes | yes |
metadata | no | yes |
crosstab | shape, matrix | whole |
matrices[*] | name, type, group_key, primary | all but auxiliary, except the inference figures a spec asked for: auxiliary.p / ci_lower / ci_upper (params.inference), p_adjusted / significant_adjusted (a multiplicity family), and the pairwise auxiliary.n beside a kept p (a companion). They exist only on that spec’s result, so a spec without inference keeps no auxiliary |
tests[*] / post_tests[*] | label, type, group_key, statistic, p_value, reject_null, p_adjusted, significant_adjusted | minimal’s keys + variant, df, alpha, multiplicity, details.effect_size (no other details key) |
regressions[*] | name, type, coefficients, p_values, advisories, an extension model’s outputs, holdout when asked for | the keys returnPresetPaths lists: the coefficient table (std_errors, ci_lower / ci_upper, df, conf_level), the fit settings and statistics, vcov / correlation / covariance, margins, collinearity, exponentiated, term_tests, holdout, advisories, an extension model’s statistics and outputs. Not kept: credible_intervals, selection, two_log_lik / aic, dispersion, theta / theta_std_err, reference / categories, the resample echoes and the multiplicity twins |
overlays[*] | name, kind, ref, summary (no payload) | whole |
components | no | no |
full is the identity: every visible top-level key, byte-identical to
a request without return. standard and minimal stamp returned
with their preset name.
Compose and chain
Every Compose slot and every chain stage is a Request, so its own
return (else the instance default) shapes responses[i] /
stages[i] exactly as a single Process would; a refusal carries
details.request / details.stage. ComposedRequest adds its own
return (same Return def) whose paths root at ComposedResponse:
only overlays… paths are valid (any other is PULSE_RETURN_INVALID,
details root: "compose"), responses is always kept whole, presets
expand to their overlay paths, and no instance default applies at that
level. A non-identity Compose-level plan stamps
ComposedResponse.returned. Shaping runs after the Compose overlay and
multiplicity folds — layers are computed from unshaped slots — and after
the whole chain, so a stage that excludes data still feeds the next
stage its rows. final is the last stage, shaped by its return;
there is no chain-level block.
Compose sweep
ComposedRequest.sweep (SweepSpec) is the one slot that expands into
ordinary Compose slots, so a sweep adds no response shape of its own:
responses carries explicit slots first, then one entry per expansion.
SweepSpec is {axes, mode, samples, rng_seed, budget, de, bo, label, request, overlays, rank}: axes are SweepAxis {name, values, range, target} (values
a non-empty list of scalars under grid / zip; range a
SweepRange {min, max, scale, integer} — SweepScale linear default, log;
integer draws whole numbers —
under random / lhs (an adaptive mode takes either kind per axis), never both; target, optional, a
params.<identifier> string writing each slot’s axis value into that
request param — present only where capability:params is), mode the closed enum SweepMode
(grid default, zip, random, lhs, de, bo; the sampling modes draw
samples slots seeded by rng_seed, 0 deriving one from the spec), request an
object in the Request shape that may carry {{axis}} / {"$var": "axis"} placeholders (the schema types it as object; the substituted
body is decoded strictly at expansion; a {{axis}} inside an
expression string is PULSE_SWEEP_EXPR_SPLICE), overlays an array of
ComposeOverlaySpec objects with placeholders, and rank a
SweepRank {by, order, top, profile, profile_bins} (SweepRankOrder: asc, desc). The slot
is omitempty, so a sweep-free request is byte-identical on the wire.
It is gated by capability:compose_sweep: on an instance that hides it
the sweep property and the Sweep* defs are absent. The sampling modes
ride capability:compose_sweep_sampling: on an instance that hides it
the SweepMode enum is grid / zip, and samples, rng_seed, the
axis range, the SweepRange def and ComposedResponse.sweep_seed are
absent. The adaptive modes ride capability:compose_sweep_adaptive:
budget (an omitempty integer, the slot count an adaptive mode
evaluates in rounds; required there with rank, refused elsewhere) is
absent on an instance that hides it, and so are the adaptive
SweepMode values (de, bo), mode de’s knobs de — a SweepDE {population, f, cr} (an integer and two numbers, each omitempty;
refused under any other mode) — with the SweepDE def, and mode bo’s
knobs bo — a SweepBO {init, n_init, batch} (init the closed enum
SweepBOInit, lhs or random, and two integers, each omitempty;
refused under any other mode) — with the SweepBO and SweepBOInit
defs. An item for_each’s mode is grid / zip and its axes carry
values only, on every instance.
A malformed sweep
is PULSE_SWEEP_INVALID with details.field (a sweep-rooted path)
and details.reason; a mode/axis mix-up is PULSE_SWEEP_MODE_MISMATCH,
a bad range PULSE_SWEEP_RANGE_INVALID, a missing or sub-1 samples
PULSE_SWEEP_SAMPLES_INVALID. pulse_predict with composed reports the
expansion as sweep {axes, mode, expanded_count, adaptive, rng_seed, labels} on the
predict result (an adaptive mode: expanded_count the budget,
adaptive: true, and null for every label after round 0’s); that
summary is not payload-reachable and is not in this schema.
A sampling sweep (random / lhs) or an adaptive one (de / bo) adds ComposedResponse.sweep_seed,
an omitempty integer: the effective seed it drew with, so pinning it as
rng_seed replays the run. Absent for grid / zip. Like ranking it
is pinned outside the Compose-level return.
A sweep with rank adds ComposedResponse.ranking, an omitempty array
of RankEntry {label, value, rank, slot, axes} (1-based, in rank order,
value always finite). slot (always present) is the entry’s 0-based
index among the sweep slots in expansion order; axes (always present)
maps each sweep axis name to the scalar the slot ran with — a number, a
string or a boolean, as the axis declared it (a drawn random / lhs
value is a number in shortest round-trip form). Only sweep slots are
ranked. A slot whose value at
rank.by is null, or whose path is missing there but resolves elsewhere,
is left out with a PULSE_SWEEP_RANK_PATH warning on its own response;
a non-number, ambiguous or nowhere-resolving path refuses the batch with
the same code. ranking is pinned outside the Compose-level return:
always emitted, never rounded by precision.
rank.profile: true adds ComposedResponse.ranking_profile, an
omitempty object keyed by axis name, each value an array of
RankProfileEntry {value, lo, hi, best, label, n}: per axis value some ranked
slot ran with, the best ranked value among those slots (best,
following rank.order, always finite), the slot achieving it (label)
and the ranked slots behind it (n). It reads the full ranking before
top; unranked slots never count. Pinned outside the Compose-level
return like ranking. A range axis (sampling or adaptive) is binned into
rank.profile_bins (default 10) equal-width bins — equal log-width
under scale: log — one entry per non-empty bin, adding the optional
numbers lo / hi (the bin edges; absent on a list axis), value
then the best slot’s draw.
An adaptive sweep (mode de / bo) also carries RankEntry.round (omitempty *int: the 0-based round the slot ran in, 0 present, absent under every other mode) and ComposedResponse.sweep_trace, an array of SweepTraceEntry {round, slots, evaluated, penalised, best, best_so_far, best_label} in round order: slots the round’s inclusive [first, last] sweep-slot span (the RankEntry.slot axis), evaluated the slots it ran, penalised those left unranked (a failed slot’s stub, or a null / missing value at rank.by), best the best ranked value among the round’s own slots by rank.order, best_so_far the best over rounds 0..round and best_label that slot’s label (ties follow rank order). best and best_so_far are null (key kept, never 0) while nothing ranked, and best_label is then absent. The trace reads the full ranking before top, is pinned outside the Compose-level return like ranking (full precision), and rides the final --stream {"ranking": ...} record ([] when no response). Both are hidden from an instance’s payload schema unless capability:compose_sweep_adaptive is enabled; non-adaptive responses are byte-identical.
Compose banner
ComposedRequest.banner (BannerSpec) is
{request, sections, groups, total, overlays}: request a typed
Request (the base every slot starts from — no label, no crosstab
columns, no crosstab shape: long), sections a non-empty list of
BannerSection {label, filterers, rows, cell, cells, overlays}, groups a list of
BannerGroup {label, columns}, total a boolean (the Total block: a
crosstab with no column grouper) and overlays request OverlaySpecs
appended to every group slot — except a section’s that sets its own
overlays, which REPLACE them on its group slots. The base request’s
labels ride only the slots whose crosstab rows or columns group by the
bound field (a binding no slot groups by stays on every slot). It expands into one crosstab slot per
section × block (Total first, then the groups), labelled
<section>:<block>, appended after the explicit and sweep slots. The
slot is omitempty, so a banner-free request is byte-identical on the
wire, and it is gated by capability:compose_banner (hidden: the
banner property and the Banner* defs are absent). A malformed banner
is PULSE_BANNER_INVALID with details.field and details.reason;
predict reports banner {sections, groups, total, expanded_count, labels}.
The banner adds ComposedResponse.banner, an omitempty
BannerResult {sections}: one BannerSectionResult {label, row_header, row_keys, column_keys, cells, column_margins, cell_label, cell_labels, normalize_applied, blocks, letters} per section, the section’s slot
matrices side by side — rows the union of the blocks’ rows, column keys
concatenated. Each BannerBlock {label, slot, total, start, count, column_header, row_margins, grand_total, measures} locates one block’s
columns and carries its own margins: a record reaches a block’s margin
only if it reached a CELL of that block. letters holds one
BannerLetters {overlay, name, kind, scope, cells} per banner overlay
carrying a letters part (from a section’s own overlays: section: true
added, overlay indexing the section’s list; absent otherwise); under column scope the letters are
re-assigned banner-wide (unique across blocks, comparison groups never
spanning two blocks) and the Total block carries no letter cell — it is
compared to nothing. Every figure is copied from its slot; undefined
figures are null. banner is pinned outside the Compose-level
return: always emitted, never rounded.
Compose base
ComposedRequest.base is an omitempty typed Request (no label)
merged into every explicit requests entry before the sweep and banner
expansion and the top-level params inheritance — never into the sweep
body, a banner slot or a fit request. A key the slot leaves unset takes
the base’s, params merge key-wise with the slot’s key winning, and
every list carries the base items first, then the slot’s own; base items
may carry for_each, expanded per slot after the merge. A base item
whose label / name / as equals one of the slot’s own in the same
list, or a base that sets label, is PULSE_COMPOSE_BASE_COLLISION
(details.reason label_collision / base_label). The normalized
request echoes the merged slots and no base. A base-free request is
byte-identical on the wire, and the slot is gated by
capability:compose_base (hidden: the base property is absent).
Compose fits
ComposedRequest.fits is an omitempty array of FitSpec {name, request}: request is an ordinary Request with no groups /
crosstab holding exactly one regression (a regression fit) or, with no
regression, exactly one vector battery — one matrices entry or one
ATTR_MAHALANOBIS / ATTR_PC_SCORE / ATTR_FACTOR_SCORE attribute (a
vector fit: the battery’s listwise mean and co-moment) — one MAT_SEM
entry is instead a SEM fit (kind sem: the fitted model’s parameter
matrices per group). Every fit runs
once, before any slot (sweep slots included), over its own cohort,
filters, features and weight; slots read it by name — a regression fit
through ATTR_REG_PREDICT / coef(), a vector fit through params.fit
on a fitted vector attribute or any co-moment MAT_* slot, a SEM fit
through ATTR_SEM_SCORE’s params.fit (row-local, bit-equal to the
inline fit over the same rows). One namespace holds all three kinds: PULSE_MODEL_NAME_COLLISION on a duplicate,
PULSE_MODEL_UNKNOWN for an unbound reference, PULSE_MODEL_KIND_MISMATCH
(details.fit, kind, expected) for a name of another kind. A
malformed entry is PULSE_FIT_INVALID with details.fit (the entry
index) and details.reason (name_missing, request_missing,
regression_count, kind_ambiguous, vector_count, grouped,
vector_source); a fit request’s own refusal keeps its
code and gains details.fit. A fit request’s return is ignored. The
fits surface as ComposedResponse.fits, an omitempty object of
FitResult keyed by fit name: a regression fit’s RegressionResult
object as is (byte-identical to the regression-only shape), or a vector
fit’s {"vector": VectorFitResult} — operator, labels, members,
basis, n, n_weight_invalid, sum_weights, n_star, mean and
covariance (a full square-symmetric MatrixValues, M2*/(N* − 1) on the
fit’s weight basis; undefined cells null), or a SEM fit’s
{"sem": SEMFitResult} — operator, model, labels, members, the
model’s observed / inner / latents orders, estimator,
conventions, meanstructure and the multi-group knobs, solver,
information, basis, n, sum_weights, dof, n_params,
converged, status, iterations, nearest_pd_min_eigenvalue (only
when the nearest positive-definite substitute was fitted) and groups
(per level level, n, sum_weights and the full-precision matrices
lambda, beta, psi, theta, nu, alpha, sample_mean). An
ordinal fit (estimator dwls / wlsmv) adds ordered (its ordered
variables, observed order), categories (each one’s category values,
ascending) and, per group, thresholds (one list per ordered variable);
all three are absent on an ML fit. A fit grouped by a column its request
computed adds group_derived: true and, when the levels were declared,
group_levels ([{value, label}], in order); both are absent on a
cohort-field group. The
vector / sem key discriminates. A fit that failed on its data keeps its entry with
an error and no figures (see Failed slots). The object is pinned outside the Compose-level return
like ranking (always emitted, never rounded). Both slots are gated by
capability:compose_fits. pulse_predict with composed lists them as
fits [{name, type, target, predictors, cohort}] — a vector fit as
{name, cohort, vector: {operator, labels, members}}, a SEM fit as
{name, cohort, sem: {operator, labels, members}} — on the predict
result (not payload-reachable).
A fits entry may carry from_sweep {regression} (FitFromSweep)
instead of request — request is therefore optional on the wire,
exactly one of the two — binding the rank-1 slot of the batch’s ranked
sweep: the sweep body’s regression whose name is regression,
refitted on the winning slot’s rows as an ordinary regression fit. Its
static signature (type, target, predictors) is read from the sweep body
and must be the same in every sweep slot. A malformed binding is
PULSE_FIT_INVALID with details.fit and details.reason
from_sweep_with_request, from_sweep_no_sweep, from_sweep_no_rank,
from_sweep_regression_unknown (details.regression, available),
from_sweep_signature_varies, from_sweep_cycle (a sweep slot reads
the fit) or from_sweep_window_cycle (a sweep slot’s window reads it in
a scalar param, details.window and details.param; all three with
details.slot, the 0-based sweep index), judged
before anything runs, identically by predict and the runtime. The key is
gated by capability:compose_sweep_bind (dependencies
capability:compose_sweep AND capability:compose_fits); predict’s fit
summary echoes it as from_sweep.
Compose optimize
ComposedRequest.optimize is an omitempty array of OptimizeSpec {name, variables, objective, direction, constraints, starts, rng_seed, tolerance, max_iterations, gradient, models, posterior, for_each}: a constrained optimisation solved once,
after the fits, with no record data. variables are {name, lower, upper, start}, each bound an OptimizeBound — a number or a
scalar expression string read once before the solve (literals,
params.<name>, coef() / sweep_axis() / response() over the batch
fits and the block’s models, result(slot, aggregation) over an
ungrouped Compose slot, lookup() and the built-ins; no variable, no
record field), "params.<name>" the simplest, yielding a finite number
(start optional; the midpoint when absent). A slot result() reads
runs once, after the fits and before the blocks, keeping its place in
responses; a bad reference (incl. an aggregation that writes no
single number) is PULSE_RESULT_INVALID, and a failed read slot fails
the batch before any block, its error naming the slot
(details.result_slot, or result_slots on a non-fail-fast aggregate). objective and every constraints[i].expr
(type eq: expr = 0; ineq: expr >= 0) are expressions over the
variables, params.<name>, coef() over the batch’s fits and the
built-ins; direction is maximize or minimize (required); starts
defaults to 8 (1 to 1000); models (gated by capability:models)
loads saved model files {name, path} for the block’s coef(), above
the batch’s fits. Predict and the runtime refuse a malformed
block identically before any fit or slot runs:
PULSE_OPTIMIZE_SPEC_INVALID, PULSE_OPTIMIZE_VARIABLE_INVALID,
PULSE_OPTIMIZE_EXPRESSION_INVALID, or the shared
PULSE_PARAMS_UNDECLARED / PULSE_MODEL_* coef() codes — each with
details.optimize (the block index) and details.field. Results land
in ComposedResponse.optimizations, an omitempty array of
OptimizeResult in declaration order — name, direction,
objective, variables [{name, value, marginal, active}],
constraints [{expr, type, value, multiplier}], converged, status,
iterations, max_violation, starts, starts_agreeing, rng_seed,
gradient, gradient_fallback — pinned outside the Compose-level return (always emitted, never
rounded); a block that failed on its numbers keeps {name, direction, error} (see Failed slots) and warns PULSE_SLOT_FAILED (slot_kind
optimizations). Each block is solved from its start point plus
starts − 1 seeded Latin-hypercube points with SLSQP and, under
gradient analytic (the default), exact forward-mode gradients of the
objective and constraints — central finite differences for the whole
block when an expression calls a function without a derivative rule
(Compose predict’s PULSE_ADVISORY_OPTIMIZE_GRADIENT_FALLBACK), and
throughout under gradient fd (unknown: PULSE_OPTIMIZE_SPEC_INVALID
gradient_unknown). The result echoes the gradient the block actually
solved with as gradient (OptimizeGradient: analytic, or fd when
asked or fallen back — a point kink, a finite value with a non-finite
partial differentiated by central differences at that point only, stays
analytic) and, on a fallback, gradient_fallback — the functions and
constructs without a derivative rule (sorted, unique; the advisory’s
details.functions for the same block, one verdict); both omitempty,
absent on a failed entry, additive (format_version stays "1.1");
marginal is ∂f/∂xᵢ, multiplier the
constraint’s Lagrange multiplier in the objective’s own direction
(∇f = Σ multiplier·∇expr on the free variables — for a budget eq it
equals every free variable’s marginal), starts_agreeing the
converged starts within 10·tolerance·max(1, |f*|) of the best. Both slots are gated by
capability:compose_optimize. pulse_predict with composed lists the
blocks as optimize [{name, direction, variables, constraints, starts, rng_seed}] on the predict result (not payload-reachable), and every
bound or start whose expression calls a request-bound function under
unresolved_scalars [{path, expression, reads}] — not statically
resolved, so its range checks run at runtime; a bound over literals and
params is range-checked by predict and never listed.
A block’s optional posterior (OptimizePosterior {objective, q, draws}, omitempty; absent, the block solves on the point estimates)
optimises
over a REG_MMM_BAYES fit’s posterior draws: the objective is
evaluated per draw and aggregated — objective mean (the default)
or quantile (the q-quantile, Hyndman–Fan type 7, q in (0, 1)) —
and each constraint holds on its mean over the draws; bounds and starts
still read the posterior means. draws > 0 evaluates a seeded
subsample (the block’s effective rng_seed, without replacement, then
in pooled draw order); 0 or at least the fit’s count is every draw. The
objective and constraints must read exactly one fit by a literal
coef() / response() fit name — a Compose fit with
params.return_draws true, or a block models file that kept its
draws — else PULSE_OPTIMIZE_SPEC_INVALID reason posterior_fit_missing,
posterior_fits_multiple, posterior_fit_not_bayes or
draws_required (and posterior_objective_unknown,
posterior_q_invalid, posterior_draws_invalid for the block itself),
refused by predict and the runtime alike before any fit runs. Per draw,
response() reads that draw’s β, curve and adstock decay (a geo
argument that geo’s own draws, none the population’s). The result adds
posterior (OptimizePosteriorResult {fit, objective, q, draws, draws_available, draws_resolved, credible_level}) and each variable’s
interval (OptimizeInterval {lower, upper}): the block re-solved on
each evaluated draw alone (one start, at the reported optimum), and the
type-7 quantiles at (1 ∓ credible_level) / 2 — the fit’s own level —
of the variable’s per-draw optimum over the draws_resolved re-solves
that converged (null when none did).
Compose comparisons
ComposedRequest.compare is an omitempty array of FitComparisonSpec {name, restricted, full, test, multiplicity}: a nested-model
comparison of two regression fits entries, run once after the fits
with no record data (R’s anova(m0, m1) / lmtest::waldtest). test
is the ComparisonTest enum f / lrt / wald (absent: f on
REG_OLS and a family that estimates its dispersion, lrt otherwise —
and on a model declaring comparisons, REG_ORDINAL, whose f is
refused and whose two fits need equal params.levels, reason
levels_differ, and on REG_MULTINOMIAL, whose f is refused and
whose two fits need an equal reference, reason reference_differs);
multiplicity (gated by capability:multiplicity) inherits the batch
block, family compose only. Predict and the runtime refuse an entry
identically before any fit or slot runs — PULSE_COMPARISON_INVALID
with details.compare (the entry index) and details.reason (the
restricted terms not a subset of the full fit’s, fit requests that
differ beyond the regression’s predictors, intercept and reporting
knobs, an unsupported fit or test under requires). Results land in
ComposedResponse.comparisons, an omitempty array of
FitComparisonResult in declaration order — name, restricted,
full, test, distribution (ComparisonDistribution f /
chisq), terms, statistic, df, df_residual (F only),
p_value, n_obs, restricted_df_residual, full_df_residual,
restricted_deviance, full_deviance, dispersion (F / LR on a
deviance), restricted_two_log_lik / full_two_log_lik (a θ-estimated
negative binomial’s LR), scaling_factor (a WLSMV SEM pair’s
Satorra–Bentler difference factor), p_adjusted /
significant_adjusted / multiplicity — pinned outside the Compose-level return (always
emitted, never rounded); an undefined figure is null, key kept. A
comparison whose fit failed on its data, or whose fits used different
row counts (PULSE_COMPARISON_ROWS_DIFFER), keeps {name, restricted, full, test, error} (see Failed slots) and warns PULSE_SLOT_FAILED
(slot_kind comparisons). Both slots are gated by
capability:compose_compare (a dependency on capability:compose_fits
and MAT_SEM, REG_OLS, REG_GLM, REG_MULTINOMIAL or REG_ORDINAL).
Two SEM fits compare by the chi-square difference: test
lrt only, terms empty, df the df difference, the per-fit
*_df_residual / *_deviance each fit’s model df and χ²;
scaling_factor is present only on two wlsmv fits (null where the
difference factor is negative). Their refusals add kind_mismatch,
test_unsupported, same_model and observed_differ; once run a
pair fails alone on df_not_positive / conventions_differ
(PULSE_COMPARISON_INVALID) or rows_differ
(PULSE_COMPARISON_ROWS_DIFFER). On
REG_MULTINOMIAL the terms are the added predictors and df counts
their K − 1 "<level>:<term>" coefficients each, (K − 1)·len(terms),
and each fit’s residual df is (K − 1)·N* − rank (anova.multinom).
Two declared or multinomial fits whose non-tested terms (ordinal
thresholds, multinomial categories) differ once fitted fail the
comparison alone with PULSE_COMPARISON_ROWS_DIFFER reason: terms_differ. A side may bind from the sweep (from_sweep):
the entry is judged against the fit request of every sweep slot that
could win — refused when every slot refuses, else valid — and the run
judges the winning slot again; a refusal there keeps {name, restricted, full, test, error} with PULSE_COMPARISON_INVALID
(details.sweep_slot / sweep_label name the winner) and warns
PULSE_SLOT_FAILED. pulse_predict with composed lists the
entries as compare [{name, restricted, full, test, distribution, terms, unresolved}] on the predict result (not payload-reachable);
unresolved {slots, refused [{slot, label, reason}], varies} is present
only on a sweep-bound entry whose slots disagree. Two vector fits
compare member-wise: each restricted battery member j is one
row of members, an array of FitComparisonMember {member, statistic, p_value, restricted_deviance, full_deviance, dispersion, p_adjusted, significant_adjusted, multiplicity} — lm(j ~ restricted others)
against lm(j ~ full others), read off the full fit’s co-moment; terms
are the tested members, the single-pair statistic, p_value and
*_deviance are null, every row is one member of the multiplicity
family, and the predict summary lists the rows’ members. The figures a
comparison reads off each fit beyond its wire result (its residual
deviance, the Pearson dispersion, the covariance its standard errors
read) travel through an internal capture on the fit’s run, never a
request, result or public type: no fit’s bytes move. Long form:
docs/src/regression.md (Nested-model comparison).
Compose post-fit
ComposedRequest.post_fit is an omitempty array of PostFitSpec {label, type, fits, params}: a run of an embedder-registered post-fit
operator (POSTFIT_<NAMESPACE>_<NAME>; Pulse ships none) once the
optimize blocks have run and before the comparisons, with no record
data. type is a PostFitType: an empty enum in the published schema
(Pulse ships no post-fit operator), the instance’s registered operators
in its own view (Pulse.PayloadSchema()), fits names regression fits
entries, params is checked against the registration’s declared
params. A malformed entry is PULSE_POSTFIT_INVALID (details.post_fit,
details.reason) before any fit or slot runs. Results land in
ComposedResponse.post_fit, an omitempty array of PostFitResult {label, type, scalars, tables, error} in declaration order: scalars
an object of named numbers, tables an object of named PostFitTable {columns, rows} whose cells are numbers, strings or null — pinned
outside the Compose-level return; an undefined figure is null, key
kept. An entry whose operator errs, or whose fit failed on its data,
keeps {label, type, error} and warns PULSE_SLOT_FAILED (slot_kind
post_fit). Both keys are gated by capability:compose_post_fit. Additive:
format_version stays "1.1". Long form:
docs/src/internals/extension-points.md (Post-fit operator).
Model files (save)
RegressionSpec.save and FitSpec.save are omitempty strings: a path,
relative to the instance filesystem root, where the finished fit is
written as a model file (model_format_version 1 plus a features
list naming exactly the optional sections it carries: robust_covariance
— the covariance echo — when a robust covariance produced the fit’s
standard errors, outputs — its coefficients named by the model — for an
extension regression whose registration supplies a scorer, dispersion
for a classical vcov fit that carries one, theta for a REG_GLM
negative_binomial fit, categories — with reference — for every
REG_MULTINOMIAL fit; the retired versions 2 to 6 are refused with a
re-save message; .pulse-model.json; the format is in
.claude/reference/byte-layout.md, “Model file”). The
path must end .pulse-model.json and stay under the root
(PULSE_MODEL_SAVE_INVALID with details.reason and details.regression
or details.fit, refused by predict and the runtime alike before any
record is read); a failed write is PULSE_MODEL_WRITE_FAILED. Replacing a
file succeeds with the warning PULSE_MODEL_OVERWRITTEN: on the
Response.warnings of the request whose regression saved, or on
ComposedResponse.warnings — an omitempty array of ResponseWarning
for batch-level diagnostics, always emitted (a warnings keep path the
Compose-level return cannot exclude) — for a fits save
(details.fit). Both save keys are
gated by capability:model_save; the file itself is not payload-reachable,
so format_version stays "1.1". Two saves naming one file in a request
or a Compose batch are refused (reason: duplicate, details.sites
naming both writers), and a batch judges every save path — fits and
slots — before any fit or slot runs (a slot’s fault gains
details.request). Materialize and ProcessChain admit no regression, so
neither ever writes a model file. A VECTOR fit’s save writes a
population file instead (population_format_version 1; the path must end
.pulse-population.json, else PULSE_MODEL_SAVE_INVALID reason
suffix): the battery’s stored listwise state — labels, members, weight
basis, counts, Σw / Σw², raw mean and raw co-moment — with nothing
derived, written atomically under the fit’s name with the same overwrite
warning (format: .claude/reference/byte-layout.md, “Population file”). A SEM fit’s save writes a SEM fit file (sem_format_version 1, 2 for an ordinal fit, or 3 for a fit grouped by a computed column; the
path must end .pulse-sem.json, else PULSE_MODEL_SAVE_INVALID reason
suffix): the model description and options, member labels, the
model’s variable orders, the solver stop and per group its level,
counts and parameter matrices at full precision, written atomically
under the fit’s name with the same overwrite warning (format:
.claude/reference/byte-layout.md, “SEM fit file”).
Loading models (models)
Request.models and FacetRequest.models are omitempty arrays of
ModelRef {name, path, inline}: each loads a model file a save wrote, under
name, into the namespace a Compose fits list binds, so
ATTR_REG_PREDICT fit and coef() resolve a loaded name exactly like
a fit (bit-for-bit the same scores). The path’s suffix picks the kind: a
.pulse-sem.json path loads a SEM fit file as a SEM fit, which
ATTR_SEM_SCORE params.fit scores from bit-for-bit like the
in-compose fit that saved it (a file whose model does not rebuild its
stored variable orders is PULSE_MODEL_FILE_INVALID). Every file is read, version-checked
and decoded before any record is read — in a Compose batch or a chain,
before any fit, slot or stage runs, so a load always sees the file as it
was before the run. Refusals, predict and runtime alike:
PULSE_MODEL_REF_INVALID (no name, or a path the save-path rule
refuses; details.model, reason), PULSE_MODEL_FILE_UNREADABLE
(missing / unreadable), PULSE_MODEL_FILE_INVALID /
PULSE_MODEL_VERSION_UNSUPPORTED (with details.model and name),
PULSE_MODEL_NAME_COLLISION (a name a fit or an earlier entry binds;
details.sources names both), then the scoring rules
(PULSE_MODEL_PREDICTOR_MISSING / _NOT_NUMERIC against the scoring
frame). Provenance is informational: a model fit on one cohort scores any
cohort holding its predictor columns. A fit request’s own models are
all it sees (fits run before the batch binds); each chain stage loads its
own. Gated by capability:models; format_version stays "1.1".
An entry sets exactly one of path and inline (both is
PULSE_MODEL_REF_INVALID path_and_inline, neither path_empty).
inline declares a coefficient-only model in the request: the
model-file document itself, judged by the same codec as a file (an
inline refusal carries details.inline: true and no path). Any number
in it (coefficients, std_errors, ci_lower, ci_upper values, df,
conf_level, dispersion, theta, n_obs, sum_weights, n_eff,
vcov.values) may be a scalar expression string over literals and
params.<name> — no request-bound function — resolved before anything
runs, so predict resolves it too (inline_invalid /
inline_not_numeric / inline_not_finite / inline_not_integer,
details.field). Types REG_OLS, REG_GLM, REG_BAYES_LINEAR,
REG_MMM_HILL, REG_MMM_BAYES (inline_type_unsupported); the
coefficients name exactly the terms the type reports
(inline_term_unknown / inline_term_missing). coef() and
sweep_axis() read it; a scoring reference is PULSE_MODEL_SCORE_INVALID
inline_not_scorable.
Loading populations (populations)
Request.populations is an omitempty array of PopulationRef {name, path}: each loads a population file a vector fit’s save wrote, under
name, as a vector fit in the same namespace, so a fitted vector
attribute’s or co-moment MAT_* slot’s params.fit resolves a loaded
name exactly like a Compose vector fit — bit-for-bit the same figures on
one architecture (a decomposition recomputed on another is
tolerance-equal), aligned to the slot’s members by label. It loads at the
same point as models and is refused with the same codes, located by
details.population: PULSE_MODEL_REF_INVALID (no name, or a path not
ending .pulse-population.json), PULSE_MODEL_FILE_UNREADABLE,
PULSE_MODEL_FILE_INVALID / PULSE_MODEL_VERSION_UNSUPPORTED,
PULSE_MODEL_NAME_COLLISION (a name a models entry, an earlier entry
or a fit binds). Provenance is informational, never compared. Gated by
capability:models; format_version stays "1.1".
Registered populations. An instance may also register populations
at pulse.New — Options.Extensions.Populations (the encoded file
bytes) and Options.PopulationsDir / PULSE_POPULATIONS_DIR (each
*.pulse-population.json under its file stem). They are bound beneath
EVERY request, so params.fit names one with no populations entry,
and the manifest lists them under extensions.populations
(PopulationMeta {name, operator, basis, labels, n}). An entry or a
Compose fit reusing a registered name is PULSE_MODEL_NAME_COLLISION,
its first source {slot: "registered"}; predict judges the same names
and labels.
Item fan-out (for_each)
Window, Feature, Attribute, Aggregation and MatrixSpec each
carry an optional for_each (ForEach {axes, mode} — the sweep’s
SweepAxis list and SweepMode). Aggregations and matrices expand
after the windows, so an aggregation may read a column a window
fan-out adds; only a Request.aggregations item fans out (on a
crosstab or banner cell the key is refused, reason
position_unsupported), and each rendered matrix needs its own
name.
Before any other check the item is replaced IN PLACE by one ordinary
item per axis combination (grid: first axis slowest; zip: lockstep),
each rendered from the item’s own body with the sweep substitution —
{{axis}} in any non-expression string (label, field; inside an
expression slot it is PULSE_FOR_EACH_EXPR_SPLICE), {"$var": "axis"} as a whole value inside params (opaque JSON; a typed
non-string key cannot hold the marker) — and decoded strictly. Plain
items are untouched, so a list may mix both, and no response shape
changes: each expanded item produces its own column (or aggregation,
or matrix result). The key is
omitempty, so a for_each-free request is byte-identical on the wire
and under CanonicalHash. It is gated by capability:for_each: on an
instance that hides it the for_each properties and the ForEach def
are absent (SweepAxis stays while a compose sweep is visible). A
malformed for_each is PULSE_FOR_EACH_INVALID with details.field (a
request-rooted path such as windows[0].for_each.axes[1]) and
details.reason; a for_each inside a sweep body fans out in each
slot after the sweep renders it, and one whose axis shares a sweep
axis’s name is refused with reason axis_shadowed. Limits.MaxDerivedColumns (default 1,000)
bounds plain plus expanded window, feature and attribute items and
Limits.MaxExpandedItems (default 1,000) the aggregations and matrices
a for_each adds (plain ones never count), both checked before any
item renders. Predict reports each fan-out as for_each [{path, axes, mode, expanded_count}] on the predict result (not
payload-reachable, so not in this schema; a Compose predict lists the
optimize blocks’ optimize[i], then each slot’s requests[i].<path>,
then each fit request’s fits[i].request.<path>).
A Compose OptimizeSpec carries the same optional for_each: the
block fans out right after the base merge, before the optimize rules
and MaxComposeSlots, its name must carry an {{axis}} (reason
name_without_axis), and the blocks it adds count toward
Limits.MaxExpandedItems once per call. Any typed scalar of a
fanned-out block (a bound, starts, a constraint expr) may be a whole
{"$var": "axis"} value, and this schema admits it there:
$defs.OptimizeSpec lets every scalar of the block — its own and its
variables’, constraints’ and models’ — be $defs.VarMarker (an object
with the one string key $var); for_each, the arrays themselves and
their entries never take one, and the runtime and predict refuse a
marker there too (PULSE_FOR_EACH_INVALID reason marker_position),
so schema and runtime agree. A model’s inline body is free-form and
takes one anywhere. The marker is valid only in a block that carries
for_each: an if (no for_each) / then re-applies the strict
property shapes, as the runtime refuses a marker there at decode. The
MCP pulse_compose input schema admits the marker at the same paths.
On an instance hiding capability:for_each neither the marker nor the
VarMarker def appears.
Undefined figures
A result figure can be undefined even when every input is present — a
ratio over an all-zero denominator, a confidence bound under two rows,
the first entry of an index-vs-prior series, a rolling window that has
not filled. The engine’s Go results carry NaN there; JSON has no NaN,
so every JSON surface writes the figure as null in place, key
kept (types.MarshalFinite), and the rest of the response serialises
normally. null means “reported, undefined here”; an absent optional
key keeps meaning “not reported for this kind”.
A figure over no value is undefined the same way: the mean, the
minimum / maximum / range, the variance / standard deviation, a
quantile, the mode, a shape moment or the average set cardinality of a
group, cell, margin or cohort with no non-null value (or, weighted,
whose weights sum to 0) is null on every execution arm — never 0.
A count or a sum of nothing stays 0. So is a figure whose formula is
0/0 on the data it has: the skewness or kurtosis of one value or of
values that never vary, the z-score where the spread is zero, and a
sample variance (AGG_WELFORD’s, a weighted weighted_variance)
below two values or a weight total of 1 — null, never 0; a
population spread of one value stays a defined 0. A series overlay
reads such a host value as a missing point: its entry keeps its key with
no statistic key at all, on the request, Compose and chain hosts
alike; a crosstab overlay reads such a cell as an absent cell — no
overlay cell, no warning, never in a denominator or a spread.
The schema says so: every float slot on a def only a result reaches —
TestResult, RegressionResult, OverlaySummary, the
OverlayPayload.scalar arm, FacetNumeric, FacetHistogram, the
weighted floor’s sum_weights / n_eff on AggregationComponents and
AggregationGroupComponents, and the rest —
is "type": ["number", "null"]. The open slots (data rows,
components operator maps, matrix cell value) already admit null.
Request floats stay "number": a decoded request never carries a
non-finite float. ExplainRequest is not a request root for this rule:
the results it carries keep their nullable floats.
Reading a result back is the inverse: plain encoding/json decodes a
null into a Go float as 0, which a reader would take for a real
figure. pulse explain --response and MCP pulse_explain decode the
result they are handed so that null in a float slot is NaN again —
undefined stays undefined (a not_computable verdict, a null number),
never a confident 0.
The nullable float slots are within format_version "1.1".
Failed slots
A regression, test (tier-1 or post) or matrix slot whose data its
operator refuses — a separated or unconverged fit, a rank-deficient
design, too few rows, zero variance, a singular matrix — fails that
slot alone; every other slot of the response is returned as usual.
The failed result keeps its object (never null in the array: a
null entry still means the slot was skipped by return) with its
identity and an error — a SlotError {code, message, details},
the refusal’s own code, message and details, the shape of an envelope
error entry:
{"regressions": [
{"name": "default", "type": "REG_GLM",
"error": {"code": "PROCESSING_REGRESSION_SEPARATION",
"message": "…", "details": {"predictors": ["collections_flag"]}}},
{"name": "ols", "type": "REG_OLS", "coefficients": {"…": 0.5}}
]}
Every numeric field of a failed result is absent (not null): a
RegressionResult writes name, type and error; a TestResult
label, type, group_key and error; a MatrixResult name,
type, group_key, group_header and error. The schema says so:
on TestResult, RegressionResult and MatrixResult the identity
keys (name / type) stay required and the figures that are always
written otherwise (statistic, p_value, alpha, reject_null;
primary) are required only when error is absent (if / then).
Each failed slot also adds a PULSE_SLOT_FAILED response warning,
details {slot_kind, index, label, code} (slot_kind the response
key, index the request slot index, code the slot’s own code;
group_key for one bucket of a grouped matrix or of a "within"
grouper refit — slot_kind groups, see Grouper refit buckets), which the --json
envelope lifts to its warnings; the run exits 0. Under
Options.Strict (--strict) the run instead fails with the slot’s
own code. Only data-dependent refusals fail alone: a configuration
fault is still fatal for the whole request. A failed slot’s error is
kept by every return preset and include list (like a nested
warnings); only an explicit exclude removes it.
A Compose fits entry whose fit fails on its data fails alone too: its
ComposedResponse.fits[name] entry carries error beside its identity
— {name, type, error} for a regression fit, {"vector": {operator, error}} for a vector fit, {"sem": {operator, error}} for a SEM fit
(on VectorFitResult / SEMFitResult operator stays
required and the figures move under the same if / then) — its
PULSE_SLOT_FAILED warning lifts to the batch warnings with
details.fit, and every other fit and slot runs. An attribute reading
it — ATTR_REG_PREDICT scoring it, an ATTR_FORMULA naming it in a
literal coef() call, a fitted vector attribute’s params.fit, a
{population} reference — is null on every row and adds a
PULSE_FIT_UNAVAILABLE warning {fit, attribute, code} to that slot’s
response; a MAT_* slot’s params.fit fails that slot alone (a
matrices entry {name, type, error} with the fit’s own code and
details.fit, plus its PULSE_SLOT_FAILED warning). A
FILTER_EXPRESSION naming it in coef() (a filter’s verdict cannot be
null) and a coef() whose fit name is not a literal are refused with
the fit’s own code and details.fit. Under Options.Strict the batch
fails with the fit’s own code. Predict
cannot foresee a data fault, so predict never reports a fit as
failing.
Additive: a response with no failed slot is byte-identical, and
format_version stays "1.1".
Whether a crosstab fuses is a predict answer
The schema cannot tell you which arm the engine will build a crosstab
on — the fused one-pass arm (memory O(cells + margins)) or the buffered
arm (holds every filter-passing record). Output is identical; only
memory differs. predict reports it as
data.crosstab_fusable (absent when the request has no crosstab) plus
data.crosstab_fusion_reasons (every reason it will not fuse, in rule
order). Both are predict result fields, not part of this schema. They honour
the instance: an engine built with Options.DisableCrosstabFusion
answers false with a reason. See skills/crosstab-guide.md.
What the schema cannot say about margin_aggregations
The auxiliary margin-only slot is fully described structurally — it is an
array of the same Aggregation shape the cell slot takes — but two of
its contracts are semantic, so validating a request against the schema
tells you nothing about either. Both are reported by predict.
Whether the figures will be emitted at all. The auxiliary figures
land only on components.crosstab.row_margin_aggregations /
column_margin_aggregations / grand_total_aggregations, and each rides
the matching DISPLAY flag (crosstab.margins.rows / .columns /
.grand). A schema-valid request with every display flag false produces
no auxiliary figure at all. Setting a normalize direction does not
help: it makes its margin required as a normalization denominator, and
an auxiliary is never a denominator. That shape warns
PULSE_CROSSTAB_MARGIN_AGG_UNOBSERVED.
Which records each figure is built from. An auxiliary observes the
same record admission as the CELL aggregator — a record contributes only
if it contributed to a cell — so a record whose cell field is null, and a
record whose axis key a grouper include excluded, are absent from every
auxiliary figure. The cell’s own row_margin_components beside them
follow the same axis rule (a record reaches any margin only if it reached
a cell, so a null or empty set or an excluded key is in no margin and no
normalize denominator) but still count a null cell field as n_null.
Nothing in the schema distinguishes the two, and the
consequence is silent: a consumer reading an auxiliary’s components.n
as a cohort count gets a well-formed, plausible, wrong number. See
skills/crosstab-guide.md and skills/response-components.md.