Expand description
Pattern detection module for design pattern mining
This module provides single-pass pattern extraction across codebases. Addresses blockers: A5 (multi-pass overhead), A23 (parse error handling)
§Architecture
The pattern detection framework uses a single-pass approach:
- Parse each file once into AST
- Walk AST once, collecting signals for ALL patterns
- Convert signals to patterns after walk
- Aggregate patterns across files
§Example
ⓘ
use tldr_core::patterns::{PatternMiner, PatternConfig};
let miner = PatternMiner::new(PatternConfig::default());
let report = miner.mine_patterns(Path::new("src"), None)?;Re-exports§
pub use constraints::generate_constraints;pub use constraints::DetectedPatterns;pub use detector::PatternDetector;pub use signals::PatternSignals;
Modules§
- api_
conventions - API convention pattern detection
- async_
patterns - Async/concurrency pattern detection
- constraints
- LLM constraint generation from detected patterns
- detector
- Pattern detector - Single-pass AST walker for pattern extraction
- error_
handling - Error handling pattern detection
- format
- Text formatting for pattern reports
- import_
patterns - Import organization pattern detection
- language_
profile - Language profile definitions for data-driven pattern detection.
- languages
- Language profile modules for post-migration languages.
- naming
- Naming convention pattern detection
- resource_
mgmt - Resource management pattern detection
- signals
- Pattern signals - Accumulated signals from single AST walk
- soft_
delete - Soft delete pattern detection
- test_
idioms - Test idiom pattern detection
- type_
coverage - Type annotation coverage pattern detection
- validation
- Input validation pattern detection
Structs§
- Pattern
Config - Configuration for pattern mining
- Pattern
Miner - Pattern miner that performs single-pass extraction across codebases
Traits§
- HasConfidence
- Trait for patterns with a confidence score
Functions§
- detect_
patterns - Detect patterns from a path (convenience function)
- detect_
patterns_ with_ config - Detect patterns with custom configuration