Lesson Learned: Dead Code and Dormant Systems
Lesson Learned: Dead Code and Dormant Systems
ID: LL-010 Date: 2025-12-11 Severity: HIGH Category: Code Quality, System Integration Impact: 0% win rate due to dormant systems and dead code
What Happened
The trading system had ~22% dead code (5,376 lines) including:
- ML Pipeline: trainer.py, inference.py, dqn_agent.py all broken (missing dependencies, NotImplementedError)
- Unused Strategies: credit_spreads, mean_reversion, wheel (0 production references)
- Orphaned Agents: crypto_learner, safety_orchestrator (never instantiated)
- Dormant Features: 6 major systems disabled by default (DeepAgents, Elite Orchestrator, etc.)
Additionally, critical functions like manage_positions() existed but were NEVER CALLED in execution flow.
Root Cause
- No Dead Code Detection: No automated check for unused code
- No Integration Testing: Functions existed but werenât tested in actual flow
- Conservative Defaults: Features defaulted to disabled without clear enablement path
- Architectural Drift: New orchestrator was built but old strategies never wired in
Impact
- 0% live win rate (positions never closed because
manage_positions()never called) - Mental toughness coaching sat unused despite 46 interventions
- RAG sentiment analysis orphaned in GrowthStrategy
- ML pipeline completely non-functional
Fix Applied
- Deleted 14 dead files (-5,376 lines)
- Enabled 6 dormant systems by default
- Wired mental toughness into Gate 0 of trading flow
- Added
manage_positions()call to crypto strategy - Re-enabled GrowthStrategy with RAG in orchestrator
Prevention Rules
- Pre-commit Hook: Dead code detector script
- CI Check: Verify all registered functions are called
- RAG Lessons Learned: Store this knowledge for future reference
- Integration Tests: Test complete trading flow, not just units
- Feature Flag Audit: Weekly review of disabled features
Tags
dead-code integration feature-flags ml-pipeline testing