Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

name: overlay-system
description: Overlay framework — OverlaySpec composition, reference families, three payload shapes, host-arm wiring (SERIES / MATRIX_RESULT / FACET / CHAIN / FORMULA), named payload parts of multi-output kinds. Per-kind detail lives in op-overlay-* atomics.
type: guide
kind: design
applies_to: process, compose, facet
covers: [OVERLAY, OverlaySpec, OverlayLayer]

Overlays

Read-only decorations of a DERIVED figure. Specs ride Request.Overlays, one layer each in Response.Overlays[i], in spec order, keyed to host coordinates; the base payload is NEVER mutated.

Which skill answers what

QuestionSkill
Pairwise kinds: p grid, letters, skips, weightsoverlay-pairwise
A pairwise leg’s n_source / p_sourcepairwise-n-sources
The Compose panel’s n modespanel-n-sources
Parity and prior-period testsoverlay-reference-tests
What a formula can readoverlay-formula-namespace

Choosing an overlay

  1. Name the question, then read its intent (pulse_skills_get intents).
  2. Filter manifest overlays[] on that intent, then on the HOST you have — each entry lists shapes, scopes, ref_kinds, buffered and inferential.
  3. Read the kind’s atomic skill; never hardcode a kind count.

OverlaySpec composition

kind, scope, ref, optional name / level / within / params; Compose-only reference / targets. scope ∈ cell|row|column|group|matrix|total. level / within mirror the crosstab’s normalize_level / normalize_within.

Predict and runtime refuse a misshapen or off-host spec with the SAME errors[0].code (PULSE_OVERLAY_REF_INCOMPATIBLE_WITH_SHAPE, …).

Reference families

ref is a discriminated union — exactly one family populated:

FamilyCompares againstHost
margin{axis}the row / column / grand margincrosstab
sibling{field, value}another group’s valuegrouped Process
baseline_index{position}, prior, rolling_mean, yoyan earlier point in the same seriesgrouped Process
population{cohort}a reference cohortfacet
stage{index or name}an earlier chain stageprocess chain
matrix{name}one matrix spec’s result, every group bucketmatrix result
reference + targets (spec top level)another Compose slotcompose

Implicit-margin kinds (χ² / Fisher cell tests) leave ref empty.

Three payload shapes

payload.shape ∈ scalar|series|matrix. Scalar: payload.scalar + optional summary. Series: payload.series.entries[i].{key, summary}, aligned to host keys; the figure is summary.statistic. Matrix: payload.matrix.cells[r][c], mirroring host cells. baseline is the centre (100 for an index, 0 for a delta / z), absent if inferential.

Parts (multi-output kinds)

A multi-output kind (pairwise under params.letters) adds payload.parts: named plain scalar | series | matrix payloads beside the primary, never nested; manifest overlays[].parts lists them (when = condition). A points × dimensions part keys its columns ["dim_1"], ["dim_2"], …. Select one via return: overlays[*].payload.parts.<part>.

Host-arm wiring

The carrying request decides the host, the host the legal kinds (an ungrouped or aggregation-free request runs none):

  • MATRIX — a crosstab (Request.Crosstab): share, margin compare, cell tests, intra-matrix pairwise.
  • SERIES — the SERIES host, a grouped Process with no crosstab: per-group self-compare (sibling, baseline, prior, rolling, year-over-year). Over N ≥ 2 groups it runs per partition (params.partition_by, a key prefix; default all but the last). Scores params.field, else aggregations[0].
  • MATRIX_RESULT — Request.Matrices with no crosstab, on a process request or Compose slot (not chain, facet or Compose-host slots): reads every group bucket of the spec ref.matrix names. Crosstab + matrices is refused.
  • FACET — FacetRequest.Overlays: population comparisons, never weighted (a set weight ⇒ PULSE_WEIGHT_UNSUPPORTED), layers on FacetResult.Overlays (facet-design).
  • CHAIN — whole-chain ChainRequest.Overlays against an earlier stage; layers on the chain response, per-stage overlays untouched. Stages of divergent shape ⇒ PULSE_OVERLAY_CHAIN_STAGE_SHAPE_DIVERGENT (process-chain).
  • FORMULA — expression over a crosstab, grouped Process or any Compose shape (SERIES partitioned, field per slot).
  • COMPOSE — the post-slot fold compares slots (reference vs targets); slots must align on schema, keys and dictionaries. Layers on overlays (top-level return prunes post-fold), buffered; single-target kinds fan out per target (<name>__<target>) (compose-requests).

A cell-VALUE reader (MATRIX, Compose slot) over a code cell (AGG_MODE of a categorical) ⇒ PROCESSING_CONFIG categorical_code.

Extension kinds (extensions.overlays): a handler per host (Matrix, Series, Compose), buffered, not chain, not facet; weighted only if weight_aware.

Per-layer warnings (OverlayLayer.Warnings)

warnings: [{code, message, details}] per layer, omitempty. PULSE_OVERLAY_REF_ZERO (zero reference), PULSE_OVERLAY_EXPECTED_LOW (expected count below 5: χ² cells, symmetry pairs). On a batch-root host it rides the layer that raised it (a fan-out target’s); a partitioned SERIES layer raises each code once (details.partitions). They never fail it.

Multiplicity

Inferential layers take multiplicity (p_adjusted figures, a layer echo); pairwise letters follow it (multiplicity-correction).

Streamability

Manifest overlays[].buffered; descriptive SERIES kinds stream. MATRIX kinds fold after the crosstab finishes, so they never decide whether it fuses (crosstab-guide). One buffered kind prices the request buffered.

Weighted hosts

Descriptive kinds read the weighted payload. Inferential kinds RUN on each cell’s floor-key N* (Σw, or Kish n_eff under probability; echoed in summary.parameters). Kinds refusing a weight (PULSE_WEIGHT_UNSUPPORTED) say so in their ## Contract. Spec "weight": null opts the slot out, not the host cell (weighting).

See