Feature: Project Service Coverage As a developer maintaining the CleverAgents system I want comprehensive tests for the project service So that project management functionality works reliably Background: Given I have a temporary test directory for project service And I have a Unit of Work instance for project testing And I have a ProjectService instance Scenario: Create project with file system error Given I have a read-only directory for project creation When I try to create a project in the read-only directory Then a FileSystemError should be raised with message "Failed to create project structure" Scenario: Create project with existing migrated project Given I have legacy JSON project data at the target location When I create a project that triggers migration Then the existing migrated project should be returned And no duplicate project should be created Scenario: Create project with migration and existing project without force Given I have a project already in database with name "test-project" And I have legacy JSON project data for migration with same name When I try to create a project with migration without force flag Then the existing migrated project should be returned And migration should have occurred Scenario: Create project with migration returns existing after migration Given I have legacy JSON project data at the target location And migration will create a project with name "migrated-project" When I create a project that triggers successful migration Then the migrated project should be returned Scenario: Get project by name that does not exist Given there are no projects in the database When I try to get a project by name "non-existent" Then a NotFoundError should be raised for project "non-existent" Scenario: Update existing project Given I have a saved project with name "update-test" When I update the project's settings Then the project should be updated successfully And the updated project should be returned Scenario: Get project by non-existent path Given there are no projects in the database When I try to get a project by path "/non/existent/path" Then no project should be returned for the path Scenario: List projects with ordering by created date Given I have multiple projects created at different times When I list all projects ordered by created date Then the projects should be returned in creation order Scenario: List projects with ordering by name Given I have multiple projects with different names When I list all projects ordered by name Then the projects should be returned in alphabetical order Scenario: Create project with force flag overwrites existing Given I have a project already in database with name "force-test" When I create a project with the same name and force flag Then a new project should be created successfully Scenario: Project statistics with no plans Given I have a saved project with no plans When I get project statistics for the saved project Then the stats should show zero plans and contexts Scenario: Project statistics with plans and contexts Given I have a saved project with plans and contexts When I get project statistics for the saved project Then the stats should show correct counts for plans and contexts Scenario: Create project initializes database Given I have an uninitialized database When I create a new project Then the database infrastructure should be initialized And the project should be created successfully Scenario: Create project with custom settings Given I want to create a project with custom settings When I create the project with custom auto_build and auto_apply Then the project should have the custom settings applied Scenario: Delete project removes from database Given I have a saved project with name "delete-test" When I delete the project Then the project should not exist in the database Scenario: Create project with special characters in name Given I want to create a project with name containing spaces When I create a project with name "my test project" using project service Then the project should be created with sanitized name "my_test_project" Scenario: Get current project from working directory Given I have a project at a specific directory And I change to that project directory When I get the current project Then the correct project should be returned Scenario: Create project handles permission denied error Given I have a directory without write permissions When I try to create a project there Then a FileSystemError should be raised with permission details Scenario: Update project that does not exist Given I have a project object that is not in database When I try to update the non-existent project Then the update should handle the missing project gracefully Scenario: Create project with extremely long name Given I want to create a project with a very long name When I create the project with 300 character name Then the project name should be truncated appropriately