refactor(joinir): Phase 79 - Detector/Recorder separation + BindingMapProvider
**Phase 79 Medium-Priority Refactoring Complete** ## Action 1: Detector/Recorder Separation **New Pure Detection Logic:** - `digitpos_detector.rs` (~350 lines, 7 tests) - Pure detection for A-4 DigitPos pattern - No binding_map dependency - Independently testable - `trim_detector.rs` (~410 lines, 9 tests) - Pure detection for A-3 Trim pattern - No binding_map dependency - Comprehensive test coverage **Simplified Promoters:** - `DigitPosPromoter`: 200+ → 80 lines (60% reduction) - Uses DigitPosDetector for detection - Focuses on orchestration + recording - Removed 6 helper methods - `LoopBodyCarrierPromoter`: 160+ → 70 lines (56% reduction) - Uses TrimDetector for detection - Clean separation of concerns - Removed 3 helper methods ## Action 2: BindingMapProvider Trait **Centralized Feature Gate:** - `binding_map_provider.rs` (~100 lines, 3 tests) - Trait to abstract binding_map access - #[cfg] guards: 10+ locations → 2 locations (80% reduction) - `MirBuilder` implementation - Clean feature-gated access - Single point of control ## Quality Metrics **Code Reduction:** - DigitPosPromoter: 200+ → 80 lines (60%) - LoopBodyCarrierPromoter: 160+ → 70 lines (56%) - Feature guards: 10+ → 2 locations (80%) **Tests:** - All tests passing: 970/970 (100%) - New test coverage: 19+ tests for detectors - No regressions **Design Improvements:** - ✅ Single Responsibility Principle - ✅ Independent unit testing - ✅ Reusable detection logic - ✅ Centralized feature gating 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@ -1108,6 +1108,22 @@ impl Default for MirBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
// Phase 79: BindingMapProvider implementation
|
||||
// Centralizes feature-gated binding_map access for promoters
|
||||
use crate::mir::loop_pattern_detection::BindingMapProvider;
|
||||
|
||||
impl BindingMapProvider for MirBuilder {
|
||||
#[cfg(feature = "normalized_dev")]
|
||||
fn get_binding_map(&self) -> Option<&std::collections::BTreeMap<String, crate::mir::BindingId>> {
|
||||
Some(&self.binding_map)
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "normalized_dev"))]
|
||||
fn get_binding_map(&self) -> Option<&std::collections::BTreeMap<String, crate::mir::BindingId>> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod binding_id_tests {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user