devforgeai 1.0.5 → 1.0.7
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/bin/devforgeai.js +0 -0
- package/package.json +9 -1
- package/src/CLAUDE.md +699 -0
- package/src/claude/hooks/phase-completion-gate.sh +0 -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/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,468 @@
|
|
|
1
|
+
# STORY-120: Session Checkpoint Protocol - Test Suite Summary
|
|
2
|
+
|
|
3
|
+
**Status:** RED PHASE (Tests are failing - module not yet implemented)
|
|
4
|
+
**Created:** 2025-12-21
|
|
5
|
+
**Framework:** pytest with fixtures
|
|
6
|
+
**Test Count:** 22 tests
|
|
7
|
+
**Coverage Target:** 95% for business logic
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Test Organization
|
|
12
|
+
|
|
13
|
+
### File Structure
|
|
14
|
+
```
|
|
15
|
+
src/.claude/scripts/devforgeai_cli/tests/session/
|
|
16
|
+
├── test_checkpoint.py # Main test file (22 tests)
|
|
17
|
+
├── __init__.py # Package initialization
|
|
18
|
+
├── fixtures/ # Test fixture files
|
|
19
|
+
│ ├── valid-checkpoint.json # Valid checkpoint fixture
|
|
20
|
+
│ ├── corrupted-checkpoint.json # Invalid JSON fixture
|
|
21
|
+
│ └── missing-fields-checkpoint.json # Schema validation fixture
|
|
22
|
+
└── TEST_SUMMARY.md # This file
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Test Breakdown by Category
|
|
28
|
+
|
|
29
|
+
### Unit Tests: write_checkpoint() - 7 Tests
|
|
30
|
+
|
|
31
|
+
**Module Function:** `write_checkpoint(story_id: str, phase: int, progress: dict) -> bool`
|
|
32
|
+
|
|
33
|
+
1. **test_write_checkpoint_creates_directory_when_missing**
|
|
34
|
+
- AC#1: Directory creation
|
|
35
|
+
- Verifies: `devforgeai/sessions/{STORY-ID}/` created if missing
|
|
36
|
+
- Expected: True, directory exists
|
|
37
|
+
|
|
38
|
+
2. **test_write_checkpoint_creates_valid_json_file**
|
|
39
|
+
- AC#2: JSON file with required fields
|
|
40
|
+
- Verifies: All required fields present (story_id, phase, phase_name, timestamp, progress_percentage, dod_completion, next_action)
|
|
41
|
+
- Expected: True, valid JSON created
|
|
42
|
+
|
|
43
|
+
3. **test_write_checkpoint_overwrites_existing_file**
|
|
44
|
+
- Behavior: Subsequent writes overwrite
|
|
45
|
+
- Verifies: New phase data replaces old
|
|
46
|
+
- Expected: True, file updated
|
|
47
|
+
|
|
48
|
+
4. **test_write_checkpoint_validates_phase_range**
|
|
49
|
+
- AC#1: Phase validation (0-7 range)
|
|
50
|
+
- Verifies: Invalid phase (9) rejected
|
|
51
|
+
- Expected: ValueError/AssertionError or False
|
|
52
|
+
|
|
53
|
+
5. **test_write_checkpoint_validates_story_id_format**
|
|
54
|
+
- AC#2: story_id format validation (STORY-NNN)
|
|
55
|
+
- Verifies: Invalid format rejected
|
|
56
|
+
- Expected: ValueError/AssertionError or False
|
|
57
|
+
|
|
58
|
+
6. **test_write_checkpoint_stores_all_required_fields**
|
|
59
|
+
- AC#2: All fields stored correctly
|
|
60
|
+
- Verifies: Each required field persisted accurately
|
|
61
|
+
- Expected: All 7 fields present in file
|
|
62
|
+
|
|
63
|
+
7. **test_write_checkpoint_creates_atomic_writes**
|
|
64
|
+
- Risk Mitigation: Concurrent write safety
|
|
65
|
+
- Verifies: Temp file + rename pattern (if implemented)
|
|
66
|
+
- Expected: Atomic writes prevent corruption
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
### Unit Tests: read_checkpoint() - 5 Tests
|
|
71
|
+
|
|
72
|
+
**Module Function:** `read_checkpoint(story_id: str) -> dict or None`
|
|
73
|
+
|
|
74
|
+
8. **test_read_checkpoint_returns_dict_when_file_exists**
|
|
75
|
+
- AC#2 & AC#3: Reading valid checkpoint
|
|
76
|
+
- Verifies: Returns dict with correct data
|
|
77
|
+
- Expected: Dict with story_id="STORY-120", phase=2
|
|
78
|
+
|
|
79
|
+
9. **test_read_checkpoint_returns_none_when_file_missing**
|
|
80
|
+
- AC#5: Graceful fallback
|
|
81
|
+
- Verifies: No exception, returns None
|
|
82
|
+
- Expected: None (not error)
|
|
83
|
+
|
|
84
|
+
10. **test_read_checkpoint_handles_corrupted_json**
|
|
85
|
+
- AC#5: Corrupted JSON handling
|
|
86
|
+
- Verifies: Invalid JSON returns None (not error)
|
|
87
|
+
- Expected: None
|
|
88
|
+
|
|
89
|
+
11. **test_read_checkpoint_validates_schema**
|
|
90
|
+
- AC#2: Schema validation
|
|
91
|
+
- Verifies: Missing fields detected
|
|
92
|
+
- Expected: None for incomplete schema
|
|
93
|
+
|
|
94
|
+
12. **test_read_checkpoint_returns_all_required_fields**
|
|
95
|
+
- AC#2: Complete field verification
|
|
96
|
+
- Verifies: All 7 required fields present
|
|
97
|
+
- Expected: All fields in returned dict
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
### Unit Tests: delete_checkpoint() - 3 Tests
|
|
102
|
+
|
|
103
|
+
**Module Function:** `delete_checkpoint(story_id: str) -> bool`
|
|
104
|
+
|
|
105
|
+
13. **test_delete_checkpoint_removes_file**
|
|
106
|
+
- AC#4: File deletion
|
|
107
|
+
- Verifies: checkpoint.json removed
|
|
108
|
+
- Expected: True, file gone
|
|
109
|
+
|
|
110
|
+
14. **test_delete_checkpoint_removes_empty_directory**
|
|
111
|
+
- AC#4: Directory cleanup
|
|
112
|
+
- Verifies: Empty session dir also removed
|
|
113
|
+
- Expected: True, directory gone
|
|
114
|
+
|
|
115
|
+
15. **test_delete_checkpoint_handles_missing_file**
|
|
116
|
+
- AC#5: Graceful missing file handling
|
|
117
|
+
- Verifies: No exception on missing checkpoint
|
|
118
|
+
- Expected: True (idempotent)
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
### Integration Tests - 2 Tests
|
|
123
|
+
|
|
124
|
+
16. **test_checkpoint_round_trip_write_read_delete**
|
|
125
|
+
- AC#1-4: Complete lifecycle
|
|
126
|
+
- Verifies: Write → Read → Delete sequence
|
|
127
|
+
- Expected: Data persists and cleans up properly
|
|
128
|
+
|
|
129
|
+
17. **test_checkpoint_concurrent_access_safety**
|
|
130
|
+
- AC#4: Multi-phase writes
|
|
131
|
+
- Verifies: Phase 1 → 2 → 3 writes correctly
|
|
132
|
+
- Expected: Final checkpoint reflects phase 3
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
### Edge Case Tests - 5 Tests
|
|
137
|
+
|
|
138
|
+
18. **test_checkpoint_with_unicode_characters**
|
|
139
|
+
- Edge case: Unicode preservation
|
|
140
|
+
- Verifies: 🐛 emoji in last_action preserved
|
|
141
|
+
- Expected: Unicode intact after read
|
|
142
|
+
|
|
143
|
+
19. **test_checkpoint_timestamp_is_iso8601**
|
|
144
|
+
- AC#2: Timestamp format validation
|
|
145
|
+
- Verifies: ISO 8601 format maintained
|
|
146
|
+
- Expected: Timestamp ends with "Z"
|
|
147
|
+
|
|
148
|
+
20. **test_checkpoint_progress_percentage_boundary_values**
|
|
149
|
+
- AC#2: Progress range validation (0-100)
|
|
150
|
+
- Verifies: Boundary values (0, 50, 100) accepted
|
|
151
|
+
- Expected: All values preserved
|
|
152
|
+
|
|
153
|
+
21. **test_resume_dev_detects_last_completed_phase**
|
|
154
|
+
- AC#3: Phase auto-detection
|
|
155
|
+
- Verifies: Phase 3 detected from checkpoint
|
|
156
|
+
- Expected: phase=3 returned
|
|
157
|
+
|
|
158
|
+
22. **test_resume_dev_falls_back_to_phase_0_if_no_checkpoint**
|
|
159
|
+
- AC#5: Fallback behavior
|
|
160
|
+
- Verifies: Missing checkpoint → None
|
|
161
|
+
- Expected: /resume-dev shows "Starting from Phase 0"
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## Test Fixtures
|
|
166
|
+
|
|
167
|
+
### pytest Fixtures Provided
|
|
168
|
+
|
|
169
|
+
**temp_session_dir**
|
|
170
|
+
- Type: pytest fixture (function-scoped)
|
|
171
|
+
- Purpose: Creates isolated temporary session directory
|
|
172
|
+
- Cleanup: Auto-removes after test
|
|
173
|
+
- Usage: `def test_foo(temp_session_dir): ...`
|
|
174
|
+
|
|
175
|
+
**valid_checkpoint_data**
|
|
176
|
+
- Type: pytest fixture (function-scoped)
|
|
177
|
+
- Returns: Dict with all AC#2 required fields
|
|
178
|
+
- Fields: story_id, phase, phase_name, timestamp, progress_percentage, dod_completion, last_action, next_action
|
|
179
|
+
- Usage: `def test_foo(valid_checkpoint_data): ...`
|
|
180
|
+
|
|
181
|
+
**valid_checkpoint_json_file**
|
|
182
|
+
- Type: pytest fixture (function-scoped)
|
|
183
|
+
- Returns: Path to valid checkpoint.json in temp dir
|
|
184
|
+
- Pre-populated: Phase 2 checkpoint
|
|
185
|
+
- Usage: `def test_foo(valid_checkpoint_json_file): ...`
|
|
186
|
+
|
|
187
|
+
**corrupted_checkpoint_json_file**
|
|
188
|
+
- Type: pytest fixture (function-scoped)
|
|
189
|
+
- Returns: Path to corrupted JSON file (invalid syntax)
|
|
190
|
+
- Purpose: Test error handling
|
|
191
|
+
- Usage: `def test_foo(corrupted_checkpoint_json_file): ...`
|
|
192
|
+
|
|
193
|
+
**missing_fields_checkpoint_json_file**
|
|
194
|
+
- Type: pytest fixture (function-scoped)
|
|
195
|
+
- Returns: Path to incomplete checkpoint (missing required fields)
|
|
196
|
+
- Purpose: Test schema validation
|
|
197
|
+
- Usage: `def test_foo(missing_fields_checkpoint_json_file): ...`
|
|
198
|
+
|
|
199
|
+
**monkeypatch_sessions_dir**
|
|
200
|
+
- Type: pytest fixture (function-scoped)
|
|
201
|
+
- Purpose: Sets DEVFORGEAI_SESSIONS_DIR environment variable
|
|
202
|
+
- Patches: Module-level sessions directory to temp directory
|
|
203
|
+
- Usage: `def test_foo(monkeypatch_sessions_dir): ...`
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## Acceptance Criteria Coverage
|
|
208
|
+
|
|
209
|
+
### AC#1: Checkpoint File Written at Phase Completion
|
|
210
|
+
- **Tests:** test_write_checkpoint_creates_directory_when_missing
|
|
211
|
+
- **Verification:** Checkpoint created in devforgeai/sessions/{STORY-ID}/checkpoint.json
|
|
212
|
+
|
|
213
|
+
### AC#2: Checkpoint Includes Required Fields
|
|
214
|
+
- **Tests:** test_write_checkpoint_creates_valid_json_file, test_write_checkpoint_stores_all_required_fields, test_read_checkpoint_returns_all_required_fields, test_checkpoint_timestamp_is_iso8601, test_checkpoint_progress_percentage_boundary_values
|
|
215
|
+
- **Required Fields:** story_id, phase, phase_name, timestamp (ISO 8601), progress_percentage (0-100), dod_completion (object with implementation/quality/testing/documentation), next_action
|
|
216
|
+
- **Verification:** All fields present and correctly formatted
|
|
217
|
+
|
|
218
|
+
### AC#3: /resume-dev Auto-Detects from Checkpoint
|
|
219
|
+
- **Tests:** test_resume_dev_detects_last_completed_phase, test_resume_dev_no_prompting_needed_when_checkpoint_exists
|
|
220
|
+
- **Verification:** read_checkpoint() returns phase without user prompting
|
|
221
|
+
|
|
222
|
+
### AC#4: Checkpoint Cleaned Up on Story Completion
|
|
223
|
+
- **Tests:** test_delete_checkpoint_removes_file, test_delete_checkpoint_removes_empty_directory, test_checkpoint_round_trip_write_read_delete
|
|
224
|
+
- **Verification:** Checkpoint deleted when story reaches Released status
|
|
225
|
+
|
|
226
|
+
### AC#5: Graceful Handling if Checkpoint Missing/Corrupted
|
|
227
|
+
- **Tests:** test_read_checkpoint_returns_none_when_file_missing, test_read_checkpoint_handles_corrupted_json, test_delete_checkpoint_handles_missing_file, test_resume_dev_falls_back_to_phase_0_if_no_checkpoint
|
|
228
|
+
- **Verification:** No errors thrown; graceful fallback to Phase 0
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## Running Tests
|
|
233
|
+
|
|
234
|
+
### Execute All Checkpoint Tests
|
|
235
|
+
```bash
|
|
236
|
+
pytest src/.claude/scripts/devforgeai_cli/tests/session/test_checkpoint.py -v
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Run Specific Test Class
|
|
240
|
+
```bash
|
|
241
|
+
pytest src/.claude/scripts/devforgeai_cli/tests/session/test_checkpoint.py::TestWriteCheckpointUnit -v
|
|
242
|
+
pytest src/.claude/scripts/devforgeai_cli/tests/session/test_checkpoint.py::TestReadCheckpointUnit -v
|
|
243
|
+
pytest src/.claude/scripts/devforgeai_cli/tests/session/test_checkpoint.py::TestDeleteCheckpointUnit -v
|
|
244
|
+
pytest src/.claude/scripts/devforgeai_cli/tests/session/test_checkpoint.py::TestCheckpointIntegration -v
|
|
245
|
+
pytest src/.claude/scripts/devforgeai_cli/tests/session/test_checkpoint.py::TestCheckpointEdgeCases -v
|
|
246
|
+
pytest src/.claude/scripts/devforgeai_cli/tests/session/test_checkpoint.py::TestResumeDevAutoDetection -v
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### Run with Coverage
|
|
250
|
+
```bash
|
|
251
|
+
pytest src/.claude/scripts/devforgeai_cli/tests/session/test_checkpoint.py \
|
|
252
|
+
--cov=src/.claude/scripts/devforgeai_cli/session \
|
|
253
|
+
--cov-report=term \
|
|
254
|
+
--cov-report=html
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### Run in Watch Mode (if pytest-watch installed)
|
|
258
|
+
```bash
|
|
259
|
+
ptw src/.claude/scripts/devforgeai_cli/tests/session/test_checkpoint.py
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## Implementation Requirements
|
|
265
|
+
|
|
266
|
+
### Module to Implement
|
|
267
|
+
**File:** `src/.claude/scripts/devforgeai_cli/session/checkpoint.py`
|
|
268
|
+
|
|
269
|
+
### Required Functions
|
|
270
|
+
|
|
271
|
+
#### write_checkpoint()
|
|
272
|
+
```python
|
|
273
|
+
def write_checkpoint(story_id: str, phase: int, progress: dict) -> bool:
|
|
274
|
+
"""
|
|
275
|
+
Write checkpoint file at phase completion.
|
|
276
|
+
|
|
277
|
+
Args:
|
|
278
|
+
story_id: Story identifier (format: STORY-NNN)
|
|
279
|
+
phase: Phase number (0-7)
|
|
280
|
+
progress: Dict with fields from AC#2
|
|
281
|
+
|
|
282
|
+
Returns:
|
|
283
|
+
True if successful, False/raise on error
|
|
284
|
+
|
|
285
|
+
Behavior:
|
|
286
|
+
- Creates devforgeai/sessions/{story_id}/ if missing
|
|
287
|
+
- Writes JSON to devforgeai/sessions/{story_id}/checkpoint.json
|
|
288
|
+
- Overwrites existing file (subsequent phase completions)
|
|
289
|
+
- Validates phase (0-7) and story_id format (STORY-NNN)
|
|
290
|
+
- Preserves all required fields exactly as provided
|
|
291
|
+
"""
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
#### read_checkpoint()
|
|
295
|
+
```python
|
|
296
|
+
def read_checkpoint(story_id: str) -> dict or None:
|
|
297
|
+
"""
|
|
298
|
+
Read checkpoint file for auto-detection.
|
|
299
|
+
|
|
300
|
+
Args:
|
|
301
|
+
story_id: Story identifier (format: STORY-NNN)
|
|
302
|
+
|
|
303
|
+
Returns:
|
|
304
|
+
Dict with checkpoint data if valid, None if:
|
|
305
|
+
- File doesn't exist
|
|
306
|
+
- JSON is corrupted
|
|
307
|
+
- Schema validation fails (missing required fields)
|
|
308
|
+
|
|
309
|
+
Behavior:
|
|
310
|
+
- Returns dict or None (never raises exception)
|
|
311
|
+
- Validates schema before returning
|
|
312
|
+
- Graceful fallback on errors (AC#5)
|
|
313
|
+
"""
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
#### delete_checkpoint()
|
|
317
|
+
```python
|
|
318
|
+
def delete_checkpoint(story_id: str) -> bool:
|
|
319
|
+
"""
|
|
320
|
+
Delete checkpoint file (when story reaches Released).
|
|
321
|
+
|
|
322
|
+
Args:
|
|
323
|
+
story_id: Story identifier
|
|
324
|
+
|
|
325
|
+
Returns:
|
|
326
|
+
True always (idempotent - success even if already deleted)
|
|
327
|
+
|
|
328
|
+
Behavior:
|
|
329
|
+
- Removes devforgeai/sessions/{story_id}/checkpoint.json
|
|
330
|
+
- Removes empty directory if it becomes empty
|
|
331
|
+
- No error if file/directory already missing
|
|
332
|
+
"""
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
### File Structure
|
|
336
|
+
```
|
|
337
|
+
src/.claude/scripts/devforgeai_cli/
|
|
338
|
+
├── session/ # NEW - Session management module
|
|
339
|
+
│ ├── __init__.py # Export checkpoint functions
|
|
340
|
+
│ └── checkpoint.py # Implement 3 functions (22 tests validate)
|
|
341
|
+
└── tests/
|
|
342
|
+
└── session/
|
|
343
|
+
├── test_checkpoint.py # 22 tests (RED phase)
|
|
344
|
+
└── fixtures/ # Test data files
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
---
|
|
348
|
+
|
|
349
|
+
## Key Design Patterns
|
|
350
|
+
|
|
351
|
+
### AAA Pattern (Every Test)
|
|
352
|
+
```python
|
|
353
|
+
def test_something():
|
|
354
|
+
# Arrange: Set up test preconditions
|
|
355
|
+
data = {"story_id": "STORY-120", ...}
|
|
356
|
+
|
|
357
|
+
# Act: Execute the behavior being tested
|
|
358
|
+
result = write_checkpoint("STORY-120", 3, data)
|
|
359
|
+
|
|
360
|
+
# Assert: Verify the outcome
|
|
361
|
+
assert result is True
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
### Fixture-Based Setup
|
|
365
|
+
- Reduces test duplication (20+ tests using same checkpoint data)
|
|
366
|
+
- Fixtures auto-cleanup (temp directories removed)
|
|
367
|
+
- Parametrized fixtures for multiple scenarios
|
|
368
|
+
|
|
369
|
+
### Error Handling Patterns
|
|
370
|
+
- No exceptions thrown for missing files (AC#5)
|
|
371
|
+
- ValueError/AssertionError for invalid inputs (phase, story_id)
|
|
372
|
+
- Schema validation before returning data
|
|
373
|
+
|
|
374
|
+
---
|
|
375
|
+
|
|
376
|
+
## Coverage Analysis
|
|
377
|
+
|
|
378
|
+
### Line Coverage Target: 95% for checkpoint.py
|
|
379
|
+
|
|
380
|
+
**Covered by tests:**
|
|
381
|
+
- write_checkpoint() complete success path
|
|
382
|
+
- write_checkpoint() validation paths (phase, story_id)
|
|
383
|
+
- write_checkpoint() directory creation
|
|
384
|
+
- read_checkpoint() success path
|
|
385
|
+
- read_checkpoint() file not found
|
|
386
|
+
- read_checkpoint() corrupted JSON
|
|
387
|
+
- read_checkpoint() schema validation
|
|
388
|
+
- delete_checkpoint() success path
|
|
389
|
+
- delete_checkpoint() missing file
|
|
390
|
+
- Edge cases: Unicode, timestamps, boundary values
|
|
391
|
+
|
|
392
|
+
**Additional coverage opportunities:**
|
|
393
|
+
- Concurrent writes (if using atomic operations)
|
|
394
|
+
- File permission errors (if added)
|
|
395
|
+
- Disk full scenarios (if added)
|
|
396
|
+
- Path traversal defense (if added)
|
|
397
|
+
|
|
398
|
+
---
|
|
399
|
+
|
|
400
|
+
## Test Pyramid Distribution
|
|
401
|
+
|
|
402
|
+
| Level | Tests | % | Rationale |
|
|
403
|
+
|-------|-------|---|-----------|
|
|
404
|
+
| **Unit** | 15 | 68% | Core function behavior |
|
|
405
|
+
| **Integration** | 2 | 9% | Round-trip, multi-phase |
|
|
406
|
+
| **Edge Cases** | 5 | 23% | Boundary, error handling |
|
|
407
|
+
|
|
408
|
+
---
|
|
409
|
+
|
|
410
|
+
## TDD Red Phase Status
|
|
411
|
+
|
|
412
|
+
**All 22 tests are currently FAILING** (expected for RED phase):
|
|
413
|
+
- Module does not exist yet
|
|
414
|
+
- Functions not implemented
|
|
415
|
+
- Tests validate the implementation contract
|
|
416
|
+
|
|
417
|
+
**Next Phase (GREEN):**
|
|
418
|
+
1. Implement checkpoint.py with 3 functions
|
|
419
|
+
2. Run `pytest` - watch all 22 tests pass
|
|
420
|
+
3. Verify 95% coverage
|
|
421
|
+
|
|
422
|
+
**Final Phase (REFACTOR):**
|
|
423
|
+
1. Optimize implementation
|
|
424
|
+
2. Add error handling
|
|
425
|
+
3. Refactor duplication in checkpoint.py
|
|
426
|
+
4. Tests remain GREEN
|
|
427
|
+
|
|
428
|
+
---
|
|
429
|
+
|
|
430
|
+
## Integration with implementing-stories Skill
|
|
431
|
+
|
|
432
|
+
These tests support **Phase 02: Test-First Design (Red Phase)** of the TDD workflow:
|
|
433
|
+
|
|
434
|
+
1. ✅ **Failing tests generated** - 22 tests (STORY-120)
|
|
435
|
+
2. ⏳ **Next: Implementation** - backend-architect implements checkpoint.py
|
|
436
|
+
3. ⏳ **Then: Verification** - All 22 tests pass (GREEN phase)
|
|
437
|
+
4. ⏳ **Finally: Refactor** - Improve code quality (REFACTOR phase)
|
|
438
|
+
|
|
439
|
+
---
|
|
440
|
+
|
|
441
|
+
## Technical Specification Mapping
|
|
442
|
+
|
|
443
|
+
| Tech Spec Requirement | Test Coverage |
|
|
444
|
+
|----------------------|----------------|
|
|
445
|
+
| write_checkpoint() function | 7 unit tests |
|
|
446
|
+
| read_checkpoint() function | 5 unit tests |
|
|
447
|
+
| delete_checkpoint() function | 3 unit tests |
|
|
448
|
+
| Directory structure: devforgeai/sessions/{story_id}/ | test_write_checkpoint_creates_directory_when_missing |
|
|
449
|
+
| JSON schema validation | 5 tests (fields, schema, corruption) |
|
|
450
|
+
| ISO 8601 timestamps | test_checkpoint_timestamp_is_iso8601 |
|
|
451
|
+
| Phase 0-7 range validation | test_write_checkpoint_validates_phase_range |
|
|
452
|
+
| Story ID format (STORY-NNN) | test_write_checkpoint_validates_story_id_format |
|
|
453
|
+
| Graceful error handling | 5 tests (AC#5) |
|
|
454
|
+
|
|
455
|
+
---
|
|
456
|
+
|
|
457
|
+
## References
|
|
458
|
+
|
|
459
|
+
- **Story File:** `devforgeai/specs/Stories/STORY-120-session-checkpoint-protocol.story.md`
|
|
460
|
+
- **Test Pattern:** Based on `src/.claude/scripts/devforgeai_cli/validators/dod_validator.py`
|
|
461
|
+
- **Test Framework:** pytest with fixtures
|
|
462
|
+
- **Coverage Tool:** pytest-cov
|
|
463
|
+
|
|
464
|
+
---
|
|
465
|
+
|
|
466
|
+
**READY FOR TDD IMPLEMENTATION**
|
|
467
|
+
|
|
468
|
+
These 22 tests form the complete RED phase for STORY-120. Proceed to Phase 03 (GREEN) to implement checkpoint.py and make all tests pass.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{invalid json content with missing closing brace
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"story_id": "STORY-120",
|
|
3
|
+
"phase": 3,
|
|
4
|
+
"phase_name": "Refactor",
|
|
5
|
+
"timestamp": "2025-12-21T15:30:00Z",
|
|
6
|
+
"progress_percentage": 67,
|
|
7
|
+
"dod_completion": {
|
|
8
|
+
"implementation": [5, 8],
|
|
9
|
+
"quality": [2, 6],
|
|
10
|
+
"testing": [3, 5],
|
|
11
|
+
"documentation": [1, 4]
|
|
12
|
+
},
|
|
13
|
+
"last_action": "code-reviewer subagent completed",
|
|
14
|
+
"next_action": "Phase 4: Integration Testing"
|
|
15
|
+
}
|