Skip to content

027.13 Agent Manage Folders

Description

As an AI Agent, I want to create, list, rename, and delete source folders, and move sources between folders, so that I can programmatically organize research data into meaningful groups.

Currently the agent can list sources but has no way to organize them into folders. This task exposes folder operations as MCP tools.

Trust Level: T3 (Suggest) — Agent proposes folder organization, researcher approves. Folder operations are reversible but affect the researcher's organizational structure.

Bounded Context: Sources / Folders Layer: Interface (MCP tools)

Acceptance Criteria

  • [x] #1 MCP tool list_folders returns all folders with id, name, parent_id hierarchy
  • [x] #2 MCP tool create_folder accepts name and optional parent_id, returns new folder ID
  • [x] #3 Duplicate folder names within same parent are rejected with clear failure message
  • [x] #4 MCP tool rename_folder accepts folder_id and new_name
  • [x] #5 MCP tool delete_folder accepts folder_id, rejects if folder contains sources
  • [x] #6 MCP tool move_source_to_folder accepts source_id and target folder_id
  • [x] #7 All tools publish corresponding domain events (FolderCreated, FolderRenamed, FolderDeleted, SourceMovedToFolder)
  • [x] #8 E2E test exists with @allure.story("QC-027.13 Agent Manage Folders") decorator

Notes

  • Folder hierarchy is flat (one level of nesting via parent_id) in the current schema
  • delete_folder enforces the "folder not empty" invariant — agent must move sources out first