**Wave D Phase 6 - Technical Debt Cleanup (Agent C6)** ## Changes - Identified deprecated code patterns across codebase - Analyzed mock repository usage (strategically retained per AGENT_M13) - Documented deprecation cleanup strategy - Prepared deprecation removal todos ## Analysis Results - Mock structs: RETAINED (strategic testing infrastructure) - Never-read fields: 2 instances in backtesting_service - Dead code warnings: 35 total across workspace - databento_old references: None found in active code ## Status - ✅ Deprecation analysis complete - ⏳ Cleanup execution pending user confirmation - 📊 Test impact assessment ready 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
109 lines
2.6 KiB
Markdown
109 lines
2.6 KiB
Markdown
# Agent M9: Mock Method Analysis - Quick Summary
|
|
|
|
**Status**: COMPLETE
|
|
**Finding**: Dead Code Pattern - REFACTOR RECOMMENDED
|
|
|
|
---
|
|
|
|
## TL;DR
|
|
|
|
The `BacktestingRepositories::mock()` trait method:
|
|
- Only called 3 times in actual code (2 in tests, 1 in wave comparison demo)
|
|
- Violates Rust idioms (should use `impl Default`)
|
|
- Forces all implementors to provide it (anti-pattern)
|
|
- Already has better alternatives in codebase
|
|
|
|
**Recommendation**: Replace with `impl Default` (1-2 hours work)
|
|
|
|
---
|
|
|
|
## Key Findings
|
|
|
|
### Call Sites
|
|
```
|
|
- ml_backtest_integration_test.rs:28 DefaultRepositories::mock()
|
|
- wave_comparison.rs:34 BacktestingRepositories::mock() [example]
|
|
- wave_comparison.rs:219, 272 DefaultRepositories::mock() [demo]
|
|
- ml/ensemble/hot_swap.rs CanaryMetrics::mock() [UNRELATED]
|
|
```
|
|
|
|
### Problem
|
|
Current pattern in `repositories.rs`:
|
|
```rust
|
|
pub trait BacktestingRepositories: Send + Sync {
|
|
// ... other methods ...
|
|
fn mock() -> Self where Self: Sized; // <- FORCES all implementors
|
|
}
|
|
```
|
|
|
|
### Better Pattern (Already in Codebase)
|
|
```rust
|
|
impl Default for DefaultRepositories {
|
|
fn default() -> Self { /* ... */ }
|
|
}
|
|
|
|
// Usage: DefaultRepositories::default() // <- Idiomatic Rust
|
|
```
|
|
|
|
---
|
|
|
|
## Refactoring Plan
|
|
|
|
1. **Add Default impls** (1 hour)
|
|
- DefaultRepositories::default()
|
|
- MockBacktestingRepositories::default()
|
|
|
|
2. **Update 5 call sites** (30 min)
|
|
- Change `.mock()` to `.default()`
|
|
|
|
3. **Remove trait method** (15 min)
|
|
- Delete from trait definition
|
|
- Delete from both implementations
|
|
|
|
4. **Verify** (15 min)
|
|
- cargo test, cargo clippy
|
|
|
|
**Total**: 2 hours, zero breaking changes
|
|
|
|
---
|
|
|
|
## Why This Matters
|
|
|
|
| Aspect | Current | After |
|
|
|--------|---------|-------|
|
|
| Idiom | Anti-pattern | Rust standard |
|
|
| Trait responsibility | Forces test method | Trait only for behavior |
|
|
| Code clarity | Ambiguous | Explicit |
|
|
| Maintenance | Medium | High |
|
|
|
|
---
|
|
|
|
## Evidence Files
|
|
|
|
- Full analysis: `/home/jgrusewski/Work/foxhunt/AGENT_M9_MOCK_METHOD_ANALYSIS.md` (14KB)
|
|
- Implementation files:
|
|
- `services/backtesting_service/src/repositories.rs` (trait + impls)
|
|
- `services/backtesting_service/tests/mock_repositories.rs` (test mocks)
|
|
|
|
---
|
|
|
|
## Test Pattern Evolution
|
|
|
|
The codebase has already evolved away from generic mocks:
|
|
|
|
1. **Early**: Used `.mock()` trait method
|
|
2. **Now**: Uses real DBN data (0.70ms load, deterministic)
|
|
3. **Best practice**: Real data > generic mocks
|
|
|
|
This change aligns with current testing evolution.
|
|
|
|
---
|
|
|
|
## Next Steps
|
|
|
|
See full analysis for:
|
|
- Alternative patterns considered (and why they're rejected)
|
|
- Exact line-by-line refactoring instructions
|
|
- Verification checklist
|
|
|