Skip to content

Rehearse compat claim-slot proofs across a released leader's rotations - #908

Merged
hardbyte merged 1 commit into
mainfrom
ccr-37ca53f6-xza211-rehearsal-claim-proof
Dec 2, 2026
Merged

hardbyte merged 1 commit into
mainfrom
ccr-37ca53f6-xza211-rehearsal-claim-proof

Conversation

@hardbyte

@hardbyte hardbyte commented Dec 1, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #906. The base is #906's branch, so the diff shows only the new cell. Retarget this PR to main once #906 merges.

What the cell does

test_compat_rescue_after_released_leader_rotates_claim_ring adds a rehearsal cell that runs a released 0.6.19 runtime and the current runtime on one database, under compat (columns) ring authority, after a migrate-first upgrade.

  1. The current runtime leads. It completes some traffic, then rescues a canary claim from a killed released claimer. That shows its rescue passes ran, and each pass first proves the sealed claim slots closed. The cell checks that the current runtime never rotated the claim ring.
  2. The cell terminates the current runtime's leader-lock session. The process keeps running, so its proof cache survives. A second released 0.6.19 runtime, waiting as a follower, takes leadership.
  3. The released leader rotates the claim ring into a new slot. A released claimer then takes a claim there and is killed. The released leader rotates past the slot. The cell checks from claim_ring_state and the rotation ledger that both rotations were 0.6's, and that nothing rescued the claim yet.
  4. The released leader is killed, and the same current process leads again.
  5. The current runtime must rescue the dead claim within 3 s of leading again (9 s on CI). The cell also checks that this bound ends before any proof the current runtime made could expire. Otherwise a slow run could pass without telling a fresh proof from an expired one.
  6. A fresh released claimer completes the rescued job. It must finish on attempt 2 with one rescue error. The killed claimer never completes it, and traffic reconciles exactly.

The released helper gains three opt-in settings: MIXED_MAINTENANCE_LEADER=0, MIXED_HEARTBEAT_STALENESS_MS and MIXED_CLAIM_ROTATE_INTERVAL_MS. Their defaults are unchanged.

Why the SQL emulation was not enough

The unit-level tests emulate a 0.6 rotator with SQL. Before #906 that SQL stamped claim_ring_slots.generation, because the code assumed 0.6 does. It does not, so the emulation and the code agreed and the tests passed. This cell runs the released artifact's own rotation, so it checks what 0.6 actually writes.

One more thing the real binary showed: a 0.6.19 leader whose lock session is terminated keeps rotating for a while. The cell therefore stops released leaders by killing the process, and only terminates the current runtime's lock session.

Evidence

Without #906 (f546557a's awa-model/src change reverted, so the source matches f546557a^):

  • 3 of 3 runs failed: "did not rescue the dead claim in sealed slot 1 within 3s of leading again".
  • 1 of 1 runs with CI=1 failed the same way at the 9 s bound.
  • A diagnostic run with the bound widened to 45 s (not committed) rescued 27.6 s after handback. That is 30.5 s after the current runtime started, the moment its cached proof expired.

With #906:

  • 5 of 5 runs passed. Rescue took 138 to 322 ms after handback.
  • 1 of 1 runs with CI=1 passed. Rescue took 986 ms.
  • The full rehearsal suite passed once: 7 of 7 cells in 112 s.

Runtime

The cell takes about 12 s locally and 16 s with CI=1. About 7 s of that is the released install and the migration.

CI placement

Today the rehearsal runs only in release-gate.yml, on manual dispatch and from release.yml on tag push. A regression like the one #906 fixes would surface only at release time.

Recommendation: add the rehearsal job to ci.yml for pull requests, gated by the existing changes job and pass markers. Gate it on awa-model/src, awa-model/migrations, awa-worker/src, awa/tests/rolling_upgrade_rehearsal_test.rs and awa-python/tests/mixed_fleet_helper.py. The pass markers already skip it for pull requests that do not touch those paths.

Cost: the whole rehearsal is about 2 minutes of test time locally, and likely 3 to 5 minutes on a shared runner. Add the test build, which the Rust cache mostly covers, and about 10 s to install the wheel. Running only this cell is about 15 to 20 s of test time. The whole job is still cheap enough, and the other cells guard the same mixed-version boundary. I have not changed any workflow triggers.

Checks

On Postgres 18.7 (Docker, localhost), with awa-pg==0.6.19 from PyPI in a uv venv, installed as release-gate.yml does:

  • cargo fmt --all
  • SQLX_OFFLINE=true cargo clippy --all-targets --all-features -- -D warnings
  • SQLX_OFFLINE=true cargo build --workspace
  • scripts/check-advisory-locks.py, scripts/check-transaction-isolation.py, scripts/ci-test-shard.sh check
  • cargo test --package awa --test rolling_upgrade_rehearsal_test -- --ignored: the new cell as listed above, and the full suite once.

hardbyte commented Dec 1, 2026

Copy link
Copy Markdown
Owner Author

The API added a "Generated by Claude Code" footer to the end of this PR description automatically. It fails the commit-metadata check, so a maintainer needs to delete it from the description.


Generated by Claude Code

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review: 1

  • release/.*

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-01T11:48:42.692266Z cae2197 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Add test_compat_rescue_after_released_leader_rotates_claim_ring to the
rolling-upgrade rehearsal. Under compat ring authority, a current runtime
leads and proves the sealed claim slots closed. It then loses leadership
without restarting, so its proof cache survives. A released 0.6.19 leader
rotates the claim ring into a slot, a released claimer takes a claim there
and is killed, and the 0.6.19 leader rotates past the slot. Leadership
returns to the same current process, which must rescue the dead claim
within a bound that ends before any proof it made could expire.

The 0.6 rotation is the released artifact's own, not SQL that emulates it.
The cell fails without #906's fix: the cached proof hides the dead claim
until it expires.

mixed_fleet_helper.py gains three opt-in settings the cell uses:
MIXED_MAINTENANCE_LEADER, MIXED_HEARTBEAT_STALENESS_MS and
MIXED_CLAIM_ROTATE_INTERVAL_MS.
@hardbyte
hardbyte force-pushed the ccr-37ca53f6-xza211-rehearsal-claim-proof branch from cae2197 to 75e78a3 Compare December 2, 2026 16:38
@hardbyte
hardbyte force-pushed the ccr-37ca53f6-xza211-claim-proof-compat-key branch from f546557 to 10a5e6d Compare December 2, 2026 16:38
@hardbyte hardbyte added the full-ci Run the full CI matrix (Python build+test, E2E) on this PR label Dec 2, 2026
@hardbyte
hardbyte changed the base branch from ccr-37ca53f6-xza211-claim-proof-compat-key to main December 2, 2026 18:00
@hardbyte
hardbyte merged commit 654b23f into main Dec 2, 2026
82 of 133 checks passed
@hardbyte
hardbyte deleted the ccr-37ca53f6-xza211-rehearsal-claim-proof branch December 2, 2026 18:01
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.

1 participant