recompute no-gaps missing intervals against the live production frontier immediately before promotion
backfill newly required intervals using the existing plan evaluator and deployability context
retain the transactional promotion-time no_gaps check as the final concurrency guard
add a deterministic stale-plan/live-frontier regression test
Root cause
A plan freezes its interval horizon when it is constructed. If the existing production snapshot advances before that plan reaches promotion, the candidate can finish every originally scheduled batch yet still be behind the live production frontier. Promotion then correctly rejects the candidate for missing intervals.
The new catch-up stage refreshes candidate intervals and schedules the additional live-frontier gaps immediately before promotion. If production advances again after that read, the existing transactional guard still fails safely.
Validation
regression test confirmed to fail at the original no-gaps promotion check with the catch-up handler disabled
make fast-test — 2,603 fast tests, 0 failures, 4 skipped; isolated suites also passed
Ruff, Ruff format, migration validation, and git diff --check upstream/main — passed
make style reaches only the local missing generated sqlmesh._version mypy errors; no changed-file type errors
independent compatibility review verdict GO
Residual race behavior
Production can still advance in the small window after catch-up. In that case, the retained promotion guard rejects the plan rather than allowing a gap.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Root cause
A plan freezes its interval horizon when it is constructed. If the existing production snapshot advances before that plan reaches promotion, the candidate can finish every originally scheduled batch yet still be behind the live production frontier. Promotion then correctly rejects the candidate for missing intervals.
The new catch-up stage refreshes candidate intervals and schedules the additional live-frontier gaps immediately before promotion. If production advances again after that read, the existing transactional guard still fails safely.
Validation
Residual race behavior
Production can still advance in the small window after catch-up. In that case, the retained promotion guard rejects the plan rather than allowing a gap.