Skip to content
MSO CloudDocumentation

ADR 0021 — Measurement bindings: a planned number is comparable only when a human said how to measure it

On this page
  • Status: Accepted (phase 1 shipped)
  • Date: 2026-07-28
  • Context owner: Platform / Marketing pillar
  • Related: ADR 0008 (marketing connector family), ADR 0017 (one mapping contract), §26 (no heuristics for discriminators in money math), §32/§35 (no fake denominators or fabricated multipliers), §49 (one definition per metric), §55 (truth traces to the operator, never to a code re-derivation), §64 (owner-gated, audit-logged decision mutations)

Context#

A tenant asked the assistant: "Is Google Ads pacing correctly?" It answered from the organisation's total budget. The answer was confidently, uselessly wrong, and the user said so.

The diagnosis found three defects stacked on each other:

  1. No channel dimension existed on the answer path. budgetPacing read budget_plans, where that org has exactly one row: platform='all', channel='marketing', 685,000,000đ for 2026. The per-channel budget did exist — in kpi_targets.ad_platform, itself the survivor of the §26/§36 hardcoded-mapping incident — but nothing generalised it and chat could not read it.
  2. The numerator and the elapsed-time denominator used different anchors. Spend-to-date was clamped to the report window start while elapsedRatio counted from the plan start, so a "this month" question against a yearly plan compared one month of spend (3.0%) with 57.3% of the year elapsed. Fixed by planSpendWindow (marketing-overview.ts), which anchors both sides on the plan start. The same defective widget rendered on the Marketing Performance page.
  3. The denominator contained budget with no measurable actual. 685M = Google 180M + Facebook 160M + PR 215M + Tools 70M + Upper funnel 60M. Only the first two map to ad_spend_daily. Pacing the whole 685M against a feed that can only ever cover 340M reports "behind" forever (§32/§35).

Defects 1 and 3 share one root cause, and it is not a date bug: a planned number carries no statement of how it is measured. Every customer's planning sheet has a different shape — by funnel stage, by channel, by team, by platform, by campaign — so that statement cannot live in code, and guessing it at query time is exactly what §26 forbids.

Decision#

The binding from a planning line to the metric that measures it is a first-class artifact, stored as per-org data, proposed by a machine and confirmed by a human. Only a confirmed binding may produce a number anyone sees.

plan_line_bindings (migration 0128_plan_line_bindings) holds one row per planning line:

column meaning
source_kind + source_id which planning store, which row (kpi_target | budget_plan)
metric_slug the metric catalog entry supplying the ACTUAL — never ad-hoc SQL (§49)
dimension_filter jsonb narrowing that metric, e.g. {"platform":"google-ads"}
status suggested | confirmed | rejected | unmeasurable
confidence_bp, rationale, suggested_by the proposal and its evidence
confirmed_by, confirmed_at who accepted responsibility for the number

D1 — Only confirmed is load-bearing

isLoadBearing() (@yng/metrics/plan-binding) is the single gate: status === 'confirmed' and structurally valid. Every read routes through it rather than testing the status string, so the check cannot be forgotten at one call site. A suggested binding never reaches a metric surface, whatever its confidence.

This is §55 applied to measurement: the truth about what a plan line means comes from the operator, not from a derivation the system found convincing.

D2 — unmeasurable is a first-class, honest state

A line an operator marks unmeasurable has no actual by definition. It is excluded from pacing denominators and reported with its reason, never folded in and never silently dropped — partitionPlanLines() returns both halves and the caller must show both. That is what fixes defect 3: pacing covers the 340M that can be measured, and the remaining 345M is stated as unmeasured rather than quietly inflating the denominator.

D3 — Validity is an exact contract, not a name match

validatePlanBinding() refuses a binding unless: the metric exists in the catalog; every dimension_filter key is a dimension that metric declares; and the metric appears in EVALUABLE_PLAN_METRICS — the set the actual-resolver can compute today. A catalog-legal binding with no resolver is worse than no binding: the operator confirms it, believes the line is measured, and the number silently never appears.

D4 — Heuristics live on the proposal side of the gate, and only there

plan-binding-suggest.ts matches a line's label against platform aliases. That is a heuristic, and §26 bans heuristics in money math — the ban holds, because this module does no money math. It emits proposals. Guessing is cheap and reversible before the confirm gate, and forbidden after it.

The proposer is deliberately conservative and requires two independent signals: the label names a platform, and the org has real measured spend on that platform. A label it cannot read produces no proposal at all. Confidence is capped below 100% on purpose. The failure mode worth designing against is not a missing suggestion — it is a confident wrong one, which converts human review into a rubber stamp.

D5 — The review screen confirms against a number, not a slug

/marketing-performance/plan-bindings shows, for each line, the actual its binding produces next to the plan. An operator is never asked "does this line map to mkt_ad_spend filtered on platform=google-ads?" — they are asked whether 64,703,199đ is the right Google Ads spend. They confirm against a number they already know.

Every mutation is owner/org-admin gated, rate-limited and audit-logged (marketing.plan_binding.*). There is deliberately no bulk "accept all high-confidence" action: one wrong confirmed binding poisons a money number, and the click is cheaper than the number is expensive.

D6 — kpi_targets.ad_platform is treated as already confirmed

That column is operator-authored data that predates this table. The resolver reads it as a confirmed mkt_ad_spend binding, with an explicit binding row taking precedence when one exists. Migrating it silently would discard a real human decision; deprecating it is phase 2.

Consequences#

Shipped (phase 1)

  • plan_line_bindings + RLS (brand-partitioned cohort) + runtime ACL grants for web and worker.
  • @yng/metrics/plan-binding (pure rules), plan-binding-read (per-line pacing), plan-binding-suggest (proposals).
  • planBindings tRPC router: review, bindableMetrics, suggest, decide, remove.
  • Review screen at /marketing-performance/plan-bindings, gated by the marketing-performance plugin (§47) and owner/org-admin role.
  • Chat tool channelBudgetPacing, and budgetPacing now declares scope: org_all_channels so the org rollup can never be attributed to one channel again.
  • planSpendWindow anchors spend-to-date on the plan start (defect 2), fixing the chat answer and the Marketing Performance widget together.

Not yet — and stated so a reader does not assume otherwise

  • budget_plans lines resolve to unsupported_source: that store carries a period/bucket grain rather than dates. They are reported as unmeasured, so a plan total still accounts for every đồng.
  • Only mkt_ad_spend has an actual-resolver. Count targets (mql, web_users) keep the KPI page's existing path until they move behind a binding.
  • The proposer is an alias matcher. An LLM pass for sheets whose labels carry no vendor name plugs into the same PlanBindingProposal shape — behind the same confirm gate, which is the part that must not change.

Risk retained. The failure mode this design cannot remove is a confirmed-but-wrong binding. Mitigations: the confirm screen shows the produced actual, decisions are audit-logged with an owner, and re-suggestion never overwrites a human decision (setWhere status='suggested').

Amendment 2026-09-03 (future)#

Plan/actual generalises onto a tenant dataset's own scenario and version axes (org_dataset_fields role scenario_axis/version_axis, ADR 0038 D1) — a PLAN/FORECAST/ACTUAL variance for a finance dataset is the delta/axis_pick DSL nodes (ADR 0040 D1) over those axes, not a second binding mechanism. Not yet built; recorded as the extension point.