Prerequisite
This task is blocked on T425729: stable natural keys must be resolved for page and user entities before verification can cover the full table. Until then, the join-based comparison cannot be implemented correctly for those entity types.
Summary
Design and implement a recurring verification step that measures how accurately the daily delta writer (source='events' rows) predicted what the monthly snapshot (source='snapshot') ultimately confirmed as truth.
Approach
wmf.mediawiki_history is the source of truth. After each monthly MWHistorySnapshotMerger run, the table contains both the ground-truth source='snapshot' rows for that month and — preserved via Iceberg time travel — the source='events' rows that the daily writer had accumulated up to that point.
The verification query:
- Time-travel read: open the Iceberg snapshot taken immediately before the monthly merge commit. This gives the source='events' rows for the month as they stood at merge time.
- Current read: read the live table restricted to source='snapshot' for the same month.
- Join on natural key per entity type and compare field by field.
This surfaces:
- Rows present in events but absent in snapshot (delta writer ingested something the monthly rebuild dropped).
- Rows present in snapshot but absent in events (late-arriving or lost events the daily writer missed).
- Field-level deviations for matched rows (e.g. revision_text_bytes, revision_text_bytes_diff, revision_is_identity_reverted — the revert-detection field most likely to diverge because the daily writer uses only a 48-hour window).
Output
A summary report per monthly run:
- Total events rows vs total snapshot rows for the month
- Match rate (rows with identical natural key on both sides)
- Per-column deviation rate for matched rows
- Highlight columns with highest deviation (expected: revert columns, given the 48-hour window approximation)
Implementation
Prototype in a notebook first, then productionize as a dedicated Airflow task appended to the monthly merge DAG (see Airflow DAG task). The verification task runs after MWHistorySnapshotMerger succeeds and reads the pre-merge Iceberg snapshot via time travel.
Open questions
- Iceberg snapshot retention policy: time-travel requires the pre-merge snapshot to still exist when verification runs. Agree with stakeholders on minimum retention before wiring this as a DAG dependency.
- Failure policy: should a high deviation rate fail the DAG or emit a warning only?