Overview
Remove the Arc<Mutex<UserOutput>> pattern throughout the codebase and replace it with direct ownership/borrowing to eliminate deadlock risks and simplify the architecture.
Specification
See detailed specification: docs/issues/164-refactor-useroutput-remove-mutex.md
📋 Background
This refactoring addresses a critical reentrancy deadlock issue discovered in CreateTemplateCommandController and implements the architectural decision documented in ADR: Remove UserOutput Mutex.
Current Problems
- Reentrancy Deadlock: Tests hang indefinitely when
UserOutput mutex is acquired through nested calls
- Architectural Mismatch: Complex concurrency mechanisms for a sequential, single-user application
- Timeout Workarounds: Defensive programming patterns that shouldn't be necessary
- Complex Lock Management: Error-prone manual lock scoping throughout codebase
🏗️ Architecture Requirements
DDD Layer: Presentation (primary), Application (secondary)
Module Path: src/presentation/user_output/, command controllers, progress reporters
Pattern: Direct ownership model with mutable borrowing
Module Structure Requirements
Architectural Constraints
Anti-Patterns to Avoid
- ❌ Mixing concerns across layers
- ❌ Domain layer depending on infrastructure
- ❌ Monolithic modules with multiple responsibilities
Implementation Plan
Phase 1: Core UserOutput Refactor
Phase 2: ProgressReporter Simplification
Phase 3: Command Controller Updates
Phase 4: Test Updates
Acceptance Criteria
Note for Contributors: These criteria define what the PR reviewer will check. Use this as your pre-review checklist before submitting the PR to minimize back-and-forth iterations.
Quality Checks:
Architecture Validation:
Functional Validation:
Documentation:
Related Issues
References
Overview
Remove the
Arc<Mutex<UserOutput>>pattern throughout the codebase and replace it with direct ownership/borrowing to eliminate deadlock risks and simplify the architecture.Specification
See detailed specification: docs/issues/164-refactor-useroutput-remove-mutex.md
📋 Background
This refactoring addresses a critical reentrancy deadlock issue discovered in
CreateTemplateCommandControllerand implements the architectural decision documented in ADR: Remove UserOutput Mutex.Current Problems
UserOutputmutex is acquired through nested calls🏗️ Architecture Requirements
DDD Layer: Presentation (primary), Application (secondary)
Module Path:
src/presentation/user_output/, command controllers, progress reportersPattern: Direct ownership model with mutable borrowing
Module Structure Requirements
Architectural Constraints
Anti-Patterns to Avoid
Implementation Plan
Phase 1: Core UserOutput Refactor
Arc<Mutex<>>wrapper fromUserOutputExecutionContextto ownUserOutputdirectly&mut UserOutputPhase 2: ProgressReporter Simplification
ProgressReporterto use direct&mut UserOutputaccessPhase 3: Command Controller Updates
&mut UserOutputPhase 4: Test Updates
UserOutputAcceptance Criteria
Quality Checks:
./scripts/pre-commit.shArchitecture Validation:
Arc<Mutex<UserOutput>>usage in codebase&mut UserOutputor ownedUserOutputProgressReporteruses direct access patternsFunctional Validation:
Documentation:
Related Issues
References