@gordon.gan/specflow 1.3.2-beta → 1.4.0-beta

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.
@@ -6,6 +6,8 @@
6
6
 
7
7
  Generate a substantive `design.md` representing your **first round of deep thinking** on this change. This is v1 of the design — refine will produce v2 by challenging assumptions, proposing alternative options, probing edge cases, and questioning scope. Your job here is to give refine something real to work with.
8
8
 
9
+ **Narrative language:** Follow the resolved `artifacts.language` for Context, Goals / Non-Goals, Decisions, Risks, and Open Questions. Keep paths, commands, code, symbols, and technical identifiers unchanged.
10
+
9
11
  ## Inputs You Must Read
10
12
 
11
13
  - `specflow/changes/<change-name>/proposal.md` — the approved proposal
@@ -4,6 +4,8 @@
4
4
 
5
5
  Generate a proposal document following the SpecFlow format. The proposal establishes WHY a change is needed and WHAT it affects.
6
6
 
7
+ **Narrative language:** Follow the resolved `artifacts.language` for Why, What Changes, Impact, Capabilities prose, and success criteria. Keep change IDs, capability IDs, paths, commands, and code symbols unchanged.
8
+
7
9
  ## Process
8
10
 
9
11
  ### Step 1: Baseline Awareness
@@ -27,6 +27,8 @@ Create one spec file per capability at `specflow/changes/<change-name>/specs/<ca
27
27
 
28
28
  **CRITICAL FORMAT — the specflow CLI parses this exact structure. Deviations will cause validation and archive failures.**
29
29
 
30
+ **Narrative language:** Follow the resolved `artifacts.language` for all business content — requirement descriptions, scenario titles, and the text after `WHEN` / `THEN`. Protocol markers below stay exactly English. Do not emit English narrative when `zh-CN` is configured.
31
+
30
32
  Use `##` headers for delta operation sections. Use `###` for requirements. Use `####` for scenarios. Use `- **WHEN**` and `- **THEN**` bullet format for scenario steps.
31
33
 
32
34
  ```markdown
@@ -66,9 +68,9 @@ TO: <new requirement name>
66
68
 
67
69
  **Format rules:**
68
70
  - Each requirement: `### Requirement: <name>` followed by description
69
- - Use SHALL/MUST for normative requirements (avoid should/may)
71
+ - Use SHALL/MUST (or 必须/应当 under zh-CN) for normative requirements (avoid should/may)
70
72
  - Each scenario: `#### Scenario: <name>` — **MUST use exactly 4 hashtags (`####`)**. Using 3 hashtags will fail validation silently.
71
- - Scenario steps: `- **WHEN** <condition>` and `- **THEN** <outcome>` — **MUST use bullet dash + bold format**
73
+ - Scenario steps: `- **WHEN** <condition>` and `- **THEN** <outcome>` — **MUST use bullet dash + bold format**; `<condition>` / `<outcome>` use the resolved artifact language
72
74
  - Every requirement MUST have at least one scenario
73
75
  - Only include the sections you need (e.g., only `## ADDED Requirements` for new capabilities)
74
76
 
@@ -30,15 +30,15 @@ This marker tells future readers (and the Apply Phase A prompt) that this docume
30
30
  - Group names are capability- or layer-oriented, not generic ("Core artifact management" — not "Phase 1")
31
31
 
32
32
  2. **Each group contains 2 to 6 concrete checkbox items**
33
- - Format: `- [ ] N.M <动作短语>` where N is the group number and M is the item index within the group
34
- - Mixed Chinese and English is acceptable (project convention); pick the language the action verb flows in
33
+ - Format: `- [ ] N.M <action phrase>` where N is the group number and M is the item index within the group
34
+ - Group titles and task descriptions MUST follow the resolved `artifacts.language` from Artifact Language Setup (zh-CN → Simplified Chinese; en → English). Keep paths, commands, code, and symbols unchanged. Do not default to English when `zh-CN` is configured, and do not mix narrative languages inside the same tasks.md.
35
35
 
36
36
  3. **Items are concrete actions, not topics**
37
- - "实现 searchNotes 纯函数" (good — specific function)
38
- - "添加 CLI --verbose 标志并接入 logger" (good — specific change)
39
- - "处理搜索逻辑" (bad vague topic, not an action)
40
- - "handle searching" (bad same problem in English)
41
- - "完善测试" (bad improvement verb without a subject)
37
+ - zh-CN good: "实现 searchNotes 纯函数"
38
+ - zh-CN good: "添加 CLI --verbose 标志并接入 logger"
39
+ - en good: "Implement searchNotes pure function"
40
+ - bad: "处理搜索逻辑" / "handle searching" (vague topic, not an action)
41
+ - bad: "完善测试" / "improve tests" (improvement verb without a subject)
42
42
 
43
43
  4. **Each item should be a coherent unit of work** — roughly the size that Apply Phase A will later expand into a handful of bite-sized TDD steps. If an item feels like it's really 5 unrelated actions, split it.
44
44
 
@@ -55,7 +55,7 @@ If the change has both parallel capabilities and deep layering, a two-level grou
55
55
 
56
56
  ## Example — Good Granularity
57
57
 
58
- Below is a short worked example for a hypothetical "add search to notes CLI" change. Study the **granularity and verb concreteness**, not the specific content.
58
+ Below is a short worked example for a hypothetical "add search to notes CLI" change when `artifacts.language` is `zh-CN`. Study the **granularity and verb concreteness**, not the specific content. If the active language is `en`, write the same structure entirely in English.
59
59
 
60
60
  ```markdown
61
61
  <!-- Plan-phase first-iteration tasks. Will be rewritten to writing-plans precision in /specflow:apply Phase A. -->
@@ -119,5 +119,6 @@ specflow/changes/<change-name>/tasks.md
119
119
  - Substantive, not placeholder
120
120
  - 3 to 8 groups, 2 to 6 items each
121
121
  - Concrete verbs on concrete subjects
122
+ - Business narrative language follows `artifacts.language`; protocol/tech tokens stay unchanged
122
123
  - Top-of-file marker comment is mandatory
123
124
  - Writing-plans precision comes in Apply Phase A — do not pre-write it here
@@ -8,7 +8,13 @@ Before creating or rewriting any SpecFlow artifact:
8
8
  - `zh-CN` → write human-readable artifact content in Simplified Chinese.
9
9
  - Missing → default to `en`.
10
10
  - Invalid → report the invalid value and use `en`; do not invent another language.
11
- 3. Apply the selected language consistently to narrative prose, requirement and scenario descriptions, design rationale, and task descriptions.
11
+ 3. Apply the selected language to **all non-protocol business content**, including:
12
+ - proposal Why / What / Impact / success criteria
13
+ - requirement descriptions and scenario titles
14
+ - text after protected `WHEN` / `THEN` markers
15
+ - design Context, Goals, Decisions, Risks, Open Questions
16
+ - task group titles and task descriptions (including Apply Phase A rewrites)
17
+ 4. Do **not** mix languages for that business content. Protocol markers and technical identifiers stay as written below; everything else follows the resolved language.
12
18
 
13
19
  ## Protected Protocol
14
20
 
@@ -0,0 +1,508 @@
1
+ ---
2
+ name: specflow-approval
3
+ description: "Post-refine technical approval document -- AI closed-loop check + code/baseline grounding + over-design guard + implementability assessment"
4
+ ---
5
+
6
+ # SpecFlow: Approval
7
+
8
+ > **HARD GATE**: phase must be `refined`. Run `/specflow:refine` first if not.
9
+ > **HARD GATE**: User must confirm before `approval.md` is written to the change directory.
10
+ > Approval does NOT advance phase — it produces an optional review artifact for human sign-off.
11
+
12
+ ## Purpose
13
+
14
+ Approval is the **post-refine, pre-apply technical review pass**: it reads the four
15
+ refined artifacts (`proposal.md`, delta `specs/`, `design.md`, `tasks.md`), **grounds them
16
+ against existing project code and spec baseline**, and produces a single `approval.md`
17
+ technical-approval document for human sign-off.
18
+
19
+ It is **optional**. Skip it when you want to go straight from refine to apply. Use it when
20
+ the change is significant enough to warrant formal technical review before implementation
21
+ begins — architecture decisions, cross-team impact, regulatory exposure, or any change where
22
+ "should we even build this, this way?" deserves a documented answer.
23
+
24
+ Unlike `/specflow:review` (which reviews code after implementation) and `/specflow:verify`
25
+ (which validates implementation against specs), approval reviews the **plan** before any
26
+ code is written. It fills the gap between refine convergence and apply execution.
27
+
28
+ Approval does five things a deterministic CLI cannot:
29
+
30
+ 1. **Integrates** the four artifacts into a single narrative with cross-references.
31
+ 2. **Checks closed-loop coherence** across requirements ↔ design ↔ specs ↔ tasks using
32
+ semantic reasoning (fuzzy wording detection, coverage gaps, traceability).
33
+ 3. **Grounds the plan against reality** — reads existing project code (anchor files) and
34
+ the main spec baseline to verify the plan can actually land on this codebase.
35
+ 4. **Guards design quality** — detects over-engineering (YAGNI violations) while confirming
36
+ reasonable extensibility is preserved.
37
+ 5. **Assesses implementability** — can an engineer execute this plan without getting stuck?
38
+
39
+ ## Invocation
40
+
41
+ ```text
42
+ /specflow:approval <change-name>
43
+ ```
44
+
45
+ Cursor: `specflow:approval <change-name>`;Codex: `$specflow-approval <change-name>`.
46
+
47
+ ## Prerequisites
48
+
49
+ - An active change exists with `.specflow.yaml` and `phase: refined`.
50
+ - If phase is not `refined`, REFUSE to proceed and suggest: "This change is in phase
51
+ `<phase>`. Run `/specflow:refine` first to complete deep review before generating an
52
+ approval document."
53
+ - All four refined artifacts exist in `specflow/changes/<name>/`:
54
+ - `proposal.md`
55
+ - `specs/**/*.md` (at least one delta spec)
56
+ - `design.md`
57
+ - `tasks.md`
58
+ - `specflow` CLI is available on PATH (for `specflow validate` and optional status lookup).
59
+ - Optional: `explore.md` with `Status: confirmed` (enriches the approval's "why" section).
60
+
61
+ ## Artifact Language Setup
62
+
63
+ Read `.claude/specflow/prompts/shared/artifact-language.md` and resolve the active planning
64
+ root's `specflow/config.yaml` before generating `approval.md`. Apply the policy to all
65
+ human-readable narrative content (summaries, assessments, evidence). Preserve protocol
66
+ markers (`### Requirement:`, `#### Scenario:`, `- **WHEN**`, `- **THEN**`), capability IDs,
67
+ change names, file paths, commands, and code in their original form.
68
+
69
+ ---
70
+
71
+ ## Stage 1: Pre-flight Validation
72
+
73
+ 1. Read `.specflow.yaml` and confirm `phase: refined`. If not, refuse and suggest `/specflow:refine`.
74
+ 2. Confirm all four artifacts exist. If any is missing, stop and tell the user which are missing.
75
+ 3. Read `specflow/config.yaml` and resolve `artifacts.language` (default `en`).
76
+ 4. Detect project tech stack signals at the project root only (do not recurse):
77
+ - `package.json` → Node/TS/JS ecosystem
78
+ - `go.mod` → Go
79
+ - `pyproject.toml` / `requirements.txt` → Python
80
+ - `Cargo.toml` → Rust
81
+ - `tsconfig.json` → TypeScript (refines Node detection)
82
+ - If none match, set `techStack: unknown`
83
+ 5. Read `specflow/specs/` baseline if it exists (for Pass 7 baseline cross-check).
84
+
85
+ Announce: "Generating technical approval document for change `<name>` (phase=refined, language=<lang>, techStack=<stack>)."
86
+
87
+ ---
88
+
89
+ ## Stage 2: Load Execution Instructions
90
+
91
+ Read the file at `.claude/specflow/prompts/approval/generate.md` and follow its instructions.
92
+
93
+ That prompt file contains the complete specification for:
94
+
95
+ - The 7-dimension closed-loop verification (Passes 1–7, each with AI self-prompt, verdict rules, evidence format)
96
+ - The design quality assessment (over-engineering signals + extensibility signals)
97
+ - The architecture design (Mermaid module-dependency/system-interaction diagrams + core-component responsibility & boundary table, with project-type adaptation)
98
+ - The detailed design generation (data structures / interfaces / business flow / core logic / config / compatibility, with project-type adaptation and traceability rules)
99
+ - The test strategy (layered test matrix: unit/integration/acceptance/regression/performance-security-compat, each layer mapped to acceptance criteria)
100
+ - The deployment/release/rollback plan (deployment method/order, release strategy, rollback, monitoring; selective with "不涉及运行时部署" for pure-library projects)
101
+ - The implementability assessment (7 dimensions with verdict rules)
102
+ - The approval document structure and generation rules
103
+ - Protocol-marker preservation and language policy enforcement
104
+ - Dashboard count computation (must be precise, not AI-guessed)
105
+ - Anchor-file extraction and code-reading rules (depth: anchor file only, no recursion)
106
+
107
+ You MUST read `generate.md` before performing any analysis or writing `approval.md`. Do not
108
+ invent the assessment dimensions or document structure — they are defined in that prompt.
109
+
110
+ ---
111
+
112
+ ## Stage 3: Extract Anchor Files
113
+
114
+ Before running the closed-loop passes, extract the set of **anchor files** that the plan
115
+ references. These are the files Pass 6 (Code Grounding) will read.
116
+
117
+ **Extraction rules** (defined in detail in `generate.md` Part A → Pass 6):
118
+
119
+ 1. Scan `design.md` and `tasks.md` for file path references (backtick-quoted paths, code
120
+ blocks, or inline paths like `src/core/...`).
121
+ 2. Collect only paths under the project root that look like source files (`.ts`, `.js`,
122
+ `.py`, `.go`, `.rs`, `.kt`, `.java`, etc.) or config files (`package.json`, `tsconfig.json`,
123
+ etc.).
124
+ 3. Deduplicate. Do NOT read directories, only files.
125
+ 4. **Depth limit: read the anchor file itself only.** Do not follow imports, do not recurse.
126
+ 5. If no anchor files are found and the project has no source code (greenfield), Pass 6
127
+ will emit `skipped (greenfield — no existing code)`. If the project HAS source code but
128
+ the plan references no existing files, that is a `FAIL` (plan is ungrounded).
129
+
130
+ Announce the extracted anchor file list to the user before Pass 1 begins.
131
+
132
+ ---
133
+
134
+ ## Stage 4: AI Closed-Loop Verification
135
+
136
+ Perform the 7 closed-loop passes defined in `generate.md`, in order:
137
+
138
+ ### Internal coherence (Passes 1–5)
139
+
140
+ 1. **Pass 1 — Requirement Closure**: proposal ↔ specs coverage
141
+ 2. **Pass 2 — Design Closure**: design decisions ↔ spec requirements
142
+ 3. **Pass 3 — Spec Closure**: scenario completeness + testability (3-level grading) + delta integrity
143
+ 4. **Pass 4 — Implementation Closure**: tasks ↔ spec requirements coverage + granularity
144
+ 5. **Pass 5 — Risk Closure**: risks ↔ mitigations + BREAKING migration + unidentified risks
145
+
146
+ ### External grounding (Passes 6–7)
147
+
148
+ 6. **Pass 6 — Code Grounding**: design/tasks anchor files exist in the project + structure
149
+ compatibility + tech-stack consistency. Reads actual project code (anchor files only).
150
+ 7. **Pass 7 — Baseline Cross-Check**: delta specs vs `specflow/specs/` main baseline —
151
+ conflict detection, duplicate-definition detection, MODIFIED name matching.
152
+
153
+ Each Pass must produce visible output to the user:
154
+
155
+ - **Verdict**: `PASS` | `WARNING` | `FAIL` | `SKIPPED`
156
+ - **Evidence**: concrete citations (file, section, requirement name, scenario name, line)
157
+
158
+ Present each Pass's result as it completes — do not batch all 7 at the end. The user should
159
+ see the reasoning unfold and can interject if a Pass reveals something that changes direction.
160
+
161
+ ### Closed-Loop Overall Verdict
162
+
163
+ After all 7 Passes:
164
+
165
+ - `FAIL` if any Pass is `FAIL`
166
+ - `PASS WITH WARNINGS` if no `FAIL` but at least one `WARNING`
167
+ - `PASS` if all Passes are `PASS` (a `SKIPPED` Pass does not affect the verdict)
168
+
169
+ ---
170
+
171
+ ## Stage 5: Design Quality Assessment
172
+
173
+ Perform the two design-quality checks defined in `generate.md` Part B:
174
+
175
+ ### Over-Engineering Check
176
+
177
+ Scan `design.md` and `tasks.md` for the 5 over-engineering signals:
178
+
179
+ 1. Interface for unrequested requirements
180
+ 2. Unnecessary abstraction layers
181
+ 3. Pre-built unused infrastructure
182
+ 4. Config fields beyond current needs
183
+ 5. Complexity exceeding problem scale
184
+
185
+ **Verdict rule**: 1 signal → `WARNING`; 3+ signals → `FAIL`; 0 signals → `PASS`.
186
+
187
+ ### Extensibility Assessment
188
+
189
+ Scan `design.md` for the 5 extensibility signals:
190
+
191
+ 1. Namespace reservation
192
+ 2. Stable interface, replaceable implementation
193
+ 3. Explicit Non-Goals
194
+ 4. Backward-compatibility path
195
+ 5. Decision rationale mentions extensibility trade-off
196
+
197
+ **Verdict rule**: 4-5 signals present → `PASS`; 2-3 → `WARNING`; 0-1 → `WARNING`.
198
+
199
+ ### Combined Design Quality Verdict
200
+
201
+ - `FAIL` if over-engineering is `FAIL`
202
+ - `WARNING` if either check is `WARNING`
203
+ - `PASS` if both are `PASS`
204
+ - **Special**: if over-engineering = `WARNING`/`FAIL` AND extensibility = `WARNING` →
205
+ escalate to `FAIL` (the plan is both bloated AND not extensible)
206
+
207
+ ---
208
+
209
+ ## Stage 6: Architecture Design
210
+
211
+ Produce the **architecture design** section (approval.md §5 架构整体设计) defined in
212
+ `generate.md` Part E. This answers "what modules make up the system, how they depend on
213
+ and interact with each other, and what each module's responsibility and boundary is."
214
+
215
+ It is complementary to Detailed Design: architecture is about **module-to-module
216
+ relationships** (macro), detailed design is about **module-internal implementation**
217
+ (micro).
218
+
219
+ ### 5.1 Overall Architecture
220
+
221
+ Draw a Mermaid diagram — **system interaction diagram** or **module dependency diagram**:
222
+
223
+ - **Module dependency / layered diagram** — `mermaid flowchart LR` (modules as nodes,
224
+ dependencies as edges)
225
+ - **System interaction diagram** — `mermaid sequenceDiagram` (participants as modules/roles)
226
+
227
+ Requirements:
228
+
229
+ 1. **Mark changed modules** (`[新增]` / `[修改]` labels or color) so the reviewer can see
230
+ the change surface at a glance.
231
+ 2. Label edges with dependency direction (who depends on whom) or interaction message
232
+ (who calls whom, passing what).
233
+ 3. Project-type mapping: CLI/library → `src/core/*`, `src/cli/*`; Web → services/components;
234
+ multi-repo → repositories/services.
235
+ 4. The diagram must be consistent with §4 decisions — every structure shown must trace to
236
+ a decision.
237
+
238
+ ### 5.2 Core Components
239
+
240
+ Define each module/component's responsibility and boundary in a table:
241
+
242
+ | Component | Responsibility | Boundary (does / does NOT) | Depends on | Change type |
243
+ |-----------|---------------|----------------------------|-----------|-------------|
244
+
245
+ Requirements:
246
+
247
+ 1. List **all involved components** (added + modified) with responsibility, boundary,
248
+ dependency.
249
+ 2. Boundary must state **what it does NOT do** — to keep logic in the right module (e.g.,
250
+ CLI does not parse slash args, core layer does not do AI reasoning).
251
+ 3. Dependency direction explicit, avoid circular dependencies.
252
+ 4. **Consistent with §5.1 diagram**: every table component appears in the diagram; table
253
+ dependencies match diagram edges.
254
+ 5. Each component boundary traces to a §4 decision.
255
+
256
+ **If the change does not alter architecture**: write the explicit `不涉及架构变更(单模块/
257
+ 单文件调整,模块边界无变化)` marker instead of leaving blank.
258
+
259
+ ### 5.3 Architecture Consistency Self-check
260
+
261
+ - Diagram marks added/modified modules; change surface visible at a glance.
262
+ - Each component has a "does NOT do" boundary.
263
+ - Diagram and table correspond 1:1.
264
+ - Component boundaries trace to §4 decisions.
265
+ - Uninvolved categories carry the explicit "不涉及架构变更" marker.
266
+
267
+ Present the architecture design to the user as part of the confirmation summary.
268
+
269
+ ---
270
+
271
+ ## Stage 7: Detailed Design
272
+
273
+ Produce the **detailed design** section (approval.md §6 方案详细设计) defined in
274
+ `generate.md` Part E. This takes the plan from "macro decisions" to "implementer-ready
275
+ detail".
276
+
277
+ The detailed design is **selective**: cover only the categories this change actually
278
+ involves. For each category NOT involved, write the explicit "不涉及 X" marker instead of
279
+ leaving it blank.
280
+
281
+ Categories (from `generate.md` §6.1–6.6):
282
+
283
+ 1. **数据结构 / 数据模型变更** — table structures, fields, types, constraints, index
284
+ recommendations (query-driven), data migration. For CLI/library projects: config
285
+ structure, state files, YAML schema.
286
+ 2. **接口设计** — API/RPC/CLI command signatures, input params (name/type/required/valid
287
+ values/defaults), output shapes, error-code definitions with status-code mapping.
288
+ 3. **业务流程** — sequence description (who calls whom, order, branches, error paths) or
289
+ state-machine transitions (states/events/conditions/terminal). Use Mermaid
290
+ `sequenceDiagram` / `stateDiagram-v2` when clarifying.
291
+ 4. **核心算法 / 逻辑说明** — input/output, processing steps, complexity, boundary conditions.
292
+ 5. **配置与运行环境** — new config keys, env vars, runtime dependencies.
293
+ 6. **兼容性与迁移** — old→new behavior mapping, migration path, rollback.
294
+
295
+ **Traceability requirement** (hard rule): every detailed-design element must trace to a
296
+ §3 Requirement/Scenario and a §4 decision. If an element cannot be written at
297
+ implementer-ready detail, mark it `[待 refine 澄清: <元素>]` and report it to the user —
298
+ this is a quality signal that the plan is not fully thought through.
299
+
300
+ **Quality self-check** after drafting:
301
+
302
+ - Every involved category has real content (signatures/fields/states), no blank placeholders.
303
+ - Every uninvolved category has the explicit "不涉及" marker.
304
+ - Data/interface/flow elements trace to spec requirements and design decisions.
305
+
306
+ Present the detailed design to the user as part of the confirmation summary.
307
+
308
+ ---
309
+
310
+ ## Stage 8: Test Strategy
311
+
312
+ Produce the **test strategy** section (approval.md §7 测试策略) defined in `generate.md`
313
+ Part E. This upgrades "is §3 acceptance verifiable" into "**how will layered tests prove
314
+ the plan is correct**." It answers: which test layer covers each acceptance criterion
315
+ (WHEN/THEN), with what tool, proving what.
316
+
317
+ ### 8.1 Layered Test Matrix
318
+
319
+ Produce a layered test matrix:
320
+
321
+ | Test layer | Covers | Tool/framework | Goal (proves what) | Acceptance criteria covered |
322
+ |-----------|--------|---------------|--------------------|----------------------------|
323
+
324
+ Layers (selective — only those this change actually needs):
325
+
326
+ - **Unit tests** — core functions/classes/internal logic
327
+ - **Integration tests** — module interactions, interface contracts, external deps
328
+ - **Acceptance tests** — spec WHEN/THEN user-visible behavior (E2E / CLI tests)
329
+ - **Regression tests** — main-spec baseline + existing behavior
330
+ - **Performance / security / compatibility** — NFR goals (as applicable)
331
+
332
+ Requirements:
333
+
334
+ 1. Each test layer **maps to §3 acceptance criteria** (cite specific Scenario names) — this
335
+ closes the loop between test strategy and acceptance criteria.
336
+ 2. Each layer annotates **tool/framework** (echoing full-stack-skills' phase→skill mapping:
337
+ test phase → test-writer/playwright/pytest).
338
+ 3. **Goals must be verifiable** ("prove P95 < 200ms", not "test performance").
339
+ 4. Distinguish **new tests** vs **modifications to existing tests**.
340
+
341
+ ### 8.2 Test Environment & Data
342
+
343
+ Cover: test environment (local tmpdir / isolated CI), fixture/seed data (incl. Chinese/
344
+ English samples), parallelism/isolation, coverage target.
345
+
346
+ ### 8.3 Test Strategy Self-check
347
+
348
+ - Every §3 acceptance criterion is covered by ≥1 test layer (closed loop).
349
+ - Every test layer has a tool and a verifiable goal.
350
+ - Existing behavior is protected by regression tests (corresponds to Pass 7 baseline).
351
+ - New tests vs modifications to existing tests are distinguished.
352
+
353
+ **If the change needs no testing**: write the explicit `不涉及测试变更(纯文档/配置变更,无
354
+ 行为逻辑需要测试)` marker.
355
+
356
+ Present the test strategy to the user as part of the confirmation summary.
357
+
358
+ ---
359
+
360
+ ## Stage 9: Deployment & Release
361
+
362
+ Produce the **deployment / release / rollback** section (approval.md §8 部署/发布/回滚方案)
363
+ defined in `generate.md` Part E. This answers "how does the change go live, how is it
364
+ released, how do we roll back if something breaks, and how do we monitor it after launch."
365
+
366
+ **Selective**: mandatory for projects with a running system; pure library/CLI/documentation
367
+ projects write the explicit `不涉及运行时部署(纯库/CLI/文档项目,无服务上线,变更通过包发布/
368
+ 版本发布交付)` marker.
369
+
370
+ ### 9.1 Deployment Plan
371
+
372
+ Cover: deployment target (prod/staging/multi-env), deployment method (image/package/code/
373
+ config; CI pipeline steps), deployment order (e.g. DB migration before app deploy), config
374
+ management (new keys per env, secrets), environment differences.
375
+
376
+ ### 9.2 Release Strategy
377
+
378
+ Cover: release method (blue-green / canary / rolling / direct replace + rationale), release
379
+ window / canary ratio, old-new compatibility during coexistence (API versioning, DB compat).
380
+
381
+ ### 9.3 Rollback Plan
382
+
383
+ Cover: rollback trigger conditions (error rate / metric thresholds), rollback method (image
384
+ revert / code revert / data rollback; auto or manual), data consistency on rollback
385
+ (if data migration), rollback verification.
386
+
387
+ ### 9.4 Monitoring & Observability
388
+
389
+ Cover: key metrics to monitor post-launch, logging/tracing, alert thresholds & owner.
390
+
391
+ ### 9.5 Deployment Self-check
392
+
393
+ - Deployment target / method / order explicit.
394
+ - Release strategy with compatibility.
395
+ - Rollback trigger / method / data consistency / verification explicit.
396
+ - Post-launch monitoring metrics & alerts explicit.
397
+
398
+ Present the deployment plan to the user as part of the confirmation summary.
399
+
400
+ ---
401
+
402
+ ## Stage 10: Implementability Assessment
403
+
404
+ Perform the 7 implementability dimensions defined in `generate.md` Part C:
405
+
406
+ 1. **Completeness** — no TODOs, placeholders, vague tasks
407
+ 2. **Spec Alignment** — tasks cover all spec requirements, no scope creep
408
+ 3. **Task Actionability** — can an engineer execute each task without ambiguity
409
+ 4. **Technical Feasibility** — design decisions are achievable in the detected tech stack
410
+ 5. **Dependency Clarity** — task dependencies and external dependencies are explicit
411
+ 6. **Architecture Consistency** — design choices match project's existing tech stack, directory structure, error-handling patterns, and test framework (grounded in code reading from Pass 6)
412
+ 7. **Implementation Risk** — high-risk module changes, data migration, concurrency, external API breaks, team tech-stack unfamiliarity
413
+
414
+ Each dimension produces a verdict (`READY` | `NEEDS REFINEMENT` | `BLOCKED`) with evidence.
415
+
416
+ ### Implementability Overall Verdict
417
+
418
+ - `BLOCKED` if any dimension is `BLOCKED`
419
+ - `NEEDS REFINEMENT` if no `BLOCKED` but any dimension is `NEEDS REFINEMENT`
420
+ - `READY` if all 7 are `READY`
421
+
422
+ ---
423
+
424
+ ## Stage 11: Generate approval.md
425
+
426
+ Following the document structure and generation rules in `generate.md` Part E, produce
427
+ `approval.md` inside the change directory at `specflow/changes/<name>/approval.md`.
428
+
429
+ Key rules:
430
+
431
+ - Dashboard counts (capability count, requirement count, scenario count, task count, anchor
432
+ file count, baseline spec count) MUST be computed by reading the actual files, not
433
+ estimated. If a count is uncertain, say so explicitly rather than guessing.
434
+ - The "Decision Review" table must include every decision found in `design.md`.
435
+ - The "Acceptance Criteria" section must include every Requirement and Scenario from all
436
+ delta specs, with 3-level testability grading.
437
+ - The "Detailed Design" section must be selective: real content for involved categories,
438
+ explicit "不涉及" markers for uninvolved ones, every element traceable to spec + decision.
439
+ - The "Test Strategy" section must be a layered matrix where every §3 acceptance criterion
440
+ is covered by ≥1 layer (closed loop), with tools and verifiable goals.
441
+ - The "Deployment/Release/Rollback" section must be selective: real plan for running
442
+ systems, explicit "不涉及运行时部署" marker for pure-library/CLI/documentation projects.
443
+ - The "Code Grounding" section (Pass 6 evidence) must cite actual file paths read and
444
+ concrete findings (function signatures, module structure, compatibility assessment).
445
+ - The human sign-off table must be empty (blank fields for the approver to fill).
446
+ - AI pre-approval recommendation must be grounded in all three verdicts (closed-loop,
447
+ design quality, implementability) — never recommend "approve" if any verdict is `FAIL`.
448
+
449
+ ---
450
+
451
+ ## Gate: User Confirmation
452
+
453
+ Present a summary to the user:
454
+
455
+ - Closed-loop overall verdict (PASS / PASS WITH WARNINGS / FAIL)
456
+ - Design quality verdict (PASS / WARNING / FAIL)
457
+ - Implementability overall verdict (READY / NEEDS REFINEMENT / BLOCKED)
458
+ - AI pre-approval recommendation (建议批准 / 有条件批准 / 退回 refine / 拒绝)
459
+ - The path where `approval.md` will be written
460
+
461
+ Ask explicitly:
462
+
463
+ > "确认生成审批文档并写入 `specflow/changes/<name>/approval.md`?"
464
+
465
+ Do NOT write the file until the user confirms. If the user wants changes to the assessment,
466
+ re-run the relevant Pass or dimension and update the summary before re-asking.
467
+
468
+ On confirmation:
469
+
470
+ 1. Write `approval.md` to the change directory.
471
+ 2. Do NOT change `phase` — it remains `refined`.
472
+ 3. Report the file path and next-step suggestions.
473
+
474
+ ---
475
+
476
+ ## Stage 12: Next-Step Suggestions
477
+
478
+ Based on the assessment results:
479
+
480
+ - **If closed-loop = PASS, design quality = PASS, and implementability = READY**:
481
+ Suggest `/specflow:apply` to begin implementation.
482
+
483
+ - **If any verdict is WARNING**:
484
+ Suggest the user either (a) proceed to `/specflow:apply` after acknowledging the warnings
485
+ in the approval document, or (b) return to `/specflow:refine` to close the gaps first.
486
+
487
+ - **If any verdict is FAIL or implementability = BLOCKED**:
488
+ Strongly recommend `/specflow:refine` to resolve the failures before implementation.
489
+ Do NOT suggest `/specflow:apply` — the plan is not ready.
490
+
491
+ In all cases, remind the user that `approval.md` is an optional artifact: it does not block
492
+ `/specflow:apply` (which only requires `phase=refined`), and it does not affect
493
+ `/specflow:archive` (which scans `specs/`, not `approval.md`).
494
+
495
+ ---
496
+
497
+ ## Not Covered by Approval
498
+
499
+ - No code implementation — `/specflow:apply` owns that.
500
+ - No phase transition — phase stays `refined` until `/specflow:apply` advances it.
501
+ - No spec validation — `/specflow:verify` owns delta + main spec regression checks.
502
+ - No code review — `/specflow:review` owns post-implementation code quality checks.
503
+ - No artifact modification — approval reads the four artifacts (and project code, read-only)
504
+ but never modifies them. If a Pass reveals a gap, the user returns to `/specflow:refine`
505
+ to fix it; approval only documents the finding.
506
+ - No full codebase scan — approval reads only the anchor files extracted in Stage 3. Full
507
+ codebase investigation is `/specflow:explore`'s job.
508
+ - Approval is **not** a gate for apply. It is a decision-support artifact for human review.