@gordon.gan/specflow 1.4.0-beta → 1.4.2-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.
Files changed (82) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/prompts/approval/database-guidance.md +79 -0
  4. package/prompts/approval/generate.md +600 -290
  5. package/skills/database/LICENSE +405 -0
  6. package/skills/database/ORIGIN.md +6 -0
  7. package/skills/database/README.md +30 -0
  8. package/skills/database/elasticsearch/LICENSE.txt +202 -0
  9. package/skills/database/elasticsearch/SKILL.md +199 -0
  10. package/skills/database/elasticsearch/examples/01-fulltext-search.md +215 -0
  11. package/skills/database/elasticsearch/examples/02-aggregation-report.md +206 -0
  12. package/skills/database/elasticsearch/examples/03-reindex-zero-downtime.md +200 -0
  13. package/skills/database/elasticsearch/examples/04-cluster-monitoring.md +204 -0
  14. package/skills/database/elasticsearch/references/01-query-dsl-fulltext.md +162 -0
  15. package/skills/database/elasticsearch/references/02-query-dsl-term.md +210 -0
  16. package/skills/database/elasticsearch/references/03-aggregations-metric.md +161 -0
  17. package/skills/database/elasticsearch/references/04-aggregations-bucket.md +236 -0
  18. package/skills/database/elasticsearch/references/05-mapping-types.md +134 -0
  19. package/skills/database/elasticsearch/references/06-analyzers.md +187 -0
  20. package/skills/database/elasticsearch/references/07-cluster-ops.md +225 -0
  21. package/skills/database/elasticsearch/references/08-elk-integration.md +170 -0
  22. package/skills/database/mysql/SKILL.md +195 -0
  23. package/skills/database/mysql/examples/01-connection-pool.md +75 -0
  24. package/skills/database/mysql/examples/02-slow-query-optimization.md +98 -0
  25. package/skills/database/mysql/examples/03-master-slave-setup.md +144 -0
  26. package/skills/database/mysql/examples/04-backup-strategy.md +212 -0
  27. package/skills/database/mysql/references/01-functions-string.md +103 -0
  28. package/skills/database/mysql/references/02-functions-date.md +152 -0
  29. package/skills/database/mysql/references/03-functions-aggregate-window.md +167 -0
  30. package/skills/database/mysql/references/04-functions-json.md +129 -0
  31. package/skills/database/mysql/references/05-sql-ddl-types.md +235 -0
  32. package/skills/database/mysql/references/06-index-optimization.md +232 -0
  33. package/skills/database/mysql/references/07-replication-ha.md +213 -0
  34. package/skills/database/mysql/references/08-backup-restore.md +207 -0
  35. package/skills/database/mysql/references/09-advanced-features.md +345 -0
  36. package/skills/database/oracle/LICENSE.txt +202 -0
  37. package/skills/database/oracle/SKILL.md +238 -0
  38. package/skills/database/oracle/examples/01-plsql-procedure.md +90 -0
  39. package/skills/database/oracle/examples/02-awr-analysis.md +99 -0
  40. package/skills/database/oracle/examples/03-rman-backup.md +108 -0
  41. package/skills/database/oracle/examples/04-dataguard-setup.md +146 -0
  42. package/skills/database/oracle/references/01-functions-string.md +91 -0
  43. package/skills/database/oracle/references/02-functions-date.md +71 -0
  44. package/skills/database/oracle/references/03-analytic-functions.md +103 -0
  45. package/skills/database/oracle/references/04-plsql-guide.md +303 -0
  46. package/skills/database/oracle/references/05-performance-tuning.md +164 -0
  47. package/skills/database/oracle/references/06-backup-recovery.md +115 -0
  48. package/skills/database/oracle/references/07-dataguard-rac.md +76 -0
  49. package/skills/database/oracle/references/08-security.md +170 -0
  50. package/skills/database/oracle/references/09-sql-syntax.md +152 -0
  51. package/skills/database/oracle/references/10-features.md +174 -0
  52. package/skills/database/postgresql/LICENSE.txt +202 -0
  53. package/skills/database/postgresql/SKILL.md +182 -0
  54. package/skills/database/postgresql/examples/.gitkeep +0 -0
  55. package/skills/database/postgresql/examples/01-jsonb-query.md +72 -0
  56. package/skills/database/postgresql/examples/02-cte-recursive.md +110 -0
  57. package/skills/database/postgresql/examples/03-performance-tuning.md +114 -0
  58. package/skills/database/postgresql/examples/04-streaming-replication.md +113 -0
  59. package/skills/database/postgresql/references/.gitkeep +0 -0
  60. package/skills/database/postgresql/references/01-functions-string.md +174 -0
  61. package/skills/database/postgresql/references/02-functions-datetime.md +54 -0
  62. package/skills/database/postgresql/references/03-functions-aggregate-window.md +142 -0
  63. package/skills/database/postgresql/references/04-functions-jsonb.md +117 -0
  64. package/skills/database/postgresql/references/05-fulltext-search.md +109 -0
  65. package/skills/database/postgresql/references/06-index-types.md +95 -0
  66. package/skills/database/postgresql/references/07-partition-fdw.md +133 -0
  67. package/skills/database/postgresql/references/08-replication-backup.md +215 -0
  68. package/skills/database/redis/LICENSE.txt +202 -0
  69. package/skills/database/redis/SKILL.md +922 -0
  70. package/skills/database/redis/examples/01-cache-usage.md +104 -0
  71. package/skills/database/redis/examples/02-session-storage.md +72 -0
  72. package/skills/database/redis/examples/03-leaderboard.md +63 -0
  73. package/skills/database/redis/examples/04-redis-cluster-setup.md +70 -0
  74. package/skills/database/redis/examples/05-stream-queue.md +65 -0
  75. package/skills/database/redis/references/command-quick-ref.md +180 -0
  76. package/skills/database/redis/references/commands-admin-key.md +413 -0
  77. package/skills/database/redis/references/commands-set-sorted-advanced.md +539 -0
  78. package/skills/database/redis/references/commands-string-hash-list.md +458 -0
  79. package/skills/database/redis/references/memory-optimization.md +150 -0
  80. package/skills/database/redis/references/redis-conf-production.md +139 -0
  81. package/skills/specflow-approval/SKILL.md +102 -181
  82. package/templates/approval.md +321 -221
@@ -0,0 +1,139 @@
1
+ # Redis 生产配置最佳实践
2
+
3
+ ## 推荐生产配置 (redis.conf)
4
+
5
+ ```conf
6
+ # ────────────────────────────────────
7
+ # 基础配置
8
+ # ────────────────────────────────────
9
+ daemonize no
10
+ pidfile /var/run/redis_6379.pid
11
+ port 6379
12
+ bind 0.0.0.0 # 生产环境改为内网 IP
13
+ protected-mode yes
14
+
15
+ # ────────────────────────────────────
16
+ # 内存管理
17
+ # ────────────────────────────────────
18
+ maxmemory 4gb
19
+ maxmemory-policy allkeys-lru
20
+ maxmemory-samples 10 # LRU 采样样本数 (越大越精确)
21
+
22
+ # ────────────────────────────────────
23
+ # 持久化 — 混合模式
24
+ # ────────────────────────────────────
25
+ save 900 1
26
+ save 300 10
27
+ save 60 10000
28
+ stop-writes-on-bgsave-error yes
29
+ rdbcompression yes
30
+ rdbchecksum yes
31
+ dbfilename dump.rdb
32
+ dir /data/redis/
33
+
34
+ appendonly yes
35
+ appendfilename "appendonly.aof"
36
+ appendfsync everysec
37
+ no-appendfsync-on-rewrite no
38
+ auto-aof-rewrite-percentage 100
39
+ auto-aof-rewrite-min-size 64mb
40
+ aof-load-truncated yes
41
+ aof-use-rdb-preamble yes # 混合持久化 (Redis 4.0+)
42
+
43
+ # ────────────────────────────────────
44
+ # 网络与连接
45
+ # ────────────────────────────────────
46
+ tcp-backlog 511
47
+ timeout 300
48
+ tcp-keepalive 300
49
+ maxclients 10000
50
+
51
+ # ────────────────────────────────────
52
+ # 复制
53
+ # ────────────────────────────────────
54
+ replica-serve-stale-data yes
55
+ replica-read-only yes
56
+ repl-diskless-sync no
57
+ repl-diskless-sync-delay 5
58
+ repl-disable-tcp-nodelay no
59
+ replica-priority 100
60
+
61
+ # ────────────────────────────────────
62
+ # 安全
63
+ # ────────────────────────────────────
64
+ requirepass your-strong-password-here
65
+ rename-command FLUSHALL ""
66
+ rename-command FLUSHDB ""
67
+ rename-command CONFIG ""
68
+ rename-command SHUTDOWN ""
69
+ rename-command DEBUG ""
70
+ rename-command SLAVEOF ""
71
+
72
+ # ────────────────────────────────────
73
+ # 慢查询日志
74
+ # ────────────────────────────────────
75
+ slowlog-log-slower-than 10000 # 记录 >10ms 的命令
76
+ slowlog-max-len 128
77
+
78
+ # ────────────────────────────────────
79
+ # 高级配置
80
+ # ────────────────────────────────────
81
+ hash-max-ziplist-entries 512
82
+ hash-max-ziplist-value 64
83
+ list-max-ziplist-size -2
84
+ list-compress-depth 0
85
+ set-max-intset-entries 512
86
+ zset-max-ziplist-entries 128
87
+ zset-max-ziplist-value 64
88
+
89
+ hz 10
90
+ dynamic-hz yes
91
+ activedefrag yes # 自动碎片整理 (Redis 4.0+)
92
+ ```
93
+
94
+ ## Docker 部署
95
+
96
+ ```bash
97
+ # 单机 Redis
98
+ docker run -d --name redis \
99
+ -p 6379:6379 \
100
+ -v /data/redis/data:/data \
101
+ -v /data/redis/redis.conf:/usr/local/etc/redis/redis.conf \
102
+ redis:7-alpine redis-server /usr/local/etc/redis/redis.conf
103
+
104
+ # Redis Cluster
105
+ docker network create redis-cluster
106
+
107
+ for port in 7000 7001 7002 7003 7004 7005; do
108
+ mkdir -p /data/redis/${port}
109
+ docker run -d --name redis-${port} \
110
+ --net redis-cluster \
111
+ -p ${port}:${port} \
112
+ -v /data/redis/${port}:/data \
113
+ redis:7-alpine redis-server \
114
+ --port ${port} \
115
+ --cluster-enabled yes \
116
+ --cluster-config-file nodes.conf \
117
+ --cluster-node-timeout 5000 \
118
+ --appendonly yes
119
+ done
120
+
121
+ # 创建集群
122
+ docker exec redis-7000 redis-cli --cluster create \
123
+ 192.168.1.100:7000 192.168.1.100:7001 192.168.1.100:7002 \
124
+ 192.168.1.100:7003 192.168.1.100:7004 192.168.1.100:7005 \
125
+ --cluster-replicas 1
126
+ ```
127
+
128
+ ## 性能调优检查清单
129
+
130
+ - [ ] `maxmemory` 设置为物理内存的 60-70%
131
+ - [ ] `maxmemory-policy` 设为 `allkeys-lru`(缓存场景)
132
+ - [ ] 禁用危险命令(FLUSHALL/CONFIG/EVAL...)
133
+ - [ ] 慢查询阈值 ≤ 10ms
134
+ - [ ] 连接池配置合理(maxTotal ≤ maxclients)
135
+ - [ ] Big Key 已拆分或索引
136
+ - [ ] 不分业务混用实例
137
+ - [ ] 监控指标已接入(INFO 命令定期采集)
138
+ - [ ] RDB + AOF 混合持久化已配置
139
+ - [ ] 主从 / Sentinel / Cluster 已部署
@@ -80,28 +80,44 @@ change names, file paths, commands, and code in their original form.
80
80
  - `Cargo.toml` → Rust
81
81
  - `tsconfig.json` → TypeScript (refines Node detection)
82
82
  - If none match, set `techStack: unknown`
83
- 5. Read `specflow/specs/` baseline if it exists (for Pass 7 baseline cross-check).
83
+ 5. **Detect database stack** (for §4.4 guidance). Follow
84
+ `prompts/approval/database-guidance.md` §1 — set
85
+ `dbStack: mysql|postgresql|oracle|redis|elasticsearch|none`. Prefer OLTP
86
+ (`mysql`/`postgresql`/`oracle`) over cache/search when multiple match.
87
+ 6. Read `specflow/specs/` baseline if it exists (for Pass 7 baseline cross-check).
84
88
 
85
- Announce: "Generating technical approval document for change `<name>` (phase=refined, language=<lang>, techStack=<stack>)."
89
+ Announce: "Generating technical approval document for change `<name>` (phase=refined, language=<lang>, techStack=<stack>, dbStack=<db>)."
86
90
 
87
91
  ---
88
92
 
89
93
  ## Stage 2: Load Execution Instructions
90
94
 
91
- Read the file at `.claude/specflow/prompts/approval/generate.md` and follow its instructions.
95
+ Read these files and follow them:
92
96
 
93
- That prompt file contains the complete specification for:
97
+ 1. `.claude/specflow/prompts/approval/generate.md` (or repo `prompts/approval/generate.md`)
98
+ 2. `prompts/approval/database-guidance.md` — DB skill router for **local** packs under
99
+ `skills/database/` (in-repo maintenance; **no remote skill dependency**). **Not an MCP
100
+ tool**: on `dbStack` hit, `Read` matched `SKILL.md` + focused references; on `none`,
101
+ LLM-only §4.4.
102
+
103
+ `generate.md` + `database-guidance.md` together specify:
94
104
 
95
105
  - The 7-dimension closed-loop verification (Passes 1–7, each with AI self-prompt, verdict rules, evidence format)
96
106
  - 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)
107
+ - The architecture design (Mermaid diagrams + **图要点说明** + core-component table)
108
+ - The detailed design generation (设计要点一览 + Happy Path 完整时序 + 业务场景时序与说明 +
109
+ data ER/DDL + interfaces inventory/fields/examples/errors + logic/config/compat)
110
+ - The test strategy (layered test matrix mapped to §5 acceptance criteria)
111
+ - The deployment/release/rollback plan
101
112
  - The implementability assessment (7 dimensions with verdict rules)
102
113
  - The approval document structure and generation rules
103
114
  - Protocol-marker preservation and language policy enforcement
104
- - Dashboard count computation (must be precise, not AI-guessed)
115
+ - §1 绪论与边界 (proposal + optional explore + AI; absorbs What/Impact; **no 变更摘要 chapter**;
116
+ pain-point diagram, User Journey, Non-Goals with reasons)
117
+ - Document order: §1 绪论 → §2 评估 → §3 架构 → §4 详细设计 → **§5 验收标准** → §6 测试 → …
118
+ - **Quality Gates G1–G4** + **Style & Tone** (hard rules in generate.md Part E)
119
+ - **DB guidance router** (`database-guidance.md` + local `skills/database/`): match project
120
+ stack → Read in-repo skill; no hit → LLM fallback; **never** fetch remote skills / MCP wrap
105
121
  - Anchor-file extraction and code-reading rules (depth: anchor file only, no recursion)
106
122
 
107
123
  You MUST read `generate.md` before performing any analysis or writing `approval.md`. Do not
@@ -150,13 +166,9 @@ Perform the 7 closed-loop passes defined in `generate.md`, in order:
150
166
  7. **Pass 7 — Baseline Cross-Check**: delta specs vs `specflow/specs/` main baseline —
151
167
  conflict detection, duplicate-definition detection, MODIFIED name matching.
152
168
 
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.
169
+ Each Pass must produce a brief result for the conversation (verdict + one-line evidence).
170
+ Do **not** dump full coverage matrices into chat unless the user asks or a Pass is
171
+ `WARNING`/`FAIL`.
160
172
 
161
173
  ### Closed-Loop Overall Verdict
162
174
 
@@ -166,6 +178,10 @@ After all 7 Passes:
166
178
  - `PASS WITH WARNINGS` if no `FAIL` but at least one `WARNING`
167
179
  - `PASS` if all Passes are `PASS` (a `SKIPPED` Pass does not affect the verdict)
168
180
 
181
+ When writing `approval.md` **§8**, use the **single compact table** only (see generate.md
182
+ Part E §8): no per-Pass long sections, no duplicate summary table. Expand evidence only
183
+ for ⚠️/❌ rows (max 2–3 bullets).
184
+
169
185
  ---
170
186
 
171
187
  ## Stage 5: Design Quality Assessment
@@ -208,61 +224,45 @@ Scan `design.md` for the 5 extensibility signals:
208
224
 
209
225
  ## Stage 6: Architecture Design
210
226
 
211
- Produce the **architecture design** section (approval.md §5 架构整体设计) defined in
227
+ Produce the **architecture design** section (approval.md **§3** 架构整体设计) defined in
212
228
  `generate.md` Part E. This answers "what modules make up the system, how they depend on
213
229
  and interact with each other, and what each module's responsibility and boundary is."
214
230
 
215
231
  It is complementary to Detailed Design: architecture is about **module-to-module
216
232
  relationships** (macro), detailed design is about **module-internal implementation**
217
- (micro).
218
-
219
- ### 5.1 Overall Architecture
233
+ (micro). Architecture is placed **before** acceptance criteria so implementers read
234
+ structure first.
220
235
 
221
- Draw a Mermaid diagram — **system interaction diagram** or **module dependency diagram**:
236
+ ### 3.1 Overall Architecture
222
237
 
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)
238
+ Draw Mermaid diagram(s) — module dependency / layered and optionally system interaction:
226
239
 
227
240
  Requirements:
228
241
 
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).
242
+ 1. **Mark changed modules** (`[新增]` / `[修改]`) so the change surface is visible.
243
+ 2. Label edges with dependency direction or interaction messages.
233
244
  3. Project-type mapping: CLI/library → `src/core/*`, `src/cli/*`; Web → services/components;
234
245
  multi-repo → repositories/services.
235
- 4. The diagram must be consistent with §4 decisions — every structure shown must trace to
236
- a decision.
246
+ 4. Consistent with **§2** decisions.
247
+ 5. **Hard rule — 图要点说明**: every architecture diagram MUST be followed by a numbered
248
+ 「设计说明 / 图要点」list (boundaries, invariants, reuse vs new) — not a restatement of
249
+ node names. Align with scenario-job-compile §3 style.
237
250
 
238
- ### 5.2 Core Components
239
-
240
- Define each module/component's responsibility and boundary in a table:
251
+ ### 3.2 Core Components
241
252
 
242
253
  | Component | Responsibility | Boundary (does / does NOT) | Depends on | Change type |
243
254
  |-----------|---------------|----------------------------|-----------|-------------|
244
255
 
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.
256
+ Requirements: list added+modified components;「不做什么」boundaries; 1:1 with diagram;
257
+ trace to §2 decisions. Optional short「组件边界总原则」list.
255
258
 
256
- **If the change does not alter architecture**: write the explicit `不涉及架构变更(单模块/
257
- 单文件调整,模块边界无变化)` marker instead of leaving blank.
259
+ **If no architecture change**: write explicit `不涉及架构变更(...)` marker.
258
260
 
259
- ### 5.3 Architecture Consistency Self-check
261
+ ### 3.3 Architecture Consistency Self-check
260
262
 
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.
263
+ - Diagrams mark added/modified modules; each has 图要点说明.
264
+ - Each component has a "does NOT do" boundary; diagram ↔ table 1:1.
265
+ - Boundaries trace to §2 decisions.
266
266
 
267
267
  Present the architecture design to the user as part of the confirmation summary.
268
268
 
@@ -270,138 +270,57 @@ Present the architecture design to the user as part of the confirmation summary.
270
270
 
271
271
  ## Stage 7: Detailed Design
272
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.
273
+ Produce the **detailed design** section (approval.md **§4** 方案详细设计) defined in
274
+ `generate.md` Part E.
280
275
 
281
- Categories (from `generate.md` §6.1–6.6):
276
+ **Selective** categories; uninvolved ones get explicit「不涉及 X」markers.
282
277
 
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.
278
+ Order and hard requirements (from `generate.md` §4.1–4.8):
294
279
 
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.
280
+ 1. **设计要点一览** P1…Pn invariants from design decisions (required).
281
+ 2. **核心业务时序 · Happy Path** complete Mermaid `sequenceDiagram` for the main success
282
+ path + post-diagram「设计要点」(required).
283
+ 3. **业务场景时序** each scenario: purpose + diagram + **设计要点说明** (required notes;
284
+ bare diagrams fail quality).
285
+ 4. **数据结构** — Before drafting §4.4: follow `database-guidance.md`. If `dbStack` hit,
286
+ `Read` `skills/database/<stack>/SKILL.md` (+ DDL/index/JSON refs as needed).
287
+ If `none`, LLM-only with SpecFlow §4.4 hard bar (ER + full CREATE TABLE + field tables…).
288
+ **Outline**: only `4.4.1–4.4.4` + `##### table`; DDL/字段说明/JSON = `**bold**`, not headings.
289
+ 5. **接口设计** — inventory + fields + examples + errors…
290
+ **Outline**: only `4.5.1–4.5.3` + `##### In`; 请求体字段/示例/错误 = `**bold**`, not headings.
291
+ 6. **核心算法 / 配置 / 兼容性** — as applicable.
299
292
 
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.
293
+ **Traceability**: every element → **§5** Requirement/Scenario and **§2** decision.
294
+ If not implementer-ready, mark `[待 refine 澄清: <元素>]`.
305
295
 
306
296
  Present the detailed design to the user as part of the confirmation summary.
307
297
 
308
298
  ---
309
299
 
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.
300
+ ## Stage 8: Acceptance Criteria (after design)
352
301
 
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.
302
+ Produce **§5 验收标准** only **after** §3 architecture and §4 detailed design are drafted
303
+ in the document order. Exhaustive Requirement + Scenario list with 3-level testability.
304
+ Do not place acceptance before the design chapters.
357
305
 
358
306
  ---
359
307
 
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
308
+ ## Stage 9: Test Strategy
371
309
 
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.
310
+ Produce the **test strategy** section (approval.md **§6** 测试策略). Every §5 acceptance
311
+ criterion maps to ≥1 test layer with tools and verifiable goals.
375
312
 
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
313
+ ---
392
314
 
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.
315
+ ## Stage 10: Deployment & Release
397
316
 
398
- Present the deployment plan to the user as part of the confirmation summary.
317
+ Produce the **deployment / release / rollback** section (approval.md **§7**).
399
318
 
400
319
  ---
401
320
 
402
- ## Stage 10: Implementability Assessment
321
+ ## Stage 11: Implementability Assessment
403
322
 
404
- Perform the 7 implementability dimensions defined in `generate.md` Part C:
323
+ Perform the 7 implementability dimensions defined in `generate.md` Part C.
405
324
 
406
325
  1. **Completeness** — no TODOs, placeholders, vague tasks
407
326
  2. **Spec Alignment** — tasks cover all spec requirements, no scope creep
@@ -421,30 +340,32 @@ Each dimension produces a verdict (`READY` | `NEEDS REFINEMENT` | `BLOCKED`) wit
421
340
 
422
341
  ---
423
342
 
424
- ## Stage 11: Generate approval.md
343
+ ## Stage 12: Generate approval.md
425
344
 
426
345
  Following the document structure and generation rules in `generate.md` Part E, produce
427
346
  `approval.md` inside the change directory at `specflow/changes/<name>/approval.md`.
428
347
 
348
+ Document chapter order (hard):
349
+
350
+ 1. §1 绪论与边界 (proposal + optional explore + AI; includes What/Impact; **no 变更摘要**)
351
+ 2. §2 技术方案评估
352
+ 3. §3 架构整体设计 (图 + **图要点说明** + 组件)
353
+ 4. §4 方案详细设计 (设计要点 + Happy Path + 业务场景说明 + 数据/接口…)
354
+ 5. §5 验收标准 (**after** design)
355
+ 6. §6 测试策略 → §7 部署 → §8 闭环 → §9 可实施性 → §10 审批
356
+
429
357
  Key rules:
430
358
 
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`.
359
+ - §1 truthful: pains from proposal/design/confirmed explore; User Journey §5; Non-Goals with reasons; What/Impact in §1.2.
360
+ - Decision Review includes every `design.md` decision.
361
+ - §5 Acceptance exhaustive with 3-level testability; placed after §3/§4.
362
+ - §3 every architecture diagram has「设计说明 / 图要点」; component table with「不做什么」.
363
+ - §4 has 设计要点一览, complete Happy Path sequence + notes, each business scenario with 设计要点; DB/API hard bars (§4.4/§4.5); outline hygiene (no heading for 请求体字段/DDL/字段说明 — bold labels only).
364
+ - **Quality Gates G1–G4**: >5-line prose flow → Mermaid; interfaces need failure examples; JSON/new-column need存量填充策略; rollback data compatibility explicit.
365
+ - **Style & Tone**: plain language; gloss obscure abbreviations on first use; ban「尽量/大概/一般情况下」; use「必须/禁止/采用 XX 方案」.
366
+ - **§8 闭环**: one compact table only; PASS one line; ⚠️/❌ ≤3 bullets; no per-Pass essays.
367
+ - Test Strategy maps every §5 criterion to ≥1 layer.
368
+ - Deployment selective; Code Grounding cites real files; sign-off blank; never recommend approve if any verdict is `FAIL`.
448
369
 
449
370
  ---
450
371
 
@@ -473,7 +394,7 @@ On confirmation:
473
394
 
474
395
  ---
475
396
 
476
- ## Stage 12: Next-Step Suggestions
397
+ ## Stage 13: Next-Step Suggestions
477
398
 
478
399
  Based on the assessment results:
479
400