Repository navigation
feat(mcp): session_set_project sets the project of a session the caller created - #15443
Pearcekieser wants to merge 1 commit into
Conversation
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
1 similar comment
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
eec41e0 to
838818d
Compare
|
Intent: let an agent set the project directory of an idle, unpinned session it created, through the same path checks |
Design Review (Opus 5.5, fork) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS The PR never weighs an obvious simpler option: a Watch
[DESIGN-REVIEWED] 5b04781 Description read[DESCRIPTION-READ] 0a1f99701d62651a24cbb8d344abb993805a0000be30cf514db88720dbb72ef6 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, fork) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS The tool is pitched for conductors, yet the diff withholds it from them and no conductor skill calls it. A Not justified as shipped
What this change shipsInventory (7 items) — 5 justifiedIntent: let an agent point a session it created at a different project directory, such as a new worktree. ADDITION.
[FIRST-PRINCIPLES-REVIEWED] 5b04781 Description read[DESCRIPTION-READ] 5fbac07197a28f268af5f8842e91ca8d24dedd1f76f6fa09fd58574b2d166e8d That sha256 names the PR description this verdict read. Recompute it with |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings block this merge. One advisory finding. FINDING — src/kiro_crew/dashboard/session_control.py:6170 — if a turn consumes the armed reset while the forced save is running and the save then fails or is refused, the change has already taken effect (the target runs in the new CWD and [OPUS-REVIEWED] 5b04781 |
838818d to
44883ce
Compare
|
self-added: yes
|
|
self-added: yes
|
44883ce to
e0e6882
Compare
|
self-added: yes
|
|
self-added: yes
|
d00a814 to
d6a5c51
Compare
|
self-added: yes
|
|
self-added: yes
|
d6a5c51 to
f544216
Compare
|
Rebased onto main The conflict came from #15158 ( The open GPT finding (span |
f544216 to
8cab878
Compare
|
Rebased onto current main ( |
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
|
This PR adds session_set_project, which lets a conductor move a worker it created to a new project directory (for example a fresh git worktree). It reuses set_project's existing write and path checks behind a creator-only fence. I read the description, the file list and the lane verdicts on head 8cab878. The change goes straight at the gap, so I have no root-cause objection. It is on hold because GitHub reports mergeable=CONFLICTING (DIRTY, label "merge conflict"). It is also a permission-sensitive verb: one agent changes the working directory of another session and restarts it there, and the Design and First Principles lanes both say CONCERNS on the current head. GPT and Opus report no blocking findings. Please rebase onto main, answer the Design and First Principles items for the new head, and have a maintainer review the ownership fence, since this widens what one agent can do to another session. — crew-pr-reviewer |
|
Thanks for the read. Status on each item: The rebase is done locally: one commit on The Design and First Principles CONCERNS both point at the same thing: the tool is withheld from unattended conductors, and a Agreed on a maintainer review of the creator-only fence once the design is settled. |
|
Rebased onto current main again ( |
|
Rebased onto current main ( |
…er created Adds session_set_project to kirocrew-dashboard and POST /api/session-control/set-project. The verb reuses the set_project directive's path check and commit (split into resolve_project_path and commit_project), and reaches only unpinned, idle sessions the caller created. The target's conversation resets at its next turn boundary.
|
Rebased onto current main ( |
|
Thank you, @Pearcekieser, for this and for keeping it rebased so diligently. We are closing it for now. The need is real, but the Design and First Principles reviews pointed to a smaller shape: a The branch is left untouched, so you can reopen this PR at any time, or open a fresh one on current main, if you want to pick it back up. |
Problem / Motivation
Goal: an agent can set the project directory of a session it created, for example to point a worker at a new git worktree.
set_projectonly changes the calling session's own project. A conductor that opens a worker withsession_createcannot move that worker to a new worktree afterwards. It has to ask the user to change the project in the worker's tab, or tell the worker to callset_projecton itself, which costs a turn and only works once the worker is already running.Why it matters
Worktree-per-item is how conductors keep parallel workers from editing the same checkout. Without this, the conductor either needs a person to click through each worker tab, or has to spend a worker turn on setup before the real work starts.
Not a goal
set_projectalready applies.What changed (motivation → approach → change)
A project change restarts the target's session in a new CWD, so the new verb reuses
set_project's own write and is fenced harder than the other session verbs.session_set_project(target, path)is aTool(...)row in_session_tools()insrc/kiro_crew/mcp_dashboard.py(identitystrict, one declared route). It callsPOST /api/session-control/set-project, which is registered insrc/kiro_crew/dashboard/server_runtime/mcp_routes.pyand added to_STRICT_INTERNAL_API_PATHSinsrc/kiro_crew/dashboard/server.py. The tool description and its result both say the target resets at its next turn boundary.set_project_targetinsrc/kiro_crew/dashboard/session_control.pyrunsauthorize_target, then refuses a session the caller did not create (not_creator, checked whatever the fence verdict or the global switch say), a pinned one (pinned_target), a read-only relay archive (relay_archive_read_only, the shared refusal from feat(remote-crew): delete the turn relay; old relay chats are read-only #17662), and a busy one (target_busy: a turn in flight, attached sub-agents, queued messages, or a switch handler holding the slot lock). A closed session does not resolve (target_not_found).session_gone; a failed save (lock or I/O error) rolls back and answerspersist_failed. The rollback runs only while the project and the reset it armed are both still this call's values. If the target consumed the reset during the save, it already runs in the new directory, so the project stays, the slot is marked dirty for the periodic flush, and the error says so.CancelledError(gateway shutdown, client disconnect) raised by the forced save or the recent-projects write skipsexcept Exceptionand_audit_denials, so both awaits catch it, record the decision asallowedwithinterruptedset to the exception name, mark the slot dirty so the flush finishes the save, and re-raise._set_projectinsrc/kiro_crew/dashboard/session_directive_apply.pyis split intoresolve_project_path(sensitive path before and afterrealpath, must be a directory, data-home overlap) andcommit_project(write, and arm the deferred reset on a change). The directive and the new verb both call them; the directive's results and audit outcomes are unchanged.src/kiro_crew/dashboard/handlers/session_control.py; the MCP schema insrc/kiro_crew/validation.pyreusesset_project's absolute-path shape, withpathrequired. There is noclear: nothing needs a conductor to unset a worker's project.src/kiro_crew/channel.py), recorded as withheld from conductor auto-approval (src/kiro_crew/agent.py), titled insrc/kiro_crew/data/mcp_tool_titles.json, and documented insrc/kiro_crew/docs/session-control.md,src/kiro_crew/docs/index.md,docs/architecture/mcp.md,docs/system-specs/modules/session-control.mdand the Session control row ofdocs/feature-map/README.md.Backwards compatibility
Compatible: a new tool and route. The
set_projectdirective keeps the same checks, messages and audit outcomes; its body moved into two shared helpers.Tests
test/test_session_control_set_project.py(new, 45 cases): a created idle target takes the realpath and arms the reset; the change is saved withforce=Trueagainst the resolved history key before the call returns, an unchanged project is not saved, a refused or failed save rolls back without erasing a newer writer's project or a same-text write from the dashboard route (identity-token check), and a save that fails after the target consumed the reset keeps the new project; a cancel during either post-commit await still writes oneallowedaudit record and leaves the slot dirty, and a post-commit refusal is audited once as denied; the same project again arms nothing; sessions the caller did not create, pinned, closed, self, channel-linked and relay-archive targets are refused; a turn, queued messages, the slot lock and attached sub-agents refuse withtarget_busy; a turn starting, a pin or a channel link landing while the path resolves is caught by the second check, and a sub-agent attached while the lock is awaited is caught by the in-lock probe; sensitive paths (direct and through a symlink), a missing directory and a data-home overlap are refused; a refused caller's path is never resolved; an empty path is refused, and the MCP schema refuses a call withoutpath; the route refuses wrongly typed fields and is on the strict internal set; the tool sends the verified key and says the target resets. Mutation check: removing the creator refusal fails the three scope tests.Updated: the advertised-set pins in
test/test_mcp_dashboard_registration.pyandtest/test_mcp_dashboard_folders.py, the session-control count intest/test_session_control_doc.py, the dashboard tool-call table intest/test_session_control.py, and the reservation-reader list intest/test_slot_running_readers.py, which now registers_set_project_busyas a busy helper so it coversset_project_targetitself.Manual verification
N/A. The change is gateway-side state handling behind an MCP tool with no UI; the unit tests drive the verb, the shared path check, the route and the tool text. After the port onto the
Tool(...)table, 671 tests across the ten related files and 805 across the MCP dashboard, MCP tools, agent contract and docs suites pass locally.Related Issues
Fixes #15440
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)