specfact-cli 0.4.2__py3-none-any.whl → 0.6.8__py3-none-any.whl
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.
- specfact_cli/__init__.py +1 -1
- specfact_cli/agents/analyze_agent.py +2 -3
- specfact_cli/analyzers/__init__.py +2 -1
- specfact_cli/analyzers/ambiguity_scanner.py +601 -0
- specfact_cli/analyzers/code_analyzer.py +462 -30
- specfact_cli/analyzers/constitution_evidence_extractor.py +491 -0
- specfact_cli/analyzers/contract_extractor.py +419 -0
- specfact_cli/analyzers/control_flow_analyzer.py +281 -0
- specfact_cli/analyzers/requirement_extractor.py +337 -0
- specfact_cli/analyzers/test_pattern_extractor.py +330 -0
- specfact_cli/cli.py +151 -206
- specfact_cli/commands/constitution.py +281 -0
- specfact_cli/commands/enforce.py +42 -34
- specfact_cli/commands/import_cmd.py +481 -152
- specfact_cli/commands/init.py +224 -55
- specfact_cli/commands/plan.py +2133 -547
- specfact_cli/commands/repro.py +100 -78
- specfact_cli/commands/sync.py +701 -186
- specfact_cli/enrichers/constitution_enricher.py +765 -0
- specfact_cli/enrichers/plan_enricher.py +294 -0
- specfact_cli/importers/speckit_converter.py +364 -48
- specfact_cli/importers/speckit_scanner.py +65 -0
- specfact_cli/models/plan.py +42 -0
- specfact_cli/resources/mappings/node-async.yaml +49 -0
- specfact_cli/resources/mappings/python-async.yaml +47 -0
- specfact_cli/resources/mappings/speckit-default.yaml +82 -0
- specfact_cli/resources/prompts/specfact-enforce.md +185 -0
- specfact_cli/resources/prompts/specfact-import-from-code.md +626 -0
- specfact_cli/resources/prompts/specfact-plan-add-feature.md +188 -0
- specfact_cli/resources/prompts/specfact-plan-add-story.md +212 -0
- specfact_cli/resources/prompts/specfact-plan-compare.md +571 -0
- specfact_cli/resources/prompts/specfact-plan-init.md +531 -0
- specfact_cli/resources/prompts/specfact-plan-promote.md +352 -0
- specfact_cli/resources/prompts/specfact-plan-review.md +1276 -0
- specfact_cli/resources/prompts/specfact-plan-select.md +401 -0
- specfact_cli/resources/prompts/specfact-plan-update-feature.md +242 -0
- specfact_cli/resources/prompts/specfact-plan-update-idea.md +211 -0
- specfact_cli/resources/prompts/specfact-repro.md +268 -0
- specfact_cli/resources/prompts/specfact-sync.md +497 -0
- specfact_cli/resources/schemas/deviation.schema.json +61 -0
- specfact_cli/resources/schemas/plan.schema.json +204 -0
- specfact_cli/resources/schemas/protocol.schema.json +53 -0
- specfact_cli/resources/templates/github-action.yml.j2 +140 -0
- specfact_cli/resources/templates/plan.bundle.yaml.j2 +141 -0
- specfact_cli/resources/templates/pr-template.md.j2 +58 -0
- specfact_cli/resources/templates/protocol.yaml.j2 +24 -0
- specfact_cli/resources/templates/telemetry.yaml.example +35 -0
- specfact_cli/sync/__init__.py +10 -1
- specfact_cli/sync/watcher.py +268 -0
- specfact_cli/telemetry.py +440 -0
- specfact_cli/utils/acceptance_criteria.py +127 -0
- specfact_cli/utils/enrichment_parser.py +445 -0
- specfact_cli/utils/feature_keys.py +12 -3
- specfact_cli/utils/ide_setup.py +170 -0
- specfact_cli/utils/structure.py +179 -2
- specfact_cli/utils/yaml_utils.py +33 -0
- specfact_cli/validators/repro_checker.py +22 -1
- specfact_cli/validators/schema.py +15 -4
- specfact_cli-0.6.8.dist-info/METADATA +456 -0
- specfact_cli-0.6.8.dist-info/RECORD +99 -0
- {specfact_cli-0.4.2.dist-info → specfact_cli-0.6.8.dist-info}/entry_points.txt +1 -0
- specfact_cli-0.6.8.dist-info/licenses/LICENSE.md +202 -0
- specfact_cli-0.4.2.dist-info/METADATA +0 -370
- specfact_cli-0.4.2.dist-info/RECORD +0 -62
- specfact_cli-0.4.2.dist-info/licenses/LICENSE.md +0 -61
- {specfact_cli-0.4.2.dist-info → specfact_cli-0.6.8.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,571 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Compare manual and auto-derived plans to detect deviations and inconsistencies.
|
|
3
|
+
---
|
|
4
|
+
# SpecFact Compare Plan Command
|
|
5
|
+
|
|
6
|
+
## User Input
|
|
7
|
+
|
|
8
|
+
```text
|
|
9
|
+
$ARGUMENTS
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
You **MUST** consider the user input before proceeding (if not empty).
|
|
13
|
+
|
|
14
|
+
## ⚠️ CRITICAL: CLI Usage Enforcement
|
|
15
|
+
|
|
16
|
+
**YOU MUST ALWAYS USE THE SPECFACT CLI**. Never create artifacts directly or implement functionality.
|
|
17
|
+
|
|
18
|
+
### Rules
|
|
19
|
+
|
|
20
|
+
1. **ALWAYS execute CLI first**: Run `specfact plan compare` before any comparison - execute the CLI command before any other operations
|
|
21
|
+
2. **NEVER write code**: Do not implement comparison logic - the CLI handles this
|
|
22
|
+
3. **NEVER create YAML/JSON directly**: All comparison reports must be CLI-generated
|
|
23
|
+
4. **NEVER bypass CLI validation**: CLI ensures schema compliance and metadata - use it, don't bypass its validation
|
|
24
|
+
5. **Use CLI output as grounding**: Parse CLI output, don't regenerate or recreate it - use the CLI output as the source of truth
|
|
25
|
+
6. **NEVER read artifacts directly**: Do NOT read plan bundle files directly to extract information. Use CLI commands to get plan information. The CLI provides all necessary data through its output.
|
|
26
|
+
7. **No internal knowledge required**: You should NOT need to know about internal implementation details (PlanBundle model, Deviation class, etc.). All operations must be performed via CLI commands.
|
|
27
|
+
|
|
28
|
+
### What Happens If You Don't Follow This
|
|
29
|
+
|
|
30
|
+
- ❌ Artifacts may not match CLI schema versions
|
|
31
|
+
- ❌ Missing metadata and telemetry
|
|
32
|
+
- ❌ Format inconsistencies
|
|
33
|
+
- ❌ Validation failures
|
|
34
|
+
- ❌ Works only in Copilot mode, fails in CI/CD
|
|
35
|
+
- ❌ Breaks when CLI internals change
|
|
36
|
+
- ❌ Requires knowledge of internal code structure
|
|
37
|
+
- ❌ Out-of-sync information if bundle files are read directly
|
|
38
|
+
|
|
39
|
+
## ⏸️ Wait States: User Input Required
|
|
40
|
+
|
|
41
|
+
**When user input is required, you MUST wait for the user's response.**
|
|
42
|
+
|
|
43
|
+
### Wait State Rules
|
|
44
|
+
|
|
45
|
+
1. **Never assume**: If input is missing, ask and wait
|
|
46
|
+
2. **Never continue**: Do not proceed until user responds
|
|
47
|
+
3. **Be explicit**: Clearly state what information you need
|
|
48
|
+
4. **Provide options**: Give examples or default suggestions
|
|
49
|
+
|
|
50
|
+
## Goal
|
|
51
|
+
|
|
52
|
+
Compare a manual plan bundle with an auto-derived plan bundle to detect deviations, mismatches, and missing features. This command helps identify gaps between planned features and actual implementation, ensuring alignment between specification and code.
|
|
53
|
+
|
|
54
|
+
**Note**: This is a **read-only comparison** operation - it generates comparison reports but does not modify plan bundles.
|
|
55
|
+
|
|
56
|
+
## Action Required
|
|
57
|
+
|
|
58
|
+
### Use CLI to Resolve Plan Numbers/Names
|
|
59
|
+
|
|
60
|
+
**⚠️ CRITICAL**: If user provides plan numbers (e.g., "19 vs 20") or plan names, you MUST use the CLI to resolve them to actual file paths. NEVER search for files directly.
|
|
61
|
+
|
|
62
|
+
### Step 1: Resolve Plan Paths Using CLI
|
|
63
|
+
|
|
64
|
+
**If user input contains plan numbers** (e.g., "19 vs 20", "compare 1 and 2"):
|
|
65
|
+
|
|
66
|
+
1. **List available plans using CLI**:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
specfact plan select
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
- Parse the CLI table output to get plan names for the specified numbers
|
|
73
|
+
- Extract the full plan file names from the table
|
|
74
|
+
|
|
75
|
+
2. **Get full plan paths using CLI**:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
specfact plan select <plan_number>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
- This will output the full plan name/path
|
|
82
|
+
- Use this to construct the full path: `.specfact/plans/<plan_name>`
|
|
83
|
+
|
|
84
|
+
**If user input contains plan names** (e.g., "main.bundle.yaml vs auto-derived.bundle.yaml"):
|
|
85
|
+
|
|
86
|
+
- Use the plan names directly (may need to add `.bundle.yaml` suffix if missing)
|
|
87
|
+
- Verify paths exist by attempting to use them with the CLI
|
|
88
|
+
|
|
89
|
+
**If arguments provided as paths**: Use them directly.
|
|
90
|
+
|
|
91
|
+
**If arguments missing**: Ask user interactively for each missing argument and **WAIT for their response**:
|
|
92
|
+
|
|
93
|
+
1. **Manual plan path**: "Which manual plan to compare? (Enter plan number, plan name, or path. Default: .specfact/plans/main.bundle.yaml)"
|
|
94
|
+
- **[WAIT FOR USER RESPONSE - DO NOT CONTINUE]**
|
|
95
|
+
|
|
96
|
+
2. **Auto plan path**: "Which auto-derived plan to compare? (Enter plan number, plan name, or path. Default: latest in .specfact/plans/)"
|
|
97
|
+
- **[WAIT FOR USER RESPONSE - DO NOT CONTINUE]**
|
|
98
|
+
|
|
99
|
+
3. **Output format**: "Output format? (1) Markdown, (2) JSON, (3) YAML (default: markdown)"
|
|
100
|
+
- **[WAIT FOR USER RESPONSE - DO NOT CONTINUE]**
|
|
101
|
+
|
|
102
|
+
4. **Output file**: "Save report to file? (optional, default: auto-generated with timestamp)"
|
|
103
|
+
- **[WAIT FOR USER RESPONSE - DO NOT CONTINUE]**
|
|
104
|
+
|
|
105
|
+
**Only execute CLI after** resolving plan paths and getting necessary information from user.
|
|
106
|
+
|
|
107
|
+
## Operating Constraints
|
|
108
|
+
|
|
109
|
+
**STRICTLY READ-ONLY**: Do **not** modify the codebase. All comparison reports must be generated by the specfact CLI.
|
|
110
|
+
|
|
111
|
+
**Mode Auto-Detection**: The CLI automatically detects operational mode (CI/CD or CoPilot) based on environment. No need to specify `--mode` flag. Mode is detected from:
|
|
112
|
+
|
|
113
|
+
- Environment variables (`SPECFACT_MODE`)
|
|
114
|
+
- CoPilot API availability
|
|
115
|
+
- IDE integration (VS Code/Cursor with CoPilot)
|
|
116
|
+
- Defaults to CI/CD mode if none detected
|
|
117
|
+
|
|
118
|
+
## Command
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
specfact plan compare [--manual PATH] [--auto PATH] [--format {markdown|json|yaml}] [--out PATH]
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**Note**: Mode is auto-detected by the CLI. No need to specify `--mode` flag.
|
|
125
|
+
|
|
126
|
+
**CRITICAL**: Always execute this CLI command. Never create comparison reports directly.
|
|
127
|
+
|
|
128
|
+
## Quick Reference
|
|
129
|
+
|
|
130
|
+
**Arguments:**
|
|
131
|
+
|
|
132
|
+
- `--manual PATH` - Manual plan bundle path (default: `.specfact/plans/main.bundle.yaml`) - **ASK USER if default not found**
|
|
133
|
+
- `--auto PATH` - Auto-derived plan bundle path (default: latest in `.specfact/reports/brownfield/`) - **ASK USER if default not found**
|
|
134
|
+
- `--format {markdown|json|yaml}` - Output format (default: `markdown`) - **ASK USER if not specified**
|
|
135
|
+
- `--out PATH` - Output file path (optional, default: auto-generated in `.specfact/reports/comparison/`)
|
|
136
|
+
|
|
137
|
+
**What it does:**
|
|
138
|
+
|
|
139
|
+
1. Loads and validates both plan bundles (manual and auto-derived)
|
|
140
|
+
2. Compares features and stories between plans
|
|
141
|
+
3. Detects deviations (missing features, mismatches, etc.)
|
|
142
|
+
4. Assigns severity (HIGH, MEDIUM, LOW) to each deviation
|
|
143
|
+
5. Generates structured comparison report (Markdown, JSON, or YAML)
|
|
144
|
+
6. Displays summary in console with deviation counts and severity breakdown
|
|
145
|
+
7. Optionally applies enforcement rules (if `.specfact/enforcement.yaml` exists)
|
|
146
|
+
|
|
147
|
+
## Interactive Flow
|
|
148
|
+
|
|
149
|
+
### Use CLI to Resolve Plan Paths
|
|
150
|
+
|
|
151
|
+
**⚠️ CRITICAL**: **NEVER search for files directly**. Always use CLI commands to resolve plan numbers/names to file paths.
|
|
152
|
+
|
|
153
|
+
**Step 1**: Parse user input to identify plan selections.
|
|
154
|
+
|
|
155
|
+
- **If user input contains plan numbers** (e.g., "19 vs 20", "compare 1 and 2"):
|
|
156
|
+
1. **Execute CLI to list plans**:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
specfact plan select
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
2. **Parse CLI table output** to extract plan names for the specified numbers
|
|
163
|
+
3. **Get full plan paths** by executing:
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
specfact plan select <plan_number>
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
- Parse the CLI output to get the full plan name
|
|
170
|
+
- Construct full path: `.specfact/plans/<plan_name>`
|
|
171
|
+
|
|
172
|
+
- **If user input contains plan names** (e.g., "main.bundle.yaml vs auto-derived.bundle.yaml"):
|
|
173
|
+
- Use plan names directly (may need to add `.bundle.yaml` suffix if missing)
|
|
174
|
+
- Construct full path: `.specfact/plans/<plan_name>`
|
|
175
|
+
|
|
176
|
+
- **If user input contains full paths**: Use them directly
|
|
177
|
+
|
|
178
|
+
**Step 2**: Resolve manual plan path.
|
|
179
|
+
|
|
180
|
+
- **If plan number/name provided**: Use CLI to resolve (see Step 1)
|
|
181
|
+
- **If missing**: Check if default path (`.specfact/plans/main.bundle.yaml`) exists using CLI
|
|
182
|
+
- **Verify using CLI**: Attempt to use the path with `specfact plan compare` - if it fails, the file doesn't exist
|
|
183
|
+
- **If not exists**: Ask user and **WAIT**:
|
|
184
|
+
|
|
185
|
+
```text
|
|
186
|
+
"Manual plan not found at default location. Enter plan number, plan name, or path to manual plan bundle,
|
|
187
|
+
or create one with `specfact plan init --interactive`?
|
|
188
|
+
[WAIT FOR USER RESPONSE - DO NOT CONTINUE]"
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
**Step 3**: Resolve auto plan path.
|
|
192
|
+
|
|
193
|
+
- **If plan number/name provided**: Use CLI to resolve (see Step 1)
|
|
194
|
+
- **If missing**: Use CLI to find latest auto-derived plan
|
|
195
|
+
- **Execute CLI to list plans**:
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
specfact plan select
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
- **Parse CLI output** to find latest auto-derived plan (by modification date)
|
|
202
|
+
- **If found**: Ask user and **WAIT**:
|
|
203
|
+
|
|
204
|
+
```text
|
|
205
|
+
"Use latest auto-derived plan: [PLAN_NAME]? (y/n, or enter different plan number/name/path)
|
|
206
|
+
[WAIT FOR USER RESPONSE - DO NOT CONTINUE]"
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
- **If not found**: Ask user and **WAIT**:
|
|
210
|
+
|
|
211
|
+
```text
|
|
212
|
+
"No auto-derived plans found. Enter plan number, plan name, or path to auto-derived plan bundle,
|
|
213
|
+
or generate one with `specfact import from-code --repo . --name my-project`?
|
|
214
|
+
[WAIT FOR USER RESPONSE - DO NOT CONTINUE]"
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
**Step 3**: Check if `--format` is specified.
|
|
218
|
+
|
|
219
|
+
- **If missing**: Ask user and **WAIT**:
|
|
220
|
+
|
|
221
|
+
```text
|
|
222
|
+
"Output format? (1) Markdown, (2) JSON, (3) YAML (default: markdown)
|
|
223
|
+
[WAIT FOR USER RESPONSE - DO NOT CONTINUE]"
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
- **If provided**: Use specified format
|
|
227
|
+
|
|
228
|
+
**Step 4**: Check if `--out` is specified.
|
|
229
|
+
|
|
230
|
+
- **If missing**: Ask user and **WAIT**:
|
|
231
|
+
|
|
232
|
+
```text
|
|
233
|
+
"Save report to file? (y/n, default: auto-generated in .specfact/reports/comparison/)
|
|
234
|
+
[WAIT FOR USER RESPONSE - DO NOT CONTINUE]"
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
- **If yes**: Generate default path with timestamp and format extension
|
|
238
|
+
- **If no**: Skip file output (display in console only)
|
|
239
|
+
- **If provided**: Use specified path
|
|
240
|
+
|
|
241
|
+
**Step 5**: Confirm execution.
|
|
242
|
+
|
|
243
|
+
- Show summary and **WAIT**:
|
|
244
|
+
|
|
245
|
+
```text
|
|
246
|
+
"Will compare [MANUAL_PATH] vs [AUTO_PATH] and save report as [OUT_PATH] in [FORMAT] format.
|
|
247
|
+
Continue? (y/n)
|
|
248
|
+
[WAIT FOR USER RESPONSE - DO NOT CONTINUE]"
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
- **If yes**: Execute CLI command
|
|
252
|
+
- **If no**: Cancel or ask for changes
|
|
253
|
+
|
|
254
|
+
**Step 6**: Execute CLI command with confirmed arguments.
|
|
255
|
+
|
|
256
|
+
**⚠️ CRITICAL**: Use the resolved file paths (not plan numbers) in the CLI command:
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
specfact plan compare --manual <MANUAL_PATH> --auto <AUTO_PATH> --format <FORMAT> --out <OUT_PATH>
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
**Example**: If user said "19 vs 20", and CLI resolved them to:
|
|
263
|
+
|
|
264
|
+
- Plan 19: `specfact-import-test-v2.2025-11-17T13-53-31.bundle.yaml`
|
|
265
|
+
- Plan 20: `specfact-import-test-v2.2025-11-17T13-53-31.enriched.2025-11-17T13-55-40.bundle.yaml`
|
|
266
|
+
|
|
267
|
+
Then execute:
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
specfact plan compare --manual .specfact/plans/specfact-import-test-v2.2025-11-17T13-53-31.bundle.yaml --auto .specfact/plans/specfact-import-test-v2.2025-11-17T13-53-31.enriched.2025-11-17T13-55-40.bundle.yaml
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
**Capture CLI output**:
|
|
274
|
+
|
|
275
|
+
- Comparison report path (if `--out` specified)
|
|
276
|
+
- Deviation counts and severity breakdown
|
|
277
|
+
- Console output with summary
|
|
278
|
+
- Any error messages or warnings
|
|
279
|
+
|
|
280
|
+
## Expected Output
|
|
281
|
+
|
|
282
|
+
**Console output (with deviations):**
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
SpecFact CLI - Plan Comparator
|
|
286
|
+
|
|
287
|
+
Manual Plan: .specfact/plans/main.bundle.yaml
|
|
288
|
+
Auto Plan: .specfact/reports/brownfield/auto-derived-2025-11-02T12-00-00.bundle.yaml
|
|
289
|
+
Total Deviations: 15
|
|
290
|
+
|
|
291
|
+
Comparison Results
|
|
292
|
+
|
|
293
|
+
Manual Plan: .specfact/plans/main.bundle.yaml
|
|
294
|
+
Auto Plan: .specfact/reports/brownfield/auto-derived-2025-11-02T12-00-00.bundle.yaml
|
|
295
|
+
Total Deviations: 15
|
|
296
|
+
|
|
297
|
+
Deviation Summary:
|
|
298
|
+
🔴 HIGH: 3
|
|
299
|
+
🟡 MEDIUM: 8
|
|
300
|
+
🔵 LOW: 4
|
|
301
|
+
|
|
302
|
+
Deviations by Type and Severity
|
|
303
|
+
┏━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
|
|
304
|
+
┃ Severity ┃ Type ┃ Description ┃ Location ┃
|
|
305
|
+
┡━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
|
|
306
|
+
│ 🔴 HIGH │ Missing Feature │ FEATURE-005 exists in auto but not │ features[4] │
|
|
307
|
+
│ │ │ in manual │ │
|
|
308
|
+
│ 🔴 HIGH │ Critical Mismatch │ STORY-003 acceptance criteria differ│ features[0]. │
|
|
309
|
+
│ │ │ significantly │ stories[2] │
|
|
310
|
+
└───────────┴───────────────────┴────────────────────────────────────┴───────────────┘
|
|
311
|
+
|
|
312
|
+
✓ Report written to: .specfact/reports/comparison/deviations-2025-11-02T12-00-00.md
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
**Console output (no deviations):**
|
|
316
|
+
|
|
317
|
+
```bash
|
|
318
|
+
No deviations found! Plans are identical.
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
**Console output (enforcement blocked):**
|
|
322
|
+
|
|
323
|
+
```bash
|
|
324
|
+
Enforcement Rules
|
|
325
|
+
Using enforcement config: .specfact/enforcement.yaml
|
|
326
|
+
|
|
327
|
+
🚫 [HIGH] missing_feature: BLOCK
|
|
328
|
+
❌ Enforcement BLOCKED: 1 deviation(s) violate quality gates
|
|
329
|
+
Fix the blocking deviations or adjust enforcement config
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
## Execution Steps
|
|
333
|
+
|
|
334
|
+
### 1. Execute CLI Command (REQUIRED)
|
|
335
|
+
|
|
336
|
+
**ALWAYS execute the specfact CLI** to perform the comparison:
|
|
337
|
+
|
|
338
|
+
```bash
|
|
339
|
+
specfact plan compare --manual <manual_path> --auto <auto_path> --format <format> --out <output_path>
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
**The CLI performs**:
|
|
343
|
+
|
|
344
|
+
- Plan bundle loading and validation
|
|
345
|
+
- Feature and story comparison
|
|
346
|
+
- Deviation detection and severity assignment
|
|
347
|
+
- Report generation (Markdown, JSON, or YAML)
|
|
348
|
+
- Enforcement rule checking (if `.specfact/enforcement.yaml` exists)
|
|
349
|
+
|
|
350
|
+
**Capture CLI output**:
|
|
351
|
+
|
|
352
|
+
- Comparison report path (if `--out` specified)
|
|
353
|
+
- Deviation counts (HIGH, MEDIUM, LOW)
|
|
354
|
+
- Console summary
|
|
355
|
+
- Any error messages or warnings
|
|
356
|
+
|
|
357
|
+
**If CLI execution fails**:
|
|
358
|
+
|
|
359
|
+
- Report the error to the user
|
|
360
|
+
- Do not attempt to create comparison reports manually
|
|
361
|
+
- Suggest fixes based on error message
|
|
362
|
+
|
|
363
|
+
### 2. Present Results
|
|
364
|
+
|
|
365
|
+
**Present the CLI-generated comparison report** to the user:
|
|
366
|
+
|
|
367
|
+
- **Report location**: Show where the CLI wrote the report file (if `--out` specified)
|
|
368
|
+
- **Deviation summary**: Show counts by severity (HIGH, MEDIUM, LOW)
|
|
369
|
+
- **Key deviations**: Highlight critical deviations from CLI output
|
|
370
|
+
- **Next steps**: Suggest actions based on deviations found
|
|
371
|
+
|
|
372
|
+
### 3. Validate Plan Bundles (Reference - CLI Handles This)
|
|
373
|
+
|
|
374
|
+
Load and validate both plan bundles:
|
|
375
|
+
|
|
376
|
+
- **Schema validation**: Use Pydantic models to validate structure
|
|
377
|
+
- **Required fields**: Check all required fields are present
|
|
378
|
+
- **Data types**: Validate data types match schema
|
|
379
|
+
- **Report errors**: If validation fails, report error and exit
|
|
380
|
+
|
|
381
|
+
### 4. Compare Plans
|
|
382
|
+
|
|
383
|
+
Perform comprehensive comparison:
|
|
384
|
+
|
|
385
|
+
#### 4.1 Feature Comparison
|
|
386
|
+
|
|
387
|
+
For each feature in both plans:
|
|
388
|
+
|
|
389
|
+
- **Feature matching**: Match features by key (exact match) or title (fuzzy match)
|
|
390
|
+
- **Feature deviations**:
|
|
391
|
+
- **Missing in manual**: Features in auto plan but not in manual
|
|
392
|
+
- **Missing in auto**: Features in manual plan but not in auto
|
|
393
|
+
- **Title mismatch**: Same key but different titles
|
|
394
|
+
- **Outcomes mismatch**: Different expected outcomes
|
|
395
|
+
- **Acceptance criteria mismatch**: Different acceptance criteria
|
|
396
|
+
- **Confidence mismatch**: Significant confidence difference (> 0.3)
|
|
397
|
+
|
|
398
|
+
#### 4.2 Story Comparison
|
|
399
|
+
|
|
400
|
+
For each story in matched features:
|
|
401
|
+
|
|
402
|
+
- **Story matching**: Match stories by key (exact match) or title (fuzzy match)
|
|
403
|
+
- **Story deviations**:
|
|
404
|
+
- **Missing in manual**: Stories in auto plan but not in manual
|
|
405
|
+
- **Missing in auto**: Stories in manual plan but not in auto
|
|
406
|
+
- **Title mismatch**: Same key but different titles
|
|
407
|
+
- **Acceptance criteria mismatch**: Different acceptance criteria
|
|
408
|
+
- **Confidence mismatch**: Significant confidence difference (> 0.3)
|
|
409
|
+
|
|
410
|
+
#### 4.3 Structure Comparison
|
|
411
|
+
|
|
412
|
+
- **Feature count**: Compare total feature counts
|
|
413
|
+
- **Story count**: Compare total story counts per feature
|
|
414
|
+
- **Coverage gaps**: Identify areas with no coverage in either plan
|
|
415
|
+
|
|
416
|
+
### 5. Assign Severity
|
|
417
|
+
|
|
418
|
+
Classify each deviation by severity:
|
|
419
|
+
|
|
420
|
+
- **HIGH**:
|
|
421
|
+
- Missing features/stories in manual plan (potential oversight)
|
|
422
|
+
- Critical acceptance criteria mismatch
|
|
423
|
+
- Confidence difference > 0.5
|
|
424
|
+
- Structural inconsistencies (orphaned stories, duplicate keys)
|
|
425
|
+
|
|
426
|
+
- **MEDIUM**:
|
|
427
|
+
- Title mismatches (possible naming inconsistencies)
|
|
428
|
+
- Acceptance criteria differences (non-critical)
|
|
429
|
+
- Confidence difference 0.3-0.5
|
|
430
|
+
- Outcome mismatches
|
|
431
|
+
|
|
432
|
+
- **LOW**:
|
|
433
|
+
- Minor title variations
|
|
434
|
+
- Confidence difference < 0.3
|
|
435
|
+
- Cosmetic differences (formatting, whitespace)
|
|
436
|
+
- Missing optional fields
|
|
437
|
+
|
|
438
|
+
### 6. Generate Comparison Report
|
|
439
|
+
|
|
440
|
+
Create structured report based on format:
|
|
441
|
+
|
|
442
|
+
#### Markdown Format
|
|
443
|
+
|
|
444
|
+
```markdown
|
|
445
|
+
# Plan Comparison Report
|
|
446
|
+
|
|
447
|
+
**Manual Plan**: `/path/to/manual.bundle.yaml`
|
|
448
|
+
**Auto Plan**: `/path/to/auto.bundle.yaml`
|
|
449
|
+
**Timestamp**: `2025-11-02T12:00:00Z`
|
|
450
|
+
**Total Deviations**: `15`
|
|
451
|
+
|
|
452
|
+
## Summary
|
|
453
|
+
|
|
454
|
+
- 🔴 **HIGH**: 3
|
|
455
|
+
- 🟡 **MEDIUM**: 8
|
|
456
|
+
- 🔵 **LOW**: 4
|
|
457
|
+
|
|
458
|
+
## Deviations
|
|
459
|
+
|
|
460
|
+
### HIGH Severity
|
|
461
|
+
|
|
462
|
+
| ID | Type | Description | Location |
|
|
463
|
+
|----|------|-------------|----------|
|
|
464
|
+
| H1 | Missing Feature | FEATURE-005 exists in auto but not in manual | features[4] |
|
|
465
|
+
| H2 | Critical Mismatch | STORY-003 acceptance criteria differ significantly | features[0].stories[2] |
|
|
466
|
+
|
|
467
|
+
### MEDIUM Severity
|
|
468
|
+
|
|
469
|
+
...
|
|
470
|
+
|
|
471
|
+
### LOW Severity
|
|
472
|
+
|
|
473
|
+
...
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
#### JSON Format
|
|
477
|
+
|
|
478
|
+
```json
|
|
479
|
+
{
|
|
480
|
+
"manual_plan": "/path/to/manual.bundle.yaml",
|
|
481
|
+
"auto_plan": "/path/to/auto.bundle.yaml",
|
|
482
|
+
"timestamp": "2025-11-02T12:00:00Z",
|
|
483
|
+
"total_deviations": 15,
|
|
484
|
+
"severity_counts": {
|
|
485
|
+
"HIGH": 3,
|
|
486
|
+
"MEDIUM": 8,
|
|
487
|
+
"LOW": 4
|
|
488
|
+
},
|
|
489
|
+
"deviations": [
|
|
490
|
+
{
|
|
491
|
+
"id": "H1",
|
|
492
|
+
"severity": "HIGH",
|
|
493
|
+
"type": "missing_feature",
|
|
494
|
+
"description": "FEATURE-005 exists in auto but not in manual",
|
|
495
|
+
"location": "features[4]"
|
|
496
|
+
}
|
|
497
|
+
]
|
|
498
|
+
}
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
#### YAML Format
|
|
502
|
+
|
|
503
|
+
Same structure as JSON, in YAML format.
|
|
504
|
+
|
|
505
|
+
### 7. Output Results
|
|
506
|
+
|
|
507
|
+
- **Console output**: Display summary with deviation counts and severity breakdown
|
|
508
|
+
- **Table view**: Show detailed deviation table in console with deviations grouped by severity
|
|
509
|
+
- **Comparison report**: Write to specified output path (if `--out` provided)
|
|
510
|
+
|
|
511
|
+
### 8. Apply Enforcement Rules (Optional)
|
|
512
|
+
|
|
513
|
+
If enforcement config exists (`.specfact/enforcement.yaml`):
|
|
514
|
+
|
|
515
|
+
- **Load config**: Parse enforcement configuration
|
|
516
|
+
- **Check blocking**: Identify deviations that should block (based on severity)
|
|
517
|
+
- **Report blocking**: If blocking deviations found, report error and exit with code 1
|
|
518
|
+
- **Report passing**: If no blocking deviations, report success
|
|
519
|
+
|
|
520
|
+
**Note**: Finding deviations is a successful comparison result. Exit code 0 indicates successful execution (even if deviations were found). Use the report file, stdout, or enforcement config to determine if deviations are critical.
|
|
521
|
+
|
|
522
|
+
## Output Format
|
|
523
|
+
|
|
524
|
+
### Deviation Structure
|
|
525
|
+
|
|
526
|
+
Each deviation includes:
|
|
527
|
+
|
|
528
|
+
- **ID**: Unique identifier (e.g., "H1", "M5", "L2")
|
|
529
|
+
- **Severity**: HIGH, MEDIUM, or LOW
|
|
530
|
+
- **Type**: Deviation type (e.g., "missing_feature", "title_mismatch")
|
|
531
|
+
- **Description**: Human-readable description
|
|
532
|
+
- **Location**: Path to deviation in plan structure (e.g., "features[0].stories[2]")
|
|
533
|
+
|
|
534
|
+
### Report Structure
|
|
535
|
+
|
|
536
|
+
- **Header**: Manual plan path, auto plan path, timestamp
|
|
537
|
+
- **Summary**: Total deviations, severity counts
|
|
538
|
+
- **Deviations by Severity**: Grouped deviations with details
|
|
539
|
+
- **Coverage Gaps**: Features/stories missing in either plan
|
|
540
|
+
- **Recommendations**: Suggestions for resolving deviations
|
|
541
|
+
|
|
542
|
+
## Guidelines
|
|
543
|
+
|
|
544
|
+
### Feature Matching
|
|
545
|
+
|
|
546
|
+
- **Exact match**: Same feature key (preferred)
|
|
547
|
+
- **Fuzzy match**: Similar feature titles (fallback, lower confidence)
|
|
548
|
+
- **No match**: Treat as missing feature
|
|
549
|
+
|
|
550
|
+
### Story Matching
|
|
551
|
+
|
|
552
|
+
- **Exact match**: Same story key within same feature (preferred)
|
|
553
|
+
- **Fuzzy match**: Similar story titles within same feature (fallback)
|
|
554
|
+
- **No match**: Treat as missing story
|
|
555
|
+
|
|
556
|
+
### Severity Assignment
|
|
557
|
+
|
|
558
|
+
- Use consistent criteria for severity classification
|
|
559
|
+
- Consider business impact when assigning severity
|
|
560
|
+
- Err on side of higher severity for missing features/stories
|
|
561
|
+
|
|
562
|
+
### Error Handling
|
|
563
|
+
|
|
564
|
+
- **Missing files**: Report error with helpful suggestions
|
|
565
|
+
- **Invalid format**: Report error and exit
|
|
566
|
+
- **Validation failures**: Report validation errors and exit
|
|
567
|
+
- **Permission errors**: Report error and exit gracefully
|
|
568
|
+
|
|
569
|
+
## Context
|
|
570
|
+
|
|
571
|
+
{ARGS}
|