Skip to content

feat(migrate): 0.7 migrate gate + canonical engine deprecation (ADR-037)#386

Open
hardbyte wants to merge 2 commits into
mainfrom
brian/370-canonical-deprecation-migrate-gate
Open

feat(migrate): 0.7 migrate gate + canonical engine deprecation (ADR-037)#386
hardbyte wants to merge 2 commits into
mainfrom
brian/370-canonical-deprecation-migrate-gate

Conversation

@hardbyte

@hardbyte hardbyte commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Closes #370. Implements roadmap decision D2 (docs/0.7-roadmap.md, PR #384).

Design

The canonical engine is deprecated in 0.7 and removed in 0.8, so awa migrate must never land 0.7-era migrations on a cluster that can still route work to it. The gate sits in awa_model::migrations::run (covering the CLI, library callers, TestClient, and Python), evaluates before anything is applied, and admits exactly two shapes:

  • Finalized: storage_transition_state.state = 'active'.
  • Fresh / effectively fresh: no awa schema at all, or canonical + unprepared with zero jobs and no runtime seen in 90s — deliberately the same conditions as awa.storage_auto_finalize_if_fresh, so the migrate gate and the worker-startup auto-finalize door admit the same clusters.

Everything else gets AwaError::StorageNotFinalized, whose message names the exact 0.6 finalize steps and both upgrade guides. Refusal is a no-op: nothing half-applied. --sql / --extract-to (print-only) are unaffected. Runtimes whose effective storage resolves to canonical now log a startup deprecation warning (in log_transition_startup_status).

An alternative — gating only v40+ migrations so a 0.7 binary could still bring a 0.5 schema to v39 — is recorded and rejected in the ADR (splits the operator experience; the applied prefix just duplicates the supported 0.6 binary).

TLA+

correctness/storage/AwaStorageTransition.tla gains a Migrate07 action gated by Migrate07GateOpen, a ghost bit recording whether canonical work / canonical-capable runtimes existed at fire time, and the invariant Migrate07OnlyOnQuiescedCanonical:

  • AwaStorageTransition.cfg (gate on): passes, 444 distinct states.
  • AwaStorageTransitionMigrate07Ungated.cfg (gate off): expected counterexample — TLC trips the invariant, witnessing why the gate is load-bearing.
  • AwaStorageTransitionCurrentGate.cfg: still trips MixedHasQueueExecutor (its historical purpose).

The transition model family is now also run in nightly CI (it previously only existed in the docs).

Docs

  • docs/adr/037-canonical-engine-deprecation.md — full ADR (supersedes the placeholder in docs: add 0.7 planning brief (0.6 recap + open-issue inventory) #384; trivial conflict there in docs/adr/README.md if this merges second).
  • docs/upgrade-0.6-to-0.7.md — the short guide: the storage step is 'be finalized'.
  • Forward pointer at the top of docs/upgrade-0.5-to-0.6.md; CHANGELOG breaking-change entry.

Tests

  • Six new gate tests: allows effectively-fresh + active (with live queue-storage runtimes); refuses canonical-with-jobs, prepared, mixed_transition, and recently-live-runtime (and re-allows once the heartbeat is >90s stale).
  • test_step_through_upgrade_preserves_data reworked: asserts the refusal on canonical-with-data, keeps data-survival coverage via the raw-SQL path (what a 0.6 binary applies), and asserts run() stays a no-op success with no pending migrations.

Verification

  • cargo fmt clean, clippy --all-targets --all-features -D warnings clean.
  • migration_test full suite: 49/49 pass; storage_finalize_cli_test 4/4; sql_only_storage_upgrade_test 2/2.
  • TLC (docker): all three configs behave as stated above.

…ate canonical engine (#370)

Implements ADR-037 / roadmap decision D2:

- `awa_model::migrations::run` refuses to apply pending migrations unless
  the storage transition is finalized (state = active) or the install is
  fresh — mirroring the exact conditions awa.storage_auto_finalize_if_fresh
  accepts at worker startup (canonical, unprepared, no jobs, no runtime
  seen in 90s). Nothing is applied on refusal; the new
  AwaError::StorageNotFinalized error names the finalize steps.
- Worker runtimes that resolve to the canonical engine log a startup
  deprecation warning (removal in 0.8).
- TLA+: AwaStorageTransition gains the Migrate07 action, the
  Migrate07OnlyOnQuiescedCanonical invariant, and an expected-counterexample
  config (Migrate07Ungated) witnessing the gate; transition model family
  added to nightly CI.
- Docs: full ADR-037, docs/upgrade-0.6-to-0.7.md, pointer from the 0.5→0.6
  guide, CHANGELOG breaking-change entry.
- Tests: six migrate-gate integration tests; step-through data-survival
  test reworked to assert the refusal and keep survival coverage via the
  0.6-equivalent raw-SQL path.
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@hardbyte, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 55 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bbe46b12-5829-4b47-84e2-646ed4177eea

📥 Commits

Reviewing files that changed from the base of the PR and between 671ca70 and 82aa7f5.

📒 Files selected for processing (20)
  • .github/workflows/nightly-chaos.yml
  • CHANGELOG.md
  • awa-model/src/error.rs
  • awa-model/src/migrations.rs
  • awa-python/python/awa/__init__.py
  • awa-python/python/awa/_awa.pyi
  • awa-python/src/errors.rs
  • awa-python/src/lib.rs
  • awa-worker/src/client.rs
  • awa/tests/migration_test.rs
  • correctness/README.md
  • correctness/storage/AwaStorageTransition.cfg
  • correctness/storage/AwaStorageTransition.tla
  • correctness/storage/AwaStorageTransitionCurrentGate.cfg
  • correctness/storage/AwaStorageTransitionMigrate07Ungated.cfg
  • correctness/storage/README.md
  • docs/adr/037-canonical-engine-deprecation.md
  • docs/adr/README.md
  • docs/upgrade-0.5-to-0.6.md
  • docs/upgrade-0.6-to-0.7.md

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8aa60335c4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread awa-model/src/error.rs
no recently-live runtimes) are exempt. See docs/upgrade-0.6-to-0.7.md and \
docs/upgrade-0.5-to-0.6.md."
)]
StorageNotFinalized { state: String },

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add Python mapping for the new error variant

Adding StorageNotFinalized makes AwaError gain a new concrete variant, but awa-python/src/errors.rs::map_awa_error still exhaustively matches the old set. Any build of the Python extension now fails with a non-exhaustive match when this gate error is reachable from migrate(), which blocks the Python package/nightly maturin develop path; add a Python error mapping for this variant.

Useful? React with 👍 / 👎.

@hardbyte hardbyte added the full-ci Run the full CI matrix (Python build+test, E2E) on this PR label Jul 6, 2026
The #370 migrate gate added a new AwaError variant; awa-python's
map_awa_error matches exhaustively, so the extension stopped compiling.
Expose it as awa.StorageNotFinalized (subclass of AwaError) so Python
callers of migrate() get the same operator guidance.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-ci Run the full CI matrix (Python build+test, E2E) on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecate the canonical engine: 0.7 migrate gate requires finalized clusters; remove paths in 0.8

1 participant