Repository navigation
fix(apps): keep agent configs through a local-source app update - #34578
Conversation
A local-source update deleted the app's agent configs before it copied the new version in, then wrote them back from a snapshot. When that write failed (a full disk) or was declined (a data home that does not own a shared agents directory), the user's edits in them were gone. The local-source branch now takes the app down the way the registry branch does: it keeps the agent configs, registration rewrites each in place, and the configs of agents the new version dropped are pruned. An app the update leaves unable to run still loses them all. The snapshot plumbing the route layer no longer passes is removed.
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS The fix is at cause level: the delete-then-rewrite order is gone and the registry branch's existing Notes
What this change shipsInventory (6 items) — 5 justifiedIntent: updating an app from a local folder no longer silently throws away the user's agent edits (model, description). This is a FIX for #32258.
[FIRST-PRINCIPLES-REVIEWED] 2f63413 Description read[DESCRIPTION-READ] 6bd6f0a630bba082f967312bc29d25b172ddcf47bd11695bb2ab857f9783387b 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 local branch now follows the same keep-then-prune order as the registry branch (#32213), and nothing in the tree still reads the removed snapshot plumbing. Notes
[DESIGN-REVIEWED] 2f63413 Description read[DESCRIPTION-READ] 85034579a39b577dc2f6fc163b1ece617e8896c14339acea60ccab327c2860ab 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 |
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: |
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: |
buluoray
left a comment
There was a problem hiding this comment.
Approve on 2f63413. The local-source update now keeps agent configs on disk through the take-down (keep_agents=True), prunes only agents the new version dropped and fully deregisters only an app that may no longer run, matching the registry branch (#32213). A failed or declined config rewrite keeps the user's edited config. No data loss found, and no specific app is hard-coded in core. Decisive lines: src/kiro_crew/apps/routes_install.py:289, src/kiro_crew/apps/routes_install.py:320-324, src/kiro_crew/apps/routes_lifecycle.py:288-306, src/kiro_crew/apps/bridges_agents.py:1044
Problem / Motivation
Goal: Updating an app from a local folder keeps the user's edits in its agent configs, even when the gateway cannot write a config back.
POST /api/apps/{name}/updatewith a localsourcedeleted the app's agent configs (<agents dir>/<app>--<agent>.json) before it copied the new version in, then wrote them back from a snapshot. When that write failed (a full disk) or registration declined it (a data home that does not own a shared agents directory), the config was gone, and the user's edits in it (model,description, ...) with it. The next boot recreated the template default.Why it matters
Anyone who develops an app locally, or installed one from a folder, updates it this way. The loss is silent: nothing says the agent's model or description went back to the template. #32213 fixed the same order on the registry update; the local branch still had it.
Not a goal
snapshot_app_agent_configsandregister_app'sprior_agent_configsfrom the bridges layer. No route passes them after this, and the open fix(apps): bring untouched agent spec values up to the new app version #32910 rewrites the code around them.resources: "app") app.What changed (motivation → approach → change)
A local update leaves the agent configs on disk while it swaps the app's files, the way a registry update already does. The configs hold the user's edits, so a config the gateway cannot rewrite keeps its last good copy instead of disappearing.
The old order was the root cause: the take-down ran a full
deregister_app, which deletes the configs, and the edits survived only if the re-registration managed to write the snapshot back. The registry branch avoids this withderegister_app(name, keep_agents=True): registration rewrites each config in place and reads the edits from the file itself.handle_update_app(routes_install.py) takes the local branch down withkeep_agents=Truetoo. After a successful copy it prunes the configs of agents the new version dropped, then registers as before. An app the update leaves unable to run (a newsessionApproval, or a disabled app) loses every config, as on the registry branch. A failed copy restores the old tree and record together, so the restore re-registers over the kept configs.sessionApprovalIn
routes_lifecycle.pythe prune moves out of_reinstall_from_registryinto a shared_prune_dropped_resources, and the route-layer snapshot plumbing goes:_snapshot_agent_configs_off_loop, theprior_agent_configsparameter of_register_app_off_loopand_restore_app_after_failed_update, and the facade'ssnapshot_app_agent_configsimport. The routes facade, two comments inbridges_register.pyand theapp-kit-platformspec (§3) say that every update keeps the agent configs.Backwards compatibility
Compatible: the update route keeps its request body, status codes and response fields, and an update that rewrites every config writes the same files as before.
Reader: src/kiro_crew/apps/routes_install.py:handle_update_app -- app -- the only caller of
_snapshot_agent_configs_off_loopand of the two removedprior_agent_configsparameters; test_an_update_keeps_an_agent_file_it_cannot_rewriteReader: src/kiro_crew/apps/routes.py:_snapshot_agent_configs_off_loop -- app -- facade names removed with their last route-layer user (
snapshot_app_agent_configsstays importable fromkiro_crew.apps.bridges, where its tests import it); test_routes_facade.pyReader: src/kiro_crew/apps/routes_lifecycle.py:_reinstall_from_registry -- app -- calls
_restore_app_after_failed_update(name)and the shared prune; test_an_agent_the_new_version_drops_does_not_come_backTests
test_an_update_keeps_an_agent_file_it_cannot_rewrite(wastest_a_registry_update_...) covers the local branch: a declined or failed (disk full) rewrite leaves the user's config byte for byte, on both branches of the update route and both registry install routes.test_an_update_that_needs_consent_leaves_no_agent_file(wastest_a_registry_update_...) covers the local branch: an update that newly asks forsessionApprovalleaves no agent config.test_local_update_failure_leaves_a_disabled_app_unregisteredpins the kept-configs take-down, with nothing registered or started.deregister_appintest_apps_routes_coverage_update_uninstall.pytake thekeep_agentskeyword.test_an_agent_the_new_version_drops_does_not_come_back[False]pins the local prune.Proof: PROVEN test/test_apps_routes_coverage_update_uninstall.py::TestUpdateApp::test_local_update_failure_leaves_a_disabled_app_unregistered (head 2f63413)
Determinism: the three changed tests (every parameter) passed 20 runs at
-n0and 10 runs at-n 4besidetest_app_routes.pyandtest_apps_routes_coverage_registry_install.py, and both changed files (75 tests) passed in 3 shuffled orders (seeds 32258, 7, 11).Manual verification
N/A — unit coverage sufficient: the route tests drive the real update route,
update_appand registration over a temporary data home, and the disk-full and declined cases are the issue's two failure causes.Screenshots / video
N/A — no frontend change.
Related Issues
Closes #32258
Sibling sweep
Swept: git grep -nE "deregister_app(|_deregister_app_off_loop(" -- src/
Sibling: src/kiro_crew/apps/routes_lifecycle.py -- not affected -- the registry take-down already keeps the configs (#32213); its prune is the shared helper
Sibling: src/kiro_crew/apps/bridges_register.py -- not affected -- a policy-denied registration scrubs the app's resources on purpose and writes nothing back
Sibling: src/kiro_crew/apps/routes_enable.py -- not affected -- the enable rollback disables the app, so no re-registration follows
Sibling: src/kiro_crew/apps/routes_uninstall.py -- not affected -- uninstall removes the app, so no re-registration follows
Sibling: src/kiro_crew/cli_commands_app.py -- not affected -- the CLI update goes through this route; its disable and uninstall remove the app's resources on purpose
Sibling: src/kiro_crew/apps/backend_runtime/registration.py -- not affected -- it drops a disabled app's resources and never re-registers
Pattern harvest
Not generalizable: the delete-then-rewrite order lived in one route's two branches; #32213 fixed the registry one and this fixes the other.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)