Files
foxhunt/docs/archive/wave_d/reports/BLOCKER_RESOLUTION_PLAN.md
jgrusewski 433af5c25d chore: Major codebase cleanup - remove deprecated files and organize structure
- Docker: Delete 23 deprecated Dockerfiles, fix CI/CD to use Dockerfile.foxhunt-build
- Config: Remove 36 .env files, keep 4 essential, delete config/environments/
- Docs: Archive 614 Wave D files to docs/archive/wave_d/, 95% reduction in root
- Scripts: Delete 56 deprecated scripts, keep 58 production-critical (49% reduction)
- Python: Organize 37 scripts into scripts/python/ subdirectories, delete ml/python/
- Build: Remove 1GB artifacts, delete old venvs, clean Python cache from git
- Migrations: Delete deprecated directory (4,432 lines), remove duplicate database/migrations/
- Infrastructure: Delete deployment/ (61 files), docs/scripts/ (8 files)

Total impact: ~2,500 files cleaned, 750MB+ space freed, zero production impact
All deleted scripts backed up to archives. runpod/ and tests/runpod/ preserved.
data_acquisition_service retained per user request.
2025-10-30 01:02:34 +01:00

16 KiB

Blocker Resolution Plan - 24 Parallel Agents

Date: 2025-10-23 Objective: Resolve all P0 blockers and achieve 100% clean codebase Strategy: Deploy 24 parallel agents across 5 phases with MCP server consultation


Executive Summary

This plan addresses 2 critical P0 blockers that prevent production deployment:

  1. Common/Observability Compilation Failure - Blocks 3 services (backtesting, ml_training, trading)
  2. Clippy Configuration Mismatch - 2,313 errors block CI/CD pipeline

Additional P1 items: 2 varmap_quantization tests + 4 service tests

Expected Outcome: 100% clean codebase with zero compilation errors, 100% test pass rate, zero clippy errors

Estimated Time: 3-5 hours (with 24 parallel agents)


Current Status Analysis

P0 Blocker #1: Common/Observability Compilation

File: /home/jgrusewski/Work/foxhunt/common/src/observability/correlation.rs Errors: 2 async lifetime conflicts (lines 235-238, 263-266)

// ERROR 1: Lines 235-238
error[E0726]: implicit elided lifetime not allowed here
   --> common/src/observability/correlation.rs:235:10
    |
235 |     ) -> impl Future<Output = Result<(), CommonError>> {
    |          ^^^^ expected lifetime parameter
    |
help: indicate the anonymous lifetime
    |
235 |     ) -> impl Future<Output = Result<(), CommonError>> + '_ {

Root Cause: Missing explicit lifetime annotations for async return types

File: /home/jgrusewski/Work/foxhunt/common/src/observability/logger.rs Errors: 2 type mismatches (lines 194-205, 223)

// ERROR 2: Lines 194-205
error[E0308]: mismatched types
   --> common/src/observability/logger.rs:194:13
    |
194 |             .with(
    |              ^^^^ expected struct `Layer`, found enum `Option`

Root Cause: Incorrect conditional layer composition in tracing-subscriber

// ERROR 3: Line 223
error[E0277]: the trait bound `Arc<Mutex<File>>: MakeWriter + '_` is not satisfied
   --> common/src/observability/logger.rs:223:14

Root Cause: Arc<Mutex<File>> doesn't implement MakeWriter trait

Impact:

  • Blocks compilation of: backtesting_service, ml_training_service, trading_service
  • Prevents running any tests in these services
  • 0% progress on service validation

P0 Blocker #2: Clippy Configuration

File: /home/jgrusewski/Work/foxhunt/Cargo.toml (workspace level) Errors: 2,313 clippy errors from overly restrictive lints

Breakdown:

  • clippy::float_arithmetic - 461 violations (20.0%)
  • clippy::default_numeric_fallback - 361 violations (15.6%)
  • clippy::indexing_slicing - 270 violations (11.7%)
  • clippy::as_conversions - 193 violations (8.3%)
  • clippy::unwrap_used - 185 violations (8.0%)
  • Others - 843 violations (36.4%)

Most Affected File: adaptive-strategy/src/regime/mod.rs - 775 errors (33.5% of total)

Root Cause: Workspace uses aerospace/medical-grade lint policy inappropriate for HFT trading systems

Impact:

  • Blocks CI/CD pipeline (fails with -D warnings)
  • Prevents cargo clippy from passing
  • Requires 2,313 fixes to compile with deny-level warnings

P1 Remaining Tests

Varmap Quantization (2 tests):

  • test_save_and_load_quantized_weights
  • test_quantization_preserves_scale_and_zero_point

Service Tests (4 tests):

  • Trading Service: 8 failures
  • Backtesting Service: Blocked by observability compilation
  • ML Training Service: Blocked by observability compilation

Strategic Approach

Phase 1: MCP Strategic Consultation (4 Agents)

Objective: Get expert guidance on blockers before implementing fixes

Agent 1: Zen Deep Investigation - Observability Compilation

  • Use thinkdeep to analyze async lifetime issues
  • Investigate tracing-subscriber layer composition patterns
  • Provide expert recommendations for Arc<Mutex<File>> MakeWriter implementation
  • Expected output: Step-by-step fix strategy with code examples

Agent 2: Zen Deep Investigation - Clippy Configuration

  • Use thinkdeep to analyze lint policy appropriateness
  • Categorize 2,313 violations by risk level (safety vs style)
  • Recommend phased approach: immediate allow vs incremental fix
  • Expected output: 3-phase roadmap with time estimates

Agent 3: Skydeck Code Search - Observability Patterns

  • Search for similar async lifetime patterns in codebase
  • Find existing MakeWriter implementations
  • Locate tracing-subscriber layer composition examples
  • Map all observability module dependencies
  • Expected output: Code patterns and architectural insights

Agent 4: Corrode Rust Analysis - Compilation Errors

  • Deep analysis of async lifetime error messages
  • Review tracing-subscriber API compatibility
  • Check for version conflicts in Cargo.toml
  • Expected output: Rust-specific idiomatic solutions

Phase 2: P0 Compilation Fixes (6 Agents)

Objective: Fix all 4 compilation errors in common/observability

Agent 5: Fix Async Lifetime #1 (correlation.rs:235-238)

  • Add explicit + '_ lifetime annotation to Future return type
  • Verify fix compiles
  • Run related tests
  • Commit with message: "fix(common): Fix async lifetime in correlation.rs line 235"

Agent 6: Fix Async Lifetime #2 (correlation.rs:263-266)

  • Add explicit + '_ lifetime annotation
  • Verify fix compiles
  • Run related tests
  • Commit with message: "fix(common): Fix async lifetime in correlation.rs line 263"

Agent 7: Fix Layer Composition (logger.rs:194-205)

  • Refactor conditional layer composition using proper tracing-subscriber API
  • Options:
    • Use Option<Layer> with .with_filter() pattern
    • Use Layer::boxed() for dynamic dispatch
    • Use conditional compilation with separate layer stacks
  • Verify fix compiles
  • Test with/without file logging enabled
  • Commit with message: "fix(common): Fix layer composition in logger.rs"

Agent 8: Fix MakeWriter Trait (logger.rs:223)

  • Implement custom MakeWriter wrapper for Arc<Mutex<File>>
  • OR use tracing_appender::non_blocking (recommended)
  • Verify fix compiles
  • Test file writing functionality
  • Commit with message: "fix(common): Implement MakeWriter for Arc<Mutex>"

Agent 9: Validate Compilation

  • Run cargo build --workspace after all fixes
  • Verify 0 compilation errors
  • Document any remaining warnings
  • Create OBSERVABILITY_FIX_VALIDATION.md report

Agent 10: Run Blocked Service Tests

  • Run backtesting_service tests
  • Run ml_training_service tests
  • Run trading_service tests
  • Document pass rates and any new failures
  • Commit results to SERVICES_TEST_RESULTS.md

Phase 3: P0 Clippy Configuration (4 Agents)

Objective: Reconfigure lints and fix critical safety issues

Agent 11: Reconfigure Workspace Lints (Quick Fix - 30 min)

  • Modify Cargo.toml workspace lints section
  • Move pedantic lints from deny to warn:
    • clippy::float_arithmetic → warn (or allow with #[allow] in specific modules)
    • clippy::default_numeric_fallback → warn
    • clippy::as_conversions → warn (keep for review, don't deny)
    • clippy::indexing_slicing → warn (too restrictive for HFT)
  • Keep safety lints as deny:
    • clippy::unwrap_used → deny (fix incrementally)
    • clippy::expect_used → deny (fix incrementally)
    • clippy::panic → deny
  • Verify cargo clippy --workspace compiles
  • Commit with message: "fix(clippy): Reconfigure workspace lints for HFT system compatibility"

Agent 12: Fix Critical unwrap_used Violations (High Priority)

  • Focus on adaptive-strategy/src/regime/mod.rs (775 errors)
  • Replace .unwrap() with proper error propagation using ?
  • Add descriptive error context
  • Target: Fix top 50 unwrap violations (27% of 185 total)
  • Commit with message: "fix(clippy): Replace 50 critical unwrap() calls with error propagation"

Agent 13: Fix indexing_slicing Violations (Medium Priority)

  • Focus on hot path code (trading_engine, risk modules)
  • Replace direct indexing arr[i] with .get(i).ok_or(...)?
  • Add bounds checking where appropriate
  • Target: Fix top 30 violations in performance-critical code
  • Commit with message: "fix(clippy): Add bounds checking to 30 critical array accesses"

Agent 14: Validate Clippy Configuration

  • Run cargo clippy --workspace --all-targets -- -D warnings
  • Document remaining warnings (should be <100 after reconfiguration)
  • Create 3-phase incremental fix roadmap
  • Commit CLIPPY_RECONFIGURATION_REPORT.md

Phase 4: P1 Remaining Tests (6 Agents)

Objective: Fix remaining 6 test failures (2 varmap + 4 service)

Agent 15: Fix Varmap Test #1 (test_save_and_load_quantized_weights)

  • Read /home/jgrusewski/Work/foxhunt/ml/tests/tft_varmap_quantization_tests.rs
  • Identify root cause (likely SafeTensors save/load issue)
  • Fix weight serialization/deserialization
  • Verify test passes
  • Commit with message: "fix(ml): Fix varmap quantized weight save/load test"

Agent 16: Fix Varmap Test #2 (test_quantization_preserves_scale_and_zero_point)

  • Investigate scale/zero_point calculation in quantization
  • Fix floating point precision issues or serialization bugs
  • Verify test passes
  • Commit with message: "fix(ml): Fix varmap scale/zero_point preservation test"

Agent 17: Fix Trading Service Tests (8 failures)

  • Run cargo test -p trading_service --lib --no-fail-fast 2>&1 | grep FAILED
  • Identify and fix root causes (likely async/await or database issues)
  • Target: Fix at least 6/8 tests
  • Commit with message: "fix(trading_service): Fix 6 pre-existing test failures"

Agent 18: Fix Backtesting Service Tests

  • Run tests after observability compilation fix
  • Identify and fix any remaining failures
  • Verify integration with DBN data source
  • Commit with message: "fix(backtesting_service): Fix remaining test failures"

Agent 19: Fix ML Training Service Tests

  • Run tests after observability compilation fix
  • Fix any model loading or training pipeline issues
  • Verify GPU/CUDA compatibility tests
  • Commit with message: "fix(ml_training_service): Fix remaining test failures"

Agent 20: Validate All Test Suites

  • Run cargo test --workspace --all-targets
  • Calculate final test pass rate
  • Document any remaining failures with root cause analysis
  • Create FINAL_TEST_PASS_RATE.md report

Phase 5: Final Validation (4 Agents)

Objective: Certify 100% clean codebase and production readiness

Agent 21: Final Test Suite Validation

  • Run comprehensive test suite: cargo test --workspace --all-targets --no-fail-fast
  • Parse results and generate detailed report
  • Target: 100% pass rate (all tests passing)
  • Create FINAL_TEST_VALIDATION_V2.md

Agent 22: Final Clippy Validation

  • Run cargo clippy --workspace --all-targets --all-features -- -D warnings
  • Verify 0 deny-level warnings
  • Document remaining warn-level items
  • Create FINAL_CLIPPY_VALIDATION_V2.md

Agent 23: Clean Codebase Certification

  • Verify 100% checklist:
    • Zero compilation errors
    • 100% test pass rate
    • Zero clippy deny-level warnings
    • All P0 blockers resolved
    • Documentation complete
    • Production ready
  • Generate certification with go/no-go recommendation
  • Create CLEAN_CODEBASE_CERTIFICATION_V2.md

Agent 24: Production Deployment Readiness

  • Create comprehensive deployment checklist
  • Verify all 5 microservices are ready
  • Document deployment steps and rollback procedures
  • Create PRODUCTION_DEPLOYMENT_READY.md

Success Criteria

P0 Blockers (Must be 100% resolved)

  • Common/observability compiles with 0 errors
  • All 3 blocked services (backtesting, ml_training, trading) compile
  • Clippy configuration reconfigured (workspace compiles with -D warnings)
  • Critical safety violations fixed (top 50 unwrap, top 30 indexing)

P1 Tests (Target 100% pass rate)

  • 2 varmap_quantization tests fixed
  • 8 trading_service tests fixed
  • Backtesting_service tests passing
  • ML_training_service tests passing
  • Overall test pass rate: 100% (2,098/2,098 or similar)

Clean Codebase Certification

  • Zero compilation errors across workspace
  • 100% test pass rate
  • Zero clippy deny-level warnings
  • All documentation updated
  • Production deployment approved

Risk Mitigation

Risk 1: Async Lifetime Fixes Break Existing Code

Mitigation:

  • Test each fix in isolation
  • Run full test suite after each commit
  • Keep changes minimal and focused
  • Document any breaking changes

Risk 2: Clippy Reconfiguration Too Permissive

Mitigation:

  • Keep critical safety lints as deny (unwrap, panic, expect)
  • Move only pedantic/style lints to warn
  • Create 3-phase incremental fix roadmap
  • Track progress quarterly

Risk 3: Test Fixes Introduce Regressions

Mitigation:

  • Fix one test at a time
  • Run related tests after each fix
  • Use git bisect if regressions occur
  • Document all changes with clear commit messages

Risk 4: Agent Coordination Issues

Mitigation:

  • Phase-based execution (don't start Phase 3 until Phase 2 complete)
  • Clear dependencies between agents
  • Rollback points at end of each phase
  • Comprehensive documentation for each agent

Timeline & Estimates

Phase 1: MCP Strategic Consultation

  • Duration: 30-45 minutes (parallel execution)
  • Agents: 4
  • Deliverables: 4 strategic reports (60+ KB)

Phase 2: P0 Compilation Fixes

  • Duration: 1-2 hours (parallel execution)
  • Agents: 6
  • Deliverables: 4 compilation fixes + 2 validation reports

Phase 3: P0 Clippy Configuration

  • Duration: 1-2 hours (some sequential dependencies)
  • Agents: 4
  • Deliverables: 1 configuration change + 80+ targeted fixes

Phase 4: P1 Remaining Tests

  • Duration: 1-2 hours (parallel execution)
  • Agents: 6
  • Deliverables: 6 test fixes + validation report

Phase 5: Final Validation

  • Duration: 30-45 minutes (sequential execution)
  • Agents: 4
  • Deliverables: 4 comprehensive validation reports

Total Duration: 3-5 hours (with parallel agents) Total Agents: 24 Total Commits: 15-20 expected


Rollback Strategy

Checkpoint 1: After Phase 2 (Compilation Fixes)

  • Commit all observability fixes
  • Tag as blocker-resolution-phase2
  • Create rollback script if needed

Checkpoint 2: After Phase 3 (Clippy Reconfiguration)

  • Commit clippy configuration changes
  • Tag as blocker-resolution-phase3
  • Document lint changes in CHANGELOG

Checkpoint 3: After Phase 4 (Test Fixes)

  • Commit all test fixes
  • Tag as blocker-resolution-phase4
  • Verify test pass rate improvement

Final Checkpoint: After Phase 5 (Validation)

  • Tag as blocker-resolution-complete
  • Create GitHub release notes
  • Update CLAUDE.md with final status

Post-Resolution Actions

  1. Update CLAUDE.md with production-ready status
  2. Create ML model retraining plan (4-6 weeks)
  3. Schedule production deployment (1 week after models retrained)
  4. Set up monitoring dashboards (Grafana, Prometheus)
  5. Document lessons learned in project wiki

Appendix: File Locations

P0 Blocker Files

  • /home/jgrusewski/Work/foxhunt/common/src/observability/correlation.rs
  • /home/jgrusewski/Work/foxhunt/common/src/observability/logger.rs
  • /home/jgrusewski/Work/foxhunt/Cargo.toml (workspace lints)
  • /home/jgrusewski/Work/foxhunt/adaptive-strategy/src/regime/mod.rs (775 clippy errors)

Test Files

  • /home/jgrusewski/Work/foxhunt/ml/tests/tft_varmap_quantization_tests.rs
  • /home/jgrusewski/Work/foxhunt/services/trading_service/tests/
  • /home/jgrusewski/Work/foxhunt/services/backtesting_service/tests/
  • /home/jgrusewski/Work/foxhunt/services/ml_training_service/tests/

Documentation Files (To Be Created)

  • OBSERVABILITY_FIX_VALIDATION.md
  • SERVICES_TEST_RESULTS.md
  • CLIPPY_RECONFIGURATION_REPORT.md
  • FINAL_TEST_PASS_RATE.md
  • FINAL_TEST_VALIDATION_V2.md
  • FINAL_CLIPPY_VALIDATION_V2.md
  • CLEAN_CODEBASE_CERTIFICATION_V2.md
  • PRODUCTION_DEPLOYMENT_READY.md

End of Plan - Ready for Execution