Repository navigation
fix(apps): take an app down only to replace it on a registry update - #32213
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. The take-down now runs inside the install, at the file copy, and the defect is linked (#14306). One rider adds a second way to keep the user's agent edits. Notes
What this change shipsInventory (7 items) — 6 justifiedIntent: updating or re-installing an app from the App Store takes it offline only while its files are swapped, and stops failing on Windows. FIX.
[FIRST-PRINCIPLES-REVIEWED] 6edab91 Description read[DESCRIPTION-READ] 443a11b23713bb38a7ba9e0e62f8008f3a21376eb92e3c47642afc4c1750a2b2 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. The take-down now sits inside the install, right where files get replaced, and every route that replaces an installed app's files goes through the shared helper. Notes
[DESIGN-REVIEWED] 6edab91 Description read[DESCRIPTION-READ] bf5ed5571d6ea4020eaa7be7b83a71f1485b349e7f855f71d9e2010d0c3b11fc That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
221ed2b to
cdbb733
Compare
[operator: bolichen97] |
|
[operator: bolichen97] The Backend Tests shard 2 red (Linux and Windows) on the previous head is |
cdbb733 to
6edab91
Compare
[operator: bolichen97] |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approved for the on-call. Review lanes pass on 6edab91, no conflict, no open change request.
Problem / Motivation
Goal: Updating or re-installing an installed app from the App Store stops its backend only for the moment its files are swapped, and brings the app back if the swap fails.
Two gaps on the registry paths:
POST /api/apps/registry/installand/install-stream) replaced the app's files with its backend still running. On Windows that fails with a sharing violation (WinError 32), the same failure the update route had before fix(apps): stop the backend before a registry update replaces files #14278.POST /api/apps/{name}/update, registry branch) stopped the backend and removed the app's agents, skills, crons and MCP servers before the clone and build. A successful update kept the app offline for the whole clone and build, and an update refused before touching any file (not in the registry, admission, downgrade, a failed build) still stopped and restarted the app.Why it matters
Anyone on Windows who re-installs an app from the App Store gets a failed install. Everyone else gets an app that goes dark for minutes during an update, and restarts for nothing when the update is refused.
Not a goal
What changed (motivation → approach → change)
The stop and the resource scrub sat in the route, before the install, because the route had no other place to put them. The issue asked for the bracket to sit inside the install, at the point where files are actually replaced.
install_from_registrytakes an optionalbefore_replacecallback and awaits it right beforeupdate_appcopies a managed app's new files in: after every gate, the clone, the build,setup.onInstalland the startup-hook recheck. A new shared helper,_reinstall_from_registryinroutes_lifecycle.py, passes the take-down (stop the backend, deregister everything but the agent configs) as that callback. The update route's registry branch and both registry install routes use it for an installed app; a fresh install callsinstall_from_registryas before. A self-managed app (resources: "app") is never taken down: it replaces no installed file and owns its own registrations. A gateway-managed app whose registry entry declaresresources: "app"takes that path too, so once the install has written its record self-managed the helper stops its backend and fully deregisters it; it registers its own from then on.The agent configs stay on disk through the take-down (
deregister_app(name, keep_agents=True)inbridges_register.py) because they hold the user's edits. Registration rewrites each one in place, so a config it cannot rewrite keeps its last good copy: a full disk, or a data home that does not own a shared agents directory, where registration declines to write. After the take-down the helper prunes the configs the installed manifest no longer declares. A failure restores an app that may run; an app the update left unable to run (a newsessionApproval) loses its configs, by the suspend on success and a deregister on failure. The update route now suspends such an app as the two registry install routes already do.The registry facade lists the two typing names the new parameter brings (
Awaitable,Callable), the routes facade names the two bridges helpers the prune uses, and theapp-kit-platformspec records where the take-down happens, which routes go through it, and why a registry update keeps the agent configs.Backwards compatibility
Compatible:
before_replaceandderegister_app'skeep_agentsare optional keywords that default to the old behaviour, every route keeps its status codes and response fields, and the update route's two preflights (startup hook 409, missing git 400) are unchanged.Removes nothing: the stop, scrub and restore still run on every update and re-install that reaches the file copy; only their position moves.
Tests
test_an_update_takes_the_app_down_only_to_copy_its_filesdrivesinstall_from_registry: a managed app is taken down after the build and the recheck, right before the copy; a self-managed app is never taken down.test_registry_reinstall_rechecks_retained_startup_before_replacementalso pins that a refusal at the recheck never takes the app down.test_reinstall_over_an_installed_app_takes_it_down_to_replace_its_filespins stop, deregister, replace, register, start on both registry install routes, for a successful and a failed replacement.test_registry_update_refused_before_the_replacement_leaves_the_app_runningpins that a clone failure on the update route stops nothing.test_registry_update_to_self_managed_cleans_up_only_gateway_owned_resourcespins a stop and a full deregister for a gateway-managed app the install makes self-managed, also when a later step fails, and neither for an app that was self-managed already.test_a_registry_update_keeps_the_users_agent_editsruns on the update route and both registry install routes.test_a_registry_update_keeps_an_agent_file_it_cannot_rewritepins, on all three routes, that a declined or failed (disk full) rewrite leaves the user's config byte for byte.test_a_registry_update_that_needs_consent_leaves_no_agent_filepins that an app a newsessionApprovaldisables keeps no agent config, on success and on a failure after the copy.test_an_agent_the_new_version_drops_does_not_come_backruns on the local and the registry update.Proof: PROVEN test/test_app_update_keeps_agent_edits.py::TestUpdateKeepsAgentEdits::test_a_registry_update_keeps_the_users_agent_edits[/api/apps/cov-test-app/update-body0-200], test/test_app_update_keeps_agent_edits.py::TestUpdateKeepsAgentEdits::test_a_registry_update_keeps_the_users_agent_edits[/api/apps/registry/install-body1-201], test/test_app_update_keeps_agent_edits.py::TestUpdateKeepsAgentEdits::test_a_registry_update_keeps_the_users_agent_edits[/api/apps/registry/install-stream-body2-200], test/test_app_update_keeps_agent_edits.py::TestUpdateKeepsAgentEdits::test_a_registry_update_keeps_an_agent_file_it_cannot_rewrite[/api/apps/cov-test-app/update-body0-200-declined], test/test_app_update_keeps_agent_edits.py::TestUpdateKeepsAgentEdits::test_a_registry_update_keeps_an_agent_file_it_cannot_rewrite[/api/apps/cov-test-app/update-body0-200-disk full] (head 6edab91)
Determinism: the three changed test files passed three runs in a shuffled order (seeds 1, 2, 3), 94 tests each. The new route test passed 20 runs at
-n0, and its file (51 tests) passed in a shuffled order (seed 14306).Manual verification
N/A — unit coverage sufficient: the route tests pin the call order around a stubbed install, and the pipeline test drives the real
install_from_registryto the swap. The Windows sharing violation itself needs a Windows host to reproduce.Screenshots / video
N/A — no frontend change.
Related Issues
Closes #14306
Sibling sweep
Swept: git grep -nE "\bupdate_app\b(|install_from_registry(" -- 'src/kiro_crew/**.py'
Sibling: src/kiro_crew/apps/routes_install.py:176 -- not affected -- the local-source branch already stops the backend before update_app and has no clone or build to wait for; its delete-then-rewrite of the agent configs predates this PR and is tracked in #32258
Sibling: src/kiro_crew/apps/default_installs.py:269 -- not affected -- it passes resolved_entry, which install_from_registry refuses for an installed app, so it only ever installs fresh
Sibling: src/kiro_crew/apps/manager_adopt.py:65 -- not affected -- it swaps a built-in record, whose code ran from the read-only package rather than the tree being replaced
Swept: git grep -nE "_deregister_app_off_loop(" -- src/kiro_crew/apps
Sibling: src/kiro_crew/apps/routes_enable.py:434 -- not affected -- the enable rollback disables the app, so no re-registration follows the deregister
Sibling: src/kiro_crew/apps/routes_uninstall.py:589 -- not affected -- uninstall removes the app, so no re-registration follows the deregister
Pattern harvest
Not generalizable: the take-down belongs at one transaction's replacement boundary, which only
install_from_registryhas; the other file swaps already stop first or replace nothing a backend holds.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)