On this page
- Status: Accepted. Batch D1a (2026-09-03), commit
b393b097. - Owners: Platform (site programme).
- Extends: ADR 0038 (the schema this ADR's fields live in).
- Related: ADR 0040 (the DSL nodes that read these properties); §32/§35 (no fabricated numbers, no silent unsupported filter).
Context#
A generic "measure" object is not enough. Active HC is a snapshot count that must never be summed
across months; Hires is a flow that must; ROI / Employee is valid only at company grain, never
per department; average headcount has TWO contractually different definitions in the same workbook
(a monthly mean and a year-start/report-month endpoint average) and silently substituting one for the
other produces a plausible, wrong number. Getting this modelling decision wrong is the single largest
correctness risk in the tenant-dataset layer — "the first person to widen a date range gets a
plausible, wrong headcount and nothing fails."
Decisions#
D1 — temporality: 'flow' | 'stock' on every measure field
org_dataset_fields.temporality (ORG_DATASET_FIELD_TEMPORALITIES, packages/schema/src/tables/org-datasets.ts).
A flow measure sums across a window (Hires, OT Hours, Staff Cost). A stock measure is a
snapshot read at a point in time — summing it across months is meaningless; the correct multi-month
reduction is an average, never a sum. Active HC is period_end at the snapshot month (163); the ROI
page's Average Active HC (159.71) is a period_average over the same stock measure, and the two are
never interchangeable.
D2 — sum never reaches a stock field — enforced twice
validateDatasetFieldExpr (packages/metrics/src/dataset-expr.ts) refuses a stored{agg:'sum'}
node (direct form) or a sum_of{measures:[...]} node naming a stock sibling (indirect form) at
TypeScript validate-time, for anything going through the DSL. A hand-authored JSON fixture, seed, or
pack export never runs that validator, so dataset-stock-flow-reduction.py closes the gap with a pure
static scan over every dataset-field-shaped JSON document in the tree, checking both the direct and
indirect forms against the document's own fieldKey -> temporality map.
D3 — Two named, non-interchangeable multi-period averages
period_average {measure, over}— the mean of the stock value across the periods in the window (HR's ROI page: 159.71).endpoint_average {measure, from: year_start, to: report_month}—(active at year start + active at report month) / 2, the AI_Data_Dictionary's contractual YTD average headcount formula.
Both are declared DSL nodes (ADR 0040), named, and reconciled separately — a dataset never silently substitutes one for the other because a widget happened to ask for "the average."
D4 — grain_scope: the lowest grain a measure is valid at
org_dataset_fields.grain_scope (e.g. ['brand','month'] for ROI/Employee). A request below the
declared grain resolves not_applicable_at_grain (D6), never an approximation.
D5 — applicable_filters: the dimension keys a measure actually honours
Everything else is declared ignored, mirroring the existing rule that the metric layer already
returns [] rather than a wrong breakdown. Three consequences, modelled as data, not copy:
- The filter bar disables a control no widget on the page honours, rather than offering a control that silently does nothing (§32's answer to "a control the reader cannot use").
- Each card prints one scope line naming the ignored dimensions and why — the generalised form of
the existing audience-widget mechanism (
widget-renderer.tsx,audience-tab-filter.ts), extended to any dataset widget. - The scope line's wording is presentation data (ADR 0029), never a fabricated per-client string.
This is the generic form of §33 (every cross-cutting filter reaches every SQL block, or is documented as ignored).
D6 — Availability is a state, never a value; SKIP is a bug
A measure resolves to exactly one of:
ok | no_data | insufficient_base | not_applicable_at_grain | source_unavailable | rule_required | missing_input
(DATASET_FIELD_AVAILABILITY_STATES, packages/metrics/src/dataset-expr.ts). A covered brand+period
with zero events is a true 0; an uncovered one is no_data. rule_required must be addressed to a
named owner, never a silent dash — the platform must not inherit blame for a number the customer
never defined. This closes the exact defect the platform already forbids elsewhere (§32/§35,
fabricated-multiplier-kpis.py) for the tenant-dataset family specifically.
D7 — Value dictionaries at the measure's own dimensions
org_dataset_value_aliases maps source spellings ("Personal plan" / "Personal Plan") onto one catalog
value at ingest, with the unmapped remainder visible in the receipt rather than silently folded — the
numeric-dataset sibling of content_value_aliases.
Consequences#
- A dataset's own schema states, once, which filters a measure honours and at what grain — a client never gets a control that quietly does nothing, and an engineer never has to special-case a department filter for one measure.
endpoint_averagevsperiod_averageare reconciled as two separate assertions inverify:data, anchored to the workbook's own contractual formulas — never one formula standing in for the other.- A measure with an undefined rule (
Promotion Ratewith no agreed denominator) rendersrule_requiredaddressed to a name, not an invented formula.
Implementation status (declared 2026-09-03)#
| Decision | Status | Evidence |
|---|---|---|
| D1 temporality field | Landed | org_, ORG_ |
| D2 stock/flow reduction guard | Landed | validate (DSL); dataset- (fixtures/packs) in audit:all |
| D3 endpoint vs period average | Landed | endpoint_/period_ DSL nodes; HR fixture + verify:data assertions distinguish both (11/15 oracle exact) |
| D4 grain scope | Landed | org_; resolver returns not_ below it |
| D5 applicable filters + scope line | Landed | org_; generalised scope-line mechanism in widget- |
| D6 availability states | Landed | DATASET_ (7 states); resolver never returns a fabricated zero for a non-ok cell (guard test) |
| D7 value aliases | Landed | org_; applied at ingest by the dataset_ promoter |