You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(apps): recover app runtime and harden startup - #672
The v1 upstream probe uses the controller's monitoring admission. The app manager can advertise a UI it failed to load, and the migration scanner can confuse a standalone BEGIN token with a SQL routine body. An app-manager crash leaves installed apps stopped, and a background catalog fetch can report a stale catalog when staging accepts the same signed metadata during the fetch.
Changes
Forward the authenticated installation ID for v1 upstream probes so the controller applies app admission.
Fail startup before generation registration when the declared UI cannot load. Publish a typed error for the Owner and clear a matching candidate only when it belongs to a never-started first-install reservation.
Recognize BEGIN ATOMIC as adjacent SQL tokens in routine definitions. Require balanced routine blocks and parentheses at EOF.
Restart the app manager with bounded backoff and check both transient and persisted maintenance fences. The manager reconciles installed apps through its existing writer fences.
Sample the catalog verification clock after reading the checkpoint under the installer lock. Persist that acceptance time with the reverified metadata.
Verification
Bun typecheck and lint, focused UI and controller tests, and the v1 controller transport regression against disposable PostgreSQL in Kiri.
203 focused Rust tests and strict Clippy in Kiri, including the SQL scanner and overlapping catalog refresh.
The production supervisor fixture verifies restart, backoff, and maintenance fences. The signed native lifecycle covers recovery from an app-manager SIGKILL, a UI boot failure, and selection of a healthy release after a failed first install.
Reviewing files that changed from the base of the PR and between fdb88c3 and 36e8e45.
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
No actionable comments were generated in the recent review.
Walkthrough
This PR updates catalog refresh checkpoint timing, reports UI package load failures through app lifecycle state, adjusts SQL migration parsing, restarts crashed app managers under guarded backoff, and passes installation identity with upstream probes.
Changes: Catalog refresh checkpoint
Layer / File(s)
Summary
Deferred clock and checkpoint refresh core/src/app_install/browse.rs, core/src/app_install/catalog.rs, core/tests/private/app_install.rs
Background refresh now reads the clock and checkpoint after acquiring the lock. The tests cover a checkpoint rewritten during staging.
UI package failure and recovery reporting
Layer / File(s)
Summary
Recovery error state and lifecycle handling core/src/app_manager/journal.rs, core/src/app_manager.rs, core/src/app_manager/lifecycle.rs, core/src/app_manager/removal.rs, core/src/app_manager/service.rs
The journal records a recovery error for UI package load failures. The manager sets or clears that error during activation and boot handling, and includes it in applicable installation status responses.
Catalog failure classification and install handling core/src/app_manager/catalog.rs, core/tests/private/app_manager/catalog.rs
Catalog install and lifecycle results classify UI package failures. Initial-install cleanup is limited to slots matching the stated untouched-install conditions.
Tests cover failed installs and failed recovery boots. The web contract and translations accept the error, and the installed-app card displays it when management is permitted.
SQL migration parsing
Layer / File(s)
Summary
Atomic routine parsing and validation core/src/app_manager/migration.rs, core/tests/private/app_manager/migration.rs
The scanner recognizes BEGIN ATOMIC routine bodies and rejects unmatched closing parentheses. Tests cover accepted and rejected SQL forms.
App-manager restart handling
Layer / File(s)
Summary
Restart scheduling and safety checks docker/production/entrypoint.sh, docker/production/fault-supervisor.sh
The supervisor reaps exited app managers and schedules restarts with backoff. Restarts are deferred when maintenance, backup recovery, marker, or journal-safety checks prevent them.
RentnerProxy/platform#523: Both PRs cover UI package loading and its relationship to an active app generation.
Merge Risk: Minimal · previous review fdb88
This change makes app startup, the app manager, catalog refresh and v1 upstream probes more reliable. The review found no concrete merge-blocking defect in the supplied code. Normal CI checks should still run before merge.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "fix(apps): recover app runtime and harden startup" names the main theme of the changeset. The diff covers app-manager recovery (RecoveryError::UiPackageUnavailable, recovery_error journalin…
Description check
The description follows the repository template. It has a Problem section and a Changes section, a Verification section, and Closes lines for issues #656, #652, #653, and #655. It omits the template h…
Linked Issues check
[#656] web/src/server/AppRuntime/hosts.server.ts now passes the installation ID to inspectControllerDomain on the v1 upstream probe path. host-operations.db.test.ts checks that one /internal/v1/diagno…
Out of Scope Changes check
Each changed area maps to a linked issue. The web locale files, InstalledAppCard.tsx, and contract.ts add the uiPackageUnavailable message and recoveryError field that #652 needs for lifecycle status …
Full details: Title check
Explanation
The title "fix(apps): recover app runtime and harden startup" names the main theme of the changeset. The diff covers app-manager recovery (RecoveryError::UiPackageUnavailable, recovery_error journaling, restart with backoff in the supervisor), startup hardening (failing startup when a declared UI cannot load), and related fixes. It does not mention the v1 upstream probe admission, the BEGIN ATOMIC scanner fix, or the catalog clock change. Those are secondary and the title does not need to cover every detail, so the title is related to the main change.
Full details: Description check
Explanation
The description follows the repository template. It has a Problem section and a Changes section, a Verification section, and Closes lines for issues #656, #652, #653, and #655. It omits the template headings for Type of change, Checklist, Breaking changes, and Screenshots. The Related issue content is present as Closes lines. The Summary heading is replaced by Problem and Changes. The Testing content is present under Verification. The author describes the change well, but several template sections are absent.
Resolution
Optionally add the missing template sections: Type of change (Bug fix is applicable), the Checklist, Breaking changes (or None), and Screenshots (or None). Rename or map the Problem and Changes content to the Summary heading if the template is enforced strictly.
Full details: Linked Issues check
Explanation
[#656] web/src/server/AppRuntime/hosts.server.ts now passes the installation ID to inspectControllerDomain on the v1 upstream probe path. host-operations.db.test.ts checks that one /internal/v1/diagnostics/domain request carries the installation ID and upstream-only fields. The controller-side Class::App admission is not re-read in this assessment, but the forwarded ID is what the issue requires.
[#652] core/src/app_manager.rs launch now maps a failed UI package load to RecoveryError::UiPackageUnavailable and aborts activation before generation registration. hasUi is derived from the loaded package. The failure is stored in the journal slot as recovery_error and exposed as recoveryError in lifecycle status and the web contract. Tests: lifecycle/ui_package.rs covers a broken release that fails with uiPackageUnavailable and a healthy release that installs. app_ui_package.rs covers the no-ui case returning None.
[#653] core/src/app_manager/migration.rs treats only adjacent BEGIN and ATOMIC tokens as a routine body opener. The scanner requires routine and parenthesis depth to be zero at EOF. migration.rs tests accept real BEGIN ATOMIC bodies and reject unclosed bodies and unmatched parentheses. The issue's exact example is not listed verbatim in the tests. Its COMMIT falls outside any routine body, and the existing rule that rejects top-level COMMIT (tested by 'COMMIT;' and 'SELECT 1; commit') covers it.
[#655] docker/production/entrypoint.sh and fault-supervisor.sh restart the app manager with bounded backoff (1 s doubling to 30 s), defer restarts during maintenance or transient markers, and log repeated crashes. The fault-supervisor test covers the delay sequence and reset after stable uptime. The lifecycle test kills the manager and checks that the active release and data return. core/src/app_install/catalog.rs and browse.rs read the clock after taking the installer lock. Background refresh persists the new acceptance time. app_install.rs tests cover a checkpoint rewritten during staging.
Full details: Out of Scope Changes check
Explanation
Each changed area maps to a linked issue. The web locale files, InstalledAppCard.tsx, and contract.ts add the uiPackageUnavailable message and recoveryError field that #652 needs for lifecycle status reporting. removal.rs and service.rs clear or expose recovery_error for the same state. The fault-supervisor and entrypoint changes implement the #655 restart and maintenance-fence behavior. The fault-supervisor journal-safety check is part of restart safety under #655. The migration.rs changes implement #653. The test-fixture changes support the acceptance tests for #652, #655, and #656. No change was found without a connection to a linked issue.
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.
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
Self-review (CodeRabbit rate-limited): Reviewed the complete PR diff at 1d27c9d against current main. PR maintenance merged the lucide-react update from main. The PR patch is identical to fdb88c3, which CodeRabbit reviewed without actionable comments.
The v1 probe forwards the trusted installation ID and keeps app admission separate from monitoring. UI loading completes before a generation can fence a healthy predecessor or register with the authority. The matching candidate is discarded only for a never-started first-install reservation. The signed fixture confirms that a healthy alternate release starts under the same ID. The migration scanner only recognizes adjacent BEGIN ATOMIC tokens and rejects incomplete boundaries. Scanner regressions cover ordinary identifiers, SQL trivia and balanced bodies. The background refresh reads its timestamp under the installer lock and still applies the current signed rollback floor.
The independent review found two issues that are fixed in the reviewed patch. App-manager recovery uses both transient markers and the persisted maintenance journal, and a broken UI can no longer keep a pristine install reservation bound to an unusable release. The combined Kiri run passed 203 focused Rust tests, strict Clippy, the native supervisor fixtures and the signed lifecycle with SIGKILL and UI recovery cases. The AppRuntime database regression passed in disposable PostgreSQL. On the updated main dependency, Bun typecheck and lint passed and all 21 focused UI and controller tests passed.
No action items or unresolved review threads remain. Merge is gated on the current head's completed CI.
Follow-up for 36e8e45. PR maintenance merged the Cargo dependency updates from main and the complete PR diff is still identical. CodeRabbit reported that the merge commit had no files to review. With the new lockfile, the 203 focused Rust tests, strict Clippy, the complete native supervisor fixture and the signed lifecycle passed again in Kiri. The lifecycle also verified the failed first install, the healthy alternate release and recovery from SIGKILL. The source review and thread resolution still apply to this head.
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.
Problem
The v1 upstream probe uses the controller's monitoring admission. The app manager can advertise a UI it failed to load, and the migration scanner can confuse a standalone BEGIN token with a SQL routine body. An app-manager crash leaves installed apps stopped, and a background catalog fetch can report a stale catalog when staging accepts the same signed metadata during the fetch.
Changes
Verification
Closes #656
Closes #652
Closes #653
Closes #655
Summary by CodeRabbit