Repository navigation
fix(apps): hand a seam back to the builtin when its copy unloads - #36325
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level concerns. The unload is the one path every disable, update and uninstall goes through, so handing the seam back there fixes the cause rather than the symptom. [DESIGN-REVIEWED] 2d2c276 Description read[DESCRIPTION-READ] 9bb168d45771826219494f9e72519f75b268f9f09c36c62b9be58b3e1af59669 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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. The hand-back is aimed at the cause the PR names: an unload removes the copy's modules but leaves its providers registered. It has exactly one caller, the single unload path ( What this change shipsInventory (4 items) — 3 justifiedIntent: when someone disables, updates or uninstalls an adopted former built-in, the core features it filled keep answering exactly as they did before adoption. FIX.
[FIRST-PRINCIPLES-REVIEWED] 2d2c276 Description read[DESCRIPTION-READ] a8baaab19df2a399725565ba3b2fe1d58a35ef714352c4cfb4d347bf1dda28c1 That sha256 names the PR description this verdict read. 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: |
|
Adoption smoke for aws-control, on an isolated in-process loopback gateway ( The built-in was enabled and given state (three profiles, an
Everything else matched on both: the legacy |
|
Red checks on head
|
ce0c570 to
8d850c4
Compare
|
Head
|
8d850c4 to
dcb3656
Compare
|
Rebased onto main carrying #36457 (8d850c4 -> dcb3656). The red |
dcb3656 to
7c0b639
Compare
|
Rebuilt on origin/main 6d61070 (carries the red-main fix #36804); diff unchanged. The prior head's only red, |
An adopted former built-in registers its seam providers from on_startup under the builtin's id, replacing the providers the wheel copy's seams.py registered. Those providers import the copy's own modules at call time, so after a disable, update or uninstall unloads them every call raises ModuleNotFoundError: the consent cards fall back to the default chain, the project pill reports an expired SSO sign-in as unavailable, and the MicroVM staging and crew digest fail, until the gateway restarts. The built-in answered whether or not it was enabled. unload_app_modules now calls seams.release_app, which restores the provider the builtin's seams module registered during the one-time load. Part of #26967
7c0b639 to
2d2c276
Compare
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approving. On this head the review traced every seams.register caller and both callers of unload_app_modules (the disable path and the route deregister path). Teardown always runs before any reload, so the hand-back never overwrites a provider a copy has just registered. The review also ran test_app_seams.py with the module loader, update invalidation and tombstone suites: 101 passed, in forward and reversed order. Reverting only the release_app call in module_loader.py reds the end-to-end test with the ModuleNotFoundError the Proof line names.
Done well: the hand-back keys on what the builtin load actually registered and restores it by identity. A builtin's own provider and seams with no builtin entry stay as they are, and core hard-codes no app id.
Optional:
release_appin seams.py:174: dropping theheld[0] == app_idcheck reds no test.test_the_builtins_own_provider_and_other_apps_are_untouchedusesprobe, which has no builtin entry. A case where a second app holds a seam that has a builtin entry would pin it.- app-kit-platform.md line 6573 is 133 characters wide. Reflowing it would match the lines around it.
- The
_fresh_processhelper also changes the existing shipped-provider test. Behaviour is the same, so keeping it is fine.
) An adopted former built-in registers its seam providers from on_startup under the builtin's id, replacing the providers the wheel copy's seams.py registered. Those providers import the copy's own modules at call time, so after a disable, update or uninstall unloads them every call raises ModuleNotFoundError: the consent cards fall back to the default chain, the project pill reports an expired SSO sign-in as unavailable, and the MicroVM staging and crew digest fail, until the gateway restarts. The built-in answered whether or not it was enabled. unload_app_modules now calls seams.release_app, which restores the provider the builtin's seams module registered during the one-time load. Part of #26967 (cherry picked from commit fe1abf3)
Problem / Motivation
Goal: Disabling, updating or uninstalling an adopted former built-in that fills a core seam keeps that core feature answering exactly as it did before adoption.
An adopted former built-in (section 33 of
app-kit-platform.md) registers its seam providers from itson_startupunder the built-in's id, so it replaces the providers the wheel copy'sseams.pyregistered. Those providers import the copy's own modules at call time. A disable, an update or an uninstall unloads those modules, after which every call raisesModuleNotFoundError: No module named '_kirocrew_app_<name>'until the gateway restarts. For aws-control (the next app to be pinned) that means thes3/ceconsent cards fall back to the CLI default chain, the project pill reports an expired SSO sign-in asunavailable, and the MicroVM secret staging and crew bundle digest fail. The built-in answered all of them whether or not it was enabled.Why it matters
Adoption must change nothing for a current user. aws-control is off by default, so switching it off after it was on is an ordinary action, and today it would silently break core features that never depended on the app being enabled. This blocks pinning aws-control.
Not a goal
adoption-pins.json(the pin PR does that).What changed (motivation → approach → change)
Root cause: an unload removes an installed copy's modules but leaves its seam providers registered over the builtin's, and nothing keeps the builtin's provider to return to.
apps/seams.py:registerkeeps the entry a builtin'sseams.pyregisters during the one-time load in_builtin_providers. Newrelease_app(app_id)hands each seam that app holds back to that entry; a seam no builtin provides stays with its app, and a builtin's own provider is never touched.apps/module_loader.unload_app_modules, the one path every disable, update and uninstall unloads through, callsseams.release_app(name).app-kit-platform.mdsection 30 states the hand-back.Backwards compatibility
Compatible: a builtin-owned record's providers are the builtin's own and are left untouched; only a provider an installed copy registered over a builtin's is replaced, and only once that copy's modules are gone.
Removes nothing: the registry gains a stash and a hand-back; no seam, key or provider is removed or renamed.
Tests
test/test_app_seams.py::TestAnInstalledCopyOfABuiltin::test_unloading_the_copy_hands_the_seam_back_to_the_builtinloads a real installedaws-controlcopy throughmodule_loader.load_app_module, runs itson_startup(which registers an account policy that imports the copy'saccountsat call time), unloads it, and asserts the seam answers from the wheel'saccounts. With theunload_app_moduleshunk reverted it fails withModuleNotFoundError: No module named '_kirocrew_app_aws-control', the production symptom.test_a_seam_no_builtin_provides_stays_with_its_appandtest_the_builtins_own_provider_and_other_apps_are_untouchedpin the two cases that must not change.test_the_load_records_every_provider_it_registersruns a fresh interpreter and asserts_builtin_providersequals_providersafter the first lookup, so every shipped builtin's provider (aws-control's three and auto-research's tombstone) has an entry to hand back to. It fails if the load stops recording them.registryfixture also restores_builtin_providers. The file's fresh-interpreter runs share one_fresh_processhelper.Proof: not provable -- other: reverting every production hunk removes the
_builtin_providersthe fixture restores, so the mutated run errors in setup; reverting only the unload hook fails the end-to-end test above with the productionModuleNotFoundErrorRun: the 21 test files that import
module_loaderorapps.seams(600 passed, 2 skipped), plustest_app_seams.py,test_module_loader.pyandtest_core_aws_control_decoupling.py(70 passed) andtest_flake_pattern_ratchet.py(68 passed) on the rebased head. Determinism: the new tests usetmp_pathor a fresh interpreter and no clock, port or sleep;TestAnInstalledCopyOfABuiltin5 repeats green and green in reversed order, and-n 4green.Manual verification
The aws-control adoption smoke on an isolated loopback gateway, run on
origin/mainand on this branch (table in the PR comment below): with the adopted copy disabled,origin/mainanswers thes3consent card with an empty profile andgranted: false, and the account policy and transfer staging raiseModuleNotFoundError; this branch answers exactly as the built-in did. Adoption, the page, an adopted backup, a no-op update, disable / enable and a store reinstall after uninstall match on both.Related Issues
Part of #26967
Follow-up: #36456 (which provider answers while the copy is enabled when its
on_startupruns before the first lookup; listed under Not a goal).Sibling sweep
Swept: git grep -n "seams.register|register_worker_slot_mode" -- src/kiro_crew
Sibling: src/kiro_crew/dashboard/chat_handlers.py -- not affected -- a worker slot mode is a plain string read once at import, so no code of the app runs when it is asked
Sibling: src/kiro_crew/apps/builtins/design_critique/seams.py -- not affected -- it registers only a worker slot mode
Sibling: src/kiro_crew/apps/builtins/auto_research/seams.py -- not affected -- its copy is not adopted yet, and the shared release_app covers it when it is
Pattern harvest
Rule candidate: review-prompt
Pattern: a registry an installed app fills from a hook keeps a provider that imports the app's modules after those modules are unloaded
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)