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:
nyash-codex
2025-12-13 07:05:30 +09:00
parent 10e78fa313
commit 48bdf2fb98
7 changed files with 1237 additions and 632 deletions

View File

@ -701,3 +701,13 @@ pub mod function_scope_capture;
// Phase 78: PromotedBindingRecorder - Type-safe BindingId recording
pub mod promoted_binding_recorder;
pub use promoted_binding_recorder::{BindingRecordError, PromotedBindingRecorder};
// Phase 79: Pure Detection Logic (Detector/Recorder separation)
pub mod digitpos_detector;
pub mod trim_detector;
pub use digitpos_detector::{DigitPosDetectionResult, DigitPosDetector};
pub use trim_detector::{TrimDetectionResult, TrimDetector};
// Phase 79: BindingMapProvider trait (centralize feature gate)
pub mod binding_map_provider;
pub use binding_map_provider::BindingMapProvider;