@chenmk/superflow 0.2.5 → 0.3.0

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 (55) hide show
  1. package/README.md +4 -1
  2. package/README.zh-CN.md +1 -0
  3. package/assets/manifest.json +3 -1
  4. package/assets/prompts/superflow-clarify.md +6 -0
  5. package/assets/prompts/superflow-pipeline.md +8 -0
  6. package/assets/scripts/superflow-archive-command-hook.sh +80 -0
  7. package/assets/scripts/superflow-delivery-check.sh +23 -4
  8. package/assets/skills/superflow-archive/SKILL.md +5 -0
  9. package/assets/skills/superflow-clarify/SKILL.md +26 -7
  10. package/assets/skills/superflow-design/SKILL.md +28 -6
  11. package/assets/skills/superflow-docs/SKILL.md +11 -0
  12. package/assets/skills/superflow-pipeline/SKILL.md +29 -0
  13. package/assets/skills/superflow-pipeline/references/api-design-template.md +11 -0
  14. package/assets/skills/superflow-pipeline/references/batch-prompt-template.md +27 -0
  15. package/assets/skills/superflow-pipeline/references/implementation-prompt-template.md +29 -1
  16. package/assets/skills/superflow-pipeline/references/quality-gate.md +2 -0
  17. package/assets/skills/superflow-pipeline/references/superpower-technical-design-template.md +41 -0
  18. package/assets/skills/superflow-pipeline/references/test-execution-template.md +10 -0
  19. package/assets/skills/superflow-pipeline/scripts/superflow-guard.sh +143 -0
  20. package/assets/skills/superflow-verify/SKILL.md +7 -0
  21. package/assets/skills-en/superflow-archive/SKILL.md +6 -0
  22. package/assets/skills-en/superflow-clarify/SKILL.md +26 -7
  23. package/assets/skills-en/superflow-design/SKILL.md +27 -5
  24. package/assets/skills-en/superflow-docs/SKILL.md +11 -0
  25. package/assets/skills-en/superflow-pipeline/SKILL.md +28 -0
  26. package/assets/skills-en/superflow-pipeline/references/api-design-template.md +13 -0
  27. package/assets/skills-en/superflow-pipeline/references/batch-prompt-template.md +16 -0
  28. package/assets/skills-en/superflow-pipeline/references/implementation-prompt-template.md +17 -0
  29. package/assets/skills-en/superflow-pipeline/references/quality-gate.md +17 -0
  30. package/assets/skills-en/superflow-pipeline/references/superpower-technical-design-template.md +46 -0
  31. package/assets/skills-en/superflow-pipeline/references/test-execution-template.md +12 -0
  32. package/assets/skills-en/superflow-pipeline/scripts/superflow-guard.sh +143 -0
  33. package/assets/skills-en/superflow-verify/SKILL.md +8 -0
  34. package/dist/app/commands/archive.js +7 -3
  35. package/dist/app/commands/archive.js.map +1 -1
  36. package/dist/app/commands/change-guard.js +27 -0
  37. package/dist/app/commands/change-guard.js.map +1 -0
  38. package/dist/app/commands/design.js +2 -20
  39. package/dist/app/commands/design.js.map +1 -1
  40. package/dist/app/commands/init.js +1 -5
  41. package/dist/app/commands/init.js.map +1 -1
  42. package/dist/app/commands/update.js +2 -5
  43. package/dist/app/commands/update.js.map +1 -1
  44. package/dist/app/commands/verify.js +7 -3
  45. package/dist/app/commands/verify.js.map +1 -1
  46. package/dist/domains/config/context.js +1 -5
  47. package/dist/domains/config/context.js.map +1 -1
  48. package/dist/domains/deps.js +1 -5
  49. package/dist/domains/deps.js.map +1 -1
  50. package/dist/domains/hook.js +1 -0
  51. package/dist/domains/hook.js.map +1 -1
  52. package/dist/platform/assets.js +9 -0
  53. package/dist/platform/assets.js.map +1 -0
  54. package/package.json +3 -2
  55. package/scripts/release-notes-check.js +102 -0
@@ -178,6 +178,60 @@ require_state_file() {
178
178
  require_file .sdd/state.yaml
179
179
  }
180
180
 
181
+ require_tasks_complete() {
182
+ local task_count unchecked_count
183
+ require_file tasks.md
184
+ [[ -f "$CHANGE_DIR/tasks.md" ]] || return 0
185
+ task_count="$(grep -Ec '^[[:space:]]*-[[:space:]]+\[[ xX]\]' "$CHANGE_DIR/tasks.md" || true)"
186
+ unchecked_count="$(grep -Ec '^[[:space:]]*-[[:space:]]+\[[[:space:]]\]' "$CHANGE_DIR/tasks.md" || true)"
187
+ [[ "$task_count" -gt 0 ]] || issues+=("tasks.md has no checkbox tasks")
188
+ [[ "$unchecked_count" -eq 0 ]] || issues+=("$unchecked_count unchecked task(s) remain in tasks.md")
189
+ }
190
+
191
+ verification_report_path() {
192
+ local value
193
+ value="$(state_get verification_report)"
194
+ [[ -n "$value" && "$value" != "null" ]] || return 1
195
+ if [[ -f "$CHANGE_DIR/$value" ]]; then
196
+ printf '%s\n' "$CHANGE_DIR/$value"
197
+ return 0
198
+ fi
199
+ if [[ -f "$value" ]]; then
200
+ printf '%s\n' "$value"
201
+ return 0
202
+ fi
203
+ return 1
204
+ }
205
+
206
+ require_closeout_markers() {
207
+ local report="${1:-$CHANGE_DIR/test-report.md}"
208
+ if [[ ! -f "$report" ]]; then
209
+ issues+=("verification report path does not exist: $report")
210
+ return 0
211
+ fi
212
+ if ! grep -Eiq '(Verification Result|验证结果|验证结论)[[:space:]::|*-]*(PASS|通过)' "$report"; then
213
+ issues+=("verification result PASS marker not found in verification report")
214
+ fi
215
+ if ! grep -Eiq '(Archive Readiness|归档就绪)[[:space:]::|*-]*(PASS|READY|通过|就绪)' "$report"; then
216
+ issues+=("archive readiness PASS marker not found in verification report")
217
+ fi
218
+ }
219
+
220
+ require_branch_handled() {
221
+ local branch_status
222
+ branch_status="$(state_get branch_status)"
223
+ [[ "$branch_status" == "handled" ]] || issues+=("branch_status must be handled before verification closeout")
224
+ }
225
+
226
+ require_full_verification_fingerprint() {
227
+ local report="$CHANGE_DIR/test-report.md"
228
+ [[ "$(state_get verify_mode)" == "full" ]] || return 0
229
+ require_grep '测试环境|test environment|staging|sandbox' "$report" "full verification test environment"
230
+ require_grep '分支|提交|版本|构建号|镜像|branch|commit|tag|build|image' "$report" "full verification deployment fingerprint"
231
+ require_grep 'https?://|Base URL|基础地址' "$report" "full verification base URL"
232
+ require_grep '验证时间|执行时间|timestamp|verified[_ -]?at|20[0-9]{2}-[0-9]{2}-[0-9]{2}' "$report" "full verification timestamp"
233
+ }
234
+
181
235
  require_spec_doc() {
182
236
  if [[ -f "$CHANGE_DIR/spec.md" ]]; then
183
237
  return
@@ -259,6 +313,28 @@ change_has_external_enum_risk() {
259
313
  "$CHANGE_DIR"/specs/*/spec.md 2>/dev/null
260
314
  }
261
315
 
316
+ change_has_external_config_risk() {
317
+ grep -RIEiq \
318
+ '第三方|外部平台|外部工具|外部集成|third[- ]party|external (platform|tool|integration|system)|SDK|MQ|Kafka|RocketMQ|TDMQ|callback|回调|webhook|支付渠道|payment gateway|cloud service|云服务' \
319
+ "$CHANGE_DIR/proposal.md" \
320
+ "$CHANGE_DIR/api.md" \
321
+ "$CHANGE_DIR/design.md" \
322
+ "$CHANGE_DIR/tests.md" \
323
+ "$CHANGE_DIR/spec.md" \
324
+ "$CHANGE_DIR"/specs/*/spec.md 2>/dev/null
325
+ }
326
+
327
+ change_has_concurrency_idempotency_risk() {
328
+ grep -RIEiq \
329
+ '并发|批量下发|批量开通|批量续费|重复提交|重复回调|重复消费|重复下发|幂等|竞态|原子占用|concurren|idempoten|race condition|duplicate (request|callback|consumption|delivery)|atomic claim' \
330
+ "$CHANGE_DIR/proposal.md" \
331
+ "$CHANGE_DIR/api.md" \
332
+ "$CHANGE_DIR/design.md" \
333
+ "$CHANGE_DIR/tests.md" \
334
+ "$CHANGE_DIR/spec.md" \
335
+ "$CHANGE_DIR"/specs/*/spec.md 2>/dev/null
336
+ }
337
+
262
338
  change_has_money_precision_risk() {
263
339
  grep -RIEiq \
264
340
  '金额|费用|价格|优惠|折扣|抵扣|退款|分账|支付|发票|余额|电费|服务费|套餐结算|比例分摊|明细分配|尾差|精度|舍入|(^|[^[:alnum:]_])(amount|fee|fees|price|discount|deduction|refund|payment|invoice|balance|proration|allocation|reconciliation|rounding)([^[:alnum:]_]|$)|revenue sharing|profit sharing|split payment|serviceFee|chargeFee|totalAmount|actualAmount|payAmount|refundAmount|discountAmount|invoiceAmount|balanceAmount' \
@@ -325,6 +401,33 @@ require_external_enum_contract() {
325
401
  require_grep '不确定|阻塞|blocker|unknown|待确认' "$path" "$label unresolved/blocker column"
326
402
  }
327
403
 
404
+ require_external_config_contract() {
405
+ local path="$1"
406
+ local label="$2"
407
+ require_grep 'External Integration Configuration And Deployment Contract|外部集成配置与部署合同|外部配置.*部署合同' "$path" "$label"
408
+ require_grep '本地.*测试.*生产|local.*test.*production|local.*staging.*production' "$path" "$label environment matrix"
409
+ require_grep '注入|创建方式|provision|injection|IaC|Secret|控制台|console' "$path" "$label injection/provisioning"
410
+ require_grep '运行 owner|创建 owner|provisioning owner|runtime owner|owner.*时点|owner.*time' "$path" "$label owner and timing"
411
+ require_grep '就绪|readiness|消息轨迹|trace|health' "$path" "$label readiness evidence"
412
+ require_grep '回滚|rollback|禁用|disable' "$path" "$label rollback"
413
+ require_grep '密钥|凭据|secret|credential' "$path" "$label secret handling"
414
+ require_grep '不得.*硬编码|禁止.*硬编码|not.*hard.?cod|must not.*hard.?cod|do not hard.?code' "$path" "$label no hard-coded external config"
415
+ require_grep '测试.*生产|test.*production|staging.*production' "$path" "$label test-production distinction"
416
+ }
417
+
418
+ require_concurrency_idempotency_contract() {
419
+ local path="$1"
420
+ local label="$2"
421
+ require_grep 'Concurrency And Idempotency Ownership|并发与幂等归属|应用层原子占用' "$path" "$label"
422
+ require_grep '业务幂等键|business idempotency key|business key' "$path" "$label business idempotency key"
423
+ require_grep '应用层原子占用|application.layer atomic claim|atomic claim' "$path" "$label application-layer atomic claim"
424
+ require_grep '短事务|short transaction|事务边界|transaction boundary' "$path" "$label short transaction boundary"
425
+ require_grep '待处理|pending|成功|success|失败|failed|状态流转|state machine' "$path" "$label state machine"
426
+ require_grep '重试|retry' "$path" "$label retry contract"
427
+ require_grep '外部调用|external call|third.party call' "$path" "$label external-call boundary"
428
+ require_grep '唯一索引.*(不是|不得|不作为).*默认|unique index.*not.*default|do not.*default.*unique index' "$path" "$label unique index is not the default"
429
+ }
430
+
328
431
  require_money_precision_contract() {
329
432
  local path="$1"
330
433
  local label="$2"
@@ -412,6 +515,13 @@ case "$PHASE" in
412
515
  require_external_enum_contract api.md "external enum binding contract"
413
516
  require_external_enum_contract sdd-quality-gate.md "external enum binding quality gate"
414
517
  fi
518
+ if change_has_external_config_risk; then
519
+ require_external_config_contract api.md "external integration configuration contract"
520
+ require_external_config_contract sdd-quality-gate.md "external integration deployment gate"
521
+ fi
522
+ if change_has_concurrency_idempotency_risk; then
523
+ require_concurrency_idempotency_contract sdd-quality-gate.md "concurrency and idempotency ownership quality gate"
524
+ fi
415
525
  if change_has_money_precision_risk; then
416
526
  require_grep 'Money Precision Boundary|金额精度边界' sdd-quality-gate.md "money precision quality gate"
417
527
  fi
@@ -450,6 +560,12 @@ case "$PHASE" in
450
560
  if change_has_external_enum_risk; then
451
561
  require_external_enum_contract "$technical_design_rel" "external enum binding matrix"
452
562
  fi
563
+ if change_has_external_config_risk; then
564
+ require_external_config_contract "$technical_design_rel" "external integration configuration and deployment contract"
565
+ fi
566
+ if change_has_concurrency_idempotency_risk; then
567
+ require_concurrency_idempotency_contract "$technical_design_rel" "concurrency and idempotency ownership contract"
568
+ fi
453
569
  if change_has_money_precision_risk; then
454
570
  require_money_precision_contract "$technical_design_rel" "money precision boundary"
455
571
  fi
@@ -481,6 +597,12 @@ case "$PHASE" in
481
597
  if change_has_external_enum_risk; then
482
598
  require_external_enum_contract "$prompt_rel" "prompt external enum binding inheritance"
483
599
  fi
600
+ if change_has_external_config_risk; then
601
+ require_external_config_contract "$prompt_rel" "prompt external integration configuration inheritance"
602
+ fi
603
+ if change_has_concurrency_idempotency_risk; then
604
+ require_concurrency_idempotency_contract "$prompt_rel" "prompt concurrency and idempotency ownership inheritance"
605
+ fi
484
606
  if change_has_money_precision_risk; then
485
607
  require_money_precision_contract "$prompt_rel" "prompt money precision inheritance"
486
608
  fi
@@ -503,6 +625,7 @@ case "$PHASE" in
503
625
  ;;
504
626
  verify)
505
627
  require_state_file
628
+ require_tasks_complete
506
629
  require_file test-report.md
507
630
  require_grep 'RED|失败证据' test-report.md "RED evidence"
508
631
  require_grep 'GREEN|通过证据' test-report.md "GREEN evidence"
@@ -512,10 +635,21 @@ case "$PHASE" in
512
635
  if change_has_external_enum_risk; then
513
636
  require_grep 'External Enum Binding|外部枚举绑定|第三方字段语义绑定|外部展示|展示文案|业务语义|财务语义|BEM|真实入口' test-report.md "external enum binding runtime evidence"
514
637
  fi
638
+ if change_has_external_config_risk; then
639
+ require_grep 'External Integration Configuration And Deployment Contract|外部集成配置与部署合同' test-report.md "external integration configuration runtime evidence"
640
+ require_grep '生产.*就绪|production.*ready|provision.*verified|资源.*存在|resource.*exists' test-report.md "external production readiness evidence"
641
+ fi
642
+ if change_has_concurrency_idempotency_risk; then
643
+ require_grep 'Concurrency And Idempotency Ownership|并发与幂等归属|应用层原子占用' test-report.md "concurrency and idempotency runtime evidence"
644
+ require_grep '并发|concurren|重复|duplicate|重试|retry' test-report.md "concurrency duplicate and retry cases"
645
+ fi
515
646
  if change_has_money_precision_risk; then
516
647
  require_money_precision_evidence test-report.md "money precision runtime evidence"
517
648
  fi
518
649
  require_test_report_lint
650
+ require_closeout_markers "$CHANGE_DIR/test-report.md"
651
+ require_branch_handled
652
+ require_full_verification_fingerprint
519
653
  require_markdown_links_valid
520
654
  if [[ "$(state_get verification_report)" == "" || "$(state_get verification_report)" == "null" ]]; then
521
655
  "$STATE" set "$CHANGE_DIR" verification_report test-report.md
@@ -524,11 +658,20 @@ case "$PHASE" in
524
658
  ;;
525
659
  archive)
526
660
  require_state_file
661
+ require_tasks_complete
527
662
  verify_result="$(state_get verify_result)"
528
663
  [[ "$verify_result" == "pass" ]] || issues+=("verify_result must be pass before archive")
529
664
  archived="$(state_get archived)"
530
665
  [[ "$archived" != "true" ]] || issues+=("archived is already true")
531
666
  require_state_value verification_report "verification_report"
667
+ report_path="$(verification_report_path || true)"
668
+ if [[ -z "$report_path" ]]; then
669
+ issues+=("verification_report path does not exist")
670
+ else
671
+ require_closeout_markers "$report_path"
672
+ fi
673
+ require_branch_handled
674
+ require_state_value verified_at "verified_at"
532
675
  transition_event="archived"
533
676
  ;;
534
677
  *)
@@ -111,6 +111,13 @@ Before pass:
111
111
  complement.
112
112
  7. Branch/worktree status is handled and `.sdd/state.yaml` has:
113
113
  `branch_status: handled`.
114
+ 8. Every checkbox in `tasks.md` is checked. A completed implementation with
115
+ stale task documentation is a verification failure, not an archive-time
116
+ cleanup item.
117
+ 9. `test-report.md` ends with the machine-checkable closeout markers
118
+ `验证结果: PASS` and `归档就绪: PASS`. For `verify_mode: full`, it also
119
+ records the test environment, branch/commit/build or image fingerprint,
120
+ Base URL, and verification timestamp.
114
121
 
115
122
  Only then run:
116
123
 
@@ -14,6 +14,10 @@ do not mark archived until the user confirms final closeout.
14
14
  - `phase: archive`.
15
15
  - `verify_result: pass`.
16
16
  - `verification_report` points to an existing report.
17
+ - Every checkbox in `tasks.md` is checked.
18
+ - The verification report contains `Verification Result: PASS` and
19
+ `Archive Readiness: PASS`.
20
+ - `branch_status: handled` and `verified_at` are recorded.
17
21
  - `superflow-state.sh recover <change-dir>` gives a coherent archive recovery action.
18
22
 
19
23
  ## Procedure
@@ -42,6 +46,8 @@ do not mark archived until the user confirms final closeout.
42
46
  the user explicitly accepts the boundary.
43
47
  - Do not use archive to hide missing API, DB, hook, SQL, test-report, or real
44
48
  integration evidence.
49
+ - Never call `openspec archive` directly to bypass the lifecycle gate. The
50
+ installed archive-command hook blocks that path when native hooks are active.
45
51
  - In a standard `openspec/changes/<name>` layout, archive must use OpenSpec
46
52
  archive semantics so delta specs are merged and the change is moved to
47
53
  `openspec/changes/archive/`. State-only archive is only a fallback for
@@ -50,6 +50,15 @@ any full SDD document or implementation prompt is generated.
50
50
  external input. If semantics are unclear, mark the feature blocked instead of
51
51
  inventing a fallback.
52
52
  - Process one feature at a time, in product-document order.
53
+ - When the pipeline selected embedded deep-clarification mode, investigate facts
54
+ from the repository, source documents, configuration, tests, logs, and tools
55
+ before asking. Ask the user only about an unresolved decision that needs owner
56
+ intent; do not ask for facts that can be found locally.
57
+ - In embedded deep-clarification mode, ask exactly one decision question at a
58
+ time. Include the recommended answer and its important consequence, wait for
59
+ the answer, then record the result before asking the next question. Do not
60
+ create SDD artifacts or implementation prompts while a current-feature
61
+ decision remains pending.
53
62
  - For long PRDs, Lark/Feishu exports, screenshots, or mixed product docs, do
54
63
  not read the whole document and generate all tasks in one pass. First create
55
64
  a source index, then process one bounded section or feature at a time. Each
@@ -85,6 +94,10 @@ Create or update these files in the active OpenSpec change directory:
85
94
  - Business semantic evidence when status/enum/sync/default behavior is involved:
86
95
  source-of-truth field, enum mapping, consumer interpretation, business basis,
87
96
  explicitly rejected fallback/default choices, and unresolved owner questions.
97
+ - Deep-clarification decision evidence when this mode is active: each question,
98
+ recommendation, user decision, consequence, and the resulting
99
+ `confirmed`/`candidate`/`pending`/`rejected` entry in
100
+ `.sdd/handoff/brainstorm-summary.md`.
88
101
 
89
102
  Use the detailed workflow in:
90
103
 
@@ -127,14 +140,20 @@ Use the detailed workflow in:
127
140
  If a proposed default, fallback, old-value retention, or null conversion is
128
141
  not explicitly approved by the requirement or owner, mark it rejected and do
129
142
  not include it in the design.
130
- 11. Ask only current-feature clarification questions.
131
- 12. Wait for programmer confirmation.
132
- 13. Draft a rough API contract: path, action, core request, core response. Field types can be approximate.
133
- 14. Wait for programmer confirmation of the rough API.
134
- 15. Produce a precise API section with field names, types, requiredness, defaults, enums, errors, examples, and curl.
135
- 16. Mark the feature as `frozen` only when understanding, rough API, precise API,
143
+ 11. If embedded deep-clarification mode is active, resolve one decision at a
144
+ time. For each question, state the recommended answer and consequence, wait
145
+ for the programmer response, then update
146
+ `.sdd/handoff/brainstorm-summary.md` under `confirmed`, `candidate`,
147
+ `pending`, or `rejected`. Stop asking once only repository-verifiable facts
148
+ remain.
149
+ 12. Ask only any remaining current-feature clarification questions.
150
+ 13. Wait for programmer confirmation.
151
+ 14. Draft a rough API contract: path, action, core request, core response. Field types can be approximate.
152
+ 15. Wait for programmer confirmation of the rough API.
153
+ 16. Produce a precise API section with field names, types, requiredness, defaults, enums, errors, examples, and curl.
154
+ 17. Mark the feature as `frozen` only when understanding, rough API, precise API,
136
155
  and validation data needs are confirmed or explicitly blocked.
137
- 17. Only after the current feature is frozen or blocked, move to the next
156
+ 18. Only after the current feature is frozen or blocked, move to the next
138
157
  indexed feature. Do not batch-confirm multiple features from memory or a
139
158
  compressed chat summary.
140
159
 
@@ -54,10 +54,32 @@ Superpowers own source-level HOW without weakening OpenSpec/SDD contracts.
54
54
  adapter/protocol translator/device gateway into a business-entry
55
55
  orchestrator, stop and return to `$superflow-docs` unless the OpenSpec/SDD
56
56
  contract explicitly grants that ownership with approval evidence.
57
- 6. For field/status/enum/sync changes, include `Field And Status Reverse
57
+ 6. For third-party platforms/tools, SDKs, MQ/Kafka, callbacks, payment
58
+ gateways, cloud services, or other external integrations, include
59
+ `External Integration Configuration And Deployment Contract`. Inventory
60
+ every endpoint, app/tenant/project ID, Topic, Tag, Consumer Group,
61
+ namespace, webhook, ACL/role, feature switch, timeout, and credential
62
+ reference. Prove the source and injection/provisioning method for local,
63
+ test, and production environments, plus owner, creation timing, readiness
64
+ check, rollback, and unresolved blockers. Runtime values and server-side
65
+ resources must not exist only as hard-coded annotations/constants. Test
66
+ auto-creation or pre-existing resources must not be treated as proof that
67
+ production will provision them. Missing production provisioning evidence
68
+ blocks design completion.
69
+ 7. For concurrent requests, batch issue/activation/renewal, duplicate callbacks,
70
+ duplicate consumption, or repeated external delivery, include
71
+ `Concurrency And Idempotency Ownership`. Use a stable business idempotency
72
+ key and an application-layer atomic claim in a short transaction; persist
73
+ `PENDING` before the external call, release database locks before calling
74
+ externally, model success/failure/uncertain states, and reuse the original
75
+ business code on retry. A unique index is not the default and may only be an
76
+ optional fallback with proven natural uniqueness, historical cleanup,
77
+ NULL/soft-delete semantics, and a conflict contract. Check-then-insert,
78
+ process-local locks, and random IDs alone are blocked.
79
+ 8. For field/status/enum/sync changes, include `Field And Status Reverse
58
80
  Impact` and prove writers, readers, filters, derived sync paths, consumers,
59
81
  and tests. Direct setter-only design is blocked.
60
- 7. For amount, fee, discount, deduction, refund, sharing, payment, invoice,
82
+ 9. For amount, fee, discount, deduction, refund, sharing, payment, invoice,
61
83
  balance, electricity fee, service fee, package settlement, proration,
62
84
  allocation, reconciliation, or financial display changes,
63
85
  include `Money Precision Boundary`. Prove calculation-state fields,
@@ -76,12 +98,12 @@ Superpowers own source-level HOW without weakening OpenSpec/SDD contracts.
76
98
  level and policy source, deterministic residual strategy with stable
77
99
  tie-breaker, and positive/zero/negative evidence. For FX changes, freeze the
78
100
  directional rate metadata and one canonical conversion path.
79
- 8. Record state:
101
+ 10. Record state:
80
102
  ```bash
81
103
  ../superflow-pipeline/scripts/superflow-state.sh set <change-dir> technical_design docs/superpowers/specs/YYYY-MM-DD-<change-id>-technical-design.md
82
104
  ../superflow-pipeline/scripts/superflow-state.sh set <change-dir> design_doc design.md
83
105
  ```
84
- 9. Update `design.md` with `Superpowers Technical Design Handoff`, update
106
+ 11. Update `design.md` with `Superpowers Technical Design Handoff`, update
85
107
  `sdd-quality-gate.md` with the technical design path and hash, then run
86
108
  `../superflow-pipeline/scripts/superflow-handoff.sh <change-dir> --refresh`.
87
109
  If the guard reports a stale or missing hash, record the printed hash in
@@ -89,7 +111,7 @@ Superpowers own source-level HOW without weakening OpenSpec/SDD contracts.
89
111
  `--refresh` again. Do not set `design_doc` to the Superpowers document;
90
112
  `design_doc` is the OpenSpec/SDD contract design, while `technical_design`
91
113
  is the Superpowers HOW document.
92
- 10. Run:
114
+ 12. Run:
93
115
  ```bash
94
116
  ../superflow-pipeline/scripts/superflow-yaml-validate.sh <change-dir>
95
117
  ../superflow-pipeline/scripts/superflow-guard.sh <change-dir> design --apply
@@ -76,6 +76,17 @@ For complex requirements, verify these before writing docs:
76
76
  If the docs only prove that a value exists, is non-null, or lets the request
77
77
  succeed, stop and return to `$superflow-clarify`. If fallback/default/keep-old-value
78
78
  behavior is proposed without explicit requirement or owner approval, stop.
79
+ - For third-party platforms/tools, SDKs, MQ/Kafka, callbacks, payment gateways,
80
+ cloud services, or other external integrations, `api.md` and
81
+ `sdd-quality-gate.md` must include `External Integration Configuration And
82
+ Deployment Contract`. Inventory endpoints, app/tenant/project IDs,
83
+ Topic/Tag/Consumer Group, namespace, webhook, ACL/role, feature switches,
84
+ timeout, and credential references across local, test, and production
85
+ environments. Record injection/provisioning method, runtime owner,
86
+ provisioning owner/time, readiness evidence, rollback, secret handling, and
87
+ blockers. Environment-dependent values must not be hard-coded; test
88
+ auto-creation or existing test resources do not prove production readiness.
89
+ Missing production provisioning evidence blocks document freeze.
79
90
  - For amount, fee, discount, deduction, refund, sharing, payment, invoice,
80
91
  balance, electricity/service fee, package settlement, proration, allocation,
81
92
  reconciliation, or financial display changes, `sdd-quality-gate.md` must
@@ -37,6 +37,11 @@ hotfix:
37
37
 
38
38
  ## Routing
39
39
 
40
+ - When the user explicitly asks for rigorous questioning, or a bounded feature
41
+ has unresolved owner decisions, mutually exclusive approaches, an unclear
42
+ source of truth, unclear acceptance behavior, or cross-system responsibility,
43
+ use `superflow-clarify` in embedded deep-clarification mode. This is a mode
44
+ inside the normal clarify phase, not a separate command the user must remember.
40
45
  - New or unclear requirement: use superflow-clarify.
41
46
  - Confirmed requirement needing full docs: use openspec-propose, then
42
47
  superflow-docs.
@@ -49,6 +54,29 @@ hotfix:
49
54
  - Urgent small behavior repair: use superflow-hotfix, unless API, DB, cross-repo,
50
55
  status, SQL, SDK, or real-entry gates are involved.
51
56
 
57
+ ## Embedded Deep Clarification
58
+
59
+ When the router selects embedded deep clarification, follow these rules inside
60
+ `superflow-clarify`:
61
+
62
+ - Do not activate it for a clear, bounded hotfix or tweak whose intended behavior
63
+ and acceptance result are already evidenced. Do not turn routine work into an
64
+ interview.
65
+ - Establish facts from the requirement, repository, configuration, tests, logs,
66
+ or available tools before asking the user. Ask only for a decision the user or
67
+ owner must make.
68
+ - Ask exactly one decision question at a time. State the recommended option and
69
+ its important consequence, then wait for the answer before the next question.
70
+ - After each answer, update `.sdd/handoff/brainstorm-summary.md` with
71
+ `confirmed`, `candidate`, `pending`, and `rejected` entries. Do not rely on
72
+ chat memory for a resolved decision.
73
+ - Do not create or change proposal, spec, design, tasks, tests, or implementation
74
+ artifacts until all decisions that affect the current feature are confirmed or
75
+ explicitly marked blocked.
76
+ - Exit deep clarification once only repository-verifiable facts remain and the
77
+ user confirms the current feature understanding. Continue through the existing
78
+ clarify workflow without invoking an external skill dependency.
79
+
52
80
  ## Required Artifacts
53
81
 
54
82
  For a full change, the docs phase must create or refresh:
@@ -11,6 +11,14 @@ Use api.md as the canonical contract before implementation.
11
11
  - Frontend mapping: screen field, API field, DTO/VO field, DB field, test case.
12
12
  - External dependency contract: SDK version, topic/path, parameter source,
13
13
  sample request/response, timeout and retry behavior.
14
+ - External Integration Configuration And Deployment Contract for third-party
15
+ platforms/tools, SDKs, MQ/Kafka, callbacks, payment providers, cloud
16
+ services, or other external integrations. Inventory endpoint,
17
+ app/tenant/project IDs, Topic/Tag/Consumer Group, namespace, webhook,
18
+ ACL/role, feature switches, timeout, and credential references for local,
19
+ test, and production; record injection/provisioning method, runtime owner,
20
+ provisioning owner/time, readiness evidence, rollback, secret handling, and
21
+ blockers.
14
22
  - File contract when upload/download/export is involved: Content-Type,
15
23
  Content-Disposition, filename rule, body format, frontend detection rule.
16
24
  - Compatibility and migration notes.
@@ -20,3 +28,8 @@ Use api.md as the canonical contract before implementation.
20
28
 
21
29
  Do not allow design, tasks, tests, or prompts to proceed if API changes are only
22
30
  summarized as core fields, same as existing endpoint, or to be added later.
31
+ Environment-dependent external configuration and server-side resources must
32
+ not exist only as hard-coded annotations, constants, or business code. Test
33
+ auto-creation, existing historical resources, or successful local startup do
34
+ not prove production readiness; missing production provisioning evidence
35
+ blocks release.
@@ -24,6 +24,22 @@ review-checklist.md, sdd-quality-gate.md, test-report.md, and technical design.
24
24
  - Do not change forbidden files or root aggregate docs from a worker batch.
25
25
  - Use TDD: record RED failure before GREEN success.
26
26
  - Do not mark mock-only or unit-only evidence as real integration.
27
+ - For third-party platforms/tools, SDKs, MQ/Kafka, callbacks, payment
28
+ providers, cloud services, or other external integrations, inherit
29
+ `External Integration Configuration And Deployment Contract`. Cover
30
+ local/test/production sources and provisioning, injection/creation,
31
+ runtime/provisioning owners and timing, readiness evidence, rollback, secret
32
+ handling, and blockers. Do not hard-code environment-dependent values or
33
+ infer production readiness from test auto-creation.
34
+ - For concurrent requests, batch issue/activation/renewal, duplicate callbacks
35
+ or consumption, and repeated external delivery, inherit `Concurrency And
36
+ Idempotency Ownership`. Define a stable business idempotency key,
37
+ application-layer atomic claim owner, short transaction boundary,
38
+ PENDING/SUCCESS/FAILED state machine, retry reuse of the original business
39
+ code, external-call boundary, and uncertain-result reconciliation. Release
40
+ database locks before external calls. A unique index is not the default and
41
+ may only be an optional fallback with explicit natural uniqueness,
42
+ historical cleanup, NULL/soft-delete behavior, and conflict handling.
27
43
  - For monetary changes, inherit `Money Precision Boundary`, retain
28
44
  calculation-state precision until the confirmed settlement/display boundary,
29
45
  record scale and rounding mode, forbid early rounding before slicing or
@@ -23,6 +23,23 @@ Superpowers technical design is canonical for source-level HOW and execution.
23
23
  - Field semantic contract checked.
24
24
  - Write-loop checked.
25
25
  - No-fallback boundary confirmed.
26
+ - External Integration Configuration And Deployment Contract copied from the
27
+ API, quality gate, and technical design for third-party platforms/tools,
28
+ SDKs, MQ/Kafka, callbacks, payment providers, cloud services, or other
29
+ external integrations. Cover local/test/production sources and provisioning,
30
+ injection/creation, runtime/provisioning owners and timing, readiness
31
+ evidence, rollback, secret handling, and blockers. Do not hard-code
32
+ environment-dependent external values or treat test auto-creation as
33
+ production readiness evidence.
34
+ - Concurrency And Idempotency Ownership copied from the technical design for
35
+ concurrent requests, batch issue/activation/renewal, duplicate callbacks or
36
+ consumption, and repeated external delivery. Define a stable business
37
+ idempotency key, application-layer atomic claim owner, short transaction
38
+ boundary, PENDING/SUCCESS/FAILED state machine, retry reuse of the original
39
+ business code, external-call boundary, and uncertain-result reconciliation.
40
+ Release database locks before external calls. A unique index is not the
41
+ default; it is only an optional fallback with explicit natural uniqueness,
42
+ historical cleanup, NULL/soft-delete behavior, and conflict handling.
26
43
  - Money Precision Boundary copied from the technical design when monetary
27
44
  behavior changes. Keep calculation-state precision until the confirmed
28
45
  settlement/display boundary, record scale and rounding mode, forbid early
@@ -16,6 +16,23 @@
16
16
  - Field/status reverse impact matrix exists when risky fields or states change.
17
17
  - Architecture boundary and call-direction matrix exists for cross-service or
18
18
  external flows.
19
+ - External Integration Configuration And Deployment Contract exists for
20
+ third-party platforms/tools, SDKs, MQ/Kafka, callbacks, payment providers,
21
+ cloud services, or other external integrations. It inventories environment
22
+ sources and provisioning for endpoints, app/tenant/project IDs,
23
+ Topic/Tag/Consumer Group, namespace, webhook, ACL/role, switches, timeouts,
24
+ and credential references; names runtime/provisioning owners, timing,
25
+ readiness evidence, rollback, secret handling, and blockers; and forbids
26
+ environment-dependent hard-coded values. Test auto-creation, existing test
27
+ resources, or local startup do not prove production readiness.
28
+ - Concurrency And Idempotency Ownership exists for concurrent requests, batch
29
+ issue/activation/renewal, duplicate callbacks/consumption, or repeated
30
+ external delivery. It defines the business idempotency key,
31
+ application-layer atomic claim owner, short transaction boundary,
32
+ PENDING/SUCCESS/FAILED state machine, retry code reuse, external-call
33
+ boundary, and uncertain-result reconciliation. A unique index is not the
34
+ default; it is only an optional fallback with explicit natural uniqueness,
35
+ historical cleanup, NULL/soft-delete behavior, and conflict handling.
19
36
  - Money precision boundary exists when amount, fee, discount, deduction,
20
37
  refund, sharing, payment, invoice, balance, electricity fee, service fee,
21
38
  package settlement, proration, allocation, reconciliation, or financial
@@ -59,6 +59,52 @@ orchestrator unless the OpenSpec/SDD contract explicitly says that module owns
59
59
  the new entry point and records the owner approval. If the correct owner is
60
60
  unclear, mark the design blocked.
61
61
 
62
+ ## External Integration Configuration And Deployment Contract
63
+
64
+ Use this whenever the change integrates with a third-party platform/tool, SDK,
65
+ MQ/Kafka, callback, payment gateway, cloud service, or other external system.
66
+
67
+ | External dependency/resource | Config/resource item | Local source/provisioning | Test source/provisioning | Production source/provisioning | Injection/creation method | Runtime owner | Provisioning owner/time | Readiness evidence | Rollback | Secret handling | Blocker |
68
+ | ---------------------------- | -------------------- | ------------------------- | ------------------------ | ------------------------------ | ------------------------- | ------------- | ----------------------- | ------------------ | -------- | --------------- | ------- |
69
+ | `<TDMQ>` | `<Consumer Group>` | `<auto/manual/IaC>` | `<existing resource>` | `<pre-created by ops>` | `<config/secret/IaC/console>` | `<service>` | `<owner + before deploy>` | `<console/API/trace>` | `<disable/rollback>` | `<secret reference only>` | `<none/blocker>` |
70
+
71
+ Required checks:
72
+
73
+ ```bash
74
+ rg -ni "https?://|endpoint|base.?url|app.?id|tenant|project.?id|topic|tag|consumer.?group|namespace|webhook|acl|role|secret|token|password|timeout" <source-and-config-paths>
75
+ rg -ni "@.*Listener|new.*Client|builder\(|System\.getenv|ConfigurationProperties|Value\(" <source-and-config-paths>
76
+ ```
77
+
78
+ Do not hard-code environment-dependent endpoints, resource names, identifiers,
79
+ credentials, ACLs, or operational switches in annotations, constants, or
80
+ business code. Stable protocol constants may remain code constants only when
81
+ the design proves they are not environment-specific and no server-side
82
+ resource must be provisioned. Test auto-creation, a successful local startup,
83
+ or an already-existing test resource is not evidence that production is
84
+ ready. Every server-side resource must have an explicit production owner,
85
+ creation timing, readiness check, and rollback path. Missing production
86
+ provisioning evidence is a blocker.
87
+
88
+ ## Concurrency And Idempotency Ownership
89
+
90
+ Complete this section for concurrent requests, batch issue/activation/renewal,
91
+ duplicate callbacks, duplicate consumption, or repeated external delivery.
92
+
93
+ | Scenario | Business idempotency key | Claim owner/resource | Application-layer atomic claim | Short transaction boundary | State machine | Retry code reuse | External-call boundary | Uncertain-result handling | Unique-index role | Test evidence |
94
+ | -------- | ------------------------ | -------------------- | ------------------------------ | -------------------------- | ------------- | ---------------- | ---------------------- | ------------------------- | ----------------- | ------------- |
95
+ | `<batch issue>` | `<package+vehicle+period>` | `<period row>` | `<lock owner then persist PENDING>` | `<commit claim independently>` | `PENDING/SUCCESS/FAILED` | `<reuse original business code>` | `<call after commit>` | `<block duplicates and reconcile>` | `<not default; optional fallback>` | `<concurrent/duplicate/retry cases>` |
96
+
97
+ Application-layer atomic claim is the default: use a stable business
98
+ idempotency key, lock an explicit owner resource in a short transaction,
99
+ persist `PENDING`, commit, and release the database lock before the external
100
+ call. Update the state after the call; every retry reuses the original business
101
+ code. An uncertain result blocks duplicate delivery and remains reconcilable.
102
+ Do not use check-then-insert, process-local locks, or random IDs as cross-instance
103
+ idempotency, and do not hold a database lock across an external call. A unique
104
+ index is not the default; it is only an optional database fallback when natural
105
+ uniqueness, historical cleanup, NULL/soft-delete behavior, and conflict handling
106
+ are explicitly contracted.
107
+
62
108
  ## Field And Status Reverse Impact
63
109
 
64
110
  Use this whenever changing field values, enum/status values, derived fields,
@@ -38,3 +38,15 @@ rounded. Record currency, provider minor unit, pre/post-round values, residual
38
38
  recipient, and positive/zero/negative or refund, tied remainder, and idempotent
39
39
  recalculation evidence. FX cases also record base/quote, rate source, and target
40
40
  settlement rounding. A two-decimal display assertion alone is insufficient.
41
+
42
+ ## Closeout
43
+
44
+ Verification Result: PASS / FAIL / BLOCKED / PARTIALLY_VERIFIED
45
+ Archive Readiness: PASS / BLOCKED
46
+
47
+ Required for `verify_mode: full`:
48
+
49
+ - Test environment:
50
+ - Branch/commit/build number or image:
51
+ - Base URL:
52
+ - Verification timestamp: