Skip to content

fix(apps): hand a seam back to the builtin when its copy unloads - #36325

Merged
bolichen97 merged 1 commit into
mainfrom
feat/w4-aws-control
Nov 14, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
feat/w4-aws-control

Conversation

@bolichen97

@bolichen97 bolichen97 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

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 its on_startup under the built-in's id, so it replaces the providers the wheel copy's seams.py registered. 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 raises ModuleNotFoundError: No module named '_kirocrew_app_<name>' until the gateway restarts. For aws-control (the next app to be pinned) that means the s3 / ce consent cards fall back to the CLI default chain, the project pill reports an expired SSO sign-in as unavailable, 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

  • Making an installed app's seams independent of its enabled state once the wheel copy is deleted (the deletion wave owns that; with no builtin provider the seam stays with the app, as today).
  • Changing which provider wins when the builtin load runs after an installed copy registered; both answer from the same code while the wheel copy ships.
  • Pinning aws-control or editing 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: register keeps the entry a builtin's seams.py registers during the one-time load in _builtin_providers. New release_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, calls seams.release_app(name).
  • app-kit-platform.md section 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_builtin loads a real installed aws-control copy through module_loader.load_app_module, runs its on_startup (which registers an account policy that imports the copy's accounts at call time), unloads it, and asserts the seam answers from the wheel's accounts. With the unload_app_modules hunk reverted it fails with ModuleNotFoundError: No module named '_kirocrew_app_aws-control', the production symptom.
  • test_a_seam_no_builtin_provides_stays_with_its_app and test_the_builtins_own_provider_and_other_apps_are_untouched pin the two cases that must not change.
  • test_the_load_records_every_provider_it_registers runs a fresh interpreter and asserts _builtin_providers equals _providers after 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.
  • The registry fixture also restores _builtin_providers. The file's fresh-interpreter runs share one _fresh_process helper.

Proof: not provable -- other: reverting every production hunk removes the _builtin_providers the fixture restores, so the mutated run errors in setup; reverting only the unload hook fails the end-to-end test above with the production ModuleNotFoundError

Run: the 21 test files that import module_loader or apps.seams (600 passed, 2 skipped), plus test_app_seams.py, test_module_loader.py and test_core_aws_control_decoupling.py (70 passed) and test_flake_pattern_ratchet.py (68 passed) on the rebased head. Determinism: the new tests use tmp_path or a fresh interpreter and no clock, port or sleep; TestAnInstalledCopyOfABuiltin 5 repeats green and green in reversed order, and -n 4 green.

Manual verification

The aws-control adoption smoke on an isolated loopback gateway, run on origin/main and on this branch (table in the PR comment below): with the adopted copy disabled, origin/main answers the s3 consent card with an empty profile and granted: false, and the account policy and transfer staging raise ModuleNotFoundError; 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_startup runs 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

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners November 13, 2026 02:40
@bolichen97
bolichen97 enabled auto-merge (squash) November 13, 2026 02:40
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 13, 2026
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 2d2c27661d36ebe741a6657acc5ddcea2f7db7f1 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 2d2c27661d36ebe741a6657acc5ddcea2f7db7f1 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 2d2c27661d36ebe741a6657acc5ddcea2f7db7f1 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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 (unload_app_modules), and nothing earlier in seams.py already releases a seam.

What this change ships

Inventory (4 items) — 3 justified

Intent: 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.

  1. After a disable, update or uninstall of an adopted copy, the s3/ce consent card, the project pill and transfer staging answer from the built-in again instead of raising ModuleNotFoundError — justified
  2. The seam registry now remembers each provider registered while the built-in seams modules load, so there is a provider to hand the seam back to — justified
  3. The app-kit-platform spec, section 30, now describes the hand-back — justified
  4. The fresh-interpreter test runs share one _fresh_process helper, and the old check=True becomes an explicit return-code assert — rides along

[FIRST-PRINCIPLES-REVIEWED] 2d2c276

Description read

[DESCRIPTION-READ] a8baaab19df2a399725565ba3b2fe1d58a35ef714352c4cfb4d347bf1dda28c1

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 2d2c27661d36ebe741a6657acc5ddcea2f7db7f1 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 2d2c276

Verdict parsed from the review's SHA-scoped output markers for commit 2d2c27661d36ebe741a6657acc5ddcea2f7db7f1.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 2d2c27661d36ebe741a6657acc5ddcea2f7db7f1 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 2d2c27661d36ebe741a6657acc5ddcea2f7db7f1 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 2d2c276

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 2d2c27661d36ebe741a6657acc5ddcea2f7db7f1 false-positive: <reason, 20 to 500 characters>

@bolichen97

Copy link
Copy Markdown
Contributor Author

Adoption smoke for aws-control, on an isolated in-process loopback gateway (test/integration harness, throwaway home, the AWS CLI pointed at a local loopback stand-in), with a harness pin for KiroCrewCaptain/kirocrew-app-aws-control@55ba00b5bcd33ff4ddbce8bad3d75f1c37c4a61a (minAppSdkLevel 2) and the wheel copy's version raised to the pin's 0.1.2 the way the pin PR will.

The built-in was enabled and given state (three profiles, an s3 consent grant, a drive, a file, a share link, the nightly backup on, an install label, a finished backup); STAGE staged the pin and the next start adopted it, enabled, with data/, the grants, the consent grant, crons, agents and MCP entries identical. Then the core seams were read through their callers at each step:

Step origin/main (4e4bba3) this branch
built-in, enabled consent card personal / us-west-2, granted same
adopted, enabled same, from the adopted copy's provider same
adopted, disabled consent card profile "", granted: false; account policy and transfer staging raise ModuleNotFoundError: No module named '_kirocrew_app_aws-control' consent card personal / us-west-2, granted, from the wheel's provider
re-enabled adopted provider answers same
after uninstall stale provider raises wheel's provider answers
a separate process wheel's provider answers same

Everything else matched on both: the legacy /aws-control route and the app bundle served, legacyNav /aws-control / Cloud, a snapshot backup by the adopted copy ran to done, an update from the store at the pinned commit was a no-op (v0.1.2 -> v0.1.2, data unchanged), disable and enable kept the drive listing, and a store reinstall after uninstall registered its routes and served the kept share. A disable drops finished job records for the built-in exactly as for the adopted copy, so that is not an adoption change.

@bolichen97

Copy link
Copy Markdown
Contributor Author

Red checks on head ce0c5703ec9f, none from this diff:

  • Backend Tests (3.12, 8) + Coverage Gate: test_reply_format_once.py::...::test_the_table_names_every_selectable_harness fails on origin/main (4e4bba3) too, reproduced locally; it is the mimocode harness row that test: name mimocode in the reply-format harness table #36315 adds. This PR touches neither the test nor the harness table.
  • CodeQL Analyze (python, javascript-typescript): API rate limit exceeded for installation in the upload step; rerun once the run completes.

@bolichen97

Copy link
Copy Markdown
Contributor Author

Head 8d850c48b6f1 (rebased on origin/main d4b588b):

  • Backend Tests (3.12, 8) / (Windows) (8) + Coverage Gate on ce0c5703ec9f: test_reply_format_once.py::TestEveryMessageWhereTheBlockCannotBeTakenOut::test_the_table_names_every_selectable_harness was main's red, fixed by fix(test): add mimocode to the compaction table every selectable harness needs #36290; the rebase carries it and the node passes locally.
  • CodeQL Analyze (python): API rate limit exceeded for installation in the upload step, not a finding; the new head re-runs it.
  • Design note (builtin providers registered outside the one-time load get no hand-back): pinned by test_the_load_records_every_provider_it_registers, a fresh-interpreter check that _builtin_providers == _providers after the first lookup. Production code is unchanged from ce0c5703ec9f.
  • Provider precedence while the copy is enabled (copy's on_startup before the first lookup loses to the wheel provider): listed under this PR's Not a goal, so it is tracked as Adopted app seam provider loses to the wheel copy when its on_startup runs before the first lookup #36456 with the fix and its test written up.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 13, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased onto main carrying #36457 (8d850c4 -> dcb3656). The red Backend Lint & Type Check (3.12) / Coverage Gate on 8d850c4 was main's mypy error in src/kiro_crew/cli_commands_memory.py:335, which #36457 fixes; this diff is unchanged. Locally on the rebased head: mypy clean (4619 files), isort/flake8/black/comment-history/brand/line-cap clean, the related tests 70 passed and the flake-pattern ratchet 68 passed.

@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebuilt on origin/main 6d61070 (carries the red-main fix #36804); diff unchanged. The prior head's only red, Backend Tests (3.12, 7) + Coverage Gate, was test_denied_commands_security_cost.py::TestSelfModuleIndexIsLinear::test_the_scan_is_linear_not_quadratic (0.518s against a 0.5s wall-clock bound), a known flake unrelated to this diff, recorded on #28212. Local: static gates, mypy and the 376 related tests are green on 7c0b639.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 13, 2026
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 13, 2026
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
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in docs/system-specs/modules/app-kit-platform.md since this head went green (6d61070 -> 342409d); CI re-running.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: passed Eligible automated validation passed for the current revision readiness: checking Automated validation is still running labels Nov 14, 2026

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_app in seams.py:174: dropping the held[0] == app_id check reds no test. test_the_builtins_own_provider_and_other_apps_are_untouched uses probe, 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_process helper also changes the existing shipped-provider test. Behaviour is the same, so keeping it is fine.

@bolichen97
bolichen97 merged commit fe1abf3 into main Nov 14, 2026
135 of 140 checks passed
@bolichen97
bolichen97 deleted the feat/w4-aws-control branch November 14, 2026 02:42
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 14, 2026
buluoray pushed a commit that referenced this pull request Nov 14, 2026
)

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)
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.

2 participants