# Completed Refactorings
| Document | Completed | Target | Notes |
| --------------------------------------------------- | ------------ | ---------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Standardize JsonView Render API | Feb 28, 2026 | Consistent `render()` return type + `Render<T>` trait for all views | See git history at `docs/refactors/plans/standardize-json-view-render-api.md` - Introduced `ViewRenderError` + `Render<T>` trait; removed inherent `render()` from all 26 view structs (13 `JsonView` + 13 `TextView`); eliminated dead fallback code; propagated errors through all handler chains with new `OutputFormatting` variant on 11 command error types; removed asymmetry between text and JSON renderers (3 phases, final commit `221c998a`, PR #402, 750 additions / 1528 deletions) |
| SDK DDD Layer Boundary Fixes | Feb 25, 2026 | Remove DDD violations from SDK public surface | See git history at `docs/refactors/plans/sdk-ddd-layer-boundary-fixes.md` - Introduced `PersistenceError`, `InvalidStateError`, `ReleaseWorkflowStep` application-layer wrappers; updated all 9 command handler error enums; added `RepositoryProvider` trait; moved infra wiring to bootstrap; deleted orphaned `src/presentation/sdk/`; renamed `RepositoryFactory` → `FileRepositoryFactory` (commits `6f3028f4`, `52628329`, PR #381) |
| Extract Shared Types Package | Feb 25, 2026 | Extract shared value objects and traits into packages/deployer-types/ | See git history at `docs/refactors/plans/extract-shared-types-package.md` - Created `packages/deployer-types/` (`torrust-tracker-deployer-types`) with all shared value objects and traits from `src/shared/` and `EnvironmentName` from `src/domain/`; root crate and SDK now depend on the types package, backward-compat re-exports maintained, PR #381 |
| Extract SDK Workspace Package | Feb 25, 2026 | Create packages/sdk/ as independently consumable workspace package | See git history at `docs/refactors/plans/extract-sdk-workspace-package.md` - Created `packages/sdk/` (`torrust-tracker-deployer-sdk`) with SDK source, README, and examples moved from root `examples/sdk/`; backward compat deferred (cyclic dep resolved in Plan 3), PR #381 |
| Presentation CLI/SDK Separation | Feb 25, 2026 | Separate CLI and SDK in presentation layer | See git history at `docs/refactors/plans/presentation-cli-sdk-separation.md` - Moved all CLI-specific modules (controllers, dispatch, input, views, error, errors, tests) under `src/presentation/cli/`, updated 160 files, SDK confirmed zero CLI imports (commit f02024f6, PR #381) |
| E2E Test Isolation - Complete Log Directory Support | Feb 18, 2026 | Add log_dir to all E2E tests | See git history at `docs/refactors/plans/e2e-test-isolation-log-dir.md` - Added `.log_dir()` to 45 ProcessRunner calls across 6 E2E test files (validate, create, list, show, destroy, purge commands); all tests produce zero production `data/` pollution (6 phases, commits 1d576a5a→1c437d80, Issue [#365](https://github.com/torrust/torrust-tracker-deployer/issues/365)) |
| Separate View Data from Views | Feb 16, 2026 | Organize presentation layer command views | See git history at `docs/refactors/plans/separate-view-data-from-views.md` - Established `view_data/` and `views/` subdirectory pattern across create, provision, list, and show command views; 4 of 5 proposals implemented (1 discarded as not needed), all 396 tests passing (commits 9a52ddc2, 6539e787, 6cf29662, 68676e16) |
| Extract Template Rendering Services | Feb 10, 2026 | Eliminate rendering duplication | See git history at `docs/refactors/plans/extract-template-rendering-services.md` - Extracted template rendering logic into shared application-layer services for all 8 template types, eliminating duplication between render command and Steps (5 phases completed, final commit 463e7933) |
| Split tracker_ports.rs into Submodule | Feb 6, 2026 | Split 562-line file into focused submodule | See git history at `docs/refactors/plans/split-tracker-ports-into-submodule.md` - Refactored monolithic file into tracker_container_setup/ submodule with 5 focused files (container_ports, tracker_ports, config, runtime, mod), PR #319 |
| Docker Compose Topology Domain Model | Jan 26, 2026 | Move topology rules to domain, derive volumes/networks | See git history at `docs/refactors/plans/docker-compose-topology-domain-model.md` - Moved all Docker Compose topology decisions to domain layer with Network/Service enums and DockerComposeTopology aggregate (Epic #287, 8 proposals) |
| Strengthen Domain Invariant Enforcement | Jan 26, 2026 | Enforce DDD invariants in domain layer | See git history at `docs/refactors/plans/strengthen-domain-invariant-enforcement.md` - Added validated constructors and private fields to domain config types (Issue #281, 6 proposals, all completed) |
| Secret Type Introduction | Dec 18, 2025 | Secret handling for sensitive data (API tokens, passwords) | See git history at `docs/refactors/plans/secret-type-introduction.md` - Introduced `ApiToken` and `Password` wrappers using secrecy crate for sensitive data handling (Issue #243) |
| Rename Test Functions to Follow Conventions | Dec 12, 2025 | All test functions with `test_` prefix (21 files) | See git history at `docs/refactors/plans/rename-test-functions-to-follow-conventions.md` - Renamed 93 test functions and 14 helper functions across 20 files to follow behavior-driven naming conventions (21 proposals, all completed), PR #228 |
| Command Code Quality Improvements | Dec 3, 2025 | `ProvisionCommand`, `ConfigureCommand` | See git history at `docs/refactors/plans/command-code-quality-improvements.md` - API simplification, state persistence, clock injection, trace writing, and test builders (5 of 9 proposals completed, 4 postponed for future work) |
| User Output Architecture Improvements | Nov 13, 2025 | `src/presentation/views/` (formerly `user_output`) | See git history at `docs/refactors/plans/user-output-architecture-improvements.md` - Superseded by Presentation Layer Reorganization which renamed user_output to views and integrated it into four-layer MVC architecture |
| Presentation Layer Reorganization | Nov 13, 2025 | `src/presentation/` | See git history at `docs/refactors/plans/presentation-layer-reorganization.md` - Transformed presentation layer into four-layer MVC architecture (Input → Dispatch → Controllers → Views), Epic #154 with 6 proposals, all completed |
| Presentation Commands Cleanup | Oct 30, 2025 | `src/presentation/commands` module | See git history at `docs/refactors/plans/presentation-commands-cleanup.md` - Eliminated duplication, improved abstraction, enhanced testability, and ensured consistent patterns across command handlers (11 proposals, all completed) |
| Move Config Module to Create Command | Oct 30, 2025 | `src/domain/config` → `src/application/command_handlers/create/config` | See git history at `docs/refactors/plans/move-config-to-create-command.md` - Moved config DTOs from domain to application layer to align with DDD principles (1 proposal, completed) |
| Command Handlers Refactoring | Oct 28, 2025 | All command handlers | See git history at `docs/refactors/plans/command-handlers-refactoring.md` - Comprehensive refactoring covering error handling, logging patterns, and method organization across all command handlers (7 proposals, all completed) |
| Consolidate Adapters in src/adapters/ | Oct 15, 2025 | External tool adapters organization | See `docs/refactors/plans/consolidate-adapters-in-src-adapters.md` - Moved all external tool adapters to unified `src/adapters/` module for better discoverability and consistency (4 proposals, all completed) |
| SSH Client Code Quality Improvements | Oct 15, 2025 | `SshClient`, `SshConfig` | See git history at `docs/refactors/ssh-client-code-quality-improvements.md` - Extracted magic numbers into SshConnectionConfig, improved test quality, enhanced error context (7 of 8 proposals completed, 2 discarded) |
| SSH Server Testing Improvements | Oct 14, 2025 | `testing/integration/ssh_server/` | See git history at `docs/refactors/ssh-server-testing-improvements.md` - Refactored SSH server testing module with trait abstractions, proper error handling, and Docker client injection (13 of 15 proposals completed) |
| SSH Client Integration Tests Refactor | Oct 13, 2025 | `tests/ssh_client_integration.rs` | See git history at `docs/refactors/ssh-client-integration-tests-refactor.md` - Split monolithic test file into focused modules, eliminated ~80% code duplication (4 of 5 proposals completed) |
| Repository Rename to Deployer | Oct 10, 2025 | Repository and package names | Renamed from "Torrust Tracker Deploy" to "Torrust Tracker Deployer" - Updated all references, package names, and added deprecation notices to PoC repositories (5 proposals, all completed) |
| Environment Context Three-Way Split | Oct 8, 2025 | `EnvironmentContext` | See git history at `docs/refactors/environment-context-three-way-split.md` - Split context into UserInputs, InternalConfig, and RuntimeOutputs (4 proposals, all completed) |
| Environment Context Extraction | Oct 8, 2025 | `Environment<S>`, `AnyEnvironmentState` | See git history at `docs/refactors/environment-context-extraction.md` - Extracted EnvironmentContext from Environment to reduce pattern matching (2 phases, all completed) |
| JSON File Repository Improvements | Oct 3, 2025 | `json_file_repository.rs` | See git history at `docs/refactors/json-file-repository-improvements.md` for the complete refactoring plan (9 proposals, all completed) |
| File Lock Improvements | Oct 3, 2025 | `file_lock.rs` | See git history at `docs/refactors/file-lock-improvements.md` for the complete refactoring plan (10 proposals, all completed) |
| Command Preparation for State Management | Oct 7, 2025 | `ProvisionCommand`, `ConfigureCommand` | See git history at `docs/refactors/command-preparation-for-state-management.md` - Refactored commands to prepare for type-state pattern integration |
| Error Context with Trace Files | Oct 7, 2025 | Error handling infrastructure | See git history at `docs/refactors/error-context-with-trace-files.md` - Replaced string-based error context with structured, type-safe context and trace files |
| Error Kind Classification Strategy | Oct 7, 2025 | `Traceable` trait, error types | See git history at `docs/refactors/error-kind-classification-strategy.md` - Moved error kind determination into error types via `Traceable` trait |
| Step Tracking for Failure Context | Oct 7, 2025 | Command execution flow | See git history at `docs/refactors/step-tracking-for-failure-context.md` - Added explicit step tracking to eliminate reverse engineering from error types |