Skip to content

test(apps): recover interrupted lifecycle transitions - #587

Merged
RentnerKev merged 2 commits into
mainfrom
rentner/test/lifecycle-recovery
Nov 26, 2026
Merged

RentnerKev merged 2 commits into
mainfrom
rentner/test/lifecycle-recovery

Conversation

@RentnerKev

Copy link
Copy Markdown
Member

Summary

This PR adds tests for #453 lifecycle transitions that were not covered so far. Each new manager scenario boots from a journal entry that an interrupted transition leaves behind. The scenarios run inside the existing privileged signed lifecycle, app_manager::tests::privileged_signed_lifecycle. That test runs as root in the Rust job (rust-coverage.sh) and in App Runtime Reference on AMD64 and ARM64.

No production code changes. Every scenario passed against the current manager, so these tests found no recovery bug.

Tests and the #453 criteria they prove

#453 criterion Where What it proves
3: interruption recoverable from the journal check_interrupted_transitions (core/tests/private/app_manager/lifecycle.rs), interrupted update An update stopped after it reserved the next generation, with 1.0.0 committed and 1.1.0 staged. The boot fences the reserved generation and restarts 1.0.0. The candidate stays staged and the approved grants are not sent again.
3 check_interrupted_transitions, uncertain grants An activation stopped after it may have published new grants. The boot restarts 1.0.0 with an empty grant set. last-grants-generation advances to the restarted generation, and the journal clears the uncertainty.
3, 6 (recovery) check_interrupted_transitions, interrupted removal A removal stopped after it reserved the installation, and the authority cannot confirm it at boot. The installation stays removing and needs recovery. start cancels the removal and runs 1.0.0 again.
3 end of exercise, resumed-removal and resumed-purge Two other installations resume at boot. A removal (Removing, with a pending fence) fences, keeps the data and ends removed. A purge (Purging) erases the data and ends purged.
2: readiness/protocol mismatch cannot promote check_interrupted_transitions, never-ready candidate A candidate stays alive but answers readiness with protocol 9.9.9. Activation fails with timed out at the 2 s startup limit. The previous release restarts with the approved grants, and the candidate stays staged. The fixture app consumes a fixture-never-ready marker once at startup, so only the candidate misreports.
2: data mismatch cannot promote check_interrupted_transitions, incompatible data Release 1.1.0-rc.2 declares data the installation never wrote, without a migration. CLI activate is refused with the incompatible-data error, before the fence. A UI rollback to it fails with incompatibleData. The manager status and the running app's PID stay unchanged.
6: removal respects owned resources removal and data purge wait while the app owns a proxy host (web/src/tests/server/AppRuntime/authority.db.test.ts) removable and purge-data return conflict while the installation owns a proxy host, before and after its generation is revoked. Deleting the host releases both.

Fixture changes:

  • lifecycle_packages adds release 1.1.0-rc.2 with a data declaration. The offered update from 1.0.0 is still 1.1.0.
  • The lifecycle authority stand-in accepts the two resumed installations.
  • The stand-in can refuse removable as unavailable while a marker file exists next to its socket.

Not in this PR

Testing

  • cargo fmt --check and Clippy with --all-targets --all-features -D warnings, on Kiri with Rust 1.99.1.
  • privileged_signed_lifecycle passed as root in a network-less, read-only container with the CI capability set (41 s). In the same container, all root app_manager::tests:: and app_install::tests:: passed.
  • authority.db.test.ts passed against PostgreSQL 18.7 with migrations applied. As a mutation check, the new test fails when the owned-host check in checkAppRuntimeDependenciesInTransaction is disabled.
  • Web type check, oxlint and type-aware oxlint passed for the changed file.

Refs #453

🤖 Generated with Claude Code

Boot the signed lifecycle fixture from journal entries that interrupted
transitions leave behind: an update after it reserved the next
generation, an activation with uncertain grants, a removal the authority
cannot confirm (cancelled by start), and removals and purges that resume
at boot.

Refuse a candidate that stays alive with an unsupported protocol after
its startup limit, and a release whose declared data the installation
never wrote, both without disturbing the running generation.

Check that removal and data purge wait while an app owns a proxy host.

Refs #453

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

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

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 37 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 aa06342 and 903693c.

Files selected for processing: 4

  • core/tests/fixtures/app-manager/app.rs
  • core/tests/private/app_install.rs
  • core/tests/private/app_manager/lifecycle.rs
  • web/src/tests/server/AppRuntime/authority.db.test.ts
  • 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

@RentnerKev
RentnerKev merged commit e083198 into main Nov 26, 2026
44 checks passed
@RentnerKev
RentnerKev deleted the rentner/test/lifecycle-recovery branch November 26, 2026 18:42
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