Repository navigation
fix(apps): launch an app's own agent on kiro-cli from a Crew-written copy - #21867
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS The fix pins the spec where kiro-cli resolves the name, which is the mechanism #19323 option B asks for. The one open premise is a kiro-cli behaviour the author measured on a single version, so it is a note, not a block. Notes
What this change shipsInventory (8 items) — 7 justifiedIntent: a palette-opened app agent on Kiro runs the app's own registered spec, never a same-named checkout spec written after the check. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] dbe3255 Description read[DESCRIPTION-READ] cc2e34e31f7982e58069f1e834b6ba9dc237e624a07688a670c27c4b161418df 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: it implements the maintainer's option-B ruling on #19323, the breaks are listed and accepted, and the new launch folder fails closed on Linux. Notes
[DESIGN-REVIEWED] dbe3255 Description read[DESCRIPTION-READ] bf52455d8557b27bdb7f975dca724866cbc2d15f0711fd32f3e74dd400df4acc 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: |
5c98b03 to
d853674
Compare
|
|
|
|
|
|
|
|
|
|
d853674 to
0f1b404
Compare
0f1b404 to
80ab4b0
Compare
|
Rebased: main moved in src/kiro_crew/dashboard/chat_runner.py and nearby files since this head went green (6fd7c1f -> bdb1c87); CI re-running. The PR's own changes are identical to 6d85e69. @chenmingwei23 the Sensitive Change Review needs a sign-off from a maintainer who is not bolichen97, on this head. Fill the template below and paste it into an "Approve" review on 7761091: [operator: bolichen97] |
|
|
|
|
Rebased onto main @chenmingwei23 the Sensitive Change Review needs a sign-off from a maintainer who is not bolichen97, on this head. Fill the template below and paste it into an "Approve" review on c362632: [operator: bolichen97] |
|
|
Redesign per the maintainer ruling on GPT's launch-name finding: kiro-cli now runs the app's launch copy from an empty Crew-owned folder, so no checkout Sensitive files on this head: @chenmingwei23 the Sensitive Change Review needs a sign-off from a maintainer who is not bolichen97, on this head. Fill the template below and paste it into an "Approve" review on fce1a9c: [operator: bolichen97] |
|
|
|
[operator: bolichen97]
|
|
|
New head for two review fixes (no sensitive-file change since fce1a9c). Redesign per the maintainer ruling on GPT's launch-name finding: kiro-cli now runs the app's launch copy from an empty Crew-owned folder, so no checkout Sensitive files on this head: @chenmingwei23 the Sensitive Change Review needs a sign-off from a maintainer who is not bolichen97, on this head. Fill the template below and paste it into an "Approve" review on 3a346fb: [operator: bolichen97] |
|
|
|
New head: the tool-call path mapping now follows the spelling the tool was given and refuses what it cannot trace; the checkout reservation of the launch prefix is removed; rebased onto main, whose split of Sensitive files on this head: @chenmingwei23 the Sensitive Change Review needs a sign-off from a maintainer who is not bolichen97, on this head. Fill the template below and paste it into an "Approve" review on 3d52349: [operator: bolichen97] |
|
|
|
[operator: bolichen97]
|
|
New head for one review fix (a metadata lock the event loop can take without waiting on file I/O) and two test skips; rebased onto main. No sensitive-file change since 3d52349. Sensitive files on this head: @chenmingwei23 the Sensitive Change Review needs a sign-off from a maintainer who is not bolichen97, on this head. Fill the template below and paste it into an "Approve" review on dbe3255: [operator: bolichen97] |
|
Problem / Motivation
Goal: On the Kiro backend, a session a palette command opened for its app's own agent runs the app's registered spec, even if the checkout gains a same-named spec after the check.
kiro-cli takes the agent as a name and looks it up in the checkout first. An app's spec is registered as
~/.kiro/agents/<app>--<agent>.jsonbut declares the bare name. The per-turn check refuses a checkout that claims that name today. But a spec written between that check and the spawn still wins, and the app-authored prompt then runs with that spec's tools and auto-approvals.Why it matters
The palette sends an app-authored prompt, often with
autoSend. If the wrong spec wins, that prompt runs with grants the app never had. The maintainer ruling on #19323 (option B) asks for the spec to be pinned on the path that picks the file. The per-turn guard stays until this is proven.Not a goal
app_command_agent_refusalor theapp_agent_refusedrow. The ruling keeps the guard until B has merged; that is a separate follow-up.What changed (motivation → approach → change)
kiro-cli resolves a bare name project-first, so pinning the file needs a name only Crew writes. That is option B of the ruling.
On a Kiro turn bound to an app agent,
apps/agent_launch.pyreads the app's own<app>--<agent>.jsonby its path and checks it declares the agent. It writes a copy to~/.kiro/agents/kirocrew-app-launch-<app tag>-<agent tag>.jsonwith that name. The copy is the spec's native skill view, the one every Kiro launch runs:skill://resources are dropped and the agent's skills come throughskill_search. Past that onlynameanddescriptionchange, so grants and trust are the app's own. The copy's name is wire-only, like KAS'skas_wire_agent_id: kiro-cli is asked for it on--agentand insession/set_mode, and the session's per-session control-plane elements are read from it. The session keeps the bare agent name as its identity, so governance, task profiles, audit, hooks and usage are unchanged. A live session started without the copy is retired first; after the claim, a Kiro provider that did not ask kiro-cli for exactly that copy is refused and reset.kiro-cli takes project agents from its process folder, not the ACP session's, and runs tools,
file://resources andAGENTS.mdin the session's (measured on kiro-cli 2.33.0). So kiro-cli runs the copy from an empty folder,<data home>/app-agent-launch/cwd, while the session still works in the checkout. No checkout.kiro/agentsis ever read for the name, however late a writer acts, so the name needs no secret: both tags are plain hashes. On Linux the sandbox seals the folder read-only, and Crew's launcher enters it by name after its seals, then checks it is read-only and empty or stops: a process started inside it would keep the writable mount under the seal. On macOS and Windows it is as safe as~/.kiro/agentsitself. It is made before every spawn, write-fenced from the file tools, and checked empty at every spawn. kiro-cli reports a tool call's diff path against that folder, so the diff follows the spelling the tool was given, resolved in the session's folder; a call it cannot trace is left unanchored, which the edit gates refuse. Crew's own reads of the spec (control plane, ref guard) take the copy by its path, never by name. Pooled MCP stubs come from the registered spec's overlay entry<app>--<agent>. Agent-by-path in kiro-cli would retire the folder (follow-up #22783). Once the turn holds its session, the session is pinned to the app's registered file, soskill_search, dollar skills, the injected skill directory and Crew's injected agent prompt read that file by its path, and a checkout's same-named spec never sets them. The spawn holds the copy as its prepared view, a search agent exactly when the projection says so, and makes the same launch-steering decision every Kiro launch makes.apps/agent_launch.py,apps/manager.py,apps/bridges_agents.py_deregister_agents,apps/bridges_register.py_prune_stale_app_resourcesacp/launch.pyprocess_directory,acp/runtime.py_map_launch_cwd_paths_pool_lookup,sandbox_leaves.py_CREW_READONLY_LEAVES,sandbox_precreate.py,security/paths_lists.py_WRITE_PROTECTED_HOME_PATHS,sandbox_wrap.py,sandbox_spawn.py,sandbox_argv.py,sandbox_plan.py,sandbox_launcher_program.pyexec_cwdenter_exec_cwdproject_agent_view, shared with the projection); the spawn holds it as its view and runs the launch-steering decisionacp/skill_projection_parts/preparation.py,acp/skill_projection.py,agent_sdk/drivers/acp.pynative_skill_view,apps/agent_launch.py,acp/runtime_spawn_launch.py,acp/runtime.py_adopt_skill_projectionskill_scope_pin.py,agent_discovery_parts/skill_scope.pysession_skill_globs,context.py,context_assembly/session_start.py,context_assembly/turn.py,context_assembly/turn_message.py,context_assembly/agent_spec.pylist_agentsandis_internal_agent_specrostersagent_spec_format.py,apps/manager.py,agent_discovery.py,agent_discovery_parts/agent_roster.py,agent_discovery_parts/spec_fields.py--agent,set_modeand the control-plane read; reported modes map back to the bare nameacp/runtime.py,acp/runtime_spawn_launch.py,acp/runtime_session_setup.py(stubs by the bare name),acp/runtime_session_create.py,acp/runtime_session_load.py,acp/runtime_session_setup.py,acp/session_handle_model_selection.py,acp/session_handle_class.py,acp/session_handle_dispatch.pyapp_launch_agent, never from the warm pool (bypass_app_launch); only the Kiro runtime gets it; a reset or compaction restart is asked for the same copysession_allocation_parts/get_or_create.py,session_parts/policy.py,providers/acp.py,providers/acp_runtime_start.py,dashboard/chat_runner.py,session_lifecycle_parts/parked_queue.pyallocation_identitydashboard/chat_turn/turn_admission.py_check_owner,dashboard/chat_turn/app_agent_binding.py,dashboard/chat_turn/turn_locals.pyDocs updated in
docs/system-specs/modules/app-kit-platform.md,command-bar.md,metrics.mdandlearn-cron-dashboard.md.Backwards compatibility
Breaking: an app agent named with the
kirocrew-app-launch-*prefix is refused. Writer sweep on origin/main @ 0e6b1f0:git grep kirocrew-app-launchandgit grep app-agent-launchfind no writer or reader; the prefix and the launch folder are new.An app agent's own MCP servers that kiro-cli starts now begin in the empty launch folder, not the checkout; one that relies on a relative path or its starting folder no longer finds the checkout there. Tools, hooks,
file://resources andAGENTS.mdstill run in the checkout.Removes nothing: the copies are new files; every agent listed today is still listed, and slot, saved chat and
app_agent_ownerkeep the bare name.Tests
test/test_app_agent_launch_copy.py: the copy is the registered spec under the reserved name; no rewrite when unchanged, refresh when changed; refusals for unregistered, wrong name, foreign file, link, and squatting spec; a checkout spec of the copy's name, by stem or by declared name, refuses neither the spawn nor the turn; rosters hide copies; deregister removes only that app's copies; a manifest update removes only the dropped agent's copy; two homes name the same agent the same way.test_a_launch_copy_runtime_keeps_the_agent_name_governance_bindsshows a task profile bound to the bare name still resolves for a launch-copy runtime, kiro-cli gets the copy's name and reported modes map back;test_the_session_control_plane_is_read_from_the_spec_kiro_cli_runsshows the control-plane elements come from the copy, not the bare view; the copy name passesis_registered_agent_name; only a Kiro provider hands it on.test_a_project_spec_written_between_check_and_spawn_is_not_the_one_launchedwrites the same-named project spec after the check passes, then asserts the session keeps the bare name, kiro-cli is asked for the copy, and the copy holds the app's prompt and grants. Also: KAS keeps the bare name, an unwritable copy refuses before any session, a claimed Kiro session started as the bare name is refused and reset, an unbound Kiro turn is unchanged.test/test_app_command_agent_guard.py: the Kiro cases now select Kiro, register the spec, and their provider reports the copy. The test for each working path (Kiro, KAS, refusals, fork, create) still passes.test/test_agent_spec_hardened_reads.py: the three new hardened reads are labelled.TestTheLaunchDirectory: created empty and owner-only; a spec placed in it, or a link at its name, refuses the turn; it is read-only (not hidden), precreated, nofollow and write-fenced; the Linux plan seals it read-only in every mode and the Seatbelt profile denies writes but not reads.TestReportedPathsPointAtTheSession: adifforlocationspath under the launch folder names the checkout; other paths and text are left;AcpRuntime._map_launch_cwd_pathsmaps by the frame's session. Process, inTestTheProcessStartsInTheLaunchDirectory: behind Crew's Linux launcher the process is created in its workspace and the plan carriesexec_cwd; without it the process is created in the folder; the launcher enters only a read-only, empty folder and stops otherwise. InTestCrewJudgesTheCopyItWrote: the copy is read by path and must carry the owner marker; stubs come from<app>--<agent>; the ref snapshot is never read by name; the control plane refuses without the copy. Reverting the mapping, the launcher entry, its seal check, the control-plane read or the stub name each makes a test fail.test_the_copy_is_a_skill_view_with_no_skill_resources(noskill://,kirocrew-coreandskill_searchpresent, prompt and grants kept);test_a_spec_that_forbids_skill_search_refuses_the_turn;test_skill_search_scopes_by_the_apps_registered_fileruns a palette turn while the checkout gains a same-named spec with its own skill mapping, and both theskill_search/dollar scope and the injected directory take the app's mapping, while an unpinned session still resolves project-first;test_a_turn_that_is_not_the_launch_copy_unpins_its_session;test_a_turn_refused_before_the_claim_keeps_the_running_turns_pin;test_the_injected_agent_prompt_is_read_from_the_pinned_file;test_the_copy_is_a_search_agent_exactly_when_its_view_is;test_a_newer_projection_keeps_the_copy_the_spawn_held;TestTheCopyRunsTheLaunchSteeringDecisiondrives a real spawn as the copy and shows the inherit decision run on the copy's view in both directions. Disabling the pin or the adoption makes 3 of these fail.test/test_agent_spec_hardened_reads.pylabels the two new spec reads.test/windows-expected-failures.txtlistsTestTheCopyRunsTheLaunchSteeringDecisionas a strict xfail. It drives a real spawn through the sharedtest_acp_spawn_offloadharness, which simulates only asyncio's subprocess, and Windows spawns through the cleanup-owned child (Windows original child pin/identity unavailable). The decision it pins is platform-independent and runs on Linux and macOS.test/test_sandbox_protected_name_holds.pycounts the new root-level directory (three entries per tier),test/test_security_gate_liveness.pythe four fence lines, andtest/test_sandbox_refactor_generated_programs.pythe new launcher plan key.kirocrew.test/test_app_agent_launch_copy.py5 times in a row (51 passed each), and in reversed order with-n0(51 passed).Manual verification
A real kiro-cli 2.32.0 ACP session, started as
kiro-cli acp --agent <copy name>. The copy was built bypublish_app_agent_launchfrom a probe app spec. It sat in a throwaway checkout's.kiro/agents, beside a same-named baredeploy.jsonwith a different prompt. It was not placed in the real~/.kiro/agents; kiro-cli resolves both scopes by the same name lookup.session/newcurrent modeavailableModes;set_modeto it okPINEAPPLE(the app's prompt; the bare spec says ORANGE)note.txtwithfs_read(in the copy'sallowedTools)MANGO, no permission requestfs_write(not allowed)Creating out.txtProcess folder vs session folder, kiro-cli 2.33.0, process started in an empty folder,
session/newnaming a fake checkout: only the process folder's.kiro/agentswas listed;pwdprinted the checkout; a relative read got the checkout's file; a relative write landed in the checkout; the write's diff preview named the process folder; relativefile://steering andAGENTS.mdcame from the checkout.Not run: a palette command through a full gateway; the unit turn tests cover that path against the session port.
Related Issues
Part of #19323
Pattern harvest
Rule candidate: when a host resolves a name project-first, start it where no project spec can sit rather than racing a scan against its read.
Pattern: a check-then-use scan of a writable directory guarding a lookup in that same directory.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)