Skip to content
MSO CloudDocumentation

ADR 0004 — MSO × UCIP off-take learning loop

On this page
  • Status: Accepted
  • Date: 2026-06-22
  • Context: docs/MSO-UCIP-Roadmap, CLAUDE.md §60
  • Supersedes / relates: ADR 0002 (plugin architecture), ADR 0003 (connector API strategy)

Context#

The ECI social→ecom case shows that, per brand, a specific social lever (KOC posts, product mentions, online-seller buzz, owned media, consulting) leads first-party sales by about one week. UCIP already had the three data layers in reach — 1st-party marketplace orders (ground truth), the ECI ecom panel (3rd-party estimate), and SocialHeat social-listening buzz (3rd-party) — plus a Measure Spine (data-reconciliation.ts). What was missing was the learning loop that turns those layers into compounding marketing memory: learn the winning lever, propose a decision, measure it against real orders, record the lesson, and sharpen next time.

We needed this to run end-to-end (not scaffolding) while obeying every UCIP invariant: org→brand + RLS, VND-integer money, is_sample, connector-as-plugin, ICT time, the Measure Spine, and the abstain rule (never fabricate a lift).

Decision#

1. Three data layers, correctly classified

  • 1st-party (ground truth): orders. The ONLY thing the Measure Spine reconciles against.
  • ECI ecom panel (3rd-party, Tầng 2): mi-eci-connector → market_intel_* (source='eci', isEstimate=true). A weekly per-brand GMV/items estimate, used for the "3 tầng + hiệu chỉnh" calibration view (ECI vs real orders).
  • SocialHeat buzz (3rd-party, Tầng 3): mi-socialheat-connector → social_signal_daily (platform='social-agg'). The lever signal the loop correlates against sales.

Both 3rd-party connectors carry thirdPartyData=true + connectorFamily='market_intel' + dependsOn=['market-intelligence']. They never feed first-party KPIs (§32/§35).

2. New tables (Phase A — Marketing/Decision Memory)

social_signal_daily, offtake_models (Marketing Memory), decisions (Decision Memory), decision_outcomes (Measure-Spine verdicts). All org+brand-partitioned with RLS, is_sample, and correlations/ratios stored as signed basis points (×10000) so the no-float rule (§2) holds. Schema reference: mso-runbook.md.

3. ECI is a multi-snapshot weekly source (deviation from Kalodata's single-snapshot MarketDataParser)

Kalodata exports are a single ranking snapshot over one window. ECI is a weekly time series (labels × W{n}-YYYY-MM weeks). Forcing it into the single-window MarketDataParser contract would lose the weekly grain the calibration view needs. So parseEciSheets produces weekly rows and the ingest writes one market_intel snapshot per ISO-week (dataset='shop', source='eci'). SocialHeat uses the staging→promoter path (import_staging_rows → promoteSocialSignals → social_signal_daily), modelled on the ad-spend promoter.

4. One math source, one persister (§60)

The off-take math (winsorise → rank/Spearman → partial-out the campaign calendar → lead-lag → prior→posterior blend → abstain gate → discount cap) lives in exactly one pure module, packages/metrics/src/offtake.ts, unit-tested against the frozen sim oracle. The memory tables are written from exactly one persister, packages/metrics/src/offtake-loop.ts, called by both the seed and the workers. No surface re-derives a correlation (audit offtake-single-source.py).

5. Govern / Explore / Calibration / Autonomy

  • Govern gate (evaluateGuardrails): OEC contract + guardrails (act only on a reliable signal; clamp discount to the 18% cap) + human approval. Approving a proposal emits only action commands supported by classifyDecisionAction; unknown fails closed. A holdout metadata field is not evidence of assignment/control integrity.
  • Calibration: the track-record card ("system says X% → right Y%") + the ECI-vs-orders calibration chart.
  • Autonomy: action authority is a separate A0–A4 ladder (mso-19), with human approval as the current boundary. It must not be inferred from evidence maturity L0–L5.

6. Verification anchored to two oracles

  • Sim oracle (sim/decision_log.json): the TS loop reproduces the winning lever + mode + every verdict EXACTLY; correlation magnitude within ±0.08 (the documented float→int-persistence rounding).
  • 1st-party orders (Measure Spine): decision_outcomes.measured_value == SUM(orders.gmv) for the brand's campaign ICT-week. Both reconciled by data-reconciliation.ts #14a/b/c (verify:data).

Consequences#

  • The off-take loop runs on a weekly cron (offtake.fit.weekly, offtake.review.weekly, ICT) and on the seed, with identical results.
  • Adding a new market-intel source = a parser + a manifest, no router changes.
  • The abstain gate means a no-signal brand (DermaPed in the demo) honestly renders — instead of a fabricated recommendation.
  • Off-take is good at direction, not point forecasts. Current real-data measurement is actual-vs-contract plus observational pre/post; randomized/geo/switchback lift needs a separately verified design.

Alternatives considered#

  • Store weekly GMV in agg_org_day. Rejected: its PK is (org, day, platform) — not brand-keyed, so it cannot hold four brands on the same week. Synthetic orders are the genuine, reconcilable 1st-party plane.
  • One generic MarketDataParser for ECI. Rejected: the single-snapshot contract loses ECI's weekly grain (see §3).
  • Call an LLM for every decision rationale. Deferred: the loop generates deterministic Vietnamese rationale/lesson copy (no AI dependency to run the seed); @yng/ai enrichment (PCN-gated) is an optional per-org layer.