Orchestrate all operational coverage guards for one submission run.
Encapsulates the assert_coverage function shared (with minor divergences) across all four ENTSO-E submission scripts, parameterized so callers can select the path they need.
The four guards run in order:
Frontier freshness (assert_frontier_fresh): the index must reach at least today - 1 h (dates.today - pd.Timedelta(hours=1)).
Actual-load lag (assert_actual_lag_within): the last non-NaN Actual Load must be within max_actual_lag_hours of now.
Interior-gap scan (assert_no_interior_gaps): no consecutive gap wider than max_actual_gap_hours h in the recent gap_scan_days-day window.
Frontier completeness (last_complete_hour): only an hour with a full set of intra-hour samples may anchor the context.
After guard 4 an optional value-sanity check is applied:
corruption_mode="preview" (default, used by team4_optuna_submit, team4_spotoptim_submit, and team4_4zones_submit): runs apply_target_corruption_policy as a forward preview only; logs the outcome but does not retract last_full_hour — the authoritative retraction happens inside prepare_data downstream.
corruption_mode="authoritative" (used by chronos, which has no prepare_data downstream): if the QC report fires, retracts last_full_hour to first_flagged_hour - 1 h in-place before computing first_pred and n_steps.
deviation_ref must be a column name present in interim when the deviation rule is active; pass None to skip the deviation check (deviation_mw is set to 0 internally, which disables it).
The fallback gate is applied after guard 4 + QC:
When fallback=True (cache was restored), last_full_hour must be >= dates.yesterday + 23 h (“yesterday 23:00 UTC”); a stale cache raises CoverageError.
True when the download used a snapshot (i.e. the DownloadResult.fallback_gate of the preceding call to download_with_fallback or download_combined_with_fallback is True). Triggers the stricter D-1 23:00 freshness gate.
Deviation-rule magnitude (MW). None (default) keeps the legacy behaviour — MAX_DEVIATION_MW_DEFAULT when a deviation_ref is given, else 0 (rule disabled). An explicit value is honoured only when deviation_ref is set (scripts pass 11_000).