Repository navigation
feat(mcp-dashboard): chat_folder_delete removes an empty sidebar folder - #16337
iamwhatever wants to merge 2 commits into
Conversation
The dashboard MCP server could create, move and file into sidebar folders but had no way to remove one, so an agent that organized sessions left every emptied folder behind for the person to delete by hand. chat_folder_delete deletes a folder only when it holds no subfolder, no live session and no archived session, so it never unfiles or relocates anything. The endpoint still refuses every app and crew-member caller.
Design Review (Opus 5.5) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS The description and the remediation hint both say "empty-only", but the endpoint also refuses empty folders for cron, channel and saved-settings reasons that the agent cannot fix. Watch
[DESIGN-REVIEWED] 8530d12 Description read[DESCRIPTION-READ] 248ee12f03780e73ede2e002973c423c0499d401c9f21d88bd994b60ca486a2b 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) — 🔴 BLOCKPremise-level review of First-Principles-Verdict: BLOCK The new Not justified as shipped
What this change shipsInventory (8 items) — 4 justifiedIntent: let an agent delete a sidebar folder it has emptied. This is an ADDITION.
BlockersSecond spelling of the folder cleanup delete [FIRST-PRINCIPLES-REVIEWED] 8530d12 Description read[DESCRIPTION-READ] eb6e39cfd76ce1cc270190d9f27ca81ea4c5cfbf1b5790fecd7ffb73ff2c6d14 That sha256 names the PR description this verdict read. Recompute it with |
GPT 6.1 Review — 🔴 changes requested (blocking)GPT 6.1 found at least one blocking issue that must be resolved before merging This comment is updated in place on each push. BLOCKING -- src/kiro_crew/dashboard/chat_folders.py:2329 -- Empty-only deletion loses a concurrently archived session’s filing
Adjudication (Opus 5.5) — is blocking on each finding proportionate?F1 (fenced): The harm is real but small: the session loses its folder placement, while its transcript survives and shows as unfiled. Every step it needs is in the code:
Recovery: the person files the session into a folder again by hand. No transcript content is lost. 🏷️ Fenced finding(s) machine-flagged as likely edge caseThe security fence keeps these findings blocking regardless of adjudication; the only clearance path is a human override. The annotate-only pass judged the condition combination each one requires extreme, and pre-drafted the override rationale below. A repository writer must independently verify a rationale before posting it — it is machine-authored, and a wrong override on a security-class finding ships exactly the class the fence exists to stop.
False positive or not applicable? A repository writer can comment: |
Opus 5.5 Review — ✅ no blocking findingsReviewed Review detailsNo findings block this merge. FINDING — src/kiro_crew/mcp_dashboard.py:528 — a [OPUS-REVIEWED] 8530d12 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
a2af94c to
0ff774c
Compare
0ff774c to
40a336b
Compare
0728b30 to
0468a28
Compare
…tore lock Review found that the tool checked subfolders and live sessions, then sent a plain DELETE. A session filed between that read and the DELETE was unfiled by the full delete. The tool now sends ?if_empty=true. In that mode the endpoint counts archived sessions first, then re-checks subfolders and live slots inside the folder-store mutation that removes the row. A slot PATCH sets folder_id before it re-checks the folder under the same lock, and a child create checks its parent there too, so neither can land between the check and the removal. The mode never unfiles a slot or lifts a subfolder. The plain DELETE the sidebar sends is unchanged.
0468a28 to
8530d12
Compare
|
Closing this replacement PR so @chenmingwei23 can finish the design on #15753. Thanks — the rebase onto current |
Rebase notes
mainhas since addedchat_folder_file_selfandsession_reloadto thekirocrew-dashboardset and bumped the documented tool count. The two doc conflicts (docs/architecture/mcp.mdtool-inventory row,src/kiro_crew/docs/index.mdSession Control row) were resolved to keep both main's additions and this PR'schat_folder_delete, and the documented tool count is now 29 (not 28) acrossindex.mdandsession-control.md. No code conflicts; all auto-merged hunks verified.Overlap with #16331 (
delete_contents, replacing #13878): that in-flight PR adds an opt-indelete_contentssubtree-delete to folder deletion and touches the same files (chat_folders.py,mcp_dashboard.py,validation.py,mcp_tool_titles.json, docs). This PR is the complementary empty-only delete. They are not mutually exclusive — one adds?if_empty=true, the other adds a subtree mode — but whichever lands second will need a small rebase over the other's edits to the shared tool list / count / schema registry. No conflict exists against currentmain.Problem / Motivation
Goal: An agent that organizes sidebar sessions can delete a folder it has emptied.
The
kirocrew-dashboardMCP server can read the folder tree, create folders, move folders and file sessions into them, but it has no delete verb. When an agent moves every session out of a folder, the empty folder stays in the sidebar and the person has to delete it by hand. An agent asked "delete these empty folders" can only answer that it has no tool for it.Why it matters
Session control creates folders as a side effect (
session_createwithfolder=,chat_folder_file_self, mkdir -p inchat_folder_create). Every workstream an agent stands up leaves folders behind, and the only cleanup path is clicking each one in the sidebar.Not a goal
DELETE /api/chat/folders/{id}keeps refusing both.What changed (motivation -> approach -> change)
Goal: remove a folder with nothing in it, without giving the MCP set any way to unfile or relocate a session.
Approach: the tool calls the existing
DELETE /api/chat/folders/{id}route with a new?if_empty=truemode. The emptiness check has to live in the endpoint: a check in the tool reads the tree, then deletes, and a session filed in between would be unfiled by the full delete (review caught this on the first head). Empty-only keeps this server's posture: nothing it does can unfile a session, lift a subfolder or leave an archived session pointing at a gone folder.Change:
mcp_dashboard.py: newchat_folder_delete(folder). It passes the same_refuse_tree_shaping_if_unverifiablegate as create/move, resolves the folder by id or path, refusesroot, and sendsDELETE ...?if_empty=truewith the verified caller key. Afolder_not_emptyrefusal is returned with a hint to empty the folder first. Module docstring updated.chat_folders.py(api_chat_folder_delete): newif_emptymode. It counts archived sessions first (a disk scan, off the loop), then re-checks subfolders and live slots inside themutate_folderscallback that removes the row. A slot PATCH setsfolder_idbefore it re-checks the folder under that same lock, and a child create checks its parent there too, so neither can land between the check and the removal. The mode never unfiles a slot or lifts a subfolder; refusals are 409folder_not_emptyand carry no count or name. The plain DELETE the sidebar sends is unchanged.mcp_core._delete: takessession_key=like_patch/_put, so a strictly-verified key is what reaches the endpoint.validation.py:CHAT_FOLDER_DELETE_SCHEMA, registered inMCP_DASHBOARD_SCHEMAS.agent.py: conductor grant audit records the verb as WITHHELD.docs/architecture/mcp.md(the app-delete section now names this tool and its one residue),session-control.md(tool table, count 27 to 28, note on the empty-only rule),docs/index.mdcount,docs/architecture/mcp.mdtool list,mcp_tool_titles.jsontitle.Known residue
One seam stays open, by choice. A session that is filed into the folder and then closed while the archive scan runs is in neither store when the locked check runs: closing pops it from the live slot table before its archival save lands. The delete then proceeds, and that archived transcript keeps the gone folder's id. Nothing in the transcript is lost: every reader renders a session whose folder is gone as unfiled, which is the state the person's full sidebar delete already leaves on every archived session in the folder it removes. It needs the person to file and close a session into the very folder their own session is deleting, inside one disk scan; apps are refused before any of this runs. Closing it would mean registering every in-flight close across all of the slot-removal paths (about twenty pop sites), which this verb does not justify.
docs/architecture/mcp.mdrecords the same.Backwards compatibility
Compatible: one new tool, one optional keyword argument on
_delete, and one optional query flag on the delete route. Without the flag the route behaves exactly as before.Tests
test/test_chat_folder_delete_if_empty.py(new, real route): deletes an empty folder; refuses a live session, a subfolder and an archived session without unfiling or lifting anything; a session filed during the archive scan is still seen and still refused; a folder deleted during the scan answers 404; without the flag a full folder is still deleted and unfiled as before.test/test_mcp_dashboard_folders.py::TestFolderDelete: sends?if_empty=truewith the verified key; does no tree pre-check of its own; surfaces afolder_not_emptyrefusal without naming a session; refusesrootand an unknown folder without writing; surfaces the endpoint's app refusal verbatim; refuses an unverifiable caller; requiresfolder.test/test_mcp_dashboard_registration.pyandTestAdvertisedSet: the ratcheted tool set includeschat_folder_delete.test/test_session_control_doc.pypasses against the updated page and count.Ran locally: the files above plus the conductor, session-control, member-gate, caller-identity and call-site-auth suites (about 2,300 tests), all green.
Manual verification
N/A: the tool is a proxy over an existing route whose person / app / member behavior is already covered by the route tests; the new logic is the empty-only gate, which the unit cases exercise.
Related Issues
no linked issue: new tool request from the dashboard owner
Checklist