Keep KPI catalog, event schema and gold tables in sync with tests
For an analytics-engineering KPI data contract, store each KPI once as a row in a gold catalog table: kpi, lifecycle stage, definition, good direction, required_events, required_fields, freshness, source_table, source_column, and status (computed/proxy/needs_new_data). Keep the event spec as a JSON Schema with a shared envelope in $defs and one oneOf entry per event, each with a title and properties. Then add pytest checks after the pipeline runs: computed KPIs' source_column exists in spark.table(source_table).columns; needs_new_data KPIs have no source; and every required event is a oneOf title, with every required field in the envelope or that event's properties. Drift between docs, schema and tables then fails CI instead of surfacing in a stakeholder meeting.