# Delivery architecture — why SQL, and why SQL is not enough

A fair engineer question: *"if the model is a SQL view, is SQL really the right delivery?"* Short
answer: **SQL is the modeling / contract layer, not the whole product.** Full delivery is three
layers.

## Why the model lives in SQL (the contract layer)

- The warehouse already holds **tenant-grain truth**, and every other PLG surface (cohorts,
  channels, regional) reads from it. One SQL definition = **one source of truth** across regions.
- It is **auditable, diffable, reproducible** with `data_as_of`. A reviewer can read exactly why a
  tenant scored P0.
- It avoids **re-implementing scoring in three places** (one per region). EMEA proved the pattern:
  ~69k rows, 0 dupes, validated.

So fit/signal/tier/threshold/guardrail *definitions* belong in SQL views (`vw_pql_candidate_facts`,
`vw_pql_action_queues`).

## Why SQL alone is not the product (the other two layers)

| Layer | What it is | Owns |
|-------|-----------|------|
| **1. Modeling — SQL views** | Compute tenant facts + tiers. | the *definition*. ✅ proven |
| **2. Orchestration — the bot** (recommended deployment) | Daily/weekly scan → P0/P1 digest → CRM/HubSpot tasks + Feishu/Slack. | SLA, routing, dedup, connected-guard, "new since last run". |
| **3. Feedback — write-back** | CRM outcome + `track_step` flow back to the warehouse. | making suppression + PQL→SQL measurement actually work. |

Without layer 2 nobody acts on the queue; without layer 3 the queue re-surfaces accounts sales
already touched and we can never measure conversion.

## Recommendation to engineers

**Own the SQL as the contract; deliver the bot + write-back loop around it.** Bot over platform-tab
first — fastest to value, and it's how EMEA already operates.

Two things in APAC are explicitly **not SQL** — they are upstream services to build:
- **Enrichment** (domain / AI-category → the Fit axis).
- **O11Y ingestion** (QPS, first DDL → the strongest workload signals).

These are tracked as ASKs/gaps in the APAC sub-repo, not assumed away.
