1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
//! RYO Suggest - Continuous refactoring suggestion engine
//!
//! This crate provides code improvement suggestions through pattern detection
//! and generates MutationSpecs for execution via ryo-executor.
//!
//! # Architecture
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────────┐
//! │ Suggest Domain Layer │
//! │ ─────────────────── │
//! │ SuggestRegistry SuggestStore SuggestService │
//! │ ├─ register() ├─ insert() ├─ query() │
//! │ ├─ get() ├─ get() ├─ detect() │
//! │ └─ by_category() └─ gc() └─ to_specs() │
//! │ ↓ ↓ ↓ │
//! │ Suggest.detect() → SuggestOpportunity → MutationSpec │
//! └─────────────────────────────────────────────────────────────────┘
//! ```
//!
//! # Usage
//!
//! ```ignore
//! use ryo_suggest::{
//! SuggestService, SuggestRegistry, SuggestQuery,
//! Suggest, SuggestCategory, SafetyLevel,
//! };
//!
//! // Create registry and register patterns
//! let mut registry = SuggestRegistry::new();
//! registry.register(MyPattern::new());
//!
//! // Create service
//! let service = SuggestService::new(registry);
//!
//! // Detect suggestions
//! let count = service.detect(&ctx, &symbols);
//!
//! // Query suggestions
//! let auto_safe = service.query(
//! &SuggestQuery::all().with_max_safety(SafetyLevel::Auto)
//! );
//!
//! // Generate mutation specs
//! for (id, _, _) in auto_safe {
//! if let Some(specs) = service.to_mutation_specs(id, &ctx) {
//! // Execute specs via ryo-executor...
//! }
//! }
//! ```
//!
//! # Key Components
//!
//! - [`Suggest`] - Trait for implementing detection patterns
//! - [`SuggestRegistry`] - Registration and lookup for Suggest implementations
//! - [`SuggestStore`] - Lifecycle management with generation-based invalidation
//! - [`SuggestService`] - Thread-safe service with RwLock for concurrent access
//! - [`SuggestStrategy`] - Control re-evaluation timing (PerGoal/PerWave/Manual)
//! - [`IntentLockQuery`] / [`IntentLockOps`] - Dirty read prevention traits
//!
//! # Spec Suggests
//!
//! ## Implemented (Problem Detection)
//!
//! | Code | Name | Category | Safety | Description |
//! |------|------|----------|--------|-------------|
//! | RS001 | `MissingSpecForDomainType` | Lint | Confirm | Detect domain types without Spec TypeAlias |
//! | RS002 | `OrphanSpec` | Refactor | Confirm | Detect unused Spec TypeAliases |
//! | RS003 | `InvalidSpecRelation` | Lint | Manual | Detect SpecRelation targets that don't exist |
//! | RS004 | `SpecGroupInconsistency` | Lint | Manual | Detect mixed Groups in same module |
//! | RS005 | `SpecRelationCycle` | Lint | Manual | Detect circular dependencies in SpecRelations |
//! | RS006 | `MissingRelation` | Pattern | Confirm | Suggest Relations based on struct field types |
//!
//! ## Implemented (Spec-Driven)
//!
//! | Code | Name | Category | Safety | Description |
//! |------|------|----------|--------|-------------|
//! | RS007 | `SpecRelationToField` | Pattern | Confirm | Spec relation → struct field suggestion |
//! | RS008 | `BidirectionalRelation` | Pattern | Confirm | Ensure bidirectional Spec relations |
//!
//! ## Future Candidates (Spec-Driven)
//!
//! | Code | Name | Category | Description |
//! |------|------|----------|-------------|
//! | RS009 | `SpecDrivenMethod` | Pattern | Spec relation → accessor method suggestion |
//! | RS010 | `SpecGroupTrait` | Pattern | Group → common trait implementation |
//! | RS011 | `SpecDrivenRepository` | Pattern | Spec → Repository trait generation |
//!
//! # Performance Suggestions
//!
//! | Code | Name | Category | Safety | Description |
//! |------|------|----------|--------|-------------|
//! | RP001 | `UnnecessaryClone` | Performance | Confirm | Detect clone() where ownership is not needed |
//!
//! # Safety Suggestions
//!
//! | Code | Name | Category | Safety | Description |
//! |------|------|----------|--------|-------------|
//! | RS101 | `UnwrapToExpect` | Safety | Confirm | Convert unwrap() to expect() with descriptive message |
//! | RS102 | `StringErrorType` | Safety | Manual | Detect string-based error types, suggest thiserror |
//!
//! ## Spec-First Generation (Planned)
//!
//! For greenfield development, a different approach is needed:
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────────┐
//! │ Spec-First Generation (vs Problem Detection) │
//! │ ───────────────────────────────────────────── │
//! │ │
//! │ Problem Detection (current): │
//! │ Code → detect() → Problems → MutationSpec │
//! │ │
//! │ Spec-First Generation (planned): │
//! │ Spec Definition → generate() → New Code │
//! │ │
//! │ Use Cases: │
//! │ - New domain model from Spec │
//! │ - Scaffold struct/fields/methods from Spec relations │
//! │ - Generate Repository/Service patterns from Spec Group │
//! └─────────────────────────────────────────────────────────────────┘
//! ```
// ========== Core Exports ==========
pub use AllowStore;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use SuggestRegistry;
pub use ;
// Pattern integration
pub use ;
// ========== Enhanced Suggestions ==========
pub use ;
pub use ;
// ========== Spec Suggestions ==========
pub use ;
// ========== Parameterized Suggestions (Code Generation) ==========
pub use ;
// ========== Spec Generators ==========
pub use ;
// ========== Generator Templates (User-defined) ==========
pub use ;
// ========== Performance Suggestions ==========
pub use ;
// ========== Safety Suggestions ==========
pub use ;