On this page
Sinh tự động bởi
scripts/docs/generate-warehouse-schema.tstừ drizzle defs (packages/schema/src/tables) +packages/schema/sql/rls-policies.sql. Không sửa tay — chạy lại script rồipnpm tsx scripts/docs-to-html.ts --only=docs/architecture/reference/warehouse-schema.md.
Postgres 19 multi-tenant theo medallion architecture. 280 bảng, nhóm theo
bronze/silver/marketing/gold + bốn plane chuyên biệt (MSO, Market Intelligence, Social,
Content Intelligence) + admin.
Cột "Cột chính" bỏ qua boilerplate (id, org_id, brand_id, is_sample,
created_at, updated_at, refreshed_at) và cắt ở 8 cột đầu.
Tenancy & RLS#
Tenancy là org → brand (invariant #1): một khách hàng = một org, fact/asset tables mang
cả org_id lẫn brand_id. Truy vấn org-scoped đi qua orgProcedure
(brand-partitioned: brandProcedure) trong apps/web/src/server/trpc.ts — mỗi resolver
chạy trong runWithRlsContext (packages/schema/src/rls-context.ts): mở transaction, pin
GUC app.current_org_id/app.current_brand_id transaction-local trên đúng một connection,
rồi route mọi query của request lên transaction đó. Policy phía Postgres đọc GUC qua helper
app_current_org()/app_current_brand() (GUC rỗng → deny). Cơ chế được kiểm chứng bằng
scripts/audit/rls-context-effective.ts.
Các cohort trong packages/schema/sql/rls-policies.sql:
| Cohort | Policy | Số bảng |
|---|---|---|
org_ |
org_: org_ |
104 |
brand_ |
org_: thêm predicate brand (row brand_ NULL / không có brand context / khớp context) |
146 |
auth_ |
yng_ với process attestation |
7 |
identity_ |
Đọc metadata; ghi theo process hoặc tenant attestation | 3 |
Brand authz chính nằm ở app-layer (org_memberships.viewable_brand_ids); RLS là lưới an
toàn. Lưu ý vận hành: RLS chỉ bind khi app connect bằng role không SUPERUSER/BYPASSRLS —
role superuser bỏ qua cả FORCE ROW LEVEL SECURITY (đánh giá mso-14, mục C4). Ngoài RLS có
chủ đích (ghi chú cuối rls-policies.sql, enforce bằng Drizzle helper ở app-layer):
notification_channel_configs, platform_ai_connections, platform_connector_credentials, platform_connector_runs, platform_connector_state, push_subscriptions, shared_trend_history, shared_trend_items, shared_trend_review_decisions, site_settings, site_themes, user_channel_identities.
audit_logs có thêm policy riêng: cấm UPDATE, DELETE chỉ cho rotation quá cửa sổ 90 ngày.
Đối chiếu RLS (giá trị audit của doc)
Tại thời điểm sinh doc: 0 bảng thiếu RLS — mọi bảng có org_id đều nằm trong một cohort hoặc được ghi chú app-layer có chủ đích.
Mục có trong rls-policies.sql nhưng KHÔNG còn trong drizzle schema (stale — dọn khi chạm file):
content_monthcontent_yearcreator_detailshop_detail
Bronze — landing, staging & mặt phẳng sync#
Payload nguồn ghi VERBATIM (§44) + hàng đợi sync/connector. Stream không canonical đi vào import_staging_rows, không vào raw_events (§17).
| Bảng | Cột chính | org_ |
brand_ |
is_ |
RLS |
|---|---|---|---|---|---|
connector_ |
connector_, streams, since, until, status, slices_, slices_, slices_ … (+4) |
✓ | ✓ | ✓ | RLS org+brand |
connector_ |
connector_, kind, label, credentials_, credentials_, credentials_, key_, org_ … (+15) |
✓ | ✓ | ✓ | RLS org+brand |
connector_ |
connector_, connector_, stream_, last_, high_, last_, last_, rows_ |
✓ | — | — | RLS org |
import_ |
source_, target_, version, name, spec, is_, is_, archived_ … (+1) |
✓ | ✓ | — | RLS org+brand |
import_ |
template_, template_, upload_, target_, source_, row_, source_, normalized_ … (+4) |
✓ | ✓ | — | RLS org+brand |
manual_ |
uploaded_, connector_, import_, upload_, filename, extension, byte_, storage_ … (+10) |
✓ | ✓ | ✓ | RLS org+brand |
org_ |
credential_, label, credentials_, credentials_, credentials_, key_, fingerprint, is_ … (+1) |
✓ | ✓ | ✓ | RLS org+brand |
platform_ |
platform, raw_, canonical_ |
✓ | — | ✓ | RLS org |
platform_ |
platform, canonical_, display_ |
✓ | ✓ | ✓ | RLS org |
raw_ |
connector_, connector_, stream_, external_, payload, payload_, source_, ingested_ … (+3) |
✓ | ✓ | ✓ | RLS org+brand |
sync_ |
job_, connector_, connector_, queue, job_, payload, error_, error_ … (+4) |
✓ | — | — | RLS org |
sync_ |
connector_, connector_, job_, status, rows_, rows_, rows_, error_ … (+7) |
✓ | — | ✓ | RLS org |
sync_ |
job_, connector_, stream_, row_, external_, reason_, reason_, raw_ |
✓ | — | ✓ | RLS org |
Silver — thực thể nghiệp vụ canonical (1st-party)#
Fact/entity đã chuẩn hoá theo platform-agnostic model — nguồn của mọi KPI 1st-party. Tiền tệ là VND integer (§2); NMV luôn đọc từ orders.nmv_blo_vnd, breakdown chỉ ALLOCATE (không tự cộng lại).
| Bảng | Cột chính | org_ |
brand_ |
is_ |
RLS |
|---|---|---|---|---|---|
ad_ |
platform, account_, campaign_, campaign_, day, spend_, impressions, clicks … (+13) |
✓ | ✓ | ✓ | RLS org+brand |
affiliate_ |
connector_, platform, platform_, order_, sku_, product_, quantity, price_ … (+15) |
✓ | ✓ | ✓ | RLS org+brand |
budget_ |
period, year, bucket, platform, channel, planned_, planned_, planned_ … (+1) |
✓ | ✓ | ✓ | RLS org+brand |
categories |
name, slug, is_ |
✓ | — | ✓ | RLS org |
category_ |
category_, platform, platform_, platform_, last_ |
✓ | — | ✓ | RLS org |
creator_ |
creator_, cost_, amount_, occurred_, notes |
✓ | ✓ | ✓ | RLS org+brand |
creator_ |
creator_, platform, day, impressions, clicks, orders_, gmv_, cancellation_ |
✓ | ✓ | ✓ | RLS org+brand |
creator_ |
creator_, platform, platform_, platform_ |
✓ | ✓ | ✓ | RLS org+brand |
creator_ |
creator_, platform, platform_, platform_, display_, bio_, avatar_, profile_ … (+28) |
✓ | ✓ | ✓ | RLS org |
creators |
canonical_, canonical_, notes, tier, followers_, engagement_, contract_, default_ |
✓ | ✓ | ✓ | RLS org+brand |
customer_ |
shopper_, order_, kind, severity, status, platform, source_, title … (+9) |
✓ | — | ✓ | RLS org |
engagement_ |
event_, platform, shopper_, creator_, product_, campaign_, occurred_, payload … (+1) |
✓ | — | ✓ | RLS org |
inventory_ |
product_, snapshot_, source_, quantity_, quantity_, expiry_, raw_, source_ |
✓ | ✓ | ✓ | RLS org+brand |
live_ |
platform, platform_, creator_, campaign_, started_, ended_, viewers, peak_ … (+5) |
✓ | — | ✓ | RLS org |
live_ |
connector_, platform, platform_, title, creator_, started_, ended_, gmv_ … (+14) |
✓ | ✓ | ✓ | RLS org+brand |
order_ |
order_, product_, platform_, quantity, unit_, promo_, unit_, list_ … (+3) |
✓ | ✓ | ✓ | RLS org+brand |
orders |
platform, platform_, platform_, status, gmv_, nmv_, nmv_, nmv_ … (+18) |
✓ | ✓ | ✓ | RLS org+brand |
org_ |
dataset_, field_, value_, label_, label_, sort_, parent_, status |
✓ | — | ✓ | RLS org |
org_ |
dataset_, record_, dim_, value_ |
✓ | ✓ | ✓ | RLS org+brand |
org_ |
dataset_, record_, measure_, value_ |
✓ | ✓ | ✓ | RLS org+brand |
org_ |
dataset_, source_, record_, grain_, period_, schema_ |
✓ | ✓ | ✓ | RLS org+brand |
payout_ |
platform, platform_, payout_, platform_, order_, payout_, expected_, actual_ … (+4) |
✓ | ✓ | ✓ | RLS org+brand |
platform_ |
product_, platform, platform_, platform_, platform_, platform_, last_, last_ … (+1) |
✓ | — | ✓ | RLS org |
po_ |
po_, product_, sku_, quantity_, quantity_, unit_ |
✓ | ✓ | ✓ | RLS org+brand |
price_ |
product_, platform, platform_, platform_, price_, observed_, source |
✓ | — | ✓ | RLS org |
product_ |
product_, platform, platform_, platform_, platform_, platform_, platform_, list_ … (+4) |
✓ | ✓ | ✓ | RLS org+brand |
products |
canonical_, canonical_, barcode_, brand, category, category_, category_, unit_ … (+2) |
✓ | ✓ | ✓ | RLS org+brand |
purchase_ |
supplier_, status, po_, total_, ordered_, expected_, received_, notes |
✓ | ✓ | ✓ | RLS org+brand |
reconciliation_ |
assertion, severity, passed, summary, details, run_ |
✓ | — | ✓ | RLS org |
service_ |
case_, event_, actor_, payload, occurred_ |
✓ | — | ✓ | RLS org |
settlement_ |
connector_, platform, external_, statement_, platform_, transaction_, fee_, currency … (+7) |
✓ | ✓ | ✓ | RLS org+brand |
shopper_ |
shopper_, platform, platform_, platform_, confidence |
✓ | — | ✓ | RLS org |
shoppers |
display_, phone_, email_, consent_, consent_, first_, last_ |
✓ | — | ✓ | RLS org |
sku_ |
sku_, brand |
✓ | — | ✓ | RLS org |
sku_ |
sku_, category_ |
✓ | — | ✓ | RLS org |
sku_ |
rule_, pattern, target_, priority, metadata, created_ |
✓ | — | ✓ | RLS org |
sla_ |
kind, severity, target_, escalate_, is_ |
✓ | — | ✓ | RLS org |
source_ |
connector_, canonical_, platform, day, source, gmv_, orders_, units_ … (+2) |
✓ | ✓ | ✓ | RLS org+brand |
targets |
period, year, quarter, month, platform, metric, target_ |
✓ | ✓ | ✓ | RLS org+brand |
video_ |
connector_, platform, platform_, title, creator_, posted_, metric_, gmv_ … (+7) |
✓ | ✓ | ✓ | RLS org+brand |
video_ |
connector_, platform, platform_, platform_, platform_, product_, metric_, gmv_ … (+4) |
✓ | ✓ | ✓ | RLS org+brand |
Marketing — mặt phẳng 1st-party ads/web/search/CRM (ADR 0008)#
Chi phí quảng cáo / web / search / CRM của chính nhà bán — 1st-party nhưng TÁCH khỏi silver marketplace (ADR 0008). KHÔNG đi qua market_intel_*, KHÔNG vào MARKET_CHAT_TOOLS (§58); Measure Spine vẫn chỉ validate trên orders (§60d) — conversions platform-ghi-nhận không phải orders, MER/CAC blended trên orders.
| Bảng | Cột chính | org_ |
brand_ |
is_ |
RLS |
|---|---|---|---|---|---|
business_ |
source, period_, data_, metric_, metric_, value_, value_, raw_ … (+1) |
✓ | ✓ | ✓ | RLS org+brand |
crm_ |
connector_, provider, deal_, title, pipeline_, stage_, stage_, opportunity_ … (+14) |
✓ | ✓ | ✓ | RLS org+brand |
crm_ |
connector_, provider, lead_, title, status_, status_, source_, opportunity_ … (+15) |
✓ | ✓ | ✓ | RLS org+brand |
crm_ |
connector_, provider, entity_, entity_, from_, to_, moved_, raw_ |
✓ | ✓ | ✓ | RLS org+brand |
email_ |
connector_, provider, campaign_, campaign_, subject, day, is_, sends … (+13) |
✓ | ✓ | ✓ | RLS org+brand |
email_ |
connector_, provider, event, event_, event_, recipient_, from_, subject … (+7) |
✓ | ✓ | ✓ | RLS org+brand |
kpi_ |
metric_, budget_, budget_, ad_, period_, period_, target_, include_ … (+1) |
✓ | ✓ | ✓ | RLS org+brand |
marketing_ |
campaign_, display_, platform, year, objective, fb_, ga4_, ga4_ … (+3) |
✓ | ✓ | ✓ | RLS org+brand |
marketing_ |
stream, api_ |
✓ | — | ✓ | RLS org |
plan_ |
source_, source_, value_, as_, note, entered_, entered_ |
✓ | ✓ | ✓ | RLS org+brand |
plan_ |
source_, source_, metric_, dimension_, status, confidence_, rationale, suggested_ … (+4) |
✓ | ✓ | ✓ | RLS org+brand |
search_ |
connector_, site_, day, page_, clicks, impressions, ctr_, position_ … (+1) |
✓ | ✓ | ✓ | RLS org+brand |
search_ |
connector_, site_, day, query, clicks, impressions, ctr_, position_ … (+1) |
✓ | ✓ | ✓ | RLS org+brand |
search_ |
connector_, site_, day, clicks, impressions, ctr_, position_, raw_ … (+1) |
✓ | ✓ | ✓ | RLS org+brand |
social_ |
connector_, platform, page_, page_, day, followers_, followers_, followers_ … (+11) |
✓ | ✓ | ✓ | RLS org+brand |
social_ |
connector_, platform, post_, page_, title, content, post_, permalink … (+19) |
✓ | ✓ | ✓ | RLS org+brand |
web_ |
connector_, property_, day, channel_, sessions, total_, new_, engaged_ … (+4) |
✓ | ✓ | ✓ | RLS org+brand |
web_ |
connector_, property_, hostname, landing_, traffic_, period_, period_, period_ … (+9) |
✓ | ✓ | ✓ | RLS org+brand |
web_ |
connector_, property_, traffic_, day, views, sessions, total_, new_ … (+7) |
✓ | ✓ | ✓ | RLS org+brand |
web_ |
connector_, property_, traffic_, period_, period_, period_, views, sessions … (+4) |
✓ | ✓ | ✓ | RLS org+brand |
web_ |
connector_, property_, source_, traffic_, period_, period_, period_, sessions … (+5) |
✓ | ✓ | ✓ | RLS org+brand |
Gold — dim / fct / agg / pred phục vụ dashboard#
Rollup/forecast do refreshOrgMaterializations (packages/metrics/src/materialize.ts) sinh — không ghi tay. Metric thiếu dữ liệu thật phải render — + mode, không fake 0/multiplier (§32/§35).
| Bảng | Cột chính | org_ |
brand_ |
is_ |
RLS |
|---|---|---|---|---|---|
action_ |
period_, period_, status, title, summary, recommendations, citations, tokens_ … (+3) |
✓ | — | ✓ | RLS org |
agg_ |
dataset_, grain, grain_, dim_, value_, platform_, mention_, label_ … (+2) |
✓ | ✓ | ✓ | RLS org+brand |
agg_ |
campaign_, gmv_, orders_, spend_, unique_, source_ |
✓ | ✓ | ✓ | RLS org+brand |
agg_ |
creator_, day, gmv_, orders_, impressions, clicks, cost_, source_ |
✓ | ✓ | ✓ | RLS org+brand |
agg_ |
dataset_, period_, dim_, value_, measure_, scenario, version, schema_ … (+2) |
✓ | ✓ | ✓ | RLS org+brand |
agg_ |
day, platform, gmv_, nmv_, nmv_, nmv_, orders_, cancelled_ … (+7) |
✓ | ✓ | ✓ | RLS org+brand |
agg_ |
shopper_, month, orders_, gmv_, source_ |
✓ | ✓ | ✓ | RLS org+brand |
agg_ |
sku_, day, units_, gmv_, cogs_, stockout_, source_ |
✓ | ✓ | ✓ | RLS org+brand |
anomalies |
metric_, severity, summary, detected_, resolved_, details, model_ |
✓ | — | ✓ | RLS org |
audience_ |
name, description, dsl, refresh_, last_, last_, is_, created_ |
✓ | — | ✓ | RLS org |
audience_ |
audience_, shopper_, entered_, exited_, snapshot_ |
✓ | — | ✓ | RLS org |
audience_ |
audience_, triggered_, candidates_, entered_, exited_, duration_, status, error_ … (+1) |
✓ | — | ✓ | RLS org |
category_ |
category_, metric_, period_, period_, value_, peer_, peer_, peer_ … (+4) |
✓ | — | ✓ | RLS org |
dim_ |
name, slug, parent_ |
✓ | — | ✓ | RLS org |
dim_ |
name, platform, start_, end_, budget_ |
✓ | ✓ | ✓ | RLS org+brand |
dim_ |
name, path, depth |
✓ | — | ✓ | RLS org |
dim_ |
code, name, kind, region_ |
✓ | — | ✓ | RLS org |
dim_ |
product_, dim_, category_, display_ |
✓ | ✓ | ✓ | RLS org+brand |
dim_ |
product_, sku_, cogs_, reorder_, safety_, lead_ |
✓ | ✓ | ✓ | RLS org+brand |
dim_ |
name, contact_, lead_ |
✓ | — | ✓ | RLS org |
fct_ |
product_, location_, movement_, quantity_, reason, reference_, reference_, occurred_ |
✓ | ✓ | ✓ | RLS org+brand |
fct_ |
order_, shopper_, touch_, touch_, creator_, campaign_, placement, credit_ … (+4) |
✓ | — | ✓ | RLS org |
holiday_ |
holiday_, code, label_, label_, sale_, is_ |
✓ | — | ✓ | RLS org |
pred_ |
creator_, score, reasons, model_, generated_ |
✓ | — | ✓ | RLS org |
pred_ |
product_, product_, affinity, support, model_, generated_ |
✓ | — | ✓ | RLS org |
pred_ |
shopper_, clv_, clv_, churn_, horizon_, model_, generated_ |
✓ | — | ✓ | RLS org |
pred_ |
sku_, day, predicted_, confidence_, confidence_, model_, generated_ |
✓ | ✓ | ✓ | RLS org+brand |
MSO — vòng học off-take (Marketing Systems OS)#
Ba lớp dữ liệu của vòng học: buzz 3rd-party (social_signal_daily) → Marketing Memory (offtake_models) → Decision Memory (decisions/decision_outcomes). Toán học chỉ ở packages/metrics/src/offtake.ts; persist chỉ từ packages/metrics/src/offtake-loop.ts (§60). Quan hệ chi tiết: mục "Decision Memory (MSO)" bên dưới.
| Bảng | Cột chính | org_ |
brand_ |
is_ |
RLS |
|---|---|---|---|---|---|
action_ |
kind, source, connector_, connector_, idempotency_, status, requires_, approval_ … (+8) |
✓ | — | ✓ | RLS org |
briefing_ |
cadence, run_, outcome, reason, duration_, docs, recorded_ |
✓ | — | ✓ | RLS org |
decision_ |
decision_, episode_, playbook_, playbook_, proposal_, policy_, policy_, payload … (+11) |
✓ | ✓ | ✓ | RLS org+brand |
decision_ |
decision_, trace_, run_, step_, parent_, event_, actor_, actor_ … (+37) |
✓ | ✓ | ✓ | RLS org+brand |
decision_ |
decision_, measured_, expected_, incremental_, variance_, verdict, lesson_, calibration_ … (+7) |
✓ | ✓ | ✓ | RLS org+brand |
decisions |
decision_, evaluation_, execution_, executed_, evaluation_, campaign_, lever, context_ … (+12) |
✓ | ✓ | ✓ | RLS org+brand |
experiment_ |
action_, subject_, subject_, arm, holdout_, observed_, confidence_, measured_ |
✓ | — | ✓ | RLS org |
experiments |
decision_, type, design_, metric_, window_, window_, treatment_, control_ … (+27) |
✓ | ✓ | ✓ | RLS org+brand |
mso_ |
slug, version, status, title, purpose, region, trigger, when_ … (+9) |
✓ | ✓ | ✓ | RLS org+brand |
offtake_ |
channel, variant_, lever, corr_, lead_, discount_, confidence_, n_ … (+3) |
✓ | ✓ | ✓ | RLS org+brand |
playbook_ |
playbook_, playbook_, segment_, matched_, proposed_, approved_, rejected_, abstained_ … (+15) |
✓ | ✓ | ✓ | RLS org+brand |
policy_ |
domain, lever, mean_, var_, n_, method |
✓ | ✓ | ✓ | RLS org+brand |
policy_ |
policy_, version, status, parent_, config, label, evaluation_, gate_ … (+4) |
✓ | ✓ | ✓ | RLS org+brand |
signal_ |
domain, plane, signal_, measure_, type, severity, impact_, rank_ … (+16) |
✓ | ✓ | ✓ | RLS org+brand |
signal_ |
domain, signal_, fired_, dismissed_, acted_, last_, last_, weight_ … (+1) |
✓ | ✓ | ✓ | RLS org+brand |
signal_ |
signal_, signal_, grain, period_, entity_, value_, computed_ |
✓ | ✓ | ✓ | RLS org+brand |
signals |
name, grain, tier, unit, label, description, sql_, version … (+1) |
✓ | ✓ | ✓ | RLS org+brand |
social_ |
platform, source, metric_, value, day |
✓ | ✓ | ✓ | RLS org+brand |
Decision Memory (MSO)
Vòng học off-take ghi lại TOÀN BỘ chu trình Signal → Recommendation → Decision → Outcome → Lesson để chu kỳ sau sắc hơn (ADR 0004, CLAUDE.md §60). Quan hệ giữa các bảng:
social_signal_daily ──(fit hàng tuần: offtake-loop.ts)──▶ offtake_models
buzz 3rd-party, Marketing Memory: lever thắng,
1 row / (brand, metric_type, ICT day) corr/confidence (basis points), mode
offtake_models ──(proposals: so SỐ với ngưỡng)──▶ decisions ──(approve)──▶ action_commands
│ natural key (org, brand, lệnh hành động,
│ decision_date, campaign_label) idempotency_key
│ ▲
│ experiment_assignments
│ (treatment/holdout theo
│ action_command_id)
(measure: orders 1st-party)
▼
decision_outcomes ←── 1–1 với decisions
verdict + lesson (unique decision_id)
social_signal_daily— tín hiệu đầu vào: buzz SocialHeat unpivot wide→long, 1 row / (brand, platformsocial-agg,metric_type, ngày ICT). Giá trị thô ghi verbatim (§44); winsorize chỉ tại thời điểm fit. Dữ liệu 3rd-party — không bao giờ nuôi KPI 1st-party (§60d).offtake_models— Marketing Memory: model đã học, 1 row / (org, brand,channel,variant_scope), upsert theo natural key.leverthắng +corr_rank_bp/confidence_bp(basis points ×10000, không float — §2),lead_days(buzz dẫn GMV ~1 tuần),per_lever(map corr đầy đủ cho heatmap),modegate trung thực:act/learning(<20 tuần) /no_reliable_signal(|corr| < 0.30 → render—, không bịa lift). Fit chạy ở worker (apps/worker/src/processors/offtake.ts), toán học thuần trongpackages/metrics/src/offtake.ts(test với oracle đóng băngsim/decision_log.json).decisions— Decision Memory: 1 row / quyết định, natural key (org, brand,decision_date,campaign_label).context_snapshotđóng băng NHỮNG GÌ vòng học biết lúc đề xuất (corr, confidence, số tuần, playbook selection trace);optionslà bảng trade-off;chosen+rationale(AI-draft, PCN-gated) là lựa chọn. Hợp đồng đo lường nằm ngay trên row:expected_outcome{metric_slug, target, horizon} +validation_metric_slug. Lifecyclestatus: proposed → approved → activated → measured, cùngabstained/learning(hệ tự kiềm) vàrejected(owner bỏ qua). Duyệt là hành động RBAC-gated: chỉ owner/org admin (requireOwnerOrOrgAdmintrongofftakerouter), stampapproved_by/approved_at+ bản ghi append-onlyaudit_logs(mso.decision.approve). Ngày chạy thật tách khỏi ngày duyệt:execution_start_dateneo cửa sổ đo,evaluation_date= ngày hẹn đối chiếu (ICT, §41).action_commands— lệnh hành động cụ thể (kind:launch_flash_sale,reprice_sku, …) vớirequires_approval/approved_byvàidempotency_key.decisions.linked_action_ids(uuid[], không FK cứng) trỏ tới các lệnh sinh ra khi duyệt.experiment_assignmentschia subject vào arm treatment/holdout theoaction_command_id— nguồn củaincremental_value.decision_outcomes— phán quyết của Measure Spine, 1–1 vớidecisions(uniquedecision_id, re-review update tại chỗ). Đo bằng ĐÚNG metric đã cam kết trongvalidation_metric_slug(gmv_vnd→ SUM,orders→ COUNT,aov→ SUM/COUNT) trênorders1st-party trong cửa sổ [execution_start_date,evaluation_date] ICT —measureActualForMetricđọc số,measureActivatedDecisions(offtake-loop.ts) quét các decision đang chạy.variance_bpcó MỘT định nghĩa duy nhất:computeOutcomeVerdict(packages/metrics/src/offtake.ts) — mọi writer gọi nó, không re-derive.verdictmáy đề xuất (hit/partial/miss/abstain/learning) chỉ thành CHÍNH THỨC khi owner xác nhận (confirmed_verdict/confirmed_by/confirmed_at); bài học cũng hai tầng —lesson_textlà draft máy,confirmed_lessonmới là tri thức được nạp vào hệ.calibration_bucketnuôi card track-record ("hệ nói X% → đúng ~Y%").mso_playbooks— thư viện playbook ngành EDITABLE (org-scoped, seed từpackages/metrics/src/mso-playbooks.ts).slugkhớp id trong metrics đểcontext_snapshot.selection.playbookIdcủa decision join ngược về record — selection là code so SỐ với ngưỡng;when_to_usechỉ là biên nhận text, không tham gia tính toán.
Mọi con số của vòng học reconcile trong scripts/audit/data-reconciliation.ts (#14a/b/c,
verify:data) với expected neo vào oracle đóng băng — không re-derive trong code (§53/§55).
Market Intelligence — estimate plane 3rd-party#
Ước lượng thị trường từ nguồn 3rd-party (white-label "MK Commerce"). KHÔNG BAO GIỜ join vào orders/NMV (§32/§35) và nằm ngoài verify:data theo chủ đích (§57) — guard bằng e2e/unit.
| Bảng | Cột chính | org_ |
brand_ |
is_ |
RLS |
|---|---|---|---|---|---|
market_ |
snapshot_, name, level, cate_, revenue_, growth_, shop_, avg_ … (+9) |
✓ | ✓ | ✓ | RLS org+brand |
market_ |
platform, shop_, seller_, main_, source, status, score_, reasons … (+2) |
✓ | ✓ | ✓ | RLS org+brand |
market_ |
snapshot_, kind, external_, rank, external_, creator_, title, revenue_ … (+15) |
✓ | ✓ | ✓ | RLS org+brand |
market_ |
snapshot_, kind, session_, rank, external_, product_, revenue_, units_ … (+9) |
✓ | ✓ | ✓ | RLS org+brand |
market_ |
snapshot_, kind, external_, annual_, creator_, title, list_, monthly_ … (+20) |
✓ | ✓ | ✓ | RLS org+brand |
market_ |
snapshot_, external_, external_, creator_, started_, finished_, title, duration_ … (+8) |
✓ | ✓ | ✓ | RLS org+brand |
market_ |
snapshot_, external_, external_, external_, product_, revenue_, units_, avg_ … (+1) |
✓ | ✓ | ✓ | RLS org+brand |
market_ |
platform, handle, display_, creator_, override_, override_, override_, demographics … (+2) |
✓ | ✓ | ✓ | RLS org+brand |
market_ |
snapshot_, external_, external_, shop_, seller_, revenue_, units_, live_ … (+3) |
✓ | ✓ | ✓ | RLS org+brand |
market_ |
snapshot_, external_, handle, display_, vendor_, capture_, revenue_, live_ … (+11) |
✓ | ✓ | ✓ | RLS org+brand |
market_ |
snapshot_, external_, external_, creator_, posted_, description, duration_, views … (+13) |
✓ | ✓ | ✓ | RLS org+brand |
market_ |
snapshot_, display_, handle, followers, revenue_, units_, avg_, engagement_ … (+22) |
✓ | ✓ | ✓ | RLS org+brand |
market_ |
snapshot_, title, creator_, started_, finished_, record_, duration_, revenue_ … (+7) |
✓ | ✓ | ✓ | RLS org+brand |
market_ |
ingest_, source, platform, file_, target_, manifest_, manifest_, spec_ … (+6) |
✓ | ✓ | ✓ | RLS org+brand |
market_ |
platform, external_, kind, value, rule, confidence_, source, dictionary_ … (+3) |
✓ | ✓ | ✓ | RLS org+brand |
market_ |
snapshot_, name, image_, category_, price_, price_, shipping_, listed_ … (+20) |
✓ | ✓ | ✓ | RLS org+brand |
market_ |
comparison_, demo_, insight_, insight_, insight_, insight_, insight_, insight_ … (+7) |
✓ | — | ✓ | RLS org |
market_ |
snapshot_, external_, external_, handle, display_, vendor_, rank_, is_ … (+6) |
✓ | ✓ | ✓ | RLS org+brand |
market_ |
snapshot_, external_, external_, creator_, rank_, started_, finished_, title … (+5) |
✓ | ✓ | ✓ | RLS org+brand |
market_ |
snapshot_, external_, external_, product_, rank_, revenue_, units_, alloc_ … (+2) |
✓ | ✓ | ✓ | RLS org+brand |
market_ |
snapshot_, external_, shop_, seller_, crawl_, rank_, rank_, revenue_ … (+29) |
✓ | ✓ | ✓ | RLS org+brand |
market_ |
snapshot_, external_, external_, external_, creator_, rank_, posted_, description … (+7) |
✓ | ✓ | ✓ | RLS org+brand |
market_ |
snapshot_, name, seller_, revenue_, units_, avg_, live_, video_ … (+9) |
✓ | ✓ | ✓ | RLS org+brand |
market_ |
source, platform, dataset, transport, scope_, scope_, scope_, scope_ … (+11) |
✓ | ✓ | ✓ | RLS org+brand |
market_ |
snapshot_, title, duration_, creator_, posted_, revenue_, units_, product_ … (+9) |
✓ | ✓ | ✓ | RLS org+brand |
market_ |
platform, handle, display_, source, status, score_, note, added_ |
✓ | ✓ | ✓ | RLS org+brand |
Social Intelligence — SocialHeat estimate plane#
Report metrics social (demand topics / SOV / trajectory / needs) — cùng kỷ luật 3rd-party như Market Intelligence: không trộn vào KPI 1st-party. Bao gồm cả nhánh SocialHeat social-listening (đa đối thủ, org-scoped) lẫn SocialTrend/SocialHeat market-intel sheet-fed (ADR 0014 D4).
| Bảng | Cột chính | org_ |
brand_ |
is_ |
RLS |
|---|---|---|---|---|---|
shared_ |
connector, window, cycle_, vendor_, origin, rank, name, passion_ … (+7) |
— | — | — | global (không có org_) |
shared_ |
connector, vendor_, origin, name, passion_, status, is_, detected_ … (+17) |
— | — | — | global (không có org_) |
shared_ |
connector, vendor_, title_, title, decision, reason, decided_, decided_ |
— | — | — | global (không có org_) |
social_ |
snapshot_, competitor_, is_, mentions, sov_, sent_, sent_, sent_ |
✓ | ✓ | ✓ | RLS org+brand |
social_ |
source, platform, category_, range_, range_, is_, captured_ |
✓ | ✓ | ✓ | RLS org+brand |
social_ |
snapshot_, topic, month, mentions, evidence_, breadth_, organic_ |
✓ | ✓ | ✓ | RLS org+brand |
social_ |
snapshot_, kind, topic, mentions, growth_, sent_, sent_, sent_ … (+1) |
✓ | ✓ | ✓ | RLS org+brand |
social_ |
source, tracked_, day, discussions, posts, comments, shares |
✓ | — | ✓ | RLS org |
social_ |
source, tracked_, platform, day, discussions |
✓ | — | ✓ | RLS org |
social_ |
source, period_, kind, rank, label, url, source_, discussions … (+1) |
✓ | — | ✓ | RLS org |
social_ |
source, mention_, created_, last_, mention_, platform_, platform, title … (+14) |
✓ | — | ✓ | RLS org |
social_ |
source, topic_, post_, likes, shares, comments, engagement_, engagement … (+12) |
✓ | — | ✓ | RLS org |
social_ |
source, snapshot_, rank, topic_, topic_, buzz_, comments, likes … (+6) |
✓ | — | ✓ | RLS org |
Content Intelligence — mặt phẳng nghiên cứu audience (§81)#
Audience CI (Content Intelligence, ADR 0022–0025): fact content_mentions + dimension catalog (taxonomy là DATA, không phải code, §81) + rollup ngày. Brand-partitioned RLS — mỗi row là nghiên cứu bảo mật của một khách hàng trả phí.
| Bảng | Cột chính | org_ |
brand_ |
is_ |
RLS |
|---|---|---|---|---|---|
agg_ |
dataset_, cross_, occurred_, occurred_, dim_, value_, dim_, value_ … (+8) |
✓ | ✓ | ✓ | RLS org+brand |
agg_ |
dataset_, occurred_, occurred_, dim_, value_, platform_, eligible, mention_ … (+6) |
✓ | ✓ | ✓ | RLS org+brand |
content_ |
dataset_, dim_, dim_, status |
✓ | ✓ | ✓ | RLS org+brand |
content_ |
dataset_, label_, taxonomy_, regulated_, deck_, status |
✓ | ✓ | ✓ | RLS org+brand |
content_ |
dataset_, dimension_, value_, label_, label_, definition_, sort_, color_ … (+4) |
✓ | ✓ | ✓ | RLS org+brand |
content_ |
dataset_, dim_, kind, role, label_, label_, display_, min_ … (+4) |
✓ | ✓ | ✓ | RLS org+brand |
content_ |
dataset_, file_, transport, template_, template_, declared_, source_, status … (+2) |
✓ | ✓ | ✓ | RLS org+brand |
content_ |
dataset_, ingest_, line_, provenance_, count_, text_, attested_, attested_ … (+1) |
✓ | ✓ | ✓ | RLS org+brand |
content_ |
dataset_, block_, status, authored_, body_, body_, body_, body_ … (+10) |
✓ | ✓ | ✓ | RLS org+brand |
content_ |
dataset_, mention_, dim_, value_, dimension_, value_, ordinal, confidence_ … (+6) |
✓ | ✓ | ✓ | RLS org+brand |
content_ |
dataset_, ingest_, mention_, source_, content, context_, source_, source_ … (+18) |
✓ | ✓ | ✓ | RLS org+brand |
content_ |
mention_, field, span_, span_, kind, detector, confidence_ |
✓ | ✓ | ✓ | RLS org+brand |
content_ |
dataset_, source_, platform_ |
✓ | ✓ | ✓ | RLS org+brand |
content_ |
dataset_, dimension_, value_, alias_, alias_, status, confirmed_, confirmed_ |
✓ | ✓ | ✓ | RLS org+brand |
Admin — tenancy, auth, AI runtime, vận hành#
Bề mặt platform: tenancy/auth/RBAC, cấu hình AI (ai_connections là runtime chính — §61), chat assistant, dashboard config, audit & vận hành.
| Bảng | Cột chính | org_ |
brand_ |
is_ |
RLS |
|---|---|---|---|---|---|
agent_ |
user_, fact_, fact_, source_, source_ |
✓ | — | ✓ | RLS org |
agent_ |
user_, role, topic, content, keywords, embedding_, source_, source_ |
✓ | — | ✓ | RLS org |
ai_ |
provider, model, api_, api_, api_, key_, base_ |
✓ | — | ✓ | RLS org |
ai_ |
role, provider, model, api_, api_, api_, key_, is_ |
✓ | — | ✓ | RLS org |
ai_ |
provider, label, models, api_, api_, api_, key_, base_ … (+2) |
✓ | — | ✓ | RLS org |
ai_ |
cache_, locale, text, provider, model, expires_ |
✓ | — | ✓ | RLS org |
ai_ |
slot, industry, body, version, body_, updated_ |
✓ | — | ✓ | RLS org |
ai_ |
provider, model, purpose, input_, output_, cached_, cache_, cache_ … (+8) |
✓ | — | ✓ | RLS org |
alert_ |
rule_, severity, message, payload, fired_, acknowledged_, acknowledged_, entity_ … (+6) |
✓ | ✓ | ✓ | RLS org+brand |
alert_ |
rule_, user_, is_, snoozed_, channels |
✓ | — | ✓ | RLS org |
alert_ |
name, metric_, condition, channels, is_ |
✓ | — | ✓ | RLS org |
alert_ |
workflow_, version, graph, graph_, kernel_, published_, published_, note |
✓ | ✓ | ✓ | RLS org+brand |
alert_ |
name, description, domain, plane, measure_, status, draft_, active_ … (+3) |
✓ | ✓ | ✓ | RLS org+brand |
api_ |
label, role, token_, token_, ttl_, expires_, last_, allowed_ … (+2) |
✓ | — | ✓ | RLS org |
audience_ |
name, kind, encrypted_, credentials_, credentials_, credentials_, config, is_ |
✓ | — | ✓ | RLS org |
audience_ |
audience_, destination_, triggered_, members_, suppressed_, consent_, frequency_, hash_ … (+5) |
✓ | — | ✓ | RLS org |
audit_ |
export_, destination, status, row_, checksum, bytes, exported_ |
✓ | — | ✓ | RLS org |
audit_ |
actor_, action, resource_, resource_, diff_, diff_, ip, user_ … (+1) |
✓ | — | — | RLS org |
auth_ |
sid, user_, last_, revoked_, amr, auth_, origin_, public_ … (+2) |
— | — | ✓ | RLS auth/process |
auth_ |
actor_, actor_, target_, reason, expires_, ended_ |
✓ | — | ✓ | RLS auth/process |
brands |
slug, name, default_, timezone, default_, logo_, mask_, theme_ … (+4) |
✓ | — | ✓ | RLS org |
briefings |
user_, persona, briefing_, cadence, title, summary, bullets, citations … (+3) |
✓ | ✓ | ✓ | RLS org+brand |
chat_ |
bot_, welcome_, persona_, industry, starter_, market_, ai_, updated_ |
✓ | ✓ | ✓ | RLS org |
chat_ |
user_, deck_, title, provider, model, archived_ |
✓ | ✓ | ✓ | RLS org+brand |
chat_ |
conversation_, role, parts, text_, prompt_, completion_, finish_, rating … (+3) |
✓ | ✓ | ✓ | RLS org+brand |
chat_ |
conversation_, user_, tool_, input, output, error_, duration_ |
✓ | ✓ | — | RLS org+brand |
collector_ |
batch_, kind, seq, sha256, bytes, object_, received_ |
— | — | — | global (không có org_) |
collector_ |
batch_, decision, decided_, reason, consumed_ |
— | — | — | global (không có org_) |
collector_ |
batch_, kind, row_, manifest_, coverage_, universe_, captured_, source_ … (+4) |
— | — | — | global (không có org_) |
collector_ |
collector_, feed_, idempotency_, contract_, window_, window_, window_, state … (+9) |
— | — | — | global (không có org_) |
collector_ |
at, collector_, key_, batch_, event, code, detail |
— | — | — | global (không có org_) |
collector_ |
collector_, feed_ |
— | — | — | global (không có org_) |
collector_ |
key, source, platform, scope_, scope_, grain, kinds, feed_ … (+1) |
— | — | — | global (không có org_) |
collector_ |
key_, collector_, public_, not_, revoked_, last_ |
— | — | — | global (không có org_) |
collectors |
name, enabled, allowed_ |
— | — | — | global (không có org_) |
dashboard_ |
widget_, cache_, payload, computed_, expires_ |
✓ | — | ✓ | RLS org |
dashboard_ |
subscription_, period_, status, reason, recipient_, row_, last_, started_ … (+1) |
✓ | — | ✓ | RLS org |
dashboard_ |
dashboard_, name, cadence, hour_, minute_, weekday, day_, format … (+9) |
✓ | ✓ | ✓ | RLS org+brand |
dashboard_ |
dashboard_, parent_, label, label_, subtitle, subtitle_, template_, filter_ … (+1) |
✓ | — | ✓ | RLS org |
dashboard_ |
user_, dashboard_, name, state, is_ |
✓ | — | ✓ | RLS org |
dashboard_ |
dashboard_, version, content, summary, restored_, tag, note, created_ |
✓ | ✓ | ✓ | RLS org+brand |
dashboard_ |
dashboard_, widget_, title, title_, config, template_, origin, template_ … (+4) |
✓ | — | ✓ | RLS org |
dashboards |
name, name_, slug, is_, template_, template_, plugin_, nav_ … (+11) |
✓ | ✓ | ✓ | RLS org+brand |
data_ |
run_, day, file_, db_, file_, db_, file_, db_ … (+3) |
✓ | — | ✓ | RLS org |
data_ |
run_, platform_, day, diff_, mismatched_, file_, db_, file_ … (+3) |
✓ | — | ✓ | RLS org |
data_ |
requested_, dataset_, platform, range_, range_, filename, extension, byte_ … (+20) |
✓ | ✓ | ✓ | RLS org+brand |
dsar_ |
subject_, identifier, identifier_, action, contact_, status, response_, requested_ … (+1) |
✓ | — | ✓ | RLS org |
frequency_ |
shopper_, channel, pushed_, audience_ |
✓ | — | ✓ | RLS org |
idp_ |
kid, kind, use, alg, public_, private_, status, not_ |
— | — | ✓ | global (không có org_) |
job_ |
queue_, job_, job_, payload, options, attempts, available_, lease_ … (+4) |
✓ | — | ✓ | RLS org |
magic_ |
token, email, expires_, used_, verifies_ |
✓ | — | — | RLS auth/process |
notification_ |
channel, label, config_, config_, config_, key_, public_, is_ … (+2) |
— | — | ✓ | global (không có org_) |
notification_ |
user_, type, dedupe_, channel, status, provider_, failure_, reason … (+4) |
✓ | — | — | RLS org |
notification_ |
user_, channel, status, opened_, flush_, closed_, item_ |
✓ | — | ✓ | RLS org |
notification_ |
user_, type, channels, is_ |
✓ | ✓ | ✓ | RLS org+brand |
notification_ |
rule_, is_, channels, recipient_, email_, email_, updated_ |
— | — | — | global (không có org_) |
notifications |
user_, type, severity, title, body, href, dedupe_, source_ … (+2) |
✓ | ✓ | ✓ | RLS org+brand |
org_ |
enabled, host, port, use_, use_, allow_, bind_, bind_ … (+7) |
✓ | — | ✓ | RLS org |
org_ |
provider_, label, provider_, enabled, issuer, client_, client_, client_ … (+9) |
✓ | — | ✓ | RLS org |
org_ |
name, provider, config, credential_, credential_, credential_, credential_, status … (+3) |
✓ | — | ✓ | RLS org |
org_ |
enabled, profile_, cadence, hour_, weekday_, destination_, retention_, last_ … (+2) |
✓ | — | ✓ | RLS org |
org_ |
blueprint_, version, applied_, applied_ |
✓ | — | ✓ | RLS org |
org_ |
kind, source_, categories, scope, status, progress, artifact_, artifact_ … (+8) |
✓ | — | ✓ | RLS org |
org_ |
dataset_, field_, role, data_, unit, scale, aggregation, temporality … (+15) |
✓ | — | ✓ | RLS org |
org_ |
dataset_, page_, tab_, widget_, period_, status, authored_, body_ … (+10) |
✓ | ✓ | ✓ | RLS org+brand |
org_ |
link_, from_, to_, join_, label_, label_, schema_, status |
✓ | — | ✓ | RLS org |
org_ |
pack_, label_, label_, dataset_, version, status, content |
✓ | — | ✓ | RLS org |
org_ |
dataset_, period_, period_, dims, measures, schema_ |
✓ | ✓ | ✓ | RLS org+brand |
org_ |
dataset_, source_, line_, provenance_, count_, text_, attested_, attested_ … (+1) |
✓ | ✓ | ✓ | RLS org+brand |
org_ |
dataset_, recon_, measure_, period_, expected_, expected_, oracle_, verdict … (+2) |
✓ | ✓ | ✓ | RLS org+brand |
org_ |
dataset_, source_, transport, template_, template_, status, last_ |
✓ | ✓ | ✓ | RLS org+brand |
org_ |
dataset_, field_, value_, alias_, alias_, status, confirmed_, confirmed_ |
✓ | — | ✓ | RLS org |
org_ |
dataset_, label_, label_, grain_, time_, vertical, schema_, cache_ … (+1) |
✓ | ✓ | ✓ | RLS org+brand |
org_ |
domain_, layer_, sequence, source_, version, state, activated_, activated_ |
✓ | — | ✓ | RLS org |
org_ |
domain, status, verification_, verified_, last_, last_ |
✓ | — | ✓ | RLS org |
org_ |
logo_, logo_, favicon_, accent_, headline, tagline, support_, legal_ … (+5) |
✓ | — | ✓ | RLS org |
org_ |
version, config, restored_, published_, published_ |
✓ | — | ✓ | RLS org |
org_ |
masked_, mask_, mask_, updated_ |
✓ | — | ✓ | RLS org |
org_ |
kind, term, term_, match_, replacement, status, origin, suggestion_ … (+1) |
✓ | ✓ | ✓ | RLS org+brand |
org_ |
user_, role, viewable_, invited_, accepted_, invited_ |
✓ | — | — | RLS identity metadata |
org_ |
menu_, menu_, menu_, hidden_, pinned_, nav_, groups |
✓ | ✓ | ✓ | RLS org |
org_ |
channel, is_, updated_ |
✓ | — | ✓ | RLS org |
org_ |
name, description, cron_, steps, graph, trigger_, trigger_, holdout_ … (+4) |
✓ | — | ✓ | RLS org |
org_ |
plugin_, plugin_, enabled, config, operator_, is_, plan, limits … (+2) |
✓ | — | ✓ | RLS org |
org_ |
role, name_, name_, description_, description_, capabilities, menu_, is_ |
✓ | — | ✓ | RLS org |
org_ |
user_, day, last_ |
✓ | — | ✓ | RLS org |
organizations |
slug, name, logo_, sidebar_, sidebar_, sidebar_, mask_, mask_ … (+28) |
— | — | ✓ | RLS identity metadata |
platform_ |
provider, label, models, api_, api_, api_, key_, base_ … (+2) |
— | — | ✓ | global (không có org_) |
platform_ |
connector, credential_, credential_, credential_, key_, fields_, updated_ |
— | — | — | global (không có org_) |
platform_ |
connector, trigger, status, started_, finished_, calls, rate_, items_ … (+11) |
— | — | — | global (không có org_) |
platform_ |
connector, settings, fingerprint, revision, announced_, last_, last_ |
— | — | — | global (không có org_) |
platform_ |
direction, event_, event_, subscription_, payload, status, attempts, next_ … (+3) |
✓ | — | ✓ | RLS org |
platform_ |
app_, url, secret_, secret_, secret_, secret_, event_, is_ |
✓ | — | ✓ | RLS org |
pred_ |
slug, version, kind, artifact_, metrics, is_, notes, trained_ |
— | — | — | global (không có org_) |
price_ |
product_, min_, max_, delta_, threshold_, platforms, status, note … (+2) |
✓ | — | ✓ | RLS org |
push_ |
user_, endpoint_, endpoint_, endpoint_, endpoint_, key_, p256dh, auth … (+3) |
— | — | ✓ | global (không có org_) |
resource_ |
resource_, resource_, name, slug, viewer_, token_, password_, expires_ … (+5) |
✓ | ✓ | ✓ | RLS org+brand |
site_ |
site_, site_, page_, landing_, landing_, logo_, logo_, favicon_ … (+6) |
— | — | — | global (không có org_) |
site_ |
slug, name_, name_, description, payload, updated_ |
✓ | — | ✓ | app-layer (chủ đích) |
suppression_ |
shopper_, reason, note, suppressed_ |
✓ | — | ✓ | RLS org |
user_ |
user_, password_, passphrase_, two_, two_, two_, two_, two_ … (+1) |
— | — | — | RLS auth/process |
user_ |
user_, channel, external_, external_, external_, external_, key_, link_ … (+3) |
— | — | ✓ | global (không có org_) |
user_ |
user_, credential_, public_, counter, transports, device_, aaguid, backed_ … (+1) |
— | — | — | RLS auth/process |
user_ |
user_, dashboard_, payload |
✓ | — | ✓ | RLS org |
user_ |
user_, provider, subject, email, last_ |
— | — | — | RLS auth/process |
users |
email, name, two_, notification_, is_, default_, last_, email_ … (+1) |
— | — | — | RLS identity metadata |
webauthn_ |
user_, client_, mode, challenge, expires_ |
— | — | — | RLS auth/process |
Bảng theo spec mso-13 §9.4 — trạng thái so với roadmap#
Bốn bảng trong docs/MSO-UCIP-Roadmap/mso-13-decision-engine-spec.html §9.4 phục vụ roadmap
L1–L4. Ba trong bốn ĐÃ SHIP (xem nhóm MSO ở trên); chỉ playbook_rules còn chưa tồn tại
trong schema (script này sẽ tự nhặt bảng khi nó xuất hiện trong packages/schema/src/tables):
| Bảng | Vai trò | Trạng thái |
|---|---|---|
signals / signal_ |
registry tín hiệu + feature store, versioned, test được (L2) | đã ship — xem nhóm MSO |
playbook_ (nâng cấp mso_) |
rule đã mã hoá — predicate máy-kiểm được thay hardcode TS (L1) | planned |
experiments |
thí nghiệm incrementality (L3) | đã ship — xem nhóm MSO |
policy_ |
posterior bandit/lift per lever (L4) | đã ship — xem nhóm MSO |
Trạng thái hiện tại so với spec:
experiment_assignmentslà tiền thân holdout đơn giản đã có TRƯỚCexperiments— gán arm treatment/holdout theoaction_command_id;experiments(bảng L3 mới, cộtdecision_id) đo lift theo lever, ghi bởipackages/metrics/src/experiments.ts.mso_playbooksgiữ phần hiển thị + guardrail template; phầnwhenpredicate máy-kiểm được (L1) sẽ nằm ởplaybook_rulesvớiversion/status(active/archived, immutable khi active — cùng kỷ luật §16 của mapping template) — đây là mảnh DUY NHẤT của §9.4 còn planned.offtake_modelshiện upsert đè theo natural key, chưa cómodel_version/valid_from(đánh giá mso-14): decision chỉ trace về model quacontext_snapshotjsonb. Khi thêm version hoá, pattern có sẵn để copy làpred_model_registry.model_version.
Quy ước chung#
- Migration: bảng mới = file trong
packages/schema/src/tables/+ export trongsrc/tables.ts+pnpm --filter @yng/schema db:generate+ RLS policy cùng change. is_sample: mặc địnhfalse, có mặt trên mọi bảng dữ liệu (invariant #3) — các bảng auth/hạ tầng (users,magic_link_tokens, …) và một số bảng ledger là ngoại lệ có chủ đích.- Tiền tệ: VND integer (
bigint), khôngnumeric/float(§2); tỷ lệ/corr lưu signed basis points ×10000 (§60). - Ngày: mọi day-edge/label theo ICT (
Asia/Ho_Chi_Minh) —@yng/ui/ict-datephía app,AT TIME ZONE 'Asia/Ho_Chi_Minh'phía SQL (§34/§41). - Credential: envelope-encrypted (AES-256-GCM,
ciphertext + iv + tag + key_version), không bao giờ log/return (invariant #4).