refactor: migrate command handlers to modular directory structure#57
Merged
Merged
Conversation
Split provision.rs (752 lines) into modular directory structure: - provision/mod.rs - Module documentation and public API - provision/handler.rs - Command handler implementation - provision/errors.rs - Error types with Traceable impl - provision/tests/ - Test organization (builders, integration) All existing tests pass. No changes to business logic. Co-authored-by: josecelano <58816+josecelano@users.noreply.github.com>
Split configure.rs (370 lines) into modular directory structure: - configure/mod.rs - Module documentation and public API - configure/handler.rs - Command handler implementation - configure/errors.rs - Error types with Traceable impl - configure/tests/ - Test organization (builders, integration) All existing tests pass. No changes to business logic. Co-authored-by: josecelano <58816+josecelano@users.noreply.github.com>
Split destroy.rs (631 lines) into modular directory structure: - destroy/mod.rs - Module documentation and public API - destroy/handler.rs - Command handler implementation - destroy/errors.rs - Error types with Traceable impl - destroy/tests/ - Test organization (builders, integration) All existing tests pass. No changes to business logic. Co-authored-by: josecelano <58816+josecelano@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor command handlers to modular directory structure
refactor: migrate command handlers to modular directory structure
Oct 27, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactors three single-file command handlers (
provision,configure,destroy) into modular directory structures matching the existingcreatehandler pattern. Reduces file sizes and improves maintainability through separation of concerns.Changes
File splits:
provision.rs(752 lines) →provision/{mod.rs, handler.rs, errors.rs, tests/}configure.rs(370 lines) →configure/{mod.rs, handler.rs, errors.rs, tests/}destroy.rs(631 lines) →destroy/{mod.rs, handler.rs, tests/}Structure per handler:
Visibility changes:
pub(crate)for test accesspub(crate)where tests require them (e.g.,build_failure_context,should_destroy_infrastructure,cleanup_state_files)All business logic preserved unchanged. Import paths updated throughout codebase.
Example
Before:
After:
Original prompt
This section details on the original issue you should resolve
<issue_title>Refactor Command Handlers to Modular Directory Structure</issue_title>
<issue_description>## Overview
Refactor the existing single-file command handlers (
provision,configure,destroy) to follow the new modular directory structure pattern established inCreateCommandHandler. This improves code organization, maintainability, and scalability by separating concerns into dedicated files.Currently, three command handlers use a single-file pattern:
provision.rs(752 lines) - Too large, mixing handler logic, errors, and testsdestroy.rs(631 lines) - Getting unwieldyconfigure.rs(370 lines) - Manageable but would benefit from separationThe
CreateCommandHandlerdemonstrates a better structure with separate files for handler logic, errors, and tests.Specification
See detailed specification: docs/issues/refactor-command-handlers-to-modular-structure.md
(Link will be updated after file rename with issue number)
🏗️ Architecture Requirements
DDD Layer: Application Layer
Module Path:
src/application/command_handlers/{provision|configure|destroy}/Pattern: Command Handler with modular organization
Target Structure
Each command handler will follow this pattern:
Architectural Constraints
Implementation Plan
Important: Migrate and commit each command handler independently. Run pre-commit checks after completing each one before moving to the next.
Subtask 1: Migrate ProvisionCommandHandler (3-4 hours)
provision/directory with modular structureprovision.rsintohandler.rs,errors.rs,tests/Subtask 2: Migrate ConfigureCommandHandler (2-3 hours)
configure/directory with modular structureconfigure.rsintohandler.rs,errors.rs,tests/Subtask 3: Migrate DestroyCommandHandler (2-3 hours)
destroy/directory with modular structuredestroy.rsintohandler.rs,errors.rs,tests/Subtask 4: Final Verification (1 hour)
Acceptance Criteria
Quality Checks:
./scripts/pre-commit.shRefactoring-Specific Criteria:
create/pattern exactlyCommit Strategy:
Related Documentation
src/application/command_handlers/create/Benefits
</issue_description>
Comments on the Issue (you ar...
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.