Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions docs/architecture/mcp.md
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,7 @@ Managed servers, registered by `agent._MANAGED_MCP_SERVERS` and installed into
| `kirocrew-cron` | `kirocrew mcp-cron` (`mcp_cron.py`) | `cron_add`, `cron_list`, `cron_update`, `cron_remove`, `cron_remove_all`, `cron_pause`, `cron_resume`, `cron_trigger`, `cron_secret_request` |
| `kirocrew-core` | `kirocrew mcp-core` (`mcp_core.py` + `mcp_tools/`) | spawn/subagent, learn, task, messaging, artifact, workflow, knowledge and session-directive tools (see below) |
| `kirocrew-computer` | `kirocrew mcp-computer` (`mcp_computer.py`) | `computer_list_apps`, `computer_launch_app`, `computer_get_state`, `computer_click`, `computer_drag`, `computer_type_text`, `computer_press_key`, `computer_set_value`, `computer_scroll`, `computer_perform_action`, `computer_end_turn` |
| `kirocrew-dashboard` | `kirocrew mcp-dashboard` (`mcp_dashboard.py`) | `chat_folder_tree`, `chat_folder_create`, `chat_folder_move`, `chat_folder_move_session`, `chat_folder_file_self`, `chat_tag_list`, `chat_tag_create`, `chat_tag_update`, `chat_tag_assign`, `chat_tag_column_list`, `chat_tag_column_create`, `chat_tag_column_move`, `chat_session_pin`, `session_create`, `session_fork`, `session_stop`, `session_end_wait`, `session_set_model`, `session_reload`, `session_close`, `session_revive`, `session_send`, `session_broadcast`, `session_status`, `session_adopt`, `session_release`, `session_read_message`, `session_summary` |
| `kirocrew-dashboard` | `kirocrew mcp-dashboard` (`mcp_dashboard.py`) | `chat_folder_tree`, `chat_folder_create`, `chat_folder_delete`, `chat_folder_move`, `chat_folder_move_session`, `chat_folder_file_self`, `chat_tag_list`, `chat_tag_create`, `chat_tag_update`, `chat_tag_assign`, `chat_tag_column_list`, `chat_tag_column_create`, `chat_tag_column_move`, `chat_session_pin`, `session_create`, `session_fork`, `session_stop`, `session_end_wait`, `session_set_model`, `session_reload`, `session_close`, `session_revive`, `session_send`, `session_broadcast`, `session_status`, `session_adopt`, `session_release`, `session_read_message`, `session_summary` |
| `kirocrew-work` | `kirocrew mcp-work` (`mcp_work.py`) | `work_brief`, `work_report`, `work_ledger_read`, `work_ledger_record` |
| `kirocrew-crew-log` | `kirocrew mcp-crew-log` (`mcp_crew_log.py`) | `crew_log_list`, `crew_log_read`, `crew_log_projection` |
| `kirocrew-debug` | `kirocrew mcp-debug` (`mcp_debug.py`) | `debug_gateway`, `debug_refusals`, `debug_threads`, `debug_processes`, `debug_snapshots` |
Expand Down Expand Up @@ -1700,11 +1700,13 @@ neither sharing a lock with it -- so "is this folder empty?" cannot be establish
atomically with the removal. Successively narrower rules each leaked through
another seam: a session filed while the archive scan awaited, a child created while
the lock was acquired, a session closing after the scan and writing its `folder_id`
on the way out. Each was closable alone; the class was not, so the verb is withheld
instead. Nothing shipped loses a capability -- no MCP tool exposes deletion and the
only client of the route is the dashboard UI -- and an app organizes its work by
creating, renaming and reparenting its own folders and filing its own sessions. The
person deletes a full folder exactly as before.
on the way out. Each was closable alone; the class was not, so the verb is refused
for every agent principal instead. The person's own sessions delete a full folder
exactly as before -- through the dashboard UI, or through `chat_folder_delete`, a
thin wrapper over the same route under the caller's own session identity, so an app
agent's call gets the endpoint's refusal and a crew member's is refused by the
member gate (no DELETE is admitted on the folder routes). An app organizes its work
by creating, renaming and reparenting its own folders and filing its own sessions.

The policy lives in the endpoints, not in the MCP server. Only the endpoint holds
the store lock and sees the authoritative tree, so a second copy of the rule in
Expand Down
2 changes: 1 addition & 1 deletion docs/system-specs/modules/learn-cron-dashboard.md

Large diffs are not rendered by default.

35 changes: 33 additions & 2 deletions src/kiro_crew/dashboard/arrival_folders.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@
from collections.abc import Sequence
from typing import TYPE_CHECKING, Any, NamedTuple

from kiro_crew.dashboard.chat_folders import MAX_CHAT_FOLDERS, folder_ids_filed_into
from kiro_crew.dashboard.chat_folders import (
MAX_CHAT_FOLDERS,
folder_ids_filed_into,
folder_is_deleting,
)
from kiro_crew.sel import sel

if TYPE_CHECKING: # pragma: no cover - typing only
Expand Down Expand Up @@ -357,10 +361,26 @@ def _resolve(folders: list[dict[str, Any]]) -> tuple[bool, str]:
# an adopted row already happens.
hidden_rows.append(str(group.get("id", "")))
group_id = str(group.get("id", ""))
if folder_is_deleting(state, group_id):
# A delete running on the group has frozen its subtree: a child
# appended now would be born outside the set that delete walks and
# commits, and outlive it re-parented to the top level with this
# arrival filed into it -- the same rule create_folder_record applies
# to a frozen parent. Nothing was appended on this branch (a group
# created above is new and cannot be frozen), so the empty filing
# leaves the tree as it was -- including the group's hidden flag: an
# un-hide deferred above is owed only by a filing that lands.
hidden_rows.clear()
return changed, ""
if not child_name:
# No sender to name: file directly under the group.
return changed, group_id
child = _find(folders, child_name, group_id)
if child is not None and folder_is_deleting(state, str(child.get("id", ""))):
# The sender's own folder is going; the delete decides it, not a
# filing made now. No filing, no deferred un-hide either.
hidden_rows.clear()
return changed, ""
if child is None:
if len(folders) >= MAX_CHAT_FOLDERS:
# Reachable only when ``Imported`` already existed and the store
Expand Down Expand Up @@ -601,9 +621,18 @@ def _discard(folders: list[dict[str, Any]]) -> tuple[bool, list[str]]:
logger.info("Rolled back arrival folder %s after a failed import", fid)


async def arrival_folder_exists(state: "DashboardState", folder_id: str) -> bool:
async def arrival_folder_exists(
state: "DashboardState", folder_id: str, *, frozen_is_present: bool = False
) -> bool:
"""Whether *folder_id* is still a folder in COMMITTED store state.

A folder a running delete has frozen (``chat_folders._deleting_folder_ids``)
exists but is going, and reads as *frozen_is_present* says: absent for a
caller about to make a NEW filing (it would outlive the folder as a dangling
id), present for the import repair that would otherwise ERASE a stored filing
from a folder the delete may yet leave standing -- if the delete commits, its
own commit-time sweep unfiles the slot.

Read through ``read_folders`` so it sees only committed rows: an unlocked
read can land mid-transaction and report a folder whose write is then rolled
back, which is exactly the dangling id this check exists to prevent.
Expand All @@ -621,6 +650,8 @@ async def arrival_folder_exists(state: "DashboardState", folder_id: str) -> bool
return False

def _read(folders: list[dict[str, Any]]) -> bool:
if folder_is_deleting(state, folder_id):
return frozen_is_present
return any(str(f.get("id", "")) == folder_id for f in folders)

try:
Expand Down
Loading
Loading