Repository navigation
fix(folders): refuse an agent move that makes a same-name sibling folder - #25627
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the PATCH route's existing sibling-name check now also covers a parent change, and nothing is taken away. [DESIGN-REVIEWED] 964ad2f Description read[DESCRIPTION-READ] 9af95146633fd36a4f6302fc9623e10c125b0fbf261a94a40535465b6bba232d 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 The fix extends the existing agent same-name guard to the one write that skipped it, so nothing blocks. What this change shipsInventory (5 items) — 5 justifiedIntent: stop an agent from ending up with two sibling folders that have the same name and so can't be told apart by path, by moving one of them. This is a FIX (#15343).
[FIRST-PRINCIPLES-REVIEWED] 964ad2f Description read[DESCRIPTION-READ] 3ecb96de9a4ffed418a8ffba40117e61be4b0ee33138c4111340871809deb398 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: |
Create and rename already refuse an agent caller a sibling whose
case-folded name is taken under the same parent, but chat_folder_move
sends a parent_id-only PATCH, so an agent could move Alpha under a parent
that already holds an Alpha; the two then share one path and every later
path lookup of either is refused as ambiguous.
PATCH /api/chat/folders/{id} now runs the same test, under the same lock,
when an internal-transport caller changes the parent, comparing the
folder's resulting name with the destination's children (409
folder_name_exists). A write that keeps both the name and the parent is
not tested. chat_folder_move explains the refusal and names the remedy.
The browser keeps a person's freedom to put two alike.
Fixes #15343
d44a6d3 to
964ad2f
Compare
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: fix (5 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: the folder PATCH route's agent same-name-sibling check now also runs on a reparent (chat_folder_move sends a parent_id-only PATCH), not only on a rename; the move tool explains the 409, and tests cover move, move-and-rename, reposition in place and the person's unchanged freedom. Spec files changed as a ride-along (a minority of the diff on both file count and changed lines), not reviewed as a design decision: docs/system-specs/modules/session-control.md.
Problem / Motivation
Goal: an agent cannot make two sibling folders with the same name by moving one.
#15186 made
POST /api/chat/foldersrefuse an agent caller a same-name sibling, and #15158 applies the rule to an agent rename throughPATCH /api/chat/folders/{id}. A reparent still gets around it:chat_folder_movesends aparent_id-only PATCH, so an agent can move its folderAlphaunder a parent that already has anAlpha.Why it matters
The two folders then share one path, and every later path lookup of either one is refused as ambiguous, so the agent (and the person's own path-based tools) can no longer address either folder by path.
Not a goal
Intended? / Repro
Intended? No. The rename check's own comment says "an agent never makes a same-name sibling, because the two then share one path" (
src/kiro_crew/dashboard/chat_folders_routes.py:560-567), and the issue is the First Principles finding on #15158.Repro (read on current main): in
api_chat_folder_update._applythe sibling test is guarded byif refuse_duplicate_name and "name" in changes:(chat_folders_routes.py:560).chat_folder_movebuildsmove_body = {"parent_id": dest_id}with noname(mcp_dashboard_folder_runs.py:343-345), so the test is skipped: movingAlpha(top level) underBravo, which holds anotherAlpha, returns 200 and leaves twoAlphas underBravo.What changed (motivation → approach → change)
Symptom: a move makes a same-name pair. Cause: the sibling test ran only when the PATCH carried a name. Change: run it when the name OR the parent changes.
chat_folders_routes.py_apply: for an internal-transport caller, the test runs whennameis in the PATCH or the resulting parent differs from the current one. It compares the folder's resulting name (the new one, else its own) with the destination's children, case-folded and trimmed, under the folder-store lock, over the whole tree; the folder's own row is excluded. A PATCH that keeps both (a reposition, a colour) is not tested, so a folder that already has a twin can still be reordered. Same 409folder_name_exists; the audit line now reads "rename or move".mcp_dashboard_folder_runs.pychat_folder_move: turnsfolder_name_existsinto a plain explanation and names the remedy (rename one first), aschat_folder_updatedoes.src/kiro_crew/docs/session-control.md(tool table) anddocs/system-specs/modules/session-control.md: name the rule for moves.Security
area: dashboardroute; no listener, bind or auth change. The new refusal only narrows what an agent caller may write; browser callers are unchanged.Backwards compatibility
Behavior change for agent callers only: a move that would make a same-name sibling is refused with the code create and rename already use. Every other move is unchanged.
Removes nothing: no key, field or error path is removed.
Tests
test/test_mcp_dashboard_folder_update.py(the endpoint, through a real aiohttp app, and the tool):test_an_agent_cannot_move_a_folder_beside_its_namesake: fails on main (200).test_an_agent_cannot_move_a_namesake_to_the_top_level: fails on main.test_an_agent_may_move_a_folder_where_its_name_is_free.test_a_move_and_rename_in_one_write_checks_the_new_name.test_a_reposition_in_place_is_not_checked.test_the_person_may_still_move_a_folder_beside_its_namesake.test_the_move_tool_explains_a_same_name_refusal.test_a_move_is_left_to_its_own_toolmoved the nestedAlphato the top level beside the otherAlpha, which this change now refuses (409). It now movesBravounderAlpha, where the name is free, so it still checks only the channel rule.Proof: not provable -- other: this host runs no local tests; CI runs them
Manual verification
N/A: no UI change. Static gates run locally: black, isort, flake8,
scripts/docs_lint.py, comment-history gate.Related Issues
Fixes #15343
Sibling sweep
Swept: git grep -n "refuse_duplicate_name|folder_name_exists" -- src/
Sibling: src/kiro_crew/dashboard/chat_folders_routes.py -- changed here (PATCH)
Sibling: src/kiro_crew/dashboard/chat_folders_records.py -- not affected (create already refuses)
Sibling: src/kiro_crew/mcp_dashboard_folder_runs.py -- changed here (move tool message; the rename tool already explains the code)
Sibling:
POST /api/chat/folders/reorder-- not affected (changes order only, never a parent)Pattern harvest
Not generalizable: one guard extended to the write that bypassed it.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributed under the project's Apache-2.0 license.