specpro-cli 0.1.0__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.
Files changed (76) hide show
  1. specpro_cli/__init__.py +16 -0
  2. specpro_cli/assets/commands/specpro.analyze.md +1102 -0
  3. specpro_cli/assets/commands/specpro.checklist.md +335 -0
  4. specpro_cli/assets/commands/specpro.clarify.md +581 -0
  5. specpro_cli/assets/commands/specpro.constitution.md +488 -0
  6. specpro_cli/assets/commands/specpro.feature.md +115 -0
  7. specpro_cli/assets/commands/specpro.implement.md +1881 -0
  8. specpro_cli/assets/commands/specpro.manual-test.md +206 -0
  9. specpro_cli/assets/commands/specpro.plan.md +3284 -0
  10. specpro_cli/assets/commands/specpro.qc.md +1489 -0
  11. specpro_cli/assets/commands/specpro.scenarios.md +154 -0
  12. specpro_cli/assets/commands/specpro.specify.md +1449 -0
  13. specpro_cli/assets/commands/specpro.status.md +863 -0
  14. specpro_cli/assets/commands/specpro.tasks.md +1207 -0
  15. specpro_cli/assets/commands/specpro.test-implement.md +462 -0
  16. specpro_cli/assets/commands/specpro.test-plan.md +383 -0
  17. specpro_cli/assets/commands/specpro.user-manual.md +178 -0
  18. specpro_cli/assets/scripts/bash/check-anti-coupling.sh +293 -0
  19. specpro_cli/assets/scripts/bash/check-prerequisites.sh +176 -0
  20. specpro_cli/assets/scripts/bash/common.sh +88 -0
  21. specpro_cli/assets/scripts/bash/create-new-feature.sh +336 -0
  22. specpro_cli/assets/scripts/bash/qc-auto-fix.sh +121 -0
  23. specpro_cli/assets/scripts/bash/setup-plan.sh +60 -0
  24. specpro_cli/assets/scripts/bash/verify-cumulative-records.sh +203 -0
  25. specpro_cli/assets/scripts/bash/verify-deliverables-tracked.sh +147 -0
  26. specpro_cli/assets/scripts/bash/verify-deployment.sh +239 -0
  27. specpro_cli/assets/scripts/bash/verify-frontmatter-yaml.sh +63 -0
  28. specpro_cli/assets/scripts/bash/verify-ledger.sh +376 -0
  29. specpro_cli/assets/scripts/bash/verify-shapes.sh +1082 -0
  30. specpro_cli/assets/scripts/git-hooks/pre-commit +243 -0
  31. specpro_cli/assets/scripts/install-git-hooks.sh +67 -0
  32. specpro_cli/assets/scripts/powershell/check-anti-coupling.ps1 +249 -0
  33. specpro_cli/assets/scripts/powershell/check-prerequisites.ps1 +148 -0
  34. specpro_cli/assets/scripts/powershell/common.ps1 +95 -0
  35. specpro_cli/assets/scripts/powershell/create-new-feature.ps1 +229 -0
  36. specpro_cli/assets/scripts/powershell/qc-auto-fix.ps1 +110 -0
  37. specpro_cli/assets/scripts/powershell/setup-plan.ps1 +61 -0
  38. specpro_cli/assets/scripts/powershell/verify-cumulative-records.ps1 +133 -0
  39. specpro_cli/assets/scripts/powershell/verify-deliverables-tracked.ps1 +112 -0
  40. specpro_cli/assets/scripts/powershell/verify-deployment.ps1 +278 -0
  41. specpro_cli/assets/scripts/powershell/verify-frontmatter-yaml.ps1 +56 -0
  42. specpro_cli/assets/scripts/powershell/verify-ledger.ps1 +383 -0
  43. specpro_cli/assets/scripts/powershell/verify-shapes.ps1 +978 -0
  44. specpro_cli/assets/templates/agent-context-template.md +49 -0
  45. specpro_cli/assets/templates/assumptions-template.md +248 -0
  46. specpro_cli/assets/templates/checklist-template.md +40 -0
  47. specpro_cli/assets/templates/clarifications-template.md +155 -0
  48. specpro_cli/assets/templates/constitution-template.md +50 -0
  49. specpro_cli/assets/templates/feature-spec-template.md +66 -0
  50. specpro_cli/assets/templates/plan-overview-template.md +150 -0
  51. specpro_cli/assets/templates/plan-template.md +387 -0
  52. specpro_cli/assets/templates/protocol-golden-bytes-guide.md +195 -0
  53. specpro_cli/assets/templates/requirements-template.md +356 -0
  54. specpro_cli/assets/templates/spec-template.md +267 -0
  55. specpro_cli/assets/templates/tasks-template.md +252 -0
  56. specpro_cli/assets/templates/test-tasks-template.md +174 -0
  57. specpro_cli/cli/__init__.py +5 -0
  58. specpro_cli/cli/cmd_init.py +416 -0
  59. specpro_cli/cli/cmd_remove.py +122 -0
  60. specpro_cli/cli/entry.py +181 -0
  61. specpro_cli/integrations/__init__.py +36 -0
  62. specpro_cli/integrations/base.py +601 -0
  63. specpro_cli/integrations/claude/__init__.py +101 -0
  64. specpro_cli/integrations/copilot/__init__.py +153 -0
  65. specpro_cli/integrations/cursor_agent/__init__.py +51 -0
  66. specpro_cli/integrations/gemini/__init__.py +44 -0
  67. specpro_cli/integrations/opencode/__init__.py +48 -0
  68. specpro_cli/integrations/qodercli/__init__.py +54 -0
  69. specpro_cli/integrations/registry.py +88 -0
  70. specpro_cli/packaged/__init__.py +5 -0
  71. specpro_cli/packaged/sync.py +106 -0
  72. specpro_cli-0.1.0.dist-info/METADATA +117 -0
  73. specpro_cli-0.1.0.dist-info/RECORD +76 -0
  74. specpro_cli-0.1.0.dist-info/WHEEL +4 -0
  75. specpro_cli-0.1.0.dist-info/entry_points.txt +2 -0
  76. specpro_cli-0.1.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,1207 @@
1
+ ---
2
+ description: Generate an actionable, dependency-ordered tasks.md for the feature based on available design artifacts.
3
+ handoffs:
4
+ - label: Analyze For Consistency
5
+ agent: specpro-analyze
6
+ prompt: Run a project analysis for consistency
7
+ send: true
8
+ - label: Implement Project
9
+ agent: specpro-implement
10
+ prompt: Start the implementation in phases
11
+ send: true
12
+ writes:
13
+ # This command's write surface: only what it produces AS THE PRODUCER of that
14
+ # (artifact, unit) pair. A write this command makes on a non-producer path is a
15
+ # boundary violation by definition (FR-051) and MUST NOT be declared here.
16
+ # The full ownership map is the UNION of every command's writes: block.
17
+ - artifact: specs/tasks.md
18
+ unit: "whole task sections, the dependency graph, parallel-execution examples, and the ## Deprecated Items block; **except** the completion checkbox of a task line -> [x], which is /specpro-implement's (it is the ONE part of a task section this command does not own)"
19
+ - artifact: specs/spec.md
20
+ unit: "per-FR Lifecycle fields -> [tasks:processed|deprecated]"
21
+ - artifact: specs/implement_issues.md
22
+ unit: "the [tasks] section -> task descriptions fixed/added/reordered; its own entries marked [x]; the statistics table (**its own row only** — seven commands declare this artifact); appended ISS-NNN entries in any section — registration is routing; only [x]-marking is section-scoped"
23
+ ---
24
+
25
+ ## User Input
26
+
27
+ ```text
28
+ $ARGUMENTS
29
+ ```
30
+
31
+ You **MUST** consider the user input before proceeding (if not empty).
32
+
33
+ **Rerun safety — detect the artifact, default to incremental** ⚠️ [settled 2026-09-13]:
34
+
35
+ **Before writing `specs/tasks.md`, detect whether it already exists.** Use the SAME check in every command:
36
+
37
+ ```bash
38
+ [ -s specs/tasks.md ] && echo EXISTS || echo NEW # -s: exists AND non-empty (an empty placeholder counts as NEW)
39
+ ```
40
+
41
+ | Detection | Mode |
42
+ |-----------|------|
43
+ | **NEW** (absent or empty) | **Initial** — generate from scratch |
44
+ | **EXISTS** | **Incremental** — evolve it; **never silently regenerate from scratch** |
45
+
46
+ **Overwriting an existing artifact requires explicit, confirmed intent:**
47
+ 1. Only when the user *explicitly* asks (in their own words) does the initial path run on an existing artifact.
48
+ 2. **Even then, confirm once more before writing** — name the artifact that will be replaced and what will be lost; wait for the answer.
49
+ 3. **Silence is not consent.** An unspecified run on an existing artifact is ALWAYS incremental.
50
+
51
+ > **Why a shared rule rather than per-command courtesy**: nine of the twelve non-implementation commands already had some protection, but each wrote it its own way (`EXISTING_SPEC` check · "creates a NEW file" · `NEVER overwrite` · "incremental regeneration" · `AUTO_MODE=false`), and **three had none at all** — not by decision, but because the discipline had no shared carrier. Overwriting an artifact the user has been evolving is not recoverable within the session; the cost of asking is one prompt.
52
+
53
+
54
+ ### Scope Resolution 🆕 (FR-063 / T050 · v0.23)
55
+
56
+ 1. **作用域判定**: 当前工作目录位于 `specs/fNNN-简称/` 内 ⇒ **feature 作用域**(读写范围 = 本 feature 目录,由 `check-prerequisites.sh` 的作用域感知解析);位于仓库根或 `specs/` 根 ⇒ **母作用域**(读写母规格链)。feature 作用域内 MUST NOT 写母产物——唯一例外:**发现登记**(台账路由,`[specify]`/`[plan]` 分区)。
57
+ 2. **新会话首次执行**: 若 `specs/features.md` 存在且含 `active` 行、而用户未指明作用域 ⇒ **询问用户**在母作用域还是某个 feature 内工作,MUST NOT 自行挑选。
58
+ 3. 本命令的产物路径随之解析:feature 作用域下落 `<feature 目录>/`,母作用域下落 `specs/`。
59
+
60
+ ## Key Concept: FR-Level Incremental Task Updates 📋 [CRITICAL]
61
+
62
+ **Design Principle**: Tasks are generated and updated based on **Functional Requirements (FRs)**, not just User Stories.
63
+
64
+ ### Why FR-Level Granularity?
65
+
66
+ User Stories contain multiple FRs. When a single FR is modified:
67
+ - ✅ **OLD APPROACH (WRONG)**: Skip entire US if US.TasksStatus = "processed"
68
+ → FR modifications are ignored ❌
69
+
70
+ - ✅ **NEW APPROACH (CORRECT)**: Check each FR's TasksStatus independently
71
+ → Only update tasks for modified FRs, preserve completed tasks from other FRs ✅
72
+
73
+ ### Update Scenarios:
74
+
75
+ 1. **US.TasksStatus = "create"**:
76
+ - Generate tasks for ALL FRs in this US
77
+
78
+ 2. **US.TasksStatus = "update"**:
79
+ - Regenerate tasks for ALL FRs in this US
80
+ - Preserve completed tasks from previous iteration
81
+
82
+ 3. **US.TasksStatus = "processed"** but some **FR.TasksStatus = "update"**:
83
+ - **Partial update**: Only regenerate tasks for those specific FRs
84
+ - **Preserve** all completed tasks from other FRs
85
+ - **US.TasksStatus remains "processed"** until US itself is modified
86
+
87
+ ### Task Format Requirement:
88
+ Every task MUST end with `(FR-XXX)` annotation to enable FR-level tracking:
89
+ ```markdown
90
+ - [ ] T-xxx [US1] Implement plugin discovery (FR-xxx)
91
+ ```
92
+
93
+ ## Outline
94
+
95
+ **Artifact Language Rule** 🌐 [CRITICAL — applies to ALL generated content]:
96
+ - **Prose content** (descriptions, rationale, scenario text, guidance) follows the project's **Artifact Language** setting — from `specs/constitution.md` → **Artifact Language** field; default `en` when absent
97
+ - **Structural anchors are ALWAYS English**, regardless of the artifact language: section headings from the template, item ID prefixes (US/FR/T/INF/IT/CE/AE), status enums, and table column names — exactly as written in the template
98
+ - **Entry field labels are structural anchors too** (`source:`, `Evidence:`, `Fix Direction:`) — never translated, even when the surrounding prose is not English. They exist to be **searched**: an entry's fields must be greppable across artifacts and projects, and a translated label silently drops out of every consumer's scan.
99
+ - Rationale: fixed anchors keep artifacts machine-parseable across specpro commands and keep instructions ↔ artifacts aligned for review
100
+
101
+ 1. **Check for --review-issues argument** 🆕:
102
+
103
+ **Purpose**: Process implement issues submitted from the implement phase
104
+
105
+ a. **Parse arguments**:
106
+ - If `$ARGUMENTS` contains `--review-issues`:
107
+ * **Skip the question below**; proceed directly to step 1b (review issues)
108
+ - Else: **detect, then ask** ⚠️ [settled 2026-09-13]:
109
+ * Check the `[tasks]` section of `specs/implement_issues.md` for open `[ ]` entries
110
+ * **None** → continue with normal task generation (step 2+). **No prompt.**
111
+ * **Some** → **ask**: "N open `[tasks]` issues in specs/implement_issues.md. Process them first, or run normally?"
112
+ - *Process first* → proceed to step 1b (review issues)
113
+ - *Run normally* → continue with normal task generation (step 2+)
114
+ * **Rationale**: the flag used to be the whole switch — not passing it left pending issues **silently unprocessed**, passing it meant overriding the work the user actually wanted, and **which issues were pending was invisible until the command ran**. Detect-then-ask makes it an explicit choice; the flag now only means *"I already know — don't ask"*.
115
+ (Same model as `/specpro-implement` and `/specpro-test-plan` — see TOOL-008.)
116
+
117
+ b. **Review implement issues**:
118
+ - Read `specs/implement_issues.md`
119
+ - Extract all issues from `[tasks]` section
120
+ - Filter for issues marked `[ ]` (pending) only
121
+ - If no pending issues found:
122
+ * Display: "✓ No pending [tasks] issues to process"
123
+ * Exit
124
+
125
+ - Display issue summary:
126
+ ```markdown
127
+ 📋 [tasks] Issues Review
128
+
129
+ Found N pending [tasks] issues:
130
+ 1. [ ] ISS-XXX: Issue description
131
+ 2. [ ] ISS-XXX: Issue description
132
+ ...
133
+ ```
134
+
135
+ - For each pending issue:
136
+ * Read issue details:
137
+ - Problem description
138
+ - Current task (what's wrong)
139
+ - Suggested fix (what should be)
140
+ - Related task IDs
141
+ * Determine appropriate action:
142
+ - **Fix task description**: Update task description
143
+ - **Delete duplicate task**: Remove duplicate task
144
+ - **Add missing task**: Insert new task
145
+ - **Reorder tasks**: Adjust task order to fix dependencies
146
+ - **Split/merge tasks**: Combine or divide tasks as needed
147
+ * Apply the change to tasks.md
148
+ * Mark issue as `[x]` in implement_issues.md
149
+ * Display: "✓ Processed ISS-XXX: [action taken]"
150
+
151
+ - Update the statistics table at the **top** of `implement_issues.md` (its position is deliberate — see the note below)
152
+ - **Edit order and idempotency check** ⚠️ [a silent false-skip, observed 2026-09-13]: write the **entry body first** (into its own section), then the derived summaries (statistics table + `Last Updated`) — never the reverse. A derived summary written first introduces the new ID into the file's text before the entry exists, so an idempotency guard that greps the file for that ID falsely concludes "already present" and **skips the entry**, while the summaries still claim it landed. For the same reason the guard MUST match the entry body's **line-start pattern**, never a full-text keyword search:
153
+ ```bash
154
+ grep -qE '^- \[[x ]\] ISS-<N>:' specs/implement_issues.md # correct — matches an ENTRY, not a mention
155
+ # grep -q 'ISS-<N>' … # wrong — also matches the statistics Pending-Items column, the Last Updated line, cross-references
156
+ ```
157
+ - **General rule: every grep/awk example shown in an instruction or template must itself obey the line-start pattern** (TOOL-009) — the executing side copies examples verbatim, so an example that uses a whole-file match propagates the same misjudgment to everyone who copies it. This file has already corrected its own sentinel self-check command under this rule.
158
+ `.specpro/scripts/bash/verify-ledger.sh` reports the resulting inconsistency as a count mismatch — but only if it is run, and by then the entry is already missing.
159
+ - **Entry placement**: append new entries to the end of their own section, never to the end of the file. The file's statistics block sits at the top precisely so that "append to the end" lands inside the last section rather than between sections; moving or duplicating a section header breaks that and produces an orphaned section no `--review-issues` run will read.
160
+ - **Verify mechanically after writing**: run `.specpro/scripts/bash/verify-ledger.sh` — it checks entry section membership, statistics-vs-actual counts, and the trailing newline in one pass (non-zero exit names the violation). Marking issues `[x]` changes the counts, so this applies to this command too, not only to commands that append. A pre-commit hook enforces the same check.
161
+
162
+ - Display completion summary:
163
+ ```markdown
164
+ ✅ Completed [tasks] issues review
165
+
166
+ Processed: N issues
167
+ Updated: specs/tasks.md
168
+ Marked as [x] in implement_issues.md
169
+
170
+ ⚠️ **This is not an unqualified "ready".** This summary covers the `[tasks]` queue;
171
+ "ready to continue" is a claim about the **chain** (Constraint 6 / FR-045). State each
172
+ upstream stage's pending status before making it — see *Upstream status reconciliation*
173
+ in the main report below.
174
+
175
+ You can now run /specpro-implement to continue implementation.
176
+ All implement issues have been addressed.
177
+ ```
178
+
179
+ 2. **Setup**: Run `.specpro/scripts/bash/check-prerequisites.sh --json` from repo root and parse FEATURE_DIR and AVAILABLE_DOCS list. All paths must be absolute. For single quotes in args like "I'm Groot", use escape syntax: e.g 'I'\''m Groot' (or double-quote if possible: "I'm Groot").
180
+
181
+ 3. **Pre-flight Checks** ✨ (Fast-fail validation before core logic):
182
+
183
+ **Purpose**: Verify environment and prerequisites before executing task generation
184
+
185
+ a. **Required files check**:
186
+ ```bash
187
+ Check these files exist:
188
+ - ✅ $FEATURE_SPEC (specs/spec.md)
189
+ - ✅ $IMPL_PLAN (specs/plan.md)
190
+
191
+ If missing:
192
+ ❌ ERROR: Required file missing: $file
193
+ Fix: Run /specpro-plan first or verify installation
194
+ EXIT 1
195
+ ```
196
+
197
+ b. **Directory permissions check**:
198
+ ```bash
199
+ Check writable directories:
200
+ - ✅ $SPECS_DIR (specs/) is writable
201
+ - ✅ $FEATURE_DIR (specs/) can create tasks.md
202
+
203
+ If not writable:
204
+ ❌ ERROR: No write permission to $directory
205
+ Fix: chmod +w $directory or run with appropriate permissions
206
+ EXIT 1
207
+ ```
208
+
209
+ c. **Spec.md format validation**:
210
+ ```bash
211
+ Check spec.md has Lifecycle fields:
212
+ - ✅ Contains "**Lifecycle**:" markers
213
+
214
+ If missing:
215
+ ⚠️ WARNING: spec.md missing Lifecycle fields
216
+ Impact: May cause incremental processing to fail
217
+ Recommendation: Run /specpro-specify to add Lifecycle tracking
218
+
219
+ Your choice:
220
+ 1. Continue anyway (may encounter issues)
221
+ 2. Exit and fix Lifecycle fields first
222
+
223
+ Your choice (1/2):
224
+ ```
225
+
226
+ d. **Plan.md existence check**:
227
+ ```bash
228
+ Check if plan.md was generated:
229
+ - ✅ plan.md exists with Technical Context
230
+
231
+ If missing or incomplete:
232
+ ❌ ERROR: plan.md not found or incomplete
233
+ Fix: Run /specpro-plan first
234
+ Task generation requires plan.md for tech stack and architecture
235
+ EXIT 1
236
+ ```
237
+
238
+ e. **Quality gate: requirements.md validation** 🆕 [ENFORCED - AUTO-REPAIR]:
239
+ ```bash
240
+ Check specs/checklists/requirements.md:
241
+ - ✅ File exists
242
+ - ✅ Every item marked `[x]` (passed) ← ⚠️ **不在此处印条数**(`T238` / `ISS-211`):条数的真源是 `requirements-template.md` 的 `**Total Items**` 与清单自身;在这里重述一个数字即制造第二个来源。此处曾印 `12`,而**真值早已是 11** —— 它漂过一次而无人察觉,正是"重述"这件事的代价。⚠️ **该 MUST 现在有触发点**:`verify-shapes.sh` 的 `SHAPE-4 req-template-total` 比对模板字面量与模板自己的准则条数。
243
+
244
+ ⚠️ CRITICAL: This is a mandatory quality gate - QC execution is enforced automatically
245
+
246
+ Check file exists:
247
+ if [[ ! -f "$SPECS_DIR/checklists/requirements.md" ]]; then
248
+ ❌ AUTO-REPAIR TRIGGERED: Missing requirements.md
249
+
250
+ Problem: Spec quality validation not completed.
251
+ Required: specs/checklists/requirements.md (all items marked [x])
252
+ Current: File not found
253
+
254
+ Action: Auto-running QC to generate requirements.md...
255
+ ```
256
+ # Auto-run QC to fix missing requirements.md
257
+ echo ""
258
+ echo "🔄 AUTO-REPAIR: Running QC to generate requirements.md..."
259
+ /specpro-qc --scope="full"
260
+ # ⚠️ **No `--auto` here, and this is a decision, not an omission** (`T203` / `ISS-163`):
261
+ # this command's `writes:` unit for `spec.md` is its **Lifecycle fields**, so a
262
+ # repair of the FR PROSE is outside its write face — and delegating the repair to
263
+ # `/specpro-qc` does not widen it (it only moves the violation one level up, where
264
+ # it is harder to see). The checklist below is still produced: that happens on
265
+ # EVERY qc run, independently of any flag. ⇒ **Every qc call in this file is
266
+ # flag-less for this reason — and so is every other caller's** (`T136`): the
267
+ # `--fix-owner` parameter used to name the artifact whose owner was authorised to
268
+ # repair it, and `FR-058` removed the repair path itself ⇒ there is no such
269
+ # parameter to pass and **no caller that passes one**. ⚠️ **Do not restore the old
270
+ # wording**: an authorisation parameter whose subject no longer exists still reads
271
+ # as a live interface, so a reader who greps for it finds it here — and only here.
272
+
273
+ # Verify QC succeeded
274
+ if [[ ! -f "$SPECS_DIR/checklists/requirements.md" ]]; then
275
+ echo ""
276
+ echo "❌ AUTO-REPAIR FAILED: QC could not generate requirements.md"
277
+ echo " Task generation is BLOCKED without quality validation."
278
+ echo " Please run /specpro-qc manually to diagnose issues."
279
+ exit 1
280
+ fi
281
+
282
+ echo "✓ AUTO-REPAIR COMPLETE: requirements.md generated, proceeding with task generation..."
283
+ ```
284
+ fi
285
+
286
+ Check all items passed:
287
+ # 完成度按「Status 取值」判定,不按复选框——模板即 `- [ ] **Status**: …`,
288
+ # 「诚实跳过」与「未做」在复选框上完全同形(工具缺陷 #10)
289
+ QC_UNRESOLVED=$(grep -E '^- \[[ x]\] \*\*Status\*\*:' "$SPECS_DIR/checklists/requirements.md" 2>/dev/null \
290
+ | grep -vE '\*\*Status\*\*:[[:space:]]*(x|⊘[[:space:]]*Skipped)[[:space:]]*$' || true)
291
+ if [ -n "$QC_UNRESOLVED" ]; then
292
+ ❌ AUTO-REPAIR TRIGGERED: Incomplete requirements.md
293
+
294
+ Problem: Spec quality validation not completed.
295
+ Required: specs/checklists/requirements.md (all items marked [x])
296
+ Current: Some items are still unchecked [ ]
297
+
298
+ Action: Auto-running QC to fix issues...
299
+ ```
300
+ # Auto-run QC to fix unchecked items
301
+ echo ""
302
+ echo "🔄 AUTO-REPAIR: Running QC to fix unchecked items..."
303
+ /specpro-qc --scope="incremental"
304
+
305
+ # Verify QC succeeded
306
+ # 完成度按「Status 取值」判定,不按复选框——模板即 `- [ ] **Status**: …`,
307
+ # 「诚实跳过」与「未做」在复选框上完全同形(工具缺陷 #10)
308
+ QC_UNRESOLVED=$(grep -E '^- \[[ x]\] \*\*Status\*\*:' "$SPECS_DIR/checklists/requirements.md" 2>/dev/null \
309
+ | grep -vE '\*\*Status\*\*:[[:space:]]*(x|⊘[[:space:]]*Skipped)[[:space:]]*$' || true)
310
+ if [ -n "$QC_UNRESOLVED" ]; then
311
+ echo ""
312
+ echo "❌ AUTO-REPAIR FAILED: QC could not resolve all issues"
313
+ echo " Check specs/checklists/requirements.md for details."
314
+ echo " Please run /specpro-qc manually to diagnose issues."
315
+ exit 1
316
+ fi
317
+
318
+ echo "✓ AUTO-REPAIR COMPLETE: All items now marked [x]"
319
+ ```
320
+ fi
321
+
322
+ ✓ Quality validation passed
323
+ ```
324
+ **Benefits**:
325
+ - ✅ Fast failure: Detect issues before execution, avoid waste
326
+ - ✅ Clear error guidance: Each error has explicit fix steps
327
+ - ✅ Improved reliability: After pre-flight checks pass, execution is more reliable
328
+
329
+ 2. **Load design documents** 📋 [2/7]: Read from FEATURE_DIR:
330
+ - **Required**: plan.md (tech stack, libraries, structure), spec.md (user stories with priorities)
331
+ - **Optional**: data-model.md (entities), contracts/ (API endpoints), research.md (decisions), quickstart.md (test scenarios)
332
+ - Note: Not all projects have all documents. Generate tasks based on what's available.
333
+
334
+ 2.5. **Load quality recommendations** 📋 [3/7]: Load quality checklist recommendations and create tasks for quality issues ✨
335
+
336
+ **Purpose**: Load quality checklist recommendations and create tasks for quality issues
337
+
338
+ a. **Check if checklists/requirements.md exists**:
339
+ - Read `specs/checklists/requirements.md`
340
+ - If file doesn't exist, note: "No quality checklist found. Proceeding without quality recommendations..."
341
+ - Proceed to step 3
342
+
343
+ b. **Parse checklist for quality issues**:
344
+ - Read the checklist's **own** fields — verbatim, and only these:
345
+ * `**Status**`: `PASS` | `BLOCK` — the producer sets `PASS` ⟺ `**Failed**` == 0
346
+ * per-item rows: `- [ ] **Status**: x | ⊘ Skipped | ✗ Failed`
347
+ - The blocking set = the rows whose per-item value is `✗ Failed`
348
+ - ⚠️ Do **not** look for `❌ FAIL` / `⚠️ WARNING` items:
349
+ `templates/requirements-template.md` emits neither ⇒ this step would find
350
+ nothing on **every** checklist and produce no `[Quality]` task, ever.
351
+ - Check if plan.md addressed these issues
352
+
353
+ c. **Create tasks for quality issues**:
354
+ - For each `✗ Failed` item not addressed in plan.md:
355
+ * Create task: "TXXX: [Quality] Fix [specific issue] from checklist"
356
+ * Priority: High (P0)
357
+ * Add to Phase 1 (Foundational) or appropriate phase
358
+ * Example: "T-xxx: [Quality][P0] Add test coverage requirement for the wire protocol (>90% per Constitution Article IV)"
359
+ - ⚠️ **`⊘ Skipped` items generate no task**: the template's rule is that an
360
+ honest skip is a conclusion, not a debt — turning one into a task converts
361
+ "not applicable here" back into an obligation, which is exactly the
362
+ conflation the `⊘` value was introduced to end.
363
+
364
+ d. **Report quality tasks created**:
365
+ ```markdown
366
+ ## Quality Tasks Created
367
+
368
+ **Quality Issues Found**: 1
369
+ - ✗ Failed: 1 blocking issue
370
+ - ⊘ Skipped: 2 (non-blocking — no task generated)
371
+
372
+ **Tasks Created**:
373
+ - T-xxx: [Quality][P0] Add test coverage requirement for the wire protocol (from ✗ Failed)
374
+
375
+ These tasks will be integrated into the task breakdown.
376
+ ```
377
+
378
+ e. **Store recommendations for task context**:
379
+ - Keep recommendations accessible during task generation
380
+ - Apply recommendations to relevant user stories/FRs
381
+ - Example: For FR-xxx (Display remote screen), add edge case task from recommendation
382
+
383
+ 3. **Load spec items and process according to Lifecycle status** 📋 [4/7]:
384
+
385
+ **Purpose**: Track which spec items have been broken down into tasks and re-breakdown only modified items.
386
+
387
+ a. **Parse spec.md for Lifecycle fields**:
388
+ - Load spec.md (from FEATURE_DIR)
389
+ - Extract ALL items with Lifecycle fields:
390
+ * User Stories: ID, Title, Priority, **Lifecycle**: [specify:<status>][plan:<status>][tasks:<status>]
391
+ * Functional Requirements: ID, Title, **Lifecycle**: [specify:<status>][plan:<status>][tasks:<status>]
392
+ ⚠️ **Those two are the whole list** (`T249` / `ISS-225`): `## Constitution Constraints` **carries no `**Lifecycle**:` field**, and a third bullet naming it used to sit here. ⚠️ **Do not add it back** — the adjudication and its three pieces of evidence are in `commands/specpro.specify.md` → *Lifecycle Update Rules* (`T239` / `ISS-212`); the short version: the template emits no such field there, the plan-layer reader enumerates two classes, and measured on `specs/spec.md` all 73 Lifecycle lines belong to a US or an FR. A class listed here but absent from the artifact is a class this step would scan for and never find — and "found none" reads the same as "there were none".
393
+
394
+ **b. Extract Independent Test and Acceptance Scenarios** 🆕:
395
+ - For each User Story (from filtered list where tasksStatus != "processed" && tasksStatus != "deprecated"):
396
+ * **Extract Independent Test** (verbatim copy - preserve exact wording from spec.md)
397
+ * **Extract Acceptance Scenarios** (all Given-When-Then scenarios)
398
+ * **Categorize scenarios by type**:
399
+ - Happy Path (1-2 scenarios): Core success case
400
+ - Error Scenarios (2-3 scenarios): Error handling and recovery
401
+ - Edge Cases (1-2 scenarios): Boundary conditions, constraints
402
+ - Permission Scenarios (1-2 scenarios): Access control, authentication
403
+ * **Count and validate scenarios**:
404
+ - Each story should have 5-9 scenarios
405
+ - All 4 types should be represented
406
+ - Warn if scenario count is outside expected range
407
+ * **Generate scenario labels**: S1, S2, S3... for each scenario in story order
408
+ * **Report scenario statistics**:
409
+ - Total scenarios per story
410
+ - Breakdown by type (Happy, Error, Edge, Permission)
411
+
412
+ c. **Categorize items by TasksStatus**:
413
+ - **Items needing breakdown**: tasksStatus != "processed" && tasksStatus != "deprecated"
414
+ * tasksStatus = "create": New items, never broken down
415
+ * tasksStatus = "update": Items modified since last Tasks breakdown
416
+ * tasksStatus = "delete": Items deleted, need removal (will become deprecated after Plan processing)
417
+ * tasksStatus = "deprecated": Already processed in previous iteration, skip
418
+ - **Items to skip**: TasksStatus = "processed"
419
+ * Already broken down and unchanged, skip task generation
420
+
421
+ d. **Report processing statistics**:
422
+ ```markdown
423
+ ## Lifecycle Processing Summary
424
+
425
+ **Total Items**: N
426
+ - **New items**: X (tasksStatus = "create")
427
+ - **Modified items**: Y (tasksStatus = "update")
428
+ - **Deprecated items**: Z (tasksStatus = "deprecated")
429
+ - **Skipping**: M (already Processed)
430
+
431
+ Breaking down X+Y items into tasks, removing Z items...
432
+ ```
433
+
434
+ e. **Filter items for workflow**:
435
+ - Create filtered list containing only:
436
+ * Items where tasksStatus != "processed" && tasksStatus != "deprecated"
437
+ * These are the ONLY items to include in task breakdown
438
+ - Items with tasksStatus = "processed" or tasksStatus = "deprecated" are excluded from task generation
439
+
440
+ 4. **Execute task generation workflow** 📋 [5/7]:
441
+
442
+ **CRITICAL: Use TasksStatus to support incremental task generation**
443
+
444
+ a. **Load plan.md and extract** 🏗️ [ENHANCED - Architecture-Aware]:
445
+ - Tech stack, libraries, project structure
446
+ - **Architecture Patterns** (from plan.md Architecture Patterns section):
447
+ * Read all architecture patterns with their Key Points
448
+ * Extract pattern names, descriptions, and key capabilities
449
+ * Store for architecture pattern task generation
450
+ - **Layered Architecture** (from plan.md Layered Architecture section):
451
+ * Read all layers with their Responsibilities, Contains, and Constraints
452
+ * Extract layer definitions and MUST/MUST NOT constraints
453
+ * Store for cross-platform task generation and constraint validation
454
+ - **Component Interaction** (from plan.md Component Interaction section):
455
+ * Read all interaction patterns and their constraints
456
+ * Extract interaction mechanisms (e.g., EventBus, PluginContext)
457
+ * Store for interaction mechanism task generation
458
+ - **Critical Constraints** (from plan.md Critical Constraints section):
459
+ * Read all constraints with their Requirements and Architecture Impact
460
+ * Extract performance requirements, resource limits, operational constraints
461
+ * Store for constraint validation task generation
462
+ - Performance requirements and constraints (general)
463
+
464
+ b. **Load ONLY spec items filtered in Step 3.e** (where tasksStatus != "processed" && tasksStatus != "deprecated"):
465
+ - **SKIP items where TasksStatus = "processed" or TasksStatus = "deprecated"**
466
+ - These items have already been broken down into tasks in previous iterations (processed) or removed (deprecated)
467
+ - Do NOT regenerate tasks for these items
468
+ - Do NOT add to tasks.md
469
+
470
+ c. **Extract user stories with their priorities** (P1, P2, P3, etc.) from filtered list:
471
+ - Only include stories where tasksStatus != "processed" && tasksStatus != "deprecated"
472
+ - Mark stories as:
473
+ * **New story**: TasksStatus = "create" (never broken down)
474
+ * **Modified story**: tasksStatus = "update" (regenerate all FR tasks in this US, preserve completed tasks from other FRs)
475
+
476
+ d. **Extract functional requirements from filtered list** 📋 [CRITICAL]:
477
+ - **Purpose**: Identify which FRs need task generation/updates
478
+ - Extract ALL FRs from filtered list (where tasksStatus != "processed" && tasksStatus != "deprecated")
479
+ - Group FRs by their parent User Story (from spec.md structure)
480
+ - For each US, categorize its FRs:
481
+ * **New FRs**: tasksStatus = "create" (generate new tasks)
482
+ * **Modified FRs**: tasksStatus = "update" (regenerate tasks for this FR only)
483
+ * **Deleted FRs**: tasksStatus = "delete" (remove tasks for this FR)
484
+ - Store FR-US mapping for task organization in Step 4.h
485
+
486
+ e. **For data-model.md**:
487
+ - If exists: Extract entities and map to user stories
488
+ - Check TasksStatus for each entity to skip already processed ones
489
+
490
+ f. **For contracts/**:
491
+ - If exists: Map endpoints to user stories
492
+ - Check TasksStatus for each contract to skip already processed ones
493
+
494
+ g. **For research.md**:
495
+ - If exists: Extract decisions for setup tasks
496
+ - Only include setup tasks for incomplete/new items
497
+
498
+ h. **Generate tasks organized by user story** 📋 [CRITICAL - FR-BASED]:
499
+ - Follow Task Generation Rules (below)
500
+ - **CRITICAL: Task generation is driven by FR TasksStatus, not just US TasksStatus**
501
+
502
+ **Update Logic**:
503
+ 1. **For USs with tasksStatus = "create"**: Generate tasks for ALL FRs in that US
504
+ 2. **For USs with tasksStatus = "update"**: Regenerate tasks for ALL FRs in that US, preserve completed subtasks
505
+ 3. **For USs with tasksStatus = "processed"**:
506
+ - Check individual FRs' TasksStatus from Step 4.d
507
+ - If any FR has tasksStatus = "update" or "create":
508
+ * Generate/update tasks ONLY for those specific FRs
509
+ * Preserve all completed tasks from other FRs
510
+ - If no FRs need updates, skip this US entirely
511
+
512
+ **Task Format**:
513
+ - Every task MUST end with `(FR-XXX)` annotation
514
+ - Example: `- [ ] T-xxx [US1] Implement plugin discovery (FR-xxx)`
515
+ - This enables precise FR-level task tracking and updates
516
+
517
+ i. **Generate architecture-aware tasks** 🏗️ [NEW - Architecture-Aware]:
518
+ **Purpose**: Generate tasks for architecture patterns, layers, interactions, and constraints
519
+
520
+ **CRITICAL**: Architecture content from plan.md MUST drive task generation to ensure completeness
521
+
522
+ **i-1. Generate Architecture Pattern tasks**:
523
+ For each Architecture Pattern extracted in Step 4.a:
524
+ - **Phase assignment** ⚠️ [settled 2026-09-13]: architecture tasks go to **Phase 2 (Foundational)** — they are infrastructure work, not User Story work — and therefore carry **NO `(FR-xxx)` annotation** (the format rule: Setup / Foundational / Polish phases have no FR annotation). Anchor them by the **pattern name** instead. Do NOT copy the `(FR-xxx)` shape from the examples below — an earlier revision of this step showed it and the examples pulled generated tasks into the wrong phase.
525
+ - **Identify pattern components**: Extract Key Points to identify required implementations
526
+ - **Generate tasks for pattern components**:
527
+ * Example: "Plugin Pattern (Microkernel + Plugins)"
528
+ - TXXX: [P] Implement the plugin manager with framework integration — Validates: Microkernel + Plugins pattern
529
+ - TXXX: [P] Implement plugin discovery from plugins directory — Validates: Microkernel + Plugins pattern
530
+ - TXXX: [P] Implement plugin lifecycle management (initialize, start, stop, shutdown) — Validates: Microkernel + Plugins pattern
531
+ - TXXX: [P] Implement hot-reload support for development mode — Validates: Microkernel + Plugins pattern
532
+ - TXXX: [P] Implement plugin dependency resolution — Validates: Microkernel + Plugins pattern
533
+ * Example: "Repository Pattern"
534
+ - TXXX: [P] Define repository interfaces in shared/commonMain — Validates: Repository pattern
535
+ - TXXX: [P] Implement the concrete repositories against the project's storage layer — Validates: Repository pattern
536
+ - TXXX: [P] Add repository mocks for unit testing — Validates: Repository pattern
537
+ * Example: "Event Bus Pattern"
538
+ - TXXX: [P] Implement EventBus with publish/subscribe mechanism — Validates: Event Bus pattern
539
+ - TXXX: [P] Implement async event delivery via coroutines — Validates: Event Bus pattern
540
+ - TXXX: [P] Add event filtering and routing — Validates: Event Bus pattern
541
+ - **See references**: Include "See: research.md Section [X]" in task notes for detailed design
542
+
543
+ **i-2. Generate Layered Architecture tasks** (from plan.md Layered Architecture):
544
+ For each Layer extracted in Step 4.a:
545
+ - **Phase assignment** ⚠️: **Phase 2 (Foundational)**; **NO `(FR-xxx)` annotation** — same rule as i-1. Anchor by the **layer name**.
546
+ - **Generate tasks for each platform layer** (if expect/actual pattern documented):
547
+ * Example: "Shared Business/Domain Layer"
548
+ - TXXX: [P] Create expect interface in commonMain — Validates: Shared/Core layer
549
+ - TXXX: [P] Create actual implementation for Android in androidMain — Validates: Shared/Core layer
550
+ - TXXX: [P] Create actual implementation for iOS in iosMain — Validates: Shared/Core layer
551
+ - TXXX: [P] Create actual implementation for Desktop in desktopMain — Validates: Shared/Core layer
552
+ - **Generate layer constraint validation tasks**:
553
+ * For each "MUST NOT" or "MUST" constraint:
554
+ - TXXX: [Quality] Validate [constraint description] (e.g., "Platform Layer MUST NOT contain business logic") — Validates: [constraint description]
555
+ - Add linting or code review task to enforce constraint
556
+ - **Apply cross-platform completeness**: Ensure all platform-specific layers are included
557
+
558
+ **i-3. Generate Component Interaction tasks** (from plan.md Component Interaction):
559
+ For each interaction pattern extracted in Step 4.a:
560
+ - **Phase assignment** ⚠️: **Phase 2 (Foundational)**; **NO `(FR-xxx)` annotation** — same rule as i-1. Anchor by the **interaction pattern name**.
561
+ - **Generate tasks for interaction mechanisms**:
562
+ * Example: "Plugin → Core via EventBus"
563
+ - TXXX: [P] Implement EventBus core with publish API — Validates: Plugin → Core interaction
564
+ - TXXX: [P] Implement EventBus subscription mechanism — Validates: Plugin → Core interaction
565
+ - TXXX: [P] Implement PluginContext eventBus exposure — Validates: Plugin → Core interaction
566
+ - TXXX: [P] Add interaction constraint validation: "Plugins MUST NOT call Core directly" — Validates: Plugin → Core interaction
567
+ - **Generate interaction constraint tasks**:
568
+ * For each constraint: Add validation task to ensure constraint is enforced
569
+
570
+ **i-4. Generate Critical Constraint validation tasks** (from plan.md Critical Constraints):
571
+ For each Critical Constraint extracted in Step 4.a:
572
+ - **Phase assignment** ⚠️: **Phase 2 (Foundational)**; **NO `(FR-xxx)` annotation** — same rule as i-1. Anchor by the **constraint description** (the `Validates:` field already carries it).
573
+ - **Generate validation task** for each constraint:
574
+ * Example: "Real-Time Responsiveness: <500ms input-to-display latency"
575
+ - TXXX: [Quality] Add performance test: Input-to-display latency <500ms — Validates: Real-Time Responsiveness constraint
576
+ - Location: [REAL test source set, see Location grounding below]
577
+ * Example: "Bounded Resource Usage: 8GB RAM, 4 CPU cores"
578
+ - TXXX: [Quality] Add resource monitoring: RAM usage <8GB — Validates: Bounded Resource Usage constraint
579
+ - TXXX: [Quality] Add resource monitoring: CPU usage <4 cores — Validates: Bounded Resource Usage constraint
580
+ - Location: [REAL test source set]
581
+ * Example: "LAN-Only Operation: No cloud dependencies"
582
+ - TXXX: [Quality] Verify no cloud API calls in dependency graph — Validates: LAN-Only Operation constraint
583
+ - Location: [REAL test source set]
584
+ - **Mark constraint validation tasks as [Quality] priority**
585
+ - **Include constraint reference**: "Validates: [constraint description from plan.md]"
586
+ - **Constraint grounding** ⚠️: the constraint description MUST be one that **exists in plan.md's Critical Constraints** at generation time — a constraint cited from memory becomes an untraceable ghost requirement (same discipline as the Task Generation Rules' constraint-citation grounding)
587
+ - **Location grounding**: the example Locations above are ILLUSTRATIVE — every generated task's Location must point to the project's REAL test source set (apply the j-4 Location grounding rules)
588
+
589
+ **Validation**: All architecture patterns, layers, interactions, and constraints have corresponding tasks; **none of these tasks carries a `(FR-xxx)` annotation** (they are Foundational, not User-Story work).
590
+
591
+ j. **Apply test coverage requirements by risk level** 🧪 [NEW - Risk-Based Quality Assurance]:
592
+ **Purpose**: Apply code test coverage requirements based on plan.md Quality Targets (which derive from Constitution Article IV)
593
+
594
+ **⚠️ CRITICAL DISTINCTION**:
595
+ - **High-Level Test Coverage** (integration / component E2E / app E2E): Planned via `/specpro-test-plan` in `specs/test-tasks.md` - NOT generated in tasks.md
596
+ - **Code Test Coverage** (this step): Line/branch coverage percentage for code modules (varies by risk level and project type)
597
+ - These are **different metrics** for different quality dimensions
598
+
599
+ **j-1. Read Quality Targets from plan.md** ⚠️ [DO NOT HARDCODE]:
600
+ Read from plan.md Section "Quality Targets" → "Risk-Based Coverage Targets" table:
601
+ - **Project Type**: Check project type classification (MVP/Personal/Enterprise/Platform/Financial)
602
+ - **Coverage Targets Table**: Extract coverage percentages for each risk level
603
+ - **Example for Platform Application**:
604
+ * HIGH-RISK → >90% coverage (from plan.md table)
605
+ * MEDIUM-RISK → >70% coverage (from plan.md table)
606
+ * LOW-RISK → Optional (from plan.md table)
607
+
608
+ **⚠️ DO NOT hardcode coverage percentages** in tasks instruction!
609
+ - Coverage targets are **project-specific** and defined in plan.md
610
+ - Different project types have different coverage requirements
611
+ - Always read from plan.md Quality Targets section
612
+
613
+ **j-1a. If that table carries NO numeric target** (`T250` / `ISS-226`) — read this before step `j-3`:
614
+ ⚠️ **The table can legitimately hold something other than a percentage.** A project whose deliverable is not measurable code (pure text · no build artifacts · no executable) MUST NOT be given a number it cannot verify; its constitution says so and that table carries the **replacement standard** instead (clause ids, a named manual procedure — whatever that project chose).
615
+ When the three cells are not numbers:
616
+ - **MUST follow the standard the table actually states** — it is the project's quality target, and it is binding exactly as a percentage would be.
617
+ - **MUST state it explicitly** in the generated material: *"this project does not use coverage percentages as its standard — see `plan.md` → Quality Targets"*, quoting the table's own wording.
618
+ - **MUST NOT emit a `>XX%` placeholder** anywhere (task annotations, `[Quality]` task titles, `Purpose` lines, the `#### Quality Checkpoints` block) — a threshold nobody can compute is the *"unverifiable declaration"* such a constitution forbids, and it **reads exactly like a real threshold**.
619
+ - **MUST NOT stay silent about the item either** — dropping it without a word is the other way to make "no target" indistinguishable from "not checked".
620
+ **判据(可跑)**:产出的 `tasks.md` 里**不出现 `XX%`**,且**出现**上面那句明确陈述。
621
+ ⚠️ **This is not the same case as "no table at all"**: `/specpro-implement` §14 already covers *"no targets defined anywhere"*. Here the target **exists** — it is simply not a percentage.
622
+
623
+ **j-2. Determine FR risk level from `Quality Targets → Risk Classification`** —— ⚠️ **不是 `Constitution Check`**(`T232` ②):后者住在 `plan-overview.md`、且 `plan.md §5.3.f` **明令**那张逐 FR 风险表**不得放在那里**(它是 `tasks` 的**机器输入**,必须与覆盖率表同处 Part I)。本标题此前把读者指向一个被禁止的落点。:
624
+ For each FR, check its risk classification in plan.md Section "Quality Targets" → "Risk Classification":
625
+ - **HIGH-RISK Modules**: Protocol implementations, cryptography, network transport, critical data operations
626
+ - **MEDIUM-RISK Modules**: Business logic, data models, platform API bindings
627
+ - **LOW-RISK Modules**: UI components, utilities, helpers
628
+
629
+ **j-3. Annotate implementation tasks with risk level**:
630
+ For each FR implementation task generated in previous steps:
631
+ - **HIGH-RISK FRs** → Add annotation: `(HIGH-RISK - Test-First required, >XX% coverage per plan.md Quality Targets)`
632
+ - **MEDIUM-RISK FRs** → Add annotation: `(MEDIUM-RISK - Test-First recommended, >XX% coverage per plan.md Quality Targets)`
633
+ - **LOW-RISK FRs** → No test requirement annotation (optional tests allowed)
634
+ - **Example** (for Platform Application with >90% target):
635
+ ```
636
+ - [ ] T-xxx [P] [US1] [S1,S2,S5] Implement plugin hot-reload support (FR-xxx)
637
+ (HIGH-RISK - Test-First required, >90% coverage per plan.md Quality Targets)
638
+ ```
639
+
640
+ **j-4. Generate test tasks based on risk level and project type**:
641
+ For each FR that requires testing, generate test tasks with **project-specific coverage targets**:
642
+
643
+ **Unit test task template** (replace XX% with actual target from plan.md):
644
+ ```markdown
645
+ - [ ] TXXX [Quality] [US#] Unit tests (>XX% coverage per plan.md Quality Targets) for [FR title]
646
+ ⚠️ **不带 `[S#]` 场景标签**(T173):本节下方「**No scenario labels on task lines**」已把那个机制
647
+ **明令退役**,而本模板此前仍带着它 —— **同一份文档里一处禁止、另一处示范**。场景→覆盖的追溯
648
+ 现在在 `/specpro-test-plan` 的 `specs/test-tasks.md` 矩阵里。
649
+ Location: [REAL unit-test source set of the module under test — from plan.md project structure / build config / existing sibling tests, e.g. tests/core-test/src/jvmTest/kotlin/.../[Feature]Test.kt]
650
+ Purpose: Achieve >XX% line/branch coverage for [risk-level] modules
651
+ ```
652
+ **Location grounding ⚠️** [prevents imagined paths]:
653
+ - NEVER invent `tests/unit/` or similar placeholder paths — Location MUST be the project's actual unit-test source set, verified against plan.md project structure, build config sourceSets, or existing sibling test files
654
+ - If the target module has NO unit-test source set yet → the task must explicitly create/register it first (state this in the task), or record an issue
655
+ - **Integration / E2E test tasks are NOT generated here** — they belong to `/specpro-test-plan` (specs/test-tasks.md). tasks.md generates unit-test tasks ONLY (four-layer test ownership)
656
+
657
+ **Coverage Target Substitution** (from plan.md Quality Targets):
658
+ - **HIGH-RISK FRs**: Substitute XX% with target from plan.md (e.g., >90% for Platform, >95% for Financial)
659
+ - **MEDIUM-RISK FRs**: Substitute XX% with target from plan.md (e.g., >70% for Platform, >80% for Financial)
660
+ - **LOW-RISK FRs**: Use "(optional)" instead of percentage
661
+
662
+ ⚠️ **j-5 was REMOVED — this step no longer produces a `#### Quality Checkpoints` block** (`T232` ③):
663
+ - **No reader**: `grep -rn 'Quality Checkpoints' commands/ templates/` returned the producer and nothing else — and this repository's own `tasks.md` carries **0** such blocks, i.e. it was never even generated here. A checklist nobody reads is the shape this repository keeps removing, and `plan.md` §5.6b's standing ruling on the sibling section is *"**No checkboxes**"* — this is the same call.
664
+ - **What replaces it**: the per-phase coverage obligations are already carried by (a) each `[Quality]` task's own `Purpose:` line, and (b) `/specpro-implement` §14, which compares **per module** against the thresholds. A phase-level aggregate checkbox added a third, weaker copy.
665
+ ⚠️ **Do not re-add it.** If a phase-level roll-up is ever genuinely needed, it must arrive with a named reader in the same change.
666
+ **Implementation Notes**:
667
+ - Code test coverage is measured by tools like JaCoCo (line/branch coverage percentage)
668
+ - Scenario automation is measured by counting scenarios with automated tests (different metric)
669
+ - Both dimensions are important: scenario coverage ensures feature validation, code coverage ensures implementation quality
670
+ - Risk-based approach ensures testing effort is proportional to module criticality
671
+ - **Project-specific**: Coverage targets vary by project type (MVP < Personal < Enterprise < Platform < Financial)
672
+
673
+ k. **Generate database evolution tasks** 🗄️ [NEW - Schema Evolution]:
674
+ **Purpose**: Generate tasks for database schema evolution (V2, V3... migrations) when entities change
675
+
676
+ **⚠️ TERMINOLOGY**: Use "Schema Evolution" NOT "database migration"
677
+ - ✅ **Schema Evolution**: Modifying database schema within SAME system (ALTER TABLE ADD COLUMN, etc.)
678
+ - ✅ **Data Migration**: Moving data from ONE database system to ANOTHER (Oracle → PostgreSQL)
679
+ - ❌ **DO NOT use "database migration"** for adding fields → Use "schema evolution" instead
680
+
681
+ **k-1. Detect database requirement**:
682
+ Read plan.md Technical Context → Storage:
683
+ - IF Storage contains "SQLDelight" OR "SQLite" OR "PostgreSQL" OR "MySQL":
684
+ → Database required, proceed to Step k-2
685
+ - ELSE:
686
+ → Skip this step (no database needed)
687
+
688
+ **k-2. Check for schema evolution requirements**:
689
+ Read data-model.md Section "Entity Changes" (if present):
690
+ - IF section exists AND has "Updated Entities":
691
+ → Schema evolution required, proceed to Step k-3
692
+ - ELSE:
693
+ → Only initial schema needed, skip to Step k-7
694
+
695
+ **k-3. Generate schema evolution tasks for each changed entity**:
696
+ For each entity in "Updated Entities" list:
697
+ 1. **Detect change type**:
698
+ - NEW field added → Generate "ALTER TABLE ADD COLUMN" migration
699
+ - REMOVED field → Generate "ALTER TABLE DROP COLUMN" migration
700
+ - RENAMED field → Generate "ALTER TABLE RENAME COLUMN" migration
701
+ - TYPE changed → Generate "ALTER TABLE ALTER COLUMN" migration
702
+ - NEW table → Generate "CREATE TABLE" migration
703
+ - DROPPED table → Generate "DROP TABLE" migration
704
+
705
+ 2. **Generate schema evolution tasks**:
706
+ Task template:
707
+ ```markdown
708
+ - [ ] TXXX [DB] {[US#] + (FR-XXX) —— 仅当本组落在**某个 User Story 阶段**时} Create V{N}__{Description}.sq schema evolution migration
709
+ Purpose: [Explanation of change: Add/remove/rename field or table]
710
+ Change type: [ALTER TABLE ADD COLUMN | DROP COLUMN | RENAME COLUMN | CREATE TABLE | DROP TABLE]
711
+ Migration file: shared/commonMain/sqldelight/com/example/db/migrations/V{N}__{Description}.sq
712
+ SQL:
713
+ ```sql
714
+ -- V{N}__{Description}
715
+ -- Generated: [DATE]
716
+ -- Purpose: [Explanation]
717
+
718
+ [SQL statement - e.g., ALTER TABLE plugin ADD COLUMN author TEXT;]
719
+ ```
720
+ Related entity: [EntityName]
721
+ Previous version: V{N-1}
722
+ New version: V{N}
723
+ Breaking change: [yes/no]
724
+ ```
725
+
726
+ 3. **Generate .sq file update task**:
727
+ ```markdown
728
+ - [ ] TXXX [DB] [US#] Update [EntityName].sq with new schema (FR-XXX)
729
+ File: shared/commonMain/sqldelight/com/example/db/[EntityName].sq
730
+ Changes:
731
+ - [List changes: Added field X, renamed field Y, etc.]
732
+ Verify: SQL syntax, foreign keys, indexes
733
+ ```
734
+
735
+ 4. **Generate DAO update task** (if applicable):
736
+ ```markdown
737
+ - [ ] TXXX [DB] [US#] Update [EntityName]Dao for new schema (FR-XXX)
738
+ File: shared/commonMain/src/[package]/dao/[EntityName]Dao.kt
739
+ Changes:
740
+ - Add [newField] to INSERT query
741
+ - Add [newField] to UPDATE query
742
+ - Update SELECT queries if needed
743
+ Test: Verify DAO compiles with new schema
744
+ ```
745
+
746
+ 5. **Generate migration test task**:
747
+ ```markdown
748
+ - [ ] TXXX [DB] {[US#] + (FR-XXX) —— 仅当落在 User Story 阶段时} Test V{N} schema evolution migration
749
+ File: shared/commonTest/src/[package]/migration/V{N}MigrationTest.kt
750
+ Test cases:
751
+ - [ ] Verify migration applies without errors
752
+ - [ ] Verify existing data preserved
753
+ - [ ] Verify new column has correct default value (if applicable)
754
+ - [ ] Verify foreign key constraints maintained
755
+ - [ ] Verify indexes created/dropped correctly
756
+ ```
757
+
758
+ **k-4. Organize schema evolution tasks by migration version**:
759
+ Group tasks by migration version (V2, V3, V4...):
760
+ - V2 tasks must complete before V3 tasks can start
761
+ - Each version: Create migration file → Update .sq file → Update DAO → Test migration
762
+ - Add version dependencies in task descriptions
763
+
764
+ **k-5. Add schema evolution to Phase 2 (Foundational) or appropriate User Story phase**:
765
+ ⚠️ **阶段决定注解,注解不得写死**(T173 / audit finding:「放到 Foundational 阶段的 schema 任务,
766
+ 该不该带 `(FR-XXX)` 与 `[US#]`」):本节上面的模板此前**逐条写死**了 `[US#]` 与 `(FR-XXX)`,
767
+ 而**格式规则明写 Foundational 阶段两者都不带** —— 照模板生成、再按本节把它放进 Phase 2,
768
+ 产出的就是一条**违反格式规则**的任务。⇒ **判据**:落在 **Phase 2(Foundational)** ⇒
769
+ **两个都不带**,用 `[DB]` 与描述锚定;落在**某个 User Story 阶段** ⇒ **两个都带**。
770
+ - IF schema evolution affects ALL entities (e.g., global change):
771
+ * Add to Phase 2 (Foundational tasks)
772
+ - ELSE IF schema evolution affects specific User Story entities:
773
+ * Add to affected User Story phase
774
+ - Mark with [DB] priority tag
775
+ - Place schema evolution tasks BEFORE entity implementation tasks
776
+ (schema must be updated before entity code can use new fields)
777
+
778
+ **k-6. Verify schema evolution task completeness**:
779
+ For each changed entity:
780
+ - [ ] Migration file creation task generated (V{N}__*)
781
+ - [ ] .sq file update task generated
782
+ - [ ] DAO update task generated (if DAO exists)
783
+ - [ ] Migration test task generated
784
+ - [ ] Tasks ordered correctly (migration → .sq → DAO → test)
785
+ - [ ] Dependencies set correctly (V2 before V3)
786
+
787
+ **k-7. Initial schema tasks** (if no schema evolution required):
788
+ If data-model.md has no "Entity Changes" section (initial specification):
789
+ Generate initial database setup tasks:
790
+ ```markdown
791
+ - [ ] TXXX [DB] [P0] Generate initial database schema files (.sq) from data-model.md (FR-XXX)
792
+ Purpose: Create the schema files for all entities using the project's database framework
793
+ Output: shared/commonMain/sqldelight/com/example/db/*.sq
794
+ Entities: [List entities from data-model.md]
795
+ Verify: All entities have .sq files, foreign keys valid, indexes created
796
+
797
+ - [ ] TXXX [DB] [P0] Create V1__InitialSchema.sq migration file (FR-XXX)
798
+ File: shared/commonMain/sqldelight/com/example/db/migrations/V1__InitialSchema.sq
799
+ Content: CREATE TABLE statements for all entities, indexes, foreign keys
800
+ Verify: SQL syntax, valid schema
801
+
802
+ - [ ] TXXX [DB] [P0] Setup database driver and connection (FR-XXX)
803
+ File: shared/commonMain/src/[package]/db/DatabaseFactory.kt
804
+ Driver: [e.g., SQLDelight driver, Android SQLite driver]
805
+ Verify: Database file created, connection successful
806
+
807
+ - [ ] TXXX [DB] [P0] Test initial database setup (FR-XXX)
808
+ File: shared/commonTest/src/[package]/db/DatabaseSetupTest.kt
809
+ Test cases:
810
+ - [ ] Verify database file created
811
+ - [ ] Verify all tables created
812
+ - [ ] Verify foreign key constraints enforced
813
+ - [ ] Verify indexes exist
814
+ ```
815
+
816
+ **k-8. Add database terminology documentation task**:
817
+ ```markdown
818
+ - [ ] TXXX [DB] [P0] Document database schema evolution workflow
819
+ File: docs/database-evolution.md
820
+ Content:
821
+ - How to add new field (modify entity → run plan → generate V2 migration)
822
+ - How to rename column (modify entity → run plan → generate V2 migration)
823
+ - How to verify migration (test cases, manual verification)
824
+ - Database Evolution vs Data Migration terminology explanation
825
+ Purpose: Ensure team uses consistent terminology
826
+ ```
827
+
828
+ **Validation**:
829
+ - All changed entities have corresponding schema evolution tasks
830
+ - Tasks follow correct order (migration → .sq → DAO → test)
831
+ - Tasks marked with [DB] priority tag
832
+ - Terminology correct: "Schema Evolution" NOT "database migration"
833
+ - Migration versions numbered correctly (V2, V3, V4...)
834
+
835
+ l. **Generate dependency graph** showing user story completion order
836
+
837
+ m. **Create parallel execution examples** per user story
838
+
839
+ n. **Validate task completeness** (each user story has all needed tasks, independently testable)
840
+
841
+ 5. **Generate tasks.md** 📋 [6/7]: Use `.specpro/templates/tasks-template.md` as structure, fill with:
842
+ - Correct feature name from plan.md
843
+ - **CHECK TasksStatus for each FR before generating tasks** 📋 [CRITICAL]:
844
+ * If FR.TasksStatus = "processed" → SKIP (do not generate/update tasks for this FR)
845
+ * If FR.TasksStatus = "deprecated" → SKIP (already removed in previous iteration)
846
+ * If FR.TasksStatus = "create", "update", or "delete" → GENERATE/UPDATE tasks for this FR
847
+ - Phase 1: Setup tasks (project initialization)
848
+ - Phase 2: Foundational tasks (blocking prerequisites for all user stories)
849
+ - Phase 3+: One phase per user story (in priority order from spec.md)
850
+ - **ONLY include FRs filtered in Step 3.e and Step 4.d**
851
+ - If US has no FRs needing updates, skip this US phase entirely
852
+ - **For each User Story phase** 🆕:
853
+ * **Copy Independent Test** from spec.md (verbatim)
854
+ * **List Acceptance Scenarios Summary**:
855
+ - Total scenarios: X
856
+ - Breakdown: Happy (Y), Error (Z), Edge (W), Permission (V)
857
+ * **No scenario labels on task lines** ⚠️ [settled 2026-09-13]: the per-task scenario-label mechanism (`[S1,S3,S4,S7]`) and the `scenario-coverage.md` mapping it depended on **were retired** with the scenario-system restructure — **the "verbatim copy" idea behind them was inherited by the `/specpro-test-plan` system**, which is where scenario→coverage traceability now lives (`specs/test-tasks.md` matrix). The labels had no consumer on the task side: nothing reads them. Do NOT re-add them, and do NOT reference `specs/scenario-coverage.md` — **that file has no producer and no consumer**, so a pointer to it is a dead link.
858
+ - **High-level tests (integration / component E2E / app E2E)**: NOT in tasks.md - planned by `/specpro-test-plan` into `specs/test-tasks.md`, executed by `/specpro-test-implement`
859
+ - **MARK completed tasks** from previous iterations:
860
+ * If regenerating a modified FR, preserve completed tasks from other FRs as [x]
861
+ * Only add new/modified tasks for the specific FR being updated as [ ]
862
+ * Mark deleted FR tasks with [DELETED] and remove in next pass
863
+ - **PRESERVE the FRs you did NOT process** ⚠️ [settled 2026-09-13]: the filter above (`ONLY include FRs filtered`) governs **which FRs get (re)generated** — it does NOT say the un-filtered ones should disappear. Tasks belonging to FRs whose `tasksStatus = "processed"` are carried over **verbatim** into the new file. Concretely: **`tasks.md` is merged, never regenerated** — dropping the un-filtered FRs would silently delete the entire task history of a mature project (a run in which every FR is `processed` filters to an EMPTY set, and an overwrite would leave an empty file). The same rule as everywhere else: absent → initial, present → incremental.
864
+ - Each phase includes: story goal, independent test criteria, tests (if requested), implementation tasks
865
+ - Final Phase: Polish & cross-cutting concerns
866
+ - All tasks must follow the strict checklist format with FR annotations (see Task Generation Rules below)
867
+ - Clear file paths for each task
868
+ - Dependencies section showing story completion order
869
+ - Parallel execution examples per story
870
+ - Implementation strategy section (MVP first, incremental delivery)
871
+
872
+ 6. **Update Lifecycle fields after task generation** 📋 [7/7]:
873
+
874
+ a. **Update spec.md with new TasksStatus** for FRs 📋 [CRITICAL]:
875
+ - For each processed **FR** (from Step 3.d filtered list and Step 4.d):
876
+ * **If FR.SpecStatus IN ("create", "update")**:
877
+ - Update FR.TasksStatus to "processed"
878
+ - Format: `**Lifecycle**: [specify:<status>][plan:<status>][tasks:processed]`
879
+ - FR.SpecStatus and FR.PlanStatus preserved
880
+ * **If FR.SpecStatus = "delete"**(⚠️ 本条与 `plan.md` 的同一分支的关系,T173 已厘清):
881
+ - ⚠️ **触发看的是上游写下的那个标记**:`/specpro-plan` 在它的 `6.a` 里把这类条目的 `tasks` 段写成
882
+ **`delete`** 并注明「**Keep delete until Tasks processes it**」 —— **那是一个移交标记,不是终态**。
883
+ 本节此前写的是「Ensure TasksStatus = "deprecated"」,**跳过了"处理"这一步就直接写终态**:
884
+ 两处对同一件事给出相反的取值,且**产出的 `Lifecycle` 字符串不同**(`[tasks:delete]` vs `[tasks:deprecated]`)。
885
+ - **本阶段是链路末端**,所以顺序是:① **先做**——`Remove all tasks for this FR from tasks.md`;
886
+ ② **再写终态**——`FR.TasksStatus = "deprecated"`。
887
+ - Lifecycle 终值:`**Lifecycle**: [specify:delete][plan:deprecated][tasks:deprecated]`
888
+ (⚠️ **中途那一格 `[tasks:delete]` 由 plan 写、由本阶段消费**;两者是**同一件事的两个时刻**,
889
+ 不是一个事实的两个来源)
890
+
891
+ - **NOTE**: User Story TasksStatus is NOT automatically updated when individual FRs are processed
892
+ * US.TasksStatus updates only when ALL FRs in that US are processed
893
+ * OR when US itself is modified (US.SpecStatus = "update")
894
+ * This enables FR-level incremental updates
895
+
896
+ b. **Write updated spec.md**:
897
+ - Update Lifecycle fields for all processed FRs
898
+ - Check if all FRs in a US are processed → update US.TasksStatus
899
+ - Preserve all other spec content
900
+ - Atomic write (overwrite entire file)
901
+
902
+ c. **Handle deprecated items in tasks.md**:
903
+ - Remove all task sections related to deprecated items
904
+ - Examples:
905
+ * Remove entire User Story phase for deprecated US
906
+ * Remove tasks for deprecated FRs
907
+ * Update dependency graph to remove deprecated items
908
+ - Add deprecation notice if needed:
909
+ ```markdown
910
+ ## Deprecated Items
911
+
912
+ The following items were deprecated and have been removed from tasks:
913
+ - FR-XXX: [Title] (deprecated in spec v0.X)
914
+ - USY: [Title] (deprecated in spec v0.X)
915
+ ```
916
+
917
+ 7. **Report & Next Steps** ✨ ENHANCED (Clear user guidance):
918
+
919
+ **Upstream status reconciliation** ⚠️ [MANDATORY before any "ready to continue" — Constraint 6 / FR-045]
920
+
921
+ **"Ready to continue" is a claim about the whole chain, not about the stage speaking.** So
922
+ before this report states any "can continue / ready" conclusion, it MUST **read** each upstream
923
+ stage's pending status on the entries that stage produced, and **state** what it found. The
924
+ over-declaration this replaces: `/specpro-tasks` closed with "✅ Ready to continue
925
+ implementation" while the design side had not taken a single step (`specs/plan.md` → Constraint 6).
926
+
927
+ **Two things, neither optional**:
928
+
929
+ 1. **Say it when the status is clean too.** "Nothing was mentioned" and "nothing is pending"
930
+ are different statements, and the first cannot be told apart from "forgot to look".
931
+ 2. **Skipped and processed counts are listed separately** — never merged into one "handled" number.
932
+
933
+ **Report shape** — every upstream gets a line, **including when it has nothing pending**
934
+ (indented, not fenced: several of these blocks sit inside an enclosing fence, and a nested
935
+ fence would close the outer one early):
936
+
937
+ Upstream reconciliation (Constraint 6)
938
+ <upstream>: N pending · M processed
939
+ Verdict: <clear to continue | upstream debts listed above>
940
+
941
+ ⚠️ **Report — do not block.** The mechanism self-heals: an upstream that completes marks its
942
+ downstream `update`. Blocking would need a judgement of "what counts as a debt", and that
943
+ judgement *is* the downstream reading its upstreams — reporting is its only legitimate form.
944
+
945
+ ⚠️ **Copied verbatim across `specpro.{specify,plan,tasks,test-plan,test-implement}.md`** (five
946
+ sites; do not exist as one because each command document is deployed and read on its own).
947
+ Only the "This stage's upstreams" line below differs per file — **change all five together**.
948
+
949
+ **This stage's upstreams**: `specify` and `plan` — pending means an entry's `[tasks: ]` marker
950
+ is not `processed`, or a `[plan]`-side design decision is not yet reflected here.
951
+
952
+
953
+ **7.1 Generated Artifacts Report** ✨ NEW:
954
+
955
+ ```markdown
956
+ ## ✅ Task Generation Complete
957
+
958
+ **Tasks File**: specs/tasks.md
959
+
960
+ **Generated Tasks**: N tasks (X new, Y preserved, Z removed)
961
+ - **New tasks**: X (from new/modified items)
962
+ - **Preserved tasks**: Y (from previous iterations)
963
+ - **Removed tasks**: Z (from deprecated items)
964
+
965
+ **FR-Level Processing**:
966
+ - **Total FRs**: M
967
+ - **FRs processed**: A (create/update/delete)
968
+ - **FRs skipped**: B (already processed)
969
+ - **FRs deprecated**: C (removed)
970
+ - **User Stories with partial FR updates**: D (US already processed, but individual FRs updated)
971
+
972
+ **Lifecycle Processing**:
973
+ - **New items**: A (tasksStatus = "create" → Processed)
974
+ - **Modified items**: B (tasksStatus = "update" → Processed)
975
+ - **Deprecated items**: C (removed from tasks.md)
976
+ - **Skipping**: D (already Processed, preserved)
977
+
978
+ **Quality Tasks Created** (if any):
979
+ - T0XX: [Quality][P0] Fix [issue] (from `✗ Failed`)
980
+ - T0YY: [Quality][P1] Address [issue] (from `✗ Failed`)
981
+ ⚠️ **`❌ FAIL` 与 `⚠️ WARNING` 都不是清单能产的取值**(`2.5.b` 明令不要按它们找):这里此前把它们当成任务的**来源标注**印在示例里 —— 而示例是被照抄的(`TOOL-009`),下一个照它写的人会去找一个不存在的档。**能产的只有 `✗ Failed`**(`⊘ Skipped` 不生成任务)。
982
+
983
+ **Parallel Opportunities**: M tasks can run in parallel
984
+ **MVP Scope**: P1 User Stories (recommended for first iteration)
985
+ ```
986
+
987
+ **7.2 Next Options** ✨ NEW (CLEAR USER GUIDANCE):
988
+
989
+ ```markdown
990
+ Your task breakdown is complete! Choose your next action:
991
+
992
+ ### Option 1: Start Implementation (Recommended) ⚡
993
+ Execute tasks in dependency order, beginning with Phase 1.
994
+
995
+ ```bash
996
+ /specpro-implement
997
+ ```
998
+
999
+ **What this does**:
1000
+ - Execute tasks in phases (Setup → Foundational → User Stories → Polish)
1001
+ - Update task checkboxes as progress
1002
+ - Provide real-time progress tracking
1003
+ - Suitable for: All projects, ready to code
1004
+
1005
+ **Estimated time**: 2-6 hours (depending on project scope)
1006
+
1007
+ ---
1008
+
1009
+ ### Option 2: Review & Adjust Tasks (Manual) 🔍
1010
+ Review generated tasks before proceeding.
1011
+
1012
+ ```bash
1013
+ # Review the task breakdown
1014
+ cat specs/tasks.md
1015
+
1016
+ # Check specific phases
1017
+ grep -A 20 "## Phase 1" specs/tasks.md
1018
+ grep -A 20 "## Phase 2" specs/tasks.md
1019
+ ```
1020
+
1021
+ **After review**:
1022
+ - If satisfied: Choose Option 1 to start implementation
1023
+ - If adjustments needed: Edit tasks.md manually, then proceed
1024
+
1025
+ **Estimated time**: 5-15 minutes (depending on depth of review)
1026
+
1027
+ ---
1028
+
1029
+ ### Option 3: Update Plan First (Optional) 📐
1030
+ Regenerate plan with detailed Phase 2-7 breakdown before tasks.
1031
+
1032
+ ```bash
1033
+ /specpro-plan --continue
1034
+ ```
1035
+
1036
+ **What this does**:
1037
+ - Generate detailed implementation plan (Phase 2-7)
1038
+ - Expand milestones and timeline
1039
+ - Add risk management strategies
1040
+ - Suitable for: Large projects, team coordination
1041
+
1042
+ **Estimated time**: 5-10 minutes, then return to tasks
1043
+
1044
+ ---
1045
+
1046
+ ### Recommended Path 🎯
1047
+
1048
+ Based on your task breakdown:
1049
+ - **Total Tasks**: N (X new, Y preserved)
1050
+ - **Complexity**: [Low/Medium/High] (based on task count and dependencies)
1051
+ - **Parallel Opportunities**: M tasks can run simultaneously
1052
+
1053
+ **Recommended**:
1054
+ ```
1055
+ 1. Quick review (Option 2) - 5 minutes
1056
+ → Verify task breakdown looks correct
1057
+ → Check critical path and dependencies
1058
+
1059
+ 2. Start implementation (Option 1) - Begin coding
1060
+ → /specpro-implement
1061
+ → Execute Phase 1 (Setup) first
1062
+ → Continue through phases incrementally
1063
+ ```
1064
+
1065
+ **Total estimated time to code**: [X hours] (based on task count)
1066
+ ```
1067
+
1068
+ **7.3 Execution Time Summary** ✨ NEW:
1069
+
1070
+ ```markdown
1071
+ **Command**: /specpro-tasks
1072
+ **Duration**: [Time taken]
1073
+ **Items Processed**: [N new/modified, M skipped]
1074
+ **Tasks Generated**: [X new, Y preserved]
1075
+
1076
+ **Performance Breakdown**:
1077
+ - Load documents: [time]
1078
+ - Quality checks: [time]
1079
+ - Lifecycle parsing: [time]
1080
+ - Task generation: [time]
1081
+ - Write files: [time]
1082
+ ```
1083
+
1084
+ **Benefits**:
1085
+ - ✅ Clear next steps guidance (3 options)
1086
+ - ✅ Recommended path (based on project scale)
1087
+ - ✅ Observable execution time
1088
+ - ✅ Prevent user confusion (explicit next steps)
1089
+
1090
+ Context for task generation: $ARGUMENTS
1091
+
1092
+ The tasks.md should be immediately executable - each task must be specific enough that an LLM can complete it without additional context.
1093
+
1094
+ ## High-Level Testing (Out of Scope for tasks.md)
1095
+
1096
+ High-level tests (integration / component E2E / app E2E) are OUT of tasks.md scope: planned by `/specpro-test-plan` (artifact `specs/test-tasks.md`: coverage matrix + INF/IT/CE/AE test tasks) and executed by `/specpro-test-implement`.
1097
+
1098
+ Unit tests remain in tasks.md scope (see Step 4.j and `[Quality]` tasks). Manual acceptance is owned by `/specpro-manual-test`.
1099
+
1100
+ ---
1101
+
1102
+ ## Task Generation Rules
1103
+
1104
+ **CRITICAL**: Tasks MUST be organized by user story to enable independent implementation and testing.
1105
+
1106
+
1107
+ **Phase 1-5 Tests**: Only generate if explicitly requested (legacy behavior).
1108
+
1109
+ ### Checklist Format (REQUIRED)
1110
+
1111
+ Every task MUST strictly follow this format:
1112
+
1113
+ ```text
1114
+ - [ ] [TaskID] [P?] [Story?] Description with file path
1115
+ ```
1116
+
1117
+ **Format Components**:
1118
+
1119
+ 1. **Checkbox**: ALWAYS start with `- [ ]` (markdown checkbox)
1120
+ 2. **Task ID**: Sequential number (T001, T002, T003...) in execution order
1121
+ 3. **[P] marker**: Include ONLY if task is parallelizable (different files, no dependencies on incomplete tasks)
1122
+ 4. **[Story] label**: REQUIRED for user story phase tasks only
1123
+ - Format: [US1], [US2], [US3], etc. (maps to user stories from spec.md)
1124
+ - Setup phase: NO story label
1125
+ - Foundational phase: NO story label
1126
+ - User Story phases: MUST have story label
1127
+ - Polish phase: NO story label
1128
+ 5. **Description**: Clear action with exact file path
1129
+ 6. **[FR-XXX] annotation**: REQUIRED for all tasks derived from functional requirements
1130
+ - Format: Task description followed by `(FR-XXX)` at the end
1131
+ - Setup phase: NO FR annotation (infrastructure tasks)
1132
+ - Foundational phase: NO FR annotation (shared tasks)
1133
+ - User Story phases: MUST have FR annotation for each task
1134
+ - Polish phase: NO FR annotation (cross-cutting tasks)
1135
+ - **CRITICAL**: This enables FR-level incremental task updates
1136
+ 7. **Constraint citation grounding** [CRITICAL]: when a task description cites a constraint or platform limitation ("per <X>", "requires <X>", "view-only per <X>"), the cited source MUST exist in spec.md / constitution.md / plan.md at generation time — NEVER cite constraints from memory or hearsay. If the constraint is real but unwritten, first register it in the spec (clarify/specify), then reference it by ID; uncited-name constraints become untraceable ghost requirements downstream
1137
+ 8. **Location coverage — the acceptance evidence's landing point** [CRITICAL] [settled 2026-09-19]: a Location is chosen by asking *where does the implementation body land*, which is a **different question** from *where does this task's acceptance evidence land*. The two can be disjoint — and then the generated task **cannot be completed as written**: it mandates evidence it has nowhere to put. This is the **existence** half's sibling (the Location-grounding rule: never invent placeholder paths); this one is the **coverage** half.
1138
+ - **The check** ⚠️: if completing the task requires evidence to be **created or registered** (a new case, a new fixture, a new regression row), that evidence's landing point MUST also be in the Location. ⚠️ **Re-running evidence that already exists does not widen it** — a grep over a file already named, or a re-run of an already-registered check, writes nothing new. Only obligations this task must **place** count. Without that clause the rule catches everything and therefore decides nothing.
1139
+ - **What counts as a landing point** — state the criterion, not just its known forms: **a place where this project stores acceptance evidence and something reads it back**. The qualifier carries the weight: *"this project stores"* excludes imagined paths (the same discipline as the Location-grounding rule), and *"something reads it back"* excludes a file that merely mentions the evidence. Known forms: a **test file** · a **fixture tree** (the case files *and* the runner that reads them) · a **regression table in a contract** — that last one **only when the contract is bound to the unit under test**; naming a similarly-named contract because the right one is missing is the symptom, not the fix. ⚠️ **The three are a sample of what the criterion admits, not the criterion** — an enumeration narrower than the distribution is this repository's most-repeated defect, so a fourth form gets **added here** when it appears, never bent to fit one of the three.
1140
+ - **How to apply it** (per generated task, once the description is written): list the task's acceptance obligations → for each, name where the evidence must live → assert every one of those is in the Location. A task whose evidence has no home yet has a **Location gap**; the fix is to **widen the Location**, never to soften the obligation. ⚠️ **Both bounds are part of the check, not just the first**: take only obligations the task must **discharge to be accepted** — a side effect it also performs (registering a finding in the ledger, updating a log, citing a file) is **not** one. Reading the rule as "name every file the task touches" inflates every Location and makes the field useless; reading it as "the body's path is enough" produces tasks that cannot be completed. The check is the pair.
1141
+ - ⚠️ **This is a rule, not a roster.** Do not maintain a list of tasks that missed it: the Locations already carry that fact, and a second copy of it drifts.
1142
+
1143
+ **Examples**:
1144
+
1145
+ - ✅ CORRECT: `- [ ] T001 Create project structure per implementation plan`
1146
+ - ✅ CORRECT: `- [ ] T005 [P] Implement authentication middleware in src/middleware/auth.py`
1147
+ - ✅ CORRECT: `- [ ] T012 [P] [US1] Create User model in src/models/user.py (FR-xxx)`
1148
+ - ✅ CORRECT: `- [ ] T014 [US1] Implement UserService in src/services/user_service.py (FR-xxx)`
1149
+ - ❌ WRONG: `- [ ] Create User model` (missing ID, Story label, and FR annotation)
1150
+ - ❌ WRONG: `T001 [US1] Create model` (missing checkbox and FR annotation)
1151
+ - ❌ WRONG: `- [ ] [US1] Create User model (FR-xxx)` (missing Task ID)
1152
+ - ❌ WRONG: `- [ ] T001 [US1] Create model` (missing file path and FR annotation)
1153
+
1154
+ ### Task Organization
1155
+
1156
+ 1. **From Functional Requirements (FRs)** - PRIMARY GENERATION SOURCE 📋 [CRITICAL]:
1157
+ - **Each FR generates one or more tasks based on its requirements**
1158
+ - Group tasks by parent User Story for phase organization
1159
+ - Every task MUST be annotated with its source FR: `(FR-XXX)`
1160
+ - Mark FR dependencies (some FRs depend on other FRs)
1161
+ - **FR TasksStatus drives incremental updates**: Only generate/update tasks for FRs with tasksStatus = "create" or "update"
1162
+
1163
+ 2. **From User Stories** - PHASE ORGANIZATION:
1164
+ - Each user story (P1, P2, P3...) gets its own phase
1165
+ - Organize FR-derived tasks into their parent US phases
1166
+ - Each phase title: "## Phase X: User Story Y - [Title] (Priority: P#)"
1167
+ - Each subsection title: "### [Feature Name] (FR-XXX through FR-YYY)"
1168
+ - Mark story dependencies (most stories should be independent)
1169
+
1170
+ 3. **From Contracts**:
1171
+ - Map each contract/endpoint → to the user story it serves
1172
+ - Contract-conformance testing is NOT generated here — mock-based contract verification belongs to the Integration layer of `/specpro-test-plan` (four-layer test ownership; contract-test assets are registered in the coverage matrix as IT-layer coverage)
1173
+
1174
+ 4. **From Data Model**:
1175
+ - Map each entity to the user story(ies) that need it
1176
+ - If entity serves multiple stories: Put in earliest story or Setup phase
1177
+ - Relationships → service layer tasks in appropriate story phase
1178
+
1179
+ 5. **From Setup/Infrastructure**:
1180
+ - Shared infrastructure → Setup phase (Phase 1)
1181
+ - Foundational/blocking tasks → Foundational phase (Phase 2)
1182
+ - Story-specific setup → within that story's phase
1183
+
1184
+ ### Phase Structure
1185
+
1186
+ - **Phase 1**: Setup (project initialization)
1187
+ - **Phase 2**: Foundational (blocking prerequisites - MUST complete before user stories)
1188
+ - **Phase 3+**: User Stories in priority order (P1, P2, P3...)
1189
+ - Within each story: Tests (if requested) → Models → Services → Endpoints → Integration
1190
+ - Each phase should be a complete, independently testable increment
1191
+ - **Final Phase**: Polish & Cross-Cutting Concerns
1192
+
1193
+ ---
1194
+
1195
+ ## Protocol Codec Module Rules 🌐 [CONDITIONAL — wire-format / protocol modules only]
1196
+
1197
+ **Activation**: decided by the **Activation Gate** (`.specpro/templates/protocol-golden-bytes-guide.md` §6) — triggers T3/T5 (a byte stream to encode/decode, or tests asserting on raw bytes). Consume the verdict recorded upstream (§6.4); do not re-judge it. When activated, task generation MUST produce the systematic four-part test matrix — not a single test task — and MUST carry forward every GAP row from the plan-layer inventory as an explicit task or an explicit deferral.
1198
+
1199
+ - **The four-part matrix** (each protocol point from the plan-layer inventory maps to coverage):
1200
+ 1. **Decode matrix**: message/tile type × full-frame vs incremental context × parameters — assert byte-by-byte or pixel-by-pixel.
1201
+ 2. **Encode reverse matrix**: `encoder(pixels) → bytes` compared against the golden anchor, byte by byte.
1202
+ 3. **Shared golden-bytes fixture**: all anchors constructed in one place, shared by the encoder and decoder matrices.
1203
+ 4. **Property-test extension**: randomized content / length / combinations, fixed seed, with a failure output that reproduces the failing parameters.
1204
+ - **Matrix inputs are built from anchored golden bytes — never from the implementation under test.** Deriving the input byte stream from the implementation's own parse semantics is a behaviour lock, not a protocol test: it mirrors the implementation's reading of the format back as "correct", so any misreading is baked into the fixture and every assertion passes by construction. Anchor both directions — the input bytes (§2) and the expected output — or record the row as a GAP (§6.3). A protocol point with no reachable anchor becomes an explicit GAP row, not a silently absent one.
1205
+ - Extension-chain boundary values — continuation markers, maximum-length encodings — MUST be specified as **byte-level examples** (see guide §1), never by prose name: "skip the marker" and "accumulate the marker" describe different streams. Runs whose length lands exactly on a marker boundary MUST have a case.
1206
+ - **Error paths are part of the matrix**: truncated stream, invalid control byte, over-long run, out-of-range index — each MUST have a decided expected behaviour (reject vs tolerate) in the matrix tasks. "Unspecified" is not an answer; it is the shape of the next latent defect — an undecided skip-and-continue path is exactly such a case.
1207
+