Skip to content

fix: launch a bot's app servers from the app's current install - #39459

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
fix/37400-app-server-launch-line
Nov 20, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
fix/37400-app-server-launch-line

Conversation

@bolichen97

@bolichen97 bolichen97 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: After an upgrade replaces an app's install, a Bot's worker still starts that app's MCP servers, with no hand edit of the Bot's file.

A Bot's file copies each server's launch line when the server is added. For an app's server that line names the interpreter of the install the app ran from at that moment. Once an upgrade deletes that install, the Bot's worker reports the server as failed to start, while ordinary chats start the same server.

Why it matters

Every Bot that was given an app's tools loses them at the next upgrade that removes the old install, and nothing but a hand edit of ~/.kiro/mates/agents/<bot>.json brings them back.

Not a goal

What changed (motivation → approach → change)

A Bot's worker now launches an enabled app's server the way the gateway registers it today, not the way it was registered when the server was added.

The worker base never carries app servers, so they reach a Bot's worker only through the Bot's file, whose entry was a copy of the gateway's entry at add time. That copy is now re-read when the worker is built (resolve_worker_spec in mate_worker.py): for a server the file adds under an installed, enabled app's own app:server key that the agent config lists now, the worker takes that entry, and keeps only the file's own autoApprove, disabled and disabledTools. The file's tool selection, approvals and exclusions apply unchanged. Every other server in the file, a disabled app's server included, keeps the launch line the file recorded, and the file is never rewritten.

Server in the Bot's file Launch line the worker uses
An enabled app's server the agent config lists The gateway's current entry
The user's own, a registry install, one copied from an old agent The file's
A disabled or removed app's server, an app HTTP server whose backend is down The file's
An app server whose declared name has a / (mounted under an alias such as scope-pkg, which a user server can also hold) The file's

The decision is recorded in docs/decisions/, and the Bot worker sections of crew-mode.md and agent-mcp-and-skill-reach.md say the same.

Backwards compatibility

Compatible: a Bot file is read the same way and nothing that starts today stops starting; only an enabled app's server changes its launch line, to the one ordinary chats already use.

Removes nothing: a launch line typed by hand for an enabled app's server in a Bot's file is no longer used, but every file field is still read and kept, and no file, route or key is removed.

Tests

test/test_mate_worker.py::TestMateFileForMember::test_an_enabled_apps_server_launches_as_the_gateway_registers_it_now: a Bot file naming a fixture app's server with an old interpreter path gets the registered entry's command, args and env; the registered entry's autoApprove does not come along; the file's disabledTools stays; a disabled app's server and a user server in the same file keep their recorded lines; a user server holding the alias an app's /-named server is keyed by (scope-pkg), and that app server under scope-pkg-2, both keep the file's line.

Proof: PROVEN test/test_mate_worker.py::TestMateFileForMember::test_an_enabled_apps_server_launches_as_the_gateway_registers_it_now (head 94d3c53)

With only the ":" not in name check taken out of mate_worker.py, the same test fails at assert servers["scope-pkg"] == user: the user's server takes the registered uvx other line.

Determinism: 20/20 runs at -n0 (plus PYTHONHASHSEED 0, 1 and 37400), 10/10 runs of test/test_mate_worker.py at -n 4 --dist loadgroup, and 3 shuffled orders (seeds 37400, 1, 2) of its 46 tests, all green.

Manual verification

Reproduced and smoke-tested on Ubuntu 24.04.5 LTS (x86_64) against a test-mode gateway in a fresh isolated home per tree: the built-in auto-improvement app enabled through POST /api/apps/auto-improvement/enable, a Bot created with python3 -m kiro_crew agent create, and the Bot's file given the app's server as an add copies it, pointed at an interpreter that was then deleted, plus a user server. The Bot's worker spec was resolved the way a worker session resolves it, and each server entry was started with an MCP initialize.

Check Base This PR
App server's command in the worker spec the deleted interpreter the gateway's live interpreter, same as the agent config
Starting that entry FileNotFoundError: [Errno 2] No such file or directory answers initialize, serverInfo={"name": "auto-improvement", "version": "1.0.0"}
The user server's command its recorded path its recorded path (unchanged, by decision)
Bot file sha256 before and after unchanged unchanged (never rewritten)
App switched off, then on again n/a off: the file's own line; on: the live line again

All 66 profile gates, scripts/local-gate.py (backend and frontend shards), semgrep and the flake-pattern ratchet passed on this commit; the one red, npm --prefix website run test:electron (missing electron modules on that host), fails identically on the base. A live hand-off to the Bot was not run (no Kiro sign-in on that host).

Real-machine verification

Machine: EC2 m7i.2xlarge, Ubuntu 24.04.5 LTS x86_64, 8 vCPU / 32 GiB
Before (main 286d87a): python3 -m pytest -n0 -q test/test_mate_worker.py::TestMateFileForMember::test_an_enabled_apps_server_launches_as_the_gateway_registers_it_now (this PR's test on the base tree) -> AssertionError on the acme:srv entry, which still has 'command': '/old/slot/bin/python3' and 'env': {'A': 'old'}; on the test-mode gateway above, the Bot's worker spec kept the deleted interpreter and starting the entry raised FileNotFoundError: [Errno 2] No such file or directory
After (head 94d3c53): the same command -> 1 passed; the same gateway steps give a worker spec with the gateway's live interpreter, and the entry answers initialize with serverInfo={"name": "auto-improvement", "version": "1.0.0"}
Cleanup: each test-mode gateway stopped by its own pid and both worktrees removed; the instance is a disposable verification host with no inbound rules, terminated by the fleet's idle reaper

Related Issues

Part of #37400

Sibling sweep

Swept: git grep -nE "transport_for_file|_collect_app_mcp_servers|registered_app_mcp_servers" -- src/kiro_crew
Sibling: src/kiro_crew/agent_capabilities.py -- not affected -- a custom agent's owned copy already refreshes app server entries from the current install in _maintain_owned
Sibling: src/kiro_crew/mcp_gateway/mate_overlays.py -- not affected -- a dead target is never stubbed, so the worker starts the registered entry; a still-present old target is the residue the spec states

Pattern harvest

Not generalizable: the only copy of a gateway-resolved app launch line that outlived its install was the Bot file's; the custom-agent copy already re-reads it.

Checklist

  • A Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...); PR Hygiene does not count commits
  • 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 19, 2026 12:05
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 19, 2026
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 94d3c53e25018298ffbea53af82621b794ede737 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 19, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 94d3c53e25018298ffbea53af82621b794ede737 — 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 one note: the "keep the file's own fields, take the rest from the live app entry" rule now has a second hand-written copy, and the two copies already differ.

Notes

  • Item 3 — duplicate of src/kiro_crew/agent_capabilities.py:862-873: _maintain_owned already rebuilds an app entry from _collect_app_mcp_servers, leaves out the live autoApprove, and keeps only the copy's autoApprove/disabled. The new own = {k: v for k, v in entry.items() if k in _TRANSPORT_DROP} also keeps disabledTools. The two rules already disagree on which fields the copy keeps. Subtraction: give both sites one shared rule for which fields stay (or reuse one site's comprehension) so a single spelling remains.

What this change ships

Inventory (5 items) — 4 justified

Intent: a Bot keeps the tools from its apps' MCP servers after an upgrade removes the app's old install, with no hand edit of the Bot's file. FIX.

  1. A Bot's worker starts an enabled app's server with the gateway's current launch line instead of the copied one — justified
  2. A launch line typed by hand for an enabled app's server in a Bot's file is no longer used — justified
  3. The live entry's autoApprove stays behind; the file's own autoApprove/disabled/disabledTools are kept — duplicate of agent_capabilities._maintain_owned app-entry refresh
  4. A disabled app's server, a user server, and an app server whose name has a / keep the file's recorded line — justified
  5. A decision entry plus matching paragraphs in the crew-mode and agent-reach specs — justified

[FIRST-PRINCIPLES-REVIEWED] 94d3c53

Description read

[DESCRIPTION-READ] 46d351eaa1a7b5c3fcb272766eb06dca0dc824f6999d3184f713e64e78b434e5

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 19, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: the worker reads the app's current registered entry and keeps the Bot's own selection fields, so a stale install path is fixed at its cause and no Bot file is rewritten.

Notes

  • _use_registered_app_launch_lines reads mcp.json under _mcp_lock and calls _app_owned_mcp_keys() every time a worker is built. That cost is fine at the rate workers start, but don't let it creep into hot paths.
  • When the registered entry is missing (for example, an HTTP app whose backend is down), the worker quietly falls back to the file's dead line. A debug log at that point would make the "failed to start" report easier to diagnose.

[DESIGN-REVIEWED] 94d3c53

Description read

[DESCRIPTION-READ] a178e670edc49d08bbf5e37353b67f99d0bdc0266c12ee0e70e54010bec653f0

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 19, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 94d3c53e25018298ffbea53af82621b794ede737 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 94d3c53

Verdict parsed from the review's SHA-scoped output markers for commit 94d3c53e25018298ffbea53af82621b794ede737.

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

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 94d3c53e25018298ffbea53af82621b794ede737 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 94d3c53

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

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 19, 2026
@bolichen97
bolichen97 force-pushed the fix/37400-app-server-launch-line branch from 7031eb1 to 07491bf Compare November 19, 2026 17:34
@bolichen97

bolichen97 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

self-added: no
mechanism: re-point a Bot-file server only under an enabled app's own unaliased app:server key

  • span=c4bfb3f40151 Base aliases misidentify app ownership after a name collision

fixed in 07491bf: a Bot-file server is re-pointed only when its name carries the : of an enabled app's own app:server key. mcp_server_alias drops the app: prefix and turns every : into - for a /-bearing name, so an alias such as scope-pkg, which a user server can hold, never qualifies.
The user's scope-pkg keeps the file's line. The test holds a user scope-pkg and the app's scope-pkg-2 and asserts both keep the file's entry; it fails on 7031eb1 at servers["scope-pkg"] == user.
The collision-aware map (mounted_aliases) exists only inside a rebuild and is never stored, so the worker cannot read it. A /-named app server keeps its recorded line, which is main's behaviour; the Crew Mode spec and the decision record say so.
[operator: bolichen97]

A Bot's file copies each MCP server's launch line when the server is
added. For an app's server that line names the interpreter of the
install the app ran from then, so an upgrade that removed that install
left the Bot's worker unable to start the server while ordinary chats
started it, and only a hand edit of the file fixed it.

The worker projection now takes an enabled app's server as the gateway
registers it now and keeps the file's own approvals, switch-off and
per-tool limits for it. Every other server in the file keeps the launch
line the file recorded, and the file is not rewritten. The decision is
recorded in docs/decisions.

Part of #37400
@bolichen97
bolichen97 force-pushed the fix/37400-app-server-launch-line branch from 07491bf to 94d3c53 Compare November 19, 2026 21:02
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in docs/decisions/README.md and the Crew Mode spec since this head's CI ran (433d99b -> 286d87a). The two Windows reds on the old head were main's flaky tests, test_the_pass_fix_is_exported_to_the_pr_queue (#39485) and test_the_bar_is_resent_only_when_its_items_change (#39566); their fixes #39545 and #39505 merged after this branch's base and are now under it. The code is unchanged; the spec's broker residue sentence now names the one server that stays wrapped (an env naming a secret:// reference). CI re-running on 94d3c53.

[operator: bolichen97]

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention labels Nov 20, 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.

Checked head 94d3c53: the worker now takes the current registered launch entry only for a Bot file server keyed under an installed, enabled app's own app:server name. It keeps the file's own autoApprove, disabled and disabledTools and drops the registered entry's approvals, so no new auto-approval reaches the worker. User servers, disabled apps and aliased names keep the recorded line, and the Bot file is never rewritten. The new test fails against the base tree and passes here, and 982 tests across the worker, overlay and capability suites pass on this head. Nothing blocks.

@KiroCrewCaptain
KiroCrewCaptain merged commit 9eba5f2 into main Nov 20, 2026
101 of 106 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the fix/37400-app-server-launch-line branch November 20, 2026 00:55
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 20, 2026
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