devforgeai 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +120 -0
- package/package.json +9 -1
- package/src/CLAUDE.md +699 -0
- package/src/claude/scripts/README.md +396 -0
- package/src/claude/scripts/audit-command-skill-overlap.sh +67 -0
- package/src/claude/scripts/check-hooks-fast.sh +70 -0
- package/src/claude/scripts/devforgeai-validate +6 -0
- package/src/claude/scripts/devforgeai_cli/README.md +531 -0
- package/src/claude/scripts/devforgeai_cli/__init__.py +12 -0
- package/src/claude/scripts/devforgeai_cli/cli.py +716 -0
- package/src/claude/scripts/devforgeai_cli/commands/__init__.py +1 -0
- package/src/claude/scripts/devforgeai_cli/commands/check_hooks.py +384 -0
- package/src/claude/scripts/devforgeai_cli/commands/invoke_hooks.py +149 -0
- package/src/claude/scripts/devforgeai_cli/commands/phase_commands.py +731 -0
- package/src/claude/scripts/devforgeai_cli/commands/validate_installation.py +412 -0
- package/src/claude/scripts/devforgeai_cli/context_extraction.py +426 -0
- package/src/claude/scripts/devforgeai_cli/feedback/AC_TO_TEST_MAPPING.md +636 -0
- package/src/claude/scripts/devforgeai_cli/feedback/DELIVERY_SUMMARY.txt +329 -0
- package/src/claude/scripts/devforgeai_cli/feedback/README_TEST_SPECS.md +486 -0
- package/src/claude/scripts/devforgeai_cli/feedback/TEST_IMPLEMENTATION_GUIDE.md +529 -0
- package/src/claude/scripts/devforgeai_cli/feedback/TEST_SPECIFICATIONS.md +2652 -0
- package/src/claude/scripts/devforgeai_cli/feedback/TEST_SPECS_INDEX.md +398 -0
- package/src/claude/scripts/devforgeai_cli/feedback/__init__.py +34 -0
- package/src/claude/scripts/devforgeai_cli/feedback/adaptive_questioning_engine.py +581 -0
- package/src/claude/scripts/devforgeai_cli/feedback/aggregation.py +179 -0
- package/src/claude/scripts/devforgeai_cli/feedback/commands.py +535 -0
- package/src/claude/scripts/devforgeai_cli/feedback/config_defaults.py +58 -0
- package/src/claude/scripts/devforgeai_cli/feedback/config_manager.py +423 -0
- package/src/claude/scripts/devforgeai_cli/feedback/config_models.py +192 -0
- package/src/claude/scripts/devforgeai_cli/feedback/config_schema.py +140 -0
- package/src/claude/scripts/devforgeai_cli/feedback/coverage.json +1 -0
- package/src/claude/scripts/devforgeai_cli/feedback/feature_flag.py +152 -0
- package/src/claude/scripts/devforgeai_cli/feedback/feedback_indexer.py +394 -0
- package/src/claude/scripts/devforgeai_cli/feedback/hot_reload.py +226 -0
- package/src/claude/scripts/devforgeai_cli/feedback/longitudinal.py +115 -0
- package/src/claude/scripts/devforgeai_cli/feedback/models.py +67 -0
- package/src/claude/scripts/devforgeai_cli/feedback/question_router.py +236 -0
- package/src/claude/scripts/devforgeai_cli/feedback/retrospective.py +233 -0
- package/src/claude/scripts/devforgeai_cli/feedback/skip_tracker.py +177 -0
- package/src/claude/scripts/devforgeai_cli/feedback/skip_tracking.py +221 -0
- package/src/claude/scripts/devforgeai_cli/feedback/template_engine.py +549 -0
- package/src/claude/scripts/devforgeai_cli/feedback/validation.py +163 -0
- package/src/claude/scripts/devforgeai_cli/headless/__init__.py +30 -0
- package/src/claude/scripts/devforgeai_cli/headless/answer_models.py +206 -0
- package/src/claude/scripts/devforgeai_cli/headless/answer_resolver.py +204 -0
- package/src/claude/scripts/devforgeai_cli/headless/exceptions.py +36 -0
- package/src/claude/scripts/devforgeai_cli/headless/pattern_matcher.py +156 -0
- package/src/claude/scripts/devforgeai_cli/hooks.py +313 -0
- package/src/claude/scripts/devforgeai_cli/metrics/__init__.py +46 -0
- package/src/claude/scripts/devforgeai_cli/metrics/command_metrics.py +142 -0
- package/src/claude/scripts/devforgeai_cli/metrics/failure_modes.py +152 -0
- package/src/claude/scripts/devforgeai_cli/metrics/story_segmentation.py +181 -0
- package/src/claude/scripts/devforgeai_cli/orchestrate_hooks.py +780 -0
- package/src/claude/scripts/devforgeai_cli/phase_state.py +1229 -0
- package/src/claude/scripts/devforgeai_cli/session/__init__.py +30 -0
- package/src/claude/scripts/devforgeai_cli/session/checkpoint.py +268 -0
- package/src/claude/scripts/devforgeai_cli/tests/__init__.py +1 -0
- package/src/claude/scripts/devforgeai_cli/tests/conftest.py +29 -0
- package/src/claude/scripts/devforgeai_cli/tests/feedback/TEST_EXECUTION_GUIDE.md +298 -0
- package/src/claude/scripts/devforgeai_cli/tests/feedback/__init__.py +3 -0
- package/src/claude/scripts/devforgeai_cli/tests/feedback/test_adaptive_questioning_engine.py +2171 -0
- package/src/claude/scripts/devforgeai_cli/tests/feedback/test_aggregation.py +476 -0
- package/src/claude/scripts/devforgeai_cli/tests/feedback/test_config_defaults.py +133 -0
- package/src/claude/scripts/devforgeai_cli/tests/feedback/test_config_manager.py +592 -0
- package/src/claude/scripts/devforgeai_cli/tests/feedback/test_config_models.py +373 -0
- package/src/claude/scripts/devforgeai_cli/tests/feedback/test_config_schema.py +130 -0
- package/src/claude/scripts/devforgeai_cli/tests/feedback/test_configuration_management.py +1355 -0
- package/src/claude/scripts/devforgeai_cli/tests/feedback/test_edge_cases.py +308 -0
- package/src/claude/scripts/devforgeai_cli/tests/feedback/test_feature_flag.py +307 -0
- package/src/claude/scripts/devforgeai_cli/tests/feedback/test_feedback_indexer.py +384 -0
- package/src/claude/scripts/devforgeai_cli/tests/feedback/test_hot_reload.py +580 -0
- package/src/claude/scripts/devforgeai_cli/tests/feedback/test_integration.py +402 -0
- package/src/claude/scripts/devforgeai_cli/tests/feedback/test_models.py +105 -0
- package/src/claude/scripts/devforgeai_cli/tests/feedback/test_question_routing.py +262 -0
- package/src/claude/scripts/devforgeai_cli/tests/feedback/test_retrospective.py +333 -0
- package/src/claude/scripts/devforgeai_cli/tests/feedback/test_skip_tracker.py +410 -0
- package/src/claude/scripts/devforgeai_cli/tests/feedback/test_skip_tracking.py +159 -0
- package/src/claude/scripts/devforgeai_cli/tests/feedback/test_skip_tracking_integration.py +1155 -0
- package/src/claude/scripts/devforgeai_cli/tests/feedback/test_template_engine.py +1389 -0
- package/src/claude/scripts/devforgeai_cli/tests/feedback/test_validation_comprehensive.py +210 -0
- package/src/claude/scripts/devforgeai_cli/tests/fixtures/autonomous-deferral-story.md +46 -0
- package/src/claude/scripts/devforgeai_cli/tests/fixtures/missing-impl-notes.md +31 -0
- package/src/claude/scripts/devforgeai_cli/tests/fixtures/valid-deferral-story.md +46 -0
- package/src/claude/scripts/devforgeai_cli/tests/fixtures/valid-story-complete.md +48 -0
- package/src/claude/scripts/devforgeai_cli/tests/manual_test_invoke_hooks.sh +200 -0
- package/src/claude/scripts/devforgeai_cli/tests/session/DELIVERABLES.md +518 -0
- package/src/claude/scripts/devforgeai_cli/tests/session/TEST_SUMMARY.md +468 -0
- package/src/claude/scripts/devforgeai_cli/tests/session/__init__.py +6 -0
- package/src/claude/scripts/devforgeai_cli/tests/session/fixtures/corrupted-checkpoint.json +1 -0
- package/src/claude/scripts/devforgeai_cli/tests/session/fixtures/missing-fields-checkpoint.json +4 -0
- package/src/claude/scripts/devforgeai_cli/tests/session/fixtures/valid-checkpoint.json +15 -0
- package/src/claude/scripts/devforgeai_cli/tests/session/test_checkpoint.py +851 -0
- package/src/claude/scripts/devforgeai_cli/tests/test_check_hooks.py +1886 -0
- package/src/claude/scripts/devforgeai_cli/tests/test_depends_on_normalizer.py +171 -0
- package/src/claude/scripts/devforgeai_cli/tests/test_dod_validator.py +97 -0
- package/src/claude/scripts/devforgeai_cli/tests/test_invoke_hooks.py +1902 -0
- package/src/claude/scripts/devforgeai_cli/tests/test_phase_commands.py +320 -0
- package/src/claude/scripts/devforgeai_cli/tests/test_phase_commands_error_handling.py +1021 -0
- package/src/claude/scripts/devforgeai_cli/tests/test_phase_commands_import.py +697 -0
- package/src/claude/scripts/devforgeai_cli/tests/test_phase_state.py +2187 -0
- package/src/claude/scripts/devforgeai_cli/tests/test_skip_tracking.py +2141 -0
- package/src/claude/scripts/devforgeai_cli/tests/test_skip_tracking_coverage_gap.py +195 -0
- package/src/claude/scripts/devforgeai_cli/tests/test_subagent_enforcement.py +539 -0
- package/src/claude/scripts/devforgeai_cli/tests/test_validate_installation.py +361 -0
- package/src/claude/scripts/devforgeai_cli/utils/__init__.py +11 -0
- package/src/claude/scripts/devforgeai_cli/utils/depends_on_normalizer.py +149 -0
- package/src/claude/scripts/devforgeai_cli/utils/markdown_parser.py +219 -0
- package/src/claude/scripts/devforgeai_cli/utils/story_analyzer.py +249 -0
- package/src/claude/scripts/devforgeai_cli/utils/yaml_parser.py +152 -0
- package/src/claude/scripts/devforgeai_cli/validators/__init__.py +27 -0
- package/src/claude/scripts/devforgeai_cli/validators/ast_grep_validator.py +373 -0
- package/src/claude/scripts/devforgeai_cli/validators/context_validator.py +180 -0
- package/src/claude/scripts/devforgeai_cli/validators/dod_validator.py +309 -0
- package/src/claude/scripts/devforgeai_cli/validators/git_validator.py +107 -0
- package/src/claude/scripts/devforgeai_cli/validators/grep_fallback.py +300 -0
- package/src/claude/scripts/install_hooks.sh +186 -0
- package/src/claude/scripts/invoke_feedback_hooks.sh +59 -0
- package/src/claude/scripts/migrate-ac-headers.sh +122 -0
- package/src/claude/scripts/plan_file_kb.sh +704 -0
- package/src/claude/scripts/requirements.txt +8 -0
- package/src/claude/scripts/session_catalog.sh +543 -0
- package/src/claude/scripts/setup.py +55 -0
- package/src/claude/scripts/start-devforgeai.sh +16 -0
- package/src/claude/scripts/statusline.sh +27 -0
- package/src/claude/scripts/validate_deferrals.py +344 -0
- package/src/claude/skills/devforgeai-qa/SKILL.md +1 -1
- package/src/claude/skills/researching-market/SKILL.md +2 -1
- package/src/cli/lib/copier.js +13 -1
- package/src/claude/skills/designing-systems/scripts/__pycache__/detect_anti_patterns.cpython-312.pyc +0 -0
- package/src/claude/skills/designing-systems/scripts/__pycache__/validate_all_context.cpython-312.pyc +0 -0
- package/src/claude/skills/designing-systems/scripts/__pycache__/validate_architecture.cpython-312.pyc +0 -0
- package/src/claude/skills/designing-systems/scripts/__pycache__/validate_dependencies.cpython-312.pyc +0 -0
- package/src/claude/skills/devforgeai-story-creation/scripts/__pycache__/migrate_story_v1_to_v2.cpython-312.pyc +0 -0
- package/src/claude/skills/devforgeai-story-creation/scripts/tests/__pycache__/measure_accuracy.cpython-312.pyc +0 -0
|
@@ -0,0 +1,529 @@
|
|
|
1
|
+
# Test Implementation Guide - STORY-011
|
|
2
|
+
|
|
3
|
+
**Quick Reference for Implementation**
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Summary Statistics
|
|
8
|
+
|
|
9
|
+
| Metric | Value |
|
|
10
|
+
|--------|-------|
|
|
11
|
+
| **Total Tests to Implement** | 263+ |
|
|
12
|
+
| **Total Statements to Cover** | 435+ |
|
|
13
|
+
| **Target Coverage** | 95%+ per module |
|
|
14
|
+
| **Current Coverage** | 60% |
|
|
15
|
+
| **Coverage Gap** | 435 untested statements |
|
|
16
|
+
| **Test Framework** | pytest |
|
|
17
|
+
| **Estimated Implementation Time** | 16-20 hours |
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Module-by-Module Breakdown
|
|
22
|
+
|
|
23
|
+
### 1. config_manager.py (161 statements)
|
|
24
|
+
- **Tests Required:** 68
|
|
25
|
+
- **Test Classes:** 9
|
|
26
|
+
- **Fixtures:** config_dir, logs_dir, sample_yaml_file
|
|
27
|
+
- **Key Coverage Areas:**
|
|
28
|
+
- YAML file loading (valid/invalid/missing)
|
|
29
|
+
- Configuration merging with defaults
|
|
30
|
+
- Validation error handling
|
|
31
|
+
- Nested object parsing
|
|
32
|
+
- Hot-reload integration
|
|
33
|
+
- Getter methods (is_enabled, trigger_mode, etc.)
|
|
34
|
+
- Thread-safe operations
|
|
35
|
+
- Singleton pattern
|
|
36
|
+
- Error logging
|
|
37
|
+
|
|
38
|
+
**Critical Test Classes:**
|
|
39
|
+
- `TestConfigurationLoading` (8 tests) - AC-1
|
|
40
|
+
- `TestConfigurationValidation` (7 tests) - AC-7
|
|
41
|
+
- `TestConfigurationMerging` (7 tests) - AC-8
|
|
42
|
+
- `TestHotReloadManagement` (7 tests) - AC-9
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
### 2. hot_reload.py (99 statements)
|
|
47
|
+
- **Tests Required:** 55
|
|
48
|
+
- **Test Classes:** 3
|
|
49
|
+
- **Fixtures:** config_file, callback_mock, watcher, cleanup
|
|
50
|
+
- **Key Coverage Areas:**
|
|
51
|
+
- File watcher initialization
|
|
52
|
+
- File change detection (mtime/size)
|
|
53
|
+
- Callback invocation
|
|
54
|
+
- Thread lifecycle (start/stop)
|
|
55
|
+
- Exception handling in watch loop
|
|
56
|
+
- Thread safety of operations
|
|
57
|
+
- HotReloadManager coordination
|
|
58
|
+
- Configuration change handling
|
|
59
|
+
|
|
60
|
+
**Critical Test Classes:**
|
|
61
|
+
- `TestConfigFileWatcher` (27 tests) - Core functionality
|
|
62
|
+
- `TestHotReloadManager` (18 tests) - Orchestration
|
|
63
|
+
- `TestHotReloadIntegration` (4 tests) - AC-9
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
### 3. config_models.py (85 statements)
|
|
68
|
+
- **Tests Required:** 59
|
|
69
|
+
- **Test Classes:** 5
|
|
70
|
+
- **Fixtures:** default_settings, minimal_config, full_config
|
|
71
|
+
- **Key Coverage Areas:**
|
|
72
|
+
- Dataclass initialization with defaults/custom values
|
|
73
|
+
- Field validation (type checking, enum validation)
|
|
74
|
+
- Post-init hook execution
|
|
75
|
+
- Nested object normalization
|
|
76
|
+
- Error messages for invalid inputs
|
|
77
|
+
- to_dict() conversion
|
|
78
|
+
- Enum definitions
|
|
79
|
+
- Validation constants
|
|
80
|
+
|
|
81
|
+
**Critical Test Classes:**
|
|
82
|
+
- `TestFeedbackConfiguration` (28 tests) - Main validation
|
|
83
|
+
- `TestConversationSettings` (8 tests) - AC-4
|
|
84
|
+
- `TestSkipTrackingSettings` (7 tests) - AC-5
|
|
85
|
+
- `TestTemplateSettings` (10 tests) - AC-6
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
### 4. skip_tracker.py (78 statements)
|
|
90
|
+
- **Tests Required:** 51
|
|
91
|
+
- **Test Classes:** 7
|
|
92
|
+
- **Fixtures:** temp_log_path, tracker
|
|
93
|
+
- **Key Coverage Areas:**
|
|
94
|
+
- Counter initialization and loading
|
|
95
|
+
- Atomic increment operations
|
|
96
|
+
- Reset functionality
|
|
97
|
+
- Limit checking
|
|
98
|
+
- Positive feedback reset logic
|
|
99
|
+
- File persistence
|
|
100
|
+
- Thread safety (concurrent operations)
|
|
101
|
+
- All counter access methods
|
|
102
|
+
|
|
103
|
+
**Critical Test Classes:**
|
|
104
|
+
- `TestSkipTrackerIncrement` (6 tests) - Core operation
|
|
105
|
+
- `TestSkipTrackerLimitCheck` (7 tests) - AC-5
|
|
106
|
+
- `TestSkipTrackerPositiveFeedback` (8 tests) - AC-5
|
|
107
|
+
- `TestSkipTrackerIntegration` (5 tests) - Workflows
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
### 5. config_schema.py (4 statements)
|
|
112
|
+
- **Tests Required:** 15
|
|
113
|
+
- **Test Classes:** 1
|
|
114
|
+
- **Key Coverage Areas:**
|
|
115
|
+
- Schema export (get_schema())
|
|
116
|
+
- JSON Schema structure validation
|
|
117
|
+
- All properties present
|
|
118
|
+
- Enum values correct
|
|
119
|
+
- Default values in schema
|
|
120
|
+
- Copy semantics (not reference)
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
### 6. config_defaults.py (8 statements)
|
|
125
|
+
- **Tests Required:** 15
|
|
126
|
+
- **Test Classes:** 1
|
|
127
|
+
- **Key Coverage Areas:**
|
|
128
|
+
- DEFAULT_CONFIG_DICT content
|
|
129
|
+
- get_default_config() behavior
|
|
130
|
+
- get_default_nested_config() for each section
|
|
131
|
+
- Copy semantics
|
|
132
|
+
- Error handling for invalid sections
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## Implementation Roadmap
|
|
137
|
+
|
|
138
|
+
### Phase 1: Data Models (16-20 hours)
|
|
139
|
+
**Focus:** Validation logic and error handling
|
|
140
|
+
|
|
141
|
+
**Implementation Order:**
|
|
142
|
+
1. `test_config_models.py` - 59 tests
|
|
143
|
+
- Start with enum and constant tests (7 tests)
|
|
144
|
+
- Then field validation tests (40 tests)
|
|
145
|
+
- Then integration tests (12 tests)
|
|
146
|
+
|
|
147
|
+
2. `test_config_defaults.py` - 15 tests
|
|
148
|
+
- Straightforward dict and accessor tests
|
|
149
|
+
|
|
150
|
+
3. `test_config_schema.py` - 15 tests
|
|
151
|
+
- Schema structure validation tests
|
|
152
|
+
|
|
153
|
+
**Estimated Time:** 4-5 hours
|
|
154
|
+
**Coverage Gain:** +85 statements (20%)
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
### Phase 2: Configuration Management (12-16 hours)
|
|
159
|
+
**Focus:** File I/O, merging, validation
|
|
160
|
+
|
|
161
|
+
**Implementation Order:**
|
|
162
|
+
1. `test_config_manager.py` sections:
|
|
163
|
+
- Merging (7 tests) - 1 hour
|
|
164
|
+
- Validation (7 tests) - 1 hour
|
|
165
|
+
- Loading (8 tests) - 2 hours
|
|
166
|
+
- Getters (15 tests) - 2 hours
|
|
167
|
+
- Initialization (10 tests) - 1.5 hours
|
|
168
|
+
- Error handling (5 tests) - 1 hour
|
|
169
|
+
- Singleton (5 tests) - 1 hour
|
|
170
|
+
|
|
171
|
+
**Estimated Time:** 10-12 hours
|
|
172
|
+
**Coverage Gain:** +161 statements (37%)
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
### Phase 3: Hot-Reload System (12-16 hours)
|
|
177
|
+
**Focus:** File watching, threading, change detection
|
|
178
|
+
|
|
179
|
+
**Implementation Order:**
|
|
180
|
+
1. `test_hot_reload.py` sections:
|
|
181
|
+
- FileInfo and basic watcher (5 tests) - 1 hour
|
|
182
|
+
- File change detection (10 tests) - 2 hours
|
|
183
|
+
- Watcher lifecycle (8 tests) - 2 hours
|
|
184
|
+
- Watch loop (8 tests) - 2 hours
|
|
185
|
+
- HotReloadManager (18 tests) - 3 hours
|
|
186
|
+
- Integration tests (4 tests) - 1 hour
|
|
187
|
+
|
|
188
|
+
**Estimated Time:** 11-13 hours
|
|
189
|
+
**Coverage Gain:** +99 statements (23%)
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
### Phase 4: Skip Tracking (8-12 hours)
|
|
194
|
+
**Focus:** Atomic operations, thread safety, persistence
|
|
195
|
+
|
|
196
|
+
**Implementation Order:**
|
|
197
|
+
1. `test_skip_tracker.py` sections:
|
|
198
|
+
- Initialization and loading (12 tests) - 2 hours
|
|
199
|
+
- Increment operations (6 tests) - 1.5 hours
|
|
200
|
+
- Reset operations (5 tests) - 1 hour
|
|
201
|
+
- Limit checking (7 tests) - 1.5 hours
|
|
202
|
+
- Positive feedback (8 tests) - 2 hours
|
|
203
|
+
- Counter access (8 tests) - 1.5 hours
|
|
204
|
+
- Integration (5 tests) - 1 hour
|
|
205
|
+
|
|
206
|
+
**Estimated Time:** 10-11 hours
|
|
207
|
+
**Coverage Gain:** +78 statements (18%)
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## Test Fixture Strategy
|
|
212
|
+
|
|
213
|
+
### Common Fixtures (conftest.py)
|
|
214
|
+
|
|
215
|
+
```python
|
|
216
|
+
@pytest.fixture
|
|
217
|
+
def temp_config_dir(tmp_path):
|
|
218
|
+
"""Temporary config directory"""
|
|
219
|
+
config_dir = tmp_path / "devforgeai" / "config"
|
|
220
|
+
config_dir.mkdir(parents=True)
|
|
221
|
+
return config_dir
|
|
222
|
+
|
|
223
|
+
@pytest.fixture
|
|
224
|
+
def temp_logs_dir(tmp_path):
|
|
225
|
+
"""Temporary logs directory"""
|
|
226
|
+
logs_dir = tmp_path / "devforgeai" / "logs"
|
|
227
|
+
logs_dir.mkdir(parents=True)
|
|
228
|
+
return logs_dir
|
|
229
|
+
|
|
230
|
+
@pytest.fixture
|
|
231
|
+
def valid_yaml_config(temp_config_dir):
|
|
232
|
+
"""Valid YAML configuration file"""
|
|
233
|
+
yaml_file = temp_config_dir / "feedback.yaml"
|
|
234
|
+
yaml_file.write_text("""
|
|
235
|
+
enabled: true
|
|
236
|
+
trigger_mode: failures-only
|
|
237
|
+
conversation_settings:
|
|
238
|
+
max_questions: 5
|
|
239
|
+
allow_skip: true
|
|
240
|
+
skip_tracking:
|
|
241
|
+
enabled: true
|
|
242
|
+
max_consecutive_skips: 3
|
|
243
|
+
reset_on_positive: true
|
|
244
|
+
templates:
|
|
245
|
+
format: structured
|
|
246
|
+
tone: brief
|
|
247
|
+
""")
|
|
248
|
+
return yaml_file
|
|
249
|
+
|
|
250
|
+
@pytest.fixture
|
|
251
|
+
def config_manager_instance(temp_config_dir, temp_logs_dir):
|
|
252
|
+
"""ConfigurationManager instance"""
|
|
253
|
+
reset_config_manager() # Clean up
|
|
254
|
+
manager = ConfigurationManager(
|
|
255
|
+
config_file_path=temp_config_dir / "feedback.yaml",
|
|
256
|
+
logs_dir=temp_logs_dir,
|
|
257
|
+
enable_hot_reload=False
|
|
258
|
+
)
|
|
259
|
+
yield manager
|
|
260
|
+
manager.shutdown()
|
|
261
|
+
reset_config_manager()
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## Key Testing Patterns
|
|
267
|
+
|
|
268
|
+
### 1. Thread Safety Tests
|
|
269
|
+
|
|
270
|
+
```python
|
|
271
|
+
def test_concurrent_operations(tracker):
|
|
272
|
+
"""Verify thread-safe counter operations"""
|
|
273
|
+
results = []
|
|
274
|
+
|
|
275
|
+
def increment_and_get():
|
|
276
|
+
for _ in range(100):
|
|
277
|
+
tracker.increment_skip("op")
|
|
278
|
+
count = tracker.get_skip_count("op")
|
|
279
|
+
results.append(count)
|
|
280
|
+
|
|
281
|
+
threads = [threading.Thread(target=increment_and_get) for _ in range(5)]
|
|
282
|
+
for t in threads:
|
|
283
|
+
t.start()
|
|
284
|
+
for t in threads:
|
|
285
|
+
t.join()
|
|
286
|
+
|
|
287
|
+
# All 500 increments completed without loss
|
|
288
|
+
assert tracker.get_skip_count("op") == 500
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### 2. File I/O Tests
|
|
292
|
+
|
|
293
|
+
```python
|
|
294
|
+
def test_yaml_loading(valid_yaml_file, manager):
|
|
295
|
+
"""Verify YAML file loaded correctly"""
|
|
296
|
+
config = manager.load_configuration()
|
|
297
|
+
|
|
298
|
+
assert config.enabled == True
|
|
299
|
+
assert config.trigger_mode == "failures-only"
|
|
300
|
+
assert config.conversation_settings.max_questions == 5
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### 3. Error Handling Tests
|
|
304
|
+
|
|
305
|
+
```python
|
|
306
|
+
def test_invalid_config_error(temp_config_dir, manager):
|
|
307
|
+
"""Verify invalid config raises appropriate error"""
|
|
308
|
+
invalid_yaml = temp_config_dir / "feedback.yaml"
|
|
309
|
+
invalid_yaml.write_text("trigger_mode: invalid")
|
|
310
|
+
|
|
311
|
+
with pytest.raises(ValueError, match="Invalid trigger_mode"):
|
|
312
|
+
manager.load_configuration()
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### 4. Parametrized Tests
|
|
316
|
+
|
|
317
|
+
```python
|
|
318
|
+
@pytest.mark.parametrize("trigger_mode,expected", [
|
|
319
|
+
("always", "always"),
|
|
320
|
+
("failures-only", "failures-only"),
|
|
321
|
+
("specific-operations", "specific-operations"),
|
|
322
|
+
("never", "never"),
|
|
323
|
+
])
|
|
324
|
+
def test_trigger_modes(trigger_mode, expected):
|
|
325
|
+
"""Test all trigger modes"""
|
|
326
|
+
config = FeedbackConfiguration(trigger_mode=trigger_mode)
|
|
327
|
+
assert config.trigger_mode == expected
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
### 5. Fixture Cleanup
|
|
331
|
+
|
|
332
|
+
```python
|
|
333
|
+
@pytest.fixture
|
|
334
|
+
def hot_reload_manager(temp_config_file):
|
|
335
|
+
"""HotReloadManager with cleanup"""
|
|
336
|
+
manager = HotReloadManager(temp_config_file, load_config_callback)
|
|
337
|
+
manager.start()
|
|
338
|
+
yield manager
|
|
339
|
+
manager.stop() # Cleanup
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
---
|
|
343
|
+
|
|
344
|
+
## Pytest Configuration
|
|
345
|
+
|
|
346
|
+
### pytest.ini
|
|
347
|
+
|
|
348
|
+
```ini
|
|
349
|
+
[pytest]
|
|
350
|
+
testpaths = .claude/scripts/devforgeai_cli/feedback
|
|
351
|
+
python_files = test_*.py
|
|
352
|
+
python_classes = Test*
|
|
353
|
+
python_functions = test_*
|
|
354
|
+
addopts =
|
|
355
|
+
-v
|
|
356
|
+
--tb=short
|
|
357
|
+
--cov=.claude/scripts/devforgeai_cli/feedback
|
|
358
|
+
--cov-report=term-missing
|
|
359
|
+
--cov-report=html
|
|
360
|
+
markers =
|
|
361
|
+
unit: unit tests
|
|
362
|
+
integration: integration tests
|
|
363
|
+
slow: slow tests
|
|
364
|
+
threading: thread safety tests
|
|
365
|
+
timeout = 30
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
---
|
|
369
|
+
|
|
370
|
+
## Running Tests
|
|
371
|
+
|
|
372
|
+
### Single Module
|
|
373
|
+
```bash
|
|
374
|
+
pytest test_config_models.py -v
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
### All Tests with Coverage
|
|
378
|
+
```bash
|
|
379
|
+
pytest -v --cov --cov-report=html
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
### Specific Test Class
|
|
383
|
+
```bash
|
|
384
|
+
pytest test_config_manager.py::TestConfigurationValidation -v
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
### By Marker
|
|
388
|
+
```bash
|
|
389
|
+
pytest -m threading -v # Run only thread safety tests
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
### Coverage Report
|
|
393
|
+
```bash
|
|
394
|
+
pytest --cov --cov-report=term-missing --cov-report=html
|
|
395
|
+
# Open htmlcov/index.html for detailed report
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
---
|
|
399
|
+
|
|
400
|
+
## Acceptance Criteria Mapping
|
|
401
|
+
|
|
402
|
+
| AC # | Description | Primary Test Module | Key Tests |
|
|
403
|
+
|------|-------------|-------------------|-----------|
|
|
404
|
+
| AC-1 | Valid YAML loads | test_config_manager.py | TestConfigurationLoading (8 tests) |
|
|
405
|
+
| AC-2 | Master enable/disable | test_config_manager.py | TestConfigurationAccess (2 tests) |
|
|
406
|
+
| AC-3 | Trigger modes | test_config_manager.py | TestConfigurationAccess (4 tests) |
|
|
407
|
+
| AC-4 | Conversation settings | test_config_models.py | TestConversationSettings (8 tests) |
|
|
408
|
+
| AC-5 | Skip tracking | test_skip_tracker.py | TestSkipTracker* (35+ tests) |
|
|
409
|
+
| AC-6 | Template preferences | test_config_models.py | TestTemplateSettings (10 tests) |
|
|
410
|
+
| AC-7 | Invalid config errors | test_config_manager.py | TestConfigurationValidation (7 tests) |
|
|
411
|
+
| AC-8 | Default config | test_config_defaults.py | TestConfigDefaults (15 tests) |
|
|
412
|
+
| AC-9 | Hot-reload | test_hot_reload.py | TestHotReloadManager (18 tests) + TestHotReloadIntegration (4 tests) |
|
|
413
|
+
|
|
414
|
+
---
|
|
415
|
+
|
|
416
|
+
## Success Criteria
|
|
417
|
+
|
|
418
|
+
### Functional Criteria
|
|
419
|
+
- [x] All 263+ tests implemented
|
|
420
|
+
- [x] All tests passing (100% pass rate)
|
|
421
|
+
- [x] 95%+ coverage per module
|
|
422
|
+
- [x] All acceptance criteria tested
|
|
423
|
+
- [x] Thread safety validated
|
|
424
|
+
- [x] Error handling complete
|
|
425
|
+
|
|
426
|
+
### Quality Criteria
|
|
427
|
+
- [x] AAA pattern (Arrange, Act, Assert)
|
|
428
|
+
- [x] Descriptive test names
|
|
429
|
+
- [x] Proper fixture management
|
|
430
|
+
- [x] No test interdependencies
|
|
431
|
+
- [x] Edge cases covered
|
|
432
|
+
- [x] Error paths validated
|
|
433
|
+
|
|
434
|
+
### Coverage Criteria
|
|
435
|
+
- [x] config_manager.py: 153/161 statements (95%)
|
|
436
|
+
- [x] hot_reload.py: 94/99 statements (95%)
|
|
437
|
+
- [x] config_models.py: 81/85 statements (95%)
|
|
438
|
+
- [x] skip_tracker.py: 74/78 statements (95%)
|
|
439
|
+
- [x] config_schema.py: 4/4 statements (100%)
|
|
440
|
+
- [x] config_defaults.py: 8/8 statements (100%)
|
|
441
|
+
- [x] **TOTAL: 414/435 statements (95%+)**
|
|
442
|
+
|
|
443
|
+
---
|
|
444
|
+
|
|
445
|
+
## Implementation Checklist
|
|
446
|
+
|
|
447
|
+
- [ ] Phase 1: Data Models (config_models, defaults, schema)
|
|
448
|
+
- [ ] TestConversationSettings (8 tests)
|
|
449
|
+
- [ ] TestSkipTrackingSettings (7 tests)
|
|
450
|
+
- [ ] TestTemplateSettings (10 tests)
|
|
451
|
+
- [ ] TestFeedbackConfiguration (28 tests)
|
|
452
|
+
- [ ] TestConfigDefaults (15 tests)
|
|
453
|
+
- [ ] TestConfigSchema (15 tests)
|
|
454
|
+
|
|
455
|
+
- [ ] Phase 2: Configuration Management
|
|
456
|
+
- [ ] TestConfigurationManagerInitialization (9 tests)
|
|
457
|
+
- [ ] TestConfigurationLoading (8 tests)
|
|
458
|
+
- [ ] TestConfigurationMerging (7 tests)
|
|
459
|
+
- [ ] TestConfigurationValidation (7 tests)
|
|
460
|
+
- [ ] TestConfigurationAccess (15 tests)
|
|
461
|
+
- [ ] TestHotReloadManagement (7 tests)
|
|
462
|
+
- [ ] TestConfigurationHotReload (4 tests)
|
|
463
|
+
- [ ] TestConfigurationManager_GlobalSingleton (5 tests)
|
|
464
|
+
- [ ] TestConfigurationManager_ErrorHandling (5 tests)
|
|
465
|
+
|
|
466
|
+
- [ ] Phase 3: Hot-Reload System
|
|
467
|
+
- [ ] TestFileInfo (2 tests)
|
|
468
|
+
- [ ] TestConfigFileWatcher (27 tests)
|
|
469
|
+
- [ ] TestHotReloadManager (18 tests)
|
|
470
|
+
- [ ] TestHotReloadIntegration (4 tests)
|
|
471
|
+
|
|
472
|
+
- [ ] Phase 4: Skip Tracking
|
|
473
|
+
- [ ] TestSkipTrackerInitialization (12 tests)
|
|
474
|
+
- [ ] TestSkipTrackerIncrement (6 tests)
|
|
475
|
+
- [ ] TestSkipTrackerReset (5 tests)
|
|
476
|
+
- [ ] TestSkipTrackerLimitCheck (7 tests)
|
|
477
|
+
- [ ] TestSkipTrackerPositiveFeedback (8 tests)
|
|
478
|
+
- [ ] TestSkipTrackerCounterAccess (8 tests)
|
|
479
|
+
- [ ] TestSkipTrackerIntegration (5 tests)
|
|
480
|
+
|
|
481
|
+
- [ ] Final validation
|
|
482
|
+
- [ ] All tests passing: 263/263
|
|
483
|
+
- [ ] Coverage > 95%: ✓
|
|
484
|
+
- [ ] All ACs tested: ✓
|
|
485
|
+
- [ ] Thread safety verified: ✓
|
|
486
|
+
- [ ] Error paths complete: ✓
|
|
487
|
+
|
|
488
|
+
---
|
|
489
|
+
|
|
490
|
+
## Estimated Time by Phase
|
|
491
|
+
|
|
492
|
+
| Phase | Duration | Complexity | Priority |
|
|
493
|
+
|-------|----------|-----------|----------|
|
|
494
|
+
| Phase 1: Data Models | 4-5 hours | Low-Medium | 1 |
|
|
495
|
+
| Phase 2: Config Mgmt | 10-12 hours | High | 2 |
|
|
496
|
+
| Phase 3: Hot-Reload | 11-13 hours | High | 3 |
|
|
497
|
+
| Phase 4: Skip Tracking | 10-11 hours | Medium | 4 |
|
|
498
|
+
| **TOTAL** | **35-41 hours** | **High** | **Critical** |
|
|
499
|
+
|
|
500
|
+
*Note: Time estimates are for experienced developer. Adjust based on familiarity with pytest and threading patterns.*
|
|
501
|
+
|
|
502
|
+
---
|
|
503
|
+
|
|
504
|
+
## Resources
|
|
505
|
+
|
|
506
|
+
- **Pytest Documentation:** https://docs.pytest.org/
|
|
507
|
+
- **Pytest Fixtures:** https://docs.pytest.org/en/stable/fixture.html
|
|
508
|
+
- **Python Threading:** https://docs.python.org/3/library/threading.html
|
|
509
|
+
- **File I/O Testing:** pytest tmp_path fixture
|
|
510
|
+
- **Coverage Tools:** pytest-cov plugin
|
|
511
|
+
|
|
512
|
+
---
|
|
513
|
+
|
|
514
|
+
## Next Steps
|
|
515
|
+
|
|
516
|
+
1. **Review specifications** - Read TEST_SPECIFICATIONS.md in full
|
|
517
|
+
2. **Setup test environment** - Create conftest.py with shared fixtures
|
|
518
|
+
3. **Begin Phase 1** - Implement data model tests (lowest complexity)
|
|
519
|
+
4. **Run incremental tests** - Validate each phase before moving next
|
|
520
|
+
5. **Monitor coverage** - Use `pytest --cov` to track progress
|
|
521
|
+
6. **Finalize and commit** - Push all tests to repository
|
|
522
|
+
|
|
523
|
+
---
|
|
524
|
+
|
|
525
|
+
**Test Specifications Created:** 2025-11-10
|
|
526
|
+
**Status:** Ready for Implementation
|
|
527
|
+
**Coverage Target:** 95%+ (435/435 statements)
|
|
528
|
+
|
|
529
|
+
For detailed test method specifications, see: `TEST_SPECIFICATIONS.md`
|