Skip to content

test(apps): migrate a reference update and refuse incompatible rollback - #586

Merged
RentnerKev merged 5 commits into
mainfrom
rentner/test/reference-migration-recovery
Nov 26, 2026
Merged

RentnerKev merged 5 commits into
mainfrom
rentner/test/reference-migration-recovery

Conversation

@RentnerKev

@RentnerKev RentnerKev commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds an end-to-end test that runs app data migrations, the refused incompatible rollback and recovery through the real app manager on amd64 and arm64. It closes the gaps the acceptance audit found for #458 criterion 4 and #453 criteria 4 and 5.

  • New privileged test core/tests/private/app_manager/lifecycle/published_greeting/data_migrations.rs. It repackages the verified official Greeting 1.0.1 archive (same bin/app, ui/, api/, LICENSE) as four releases. Each release rewrites version and data in app.json and adds migrations/*.sql. The test clones the official 1.0.1 catalog entry for each release and signs one catalog revision per release with the replay repository. Loopback distribution hosts serve them. The test then drives the real manager through the catalog UI in a fresh appliance state.

    Release Data target Read / write Steps
    1.1.0 1 [1] / [1] initialize (0→1)
    1.2.0 2 [2] / [2] initialize, broken (1→2: adds a column, then violates NOT NULL)
    1.3.0 2 [2] / [2] initialize, upgrade (1→2)
    1.4.0 3 [3] / [3] initialize, upgrade, archive (2→3, can run twice, logs one row)
  • Failing activation without a separate binary. Before the 1.4.0 update, the test writes {} to the app-owned greeting.json (app UID, mode 0600). The official backend exits at startup on invalid state, so the migration commits and then activation fails. The test restores the file before it posts recover.

  • Fixture script. app-greeting-lifecycle.sh gains a --migrations mode and a fourth run_fixture call with NET_BIND_SERVICE and the /greeting mount, like the existing calls. Only that run gets a 3 GiB state tmpfs instead of 1 GiB, because four archives and four staged packages of the ~50 MB Greeting build do not fit in 1 GiB. The test runs in App Runtime Reference on both architectures and in the Rust job through rust-coverage.sh.

  • Evidence. The test writes greeting-migrations.json, which is uploaded with the other reference evidence.

  • Helper reuse. Two existing helpers are made visible instead of being rewritten: pack_fixture_archive becomes pub(crate) and portable_backup::postgres becomes pub(super).

Each update needs its own catalog revision, because the manager offers only the latest newer release. The test restarts the manager after serving each revision, since the listing otherwise refreshes only every 60 s.

Assertions and criteria

Step Assertion Criterion
1. Install 1.1.0 The fresh install runs initialize. Recorded data version 1, rows (1,first);(2,second), log 1. #458 criterion 4 (migration through the real catalog/package path)
2. Update to 1.2.0 Fails with operationFailed. 1.1.0 is running again in a new generation (failed activation + restart = +2) with recoveryRequired: false. Recorded version still 1, rows and log unchanged, partial revision column absent. Greeting and greeting.json unchanged. #453 criterion 4 (migration failure preserves a safe prior state), #453 criterion 5 (automatic restart only because 1.1.0 can still open the data), #458 criterion 4 (interrupted migration has a deterministic outcome)
3. Update to 1.3.0 Succeeds. Recorded version 2, column revision added, rows (1,first,2);(2,second,2), log 1,2. Greeting readable. #458 criterion 4
4. Roll back to 1.1.0 Fails with incompatibleData. The generation, the running 1.3.0 release and the whole manager status are unchanged. Recorded version, rows, log, greeting and greeting.json are unchanged. #453 criterion 5 (no rollback when old code cannot read the current data), #458 criterion 4 (incompatible data)
5. Update to 1.4.0 with a failing start Fails with operationFailed. The catalog row shows recoveryRequired, and the manager reports running: false, active 1.3.0, candidate 1.4.0. Recorded version 3 and log 1,2,3: the committed migration was not discarded and 1.3.0 was not restarted on version-3 data. #453 criterion 4 (reports recovery-required), #453 criterion 5 (post-cutover writes are not silently discarded)
5. recover Succeeds. 1.4.0 runs in the next generation with 1.3.0 as previous release. Recorded version 3, log still 1,2,3 (no second migration). Greeting readable. #458 criterion 4 (incompatible-data recovery is deterministic), #453 criterion 4

Code fixes

None. The manager behaved as designed in every step.

Not covered

Verification

  • cargo check --locked --all-targets and cargo clippy --locked --all-targets --all-features -- -D warnings pass on Rust 1.99.1 in Kiri.
  • cargo fmt --check passes. bun --no-env-file fmt --check passes for the workflow.
  • The privileged PostgreSQL run is proven by CI: App Runtime Reference (amd64, arm64) and the Rust coverage job.

Refs #458
Refs #453

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Expanded validation of published app data migrations across fresh installs, successful upgrades, failed migrations, rollback attempts, and recovery when an upgraded app fails to start.
    • Added checks for preserved app data, database versions, and installation status throughout migration scenarios.
    • CI now records and uploads migration test results alongside existing app lifecycle verification.

Repackage the official Greeting 1.0.1 archive as four signed releases with
declared SQL migrations and drive them through the real app manager in a
fresh appliance state: a fresh install migrates from empty state, a failing
migration rolls back and restarts the previous release, an update migrates
version 1 to 2, a rollback to 1.1.0 is refused as incompatible before the
fence, and a committed migration whose backend fails to start stays
recovery-required until recover finishes it without migrating again.

The App Runtime Reference and Rust coverage jobs run it on amd64 and arm64
through a new --migrations mode of the Greeting lifecycle fixture.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 38 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between c237f0d and 8c586b2.

Files selected for processing: 6

  • .github/scripts/ci/fixtures/app-greeting-lifecycle.sh
  • .github/workflows/app-runtime-reference.yml
  • core/tests/private/app_install.rs
  • core/tests/private/app_manager/lifecycle/published_greeting.rs
  • core/tests/private/app_manager/lifecycle/published_greeting/data_migrations.rs
  • core/tests/private/app_manager/lifecycle/published_greeting/portable_backup.rs

No actionable comments were generated in the recent review.

Walkthrough

The pull request adds a privileged integration test for published Greeting data migrations. It checks migration, rollback, and recovery scenarios through the app manager. The CI fixture script runs the test and the workflow uploads its JSON evidence report.

Changes: Published Greeting migrations

Layer / File(s) Summary
Build migration release fixtures
core/tests/private/app_manager/lifecycle/published_greeting/data_migrations.rs, core/tests/private/app_manager/lifecycle/published_greeting.rs, core/tests/private/app_manager/lifecycle/published_greeting/portable_backup.rs, core/tests/private/app_install.rs
The test defines migration steps, repackages the official archive into signed catalog releases, and adds helpers for release and database checks. The test module includes the new migration test. Two existing helpers gain parent-module visibility.
Exercise migration and recovery outcomes
core/tests/private/app_manager/lifecycle/published_greeting/data_migrations.rs
The integration test checks fresh installation, failed and successful migrations, incompatible rollback rejection, and recovery after a migration commits but the candidate backend fails to start. It writes a JSON evidence report.
Run migration fixture in CI
.github/scripts/ci/fixtures/app-greeting-lifecycle.sh, .github/workflows/app-runtime-reference.yml
The fixture script adds a migrations mode with a larger state tmpfs and checks for the report. The workflow includes the report in its artifact upload.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Other

Possibly related issues

Possibly related PRs

Merge Risk: Minimal · previous review c237f

This change adds a privileged migration, rollback and recovery test and its CI wiring, and it does not alter product behavior. If the recovery scenario's startup-failure trigger does not behave as assumed, the new CI test would fail in the App Runtime Reference run, so the first CI results will show it. No merge-blocking risk is established.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "test(apps): migrate a reference update and refuse incompatible rollback" matches the main change: an end-to-end privileged test covering data migrations, refused incompatible rollback, and …
Description check Passed The description follows the repository template. It has a Summary, a Related issue section (refs #458 and #453, with the closing style not used because this is a test-only change), testing details, an…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "test(apps): migrate a reference update and refuse incompatible rollback" matches the main change: an end-to-end privileged test covering data migrations, refused incompatible rollback, and recovery through the real app manager. It follows a conventional commit style. It omits the recovery-after-failed-start scenario and the fixture/evidence changes, which is acceptable for a title.

Full details: Description check

Explanation

The description follows the repository template. It has a Summary, a Related issue section (refs #458 and #453, with the closing style not used because this is a test-only change), testing details, and assertions. The Type of change checkboxes are not ticked, and the Checklist, Breaking changes, and Screenshots sections are not explicitly filled in. The Testing section lists commands and CI runs. The Related issue section uses Refs rather than Fixes or Closes, and the template asks for N/A with a reason for tiny changes, so the reason is only implicit.

Resolution

Tick the Type of change box (Testing or CI / tooling fits best; the template has no Testing option, so use Other). Mark the Checklist items that apply. Write None under Breaking changes and Screenshots. Optionally state in Related issue why Refs is used instead of Fixes.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • 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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between a232348 and c237f0d.

Files selected for processing: 6

  • .github/scripts/ci/fixtures/app-greeting-lifecycle.sh
  • .github/workflows/app-runtime-reference.yml
  • core/tests/private/app_install.rs
  • core/tests/private/app_manager/lifecycle/published_greeting.rs
  • core/tests/private/app_manager/lifecycle/published_greeting/data_migrations.rs
  • core/tests/private/app_manager/lifecycle/published_greeting/portable_backup.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@RentnerKev
RentnerKev merged commit 9c6cf25 into main Nov 26, 2026
45 checks passed
@RentnerKev
RentnerKev deleted the rentner/test/reference-migration-recovery branch November 26, 2026 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant