-- ailf.official_runs — canonical trend series
--
-- Filters ailf.reports down to the runs that form the canonical
-- core-docs scheduled evaluation series (daily-baseline, weekly-full).
-- Dashboards that must stay stable across ad-hoc / test / external-team
-- activity should point at this view, not at `ailf.reports` directly.
--
-- Predicate (D0037):
--   classification = 'official'  — intent: tracked trend series
--   trigger_type   = 'scheduled' — mechanism: cron, not PR/manual/webhook
--   owner_team     = 'core-docs' — attributable to the docs team
--
-- Historical rows predating D0037 have classification = NULL and are
-- excluded. Backfill is a separate one-shot; see
-- scripts/backfill-run-classification.ts.
--
-- Source: ailf.reports (view over ailf_raw.reports)
-- Target: ailf.official_runs (this view)
--
-- Usage:
--   bq query --use_legacy_sql=false < views/official_runs.sql
--
-- @see docs/decisions/D0037-run-classification-and-ownership-taxonomy.md
-- @see docs/design-docs/run-classification-and-ownership.md

CREATE OR REPLACE VIEW `data-platform-302218.ailf.official_runs` AS
SELECT *
FROM   `data-platform-302218.ailf.reports`
WHERE  classification = 'official'
  AND  trigger_type   = 'scheduled'
  AND  owner_team     = 'core-docs';
