Skip to content

027.14 Agent Remove Source

Description

As an AI Agent, I want to remove a source from the project so that I can help the researcher clean up unused or duplicate data during automated workflows.

Source removal is a destructive operation that deletes the source entry, its fulltext content, and all associated coded segments. Because of the potential for data loss, this tool requires explicit confirmation or operates under trust level T3 (suggest mode with researcher approval).

Trust Level: T3 (Suggest) — Agent proposes removal, researcher approves. Deletion is irreversible and removes coded segments.

Bounded Context: Sources Layer: Interface (MCP tool)

Acceptance Criteria

  • [x] #1 MCP tool remove_source is registered with source_id as required parameter
  • [x] #2 Agent can remove a source by providing its ID
  • [x] #3 Non-existent source IDs return clear SourceNotRemoved failure message
  • [x] #4 Tool returns confirmation with source name and deletion details (segments removed count)
  • [x] #5 SourceRemoved domain event is published on success
  • [x] #6 Tool response includes requires_approval: true flag for T3 trust level workflows
  • [x] #7 Optional confirm boolean parameter — when false, returns preview of what would be deleted without actually deleting
  • [x] #8 E2E test exists with @allure.story("QC-027.14 Agent Remove Source") decorator

Notes

  • The preview mode (confirm=false) allows the agent to show the researcher what would be affected before committing
  • Coded segments are cascade-deleted when a source is removed — this is the primary reason for the T3 trust level
  • Consider adding an undo capability in future for safer agent-driven cleanup