@chenmk/superflow 0.2.5 → 0.4.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 (116) hide show
  1. package/README.md +24 -2
  2. package/README.zh-CN.md +17 -1
  3. package/assets/manifest.json +7 -4
  4. package/assets/prompts/superflow-clarify.md +6 -0
  5. package/assets/prompts/superflow-design.md +3 -0
  6. package/assets/prompts/superflow-docs.md +4 -1
  7. package/assets/prompts/superflow-pipeline.md +8 -0
  8. package/assets/scripts/superflow-archive-command-hook.sh +80 -0
  9. package/assets/scripts/superflow-delivery-check.sh +23 -4
  10. package/assets/scripts/superflow-dependency-update-hook.sh +1 -1
  11. package/assets/scripts/superflow-managed-work-check.mjs +194 -0
  12. package/assets/scripts/superflow-managed-work-guard.sh +103 -0
  13. package/assets/skills/openspec-propose/SKILL.md +11 -0
  14. package/assets/skills/superflow-archive/SKILL.md +5 -0
  15. package/assets/skills/superflow-clarify/SKILL.md +26 -7
  16. package/assets/skills/superflow-design/SKILL.md +38 -7
  17. package/assets/skills/superflow-docs/SKILL.md +27 -0
  18. package/assets/skills/superflow-pipeline/SKILL.md +75 -0
  19. package/assets/skills/superflow-pipeline/references/api-design-template.md +11 -0
  20. package/assets/skills/superflow-pipeline/references/batch-prompt-template.md +27 -0
  21. package/assets/skills/superflow-pipeline/references/document-templates.md +8 -0
  22. package/assets/skills/superflow-pipeline/references/implementation-prompt-template.md +29 -1
  23. package/assets/skills/superflow-pipeline/references/managed-work.md +58 -0
  24. package/assets/skills/superflow-pipeline/references/quality-gate.md +3 -0
  25. package/assets/skills/superflow-pipeline/references/superpower-technical-design-template.md +51 -0
  26. package/assets/skills/superflow-pipeline/references/test-execution-template.md +10 -0
  27. package/assets/skills/superflow-pipeline/scripts/superflow-archive.sh +1 -1
  28. package/assets/skills/superflow-pipeline/scripts/superflow-guard.sh +215 -2
  29. package/assets/skills/superflow-verify/SKILL.md +7 -0
  30. package/assets/skills-en/openspec-propose/SKILL.md +14 -0
  31. package/assets/skills-en/superflow-archive/SKILL.md +6 -0
  32. package/assets/skills-en/superflow-clarify/SKILL.md +26 -7
  33. package/assets/skills-en/superflow-design/SKILL.md +38 -6
  34. package/assets/skills-en/superflow-docs/SKILL.md +27 -0
  35. package/assets/skills-en/superflow-pipeline/SKILL.md +76 -0
  36. package/assets/skills-en/superflow-pipeline/references/api-design-template.md +13 -0
  37. package/assets/skills-en/superflow-pipeline/references/batch-prompt-template.md +16 -0
  38. package/assets/skills-en/superflow-pipeline/references/document-templates.md +5 -0
  39. package/assets/skills-en/superflow-pipeline/references/implementation-prompt-template.md +17 -0
  40. package/assets/skills-en/superflow-pipeline/references/managed-work.md +34 -0
  41. package/assets/skills-en/superflow-pipeline/references/quality-gate.md +25 -0
  42. package/assets/skills-en/superflow-pipeline/references/superpower-technical-design-template.md +57 -0
  43. package/assets/skills-en/superflow-pipeline/references/test-execution-template.md +12 -0
  44. package/assets/skills-en/superflow-pipeline/scripts/superflow-archive.sh +1 -1
  45. package/assets/skills-en/superflow-pipeline/scripts/superflow-guard.sh +214 -2
  46. package/assets/skills-en/superflow-verify/SKILL.md +8 -0
  47. package/dist/app/cli.js +120 -102
  48. package/dist/app/cli.js.map +1 -1
  49. package/dist/app/commands/archive.js +7 -3
  50. package/dist/app/commands/archive.js.map +1 -1
  51. package/dist/app/commands/change-guard.js +27 -0
  52. package/dist/app/commands/change-guard.js.map +1 -0
  53. package/dist/app/commands/design.js +2 -20
  54. package/dist/app/commands/design.js.map +1 -1
  55. package/dist/app/commands/init.js +7 -7
  56. package/dist/app/commands/init.js.map +1 -1
  57. package/dist/app/commands/managed-service.js +5 -0
  58. package/dist/app/commands/managed-service.js.map +1 -0
  59. package/dist/app/commands/pipeline.js +123 -3
  60. package/dist/app/commands/pipeline.js.map +1 -1
  61. package/dist/app/commands/status.js +199 -77
  62. package/dist/app/commands/status.js.map +1 -1
  63. package/dist/app/commands/uninstall.js +5 -2
  64. package/dist/app/commands/uninstall.js.map +1 -1
  65. package/dist/app/commands/update.js +33 -11
  66. package/dist/app/commands/update.js.map +1 -1
  67. package/dist/app/commands/verify.js +7 -3
  68. package/dist/app/commands/verify.js.map +1 -1
  69. package/dist/domains/config/cli-help.js +103 -73
  70. package/dist/domains/config/cli-help.js.map +1 -1
  71. package/dist/domains/config/context.js +1 -5
  72. package/dist/domains/config/context.js.map +1 -1
  73. package/dist/domains/deps.js +3 -6
  74. package/dist/domains/deps.js.map +1 -1
  75. package/dist/domains/hook.js +71 -37
  76. package/dist/domains/hook.js.map +1 -1
  77. package/dist/domains/managed-work/contract.js +218 -0
  78. package/dist/domains/managed-work/contract.js.map +1 -0
  79. package/dist/domains/managed-work/i18n.js +12 -0
  80. package/dist/domains/managed-work/i18n.js.map +1 -0
  81. package/dist/domains/managed-work/input.js +111 -0
  82. package/dist/domains/managed-work/input.js.map +1 -0
  83. package/dist/domains/managed-work/journal.js +122 -0
  84. package/dist/domains/managed-work/journal.js.map +1 -0
  85. package/dist/domains/managed-work/lock.js +40 -0
  86. package/dist/domains/managed-work/lock.js.map +1 -0
  87. package/dist/domains/managed-work/notifications.js +53 -0
  88. package/dist/domains/managed-work/notifications.js.map +1 -0
  89. package/dist/domains/managed-work/paths.js +18 -0
  90. package/dist/domains/managed-work/paths.js.map +1 -0
  91. package/dist/domains/managed-work/prompts.js +218 -0
  92. package/dist/domains/managed-work/prompts.js.map +1 -0
  93. package/dist/domains/managed-work/runner.js +626 -0
  94. package/dist/domains/managed-work/runner.js.map +1 -0
  95. package/dist/domains/managed-work/schemas.js +85 -0
  96. package/dist/domains/managed-work/schemas.js.map +1 -0
  97. package/dist/domains/managed-work/service.js +121 -0
  98. package/dist/domains/managed-work/service.js.map +1 -0
  99. package/dist/domains/managed-work/state.js +90 -0
  100. package/dist/domains/managed-work/state.js.map +1 -0
  101. package/dist/domains/managed-work/storage.js +181 -0
  102. package/dist/domains/managed-work/storage.js.map +1 -0
  103. package/dist/domains/managed-work/types.js +16 -0
  104. package/dist/domains/managed-work/types.js.map +1 -0
  105. package/dist/domains/managed-work/wait.js +40 -0
  106. package/dist/domains/managed-work/wait.js.map +1 -0
  107. package/dist/platform/agent-process.js +308 -0
  108. package/dist/platform/agent-process.js.map +1 -0
  109. package/dist/platform/assets.js +9 -0
  110. package/dist/platform/assets.js.map +1 -0
  111. package/dist/platform/process-liveness.js +10 -0
  112. package/dist/platform/process-liveness.js.map +1 -0
  113. package/dist/platform/version-check.js +30 -9
  114. package/dist/platform/version-check.js.map +1 -1
  115. package/package.json +3 -2
  116. package/scripts/release-notes-check.js +102 -0
@@ -19,6 +19,38 @@ other:
19
19
  - Handoff files and state files are the memory boundary. Do not rely on chat
20
20
  memory after compaction.
21
21
 
22
+ ## Managed Work And Dual-Agent Closure
23
+
24
+ When the user says to use Superflow for managed delivery and provides an
25
+ implementation prompt, change directory, or direct task, use built-in managed
26
+ mode. Do not require the user to name `superflow-pipeline`, roles, or CLI flags:
27
+
28
+ ```bash
29
+ superflow pipeline "<implementation prompt, change directory, or direct task>" --managed --project "<project root>" \
30
+ --supervisor codex --executor claude --language en
31
+ ```
32
+
33
+ Swap the roles when Claude is the current entry agent. The command always uses
34
+ the independent background service while following the local task journal to a
35
+ terminal state, then the current agent reads the report and summarizes in the
36
+ same conversation. Losing the follower does not stop the task. Read
37
+ `references/managed-work.md` before dispatch. Do not spawn the peer CLI by hand.
38
+
39
+ Hard gates:
40
+
41
+ - Persist one supervisor session and one executor session per task; resume exact IDs.
42
+ - Task contract, event journal, review results, and evidence are authoritative.
43
+ - Maximum 5 reviews, 7 executor calls, and 12 total agent calls.
44
+ - Revalidate the frozen contract and hard limits on every start or resume. Engineering work cannot enter review with only one verification category.
45
+ - Resolve a change directory through `.sdd/state.yaml` `implementation_prompt`, reject `tasks.md` as an execution entry, and freeze one prompt snapshot plus SHA-256 for both agents.
46
+ - Supervisor is read-only; executor cannot edit `.superflow/tasks` or commit/push/publish.
47
+ - A passing run stops at `awaiting_git_approval`; Git requires the user's approval.
48
+ - Use `superflow status <project-root>` instead of model polling.
49
+ - `superflow-managed-work-check.mjs` must pass before delivery-ready status.
50
+ - Record the single delivery-ready event only after the integrity script passes.
51
+ - After the managed command returns a terminal state, read the task report and summarize it to the user instead of returning only a task ID.
52
+ - Freeze the selected language into the task contract. Executor and reviewer prompts, resumed rounds, journals, reports, notifications, and errors must inherit that language without switching mid-run.
53
+
22
54
  ## Phase Order
23
55
 
24
56
  Always route work through this order unless the task is explicitly a tweak or
@@ -37,6 +69,11 @@ hotfix:
37
69
 
38
70
  ## Routing
39
71
 
72
+ - When the user explicitly asks for rigorous questioning, or a bounded feature
73
+ has unresolved owner decisions, mutually exclusive approaches, an unclear
74
+ source of truth, unclear acceptance behavior, or cross-system responsibility,
75
+ use `superflow-clarify` in embedded deep-clarification mode. This is a mode
76
+ inside the normal clarify phase, not a separate command the user must remember.
40
77
  - New or unclear requirement: use superflow-clarify.
41
78
  - Confirmed requirement needing full docs: use openspec-propose, then
42
79
  superflow-docs.
@@ -49,8 +86,47 @@ hotfix:
49
86
  - Urgent small behavior repair: use superflow-hotfix, unless API, DB, cross-repo,
50
87
  status, SQL, SDK, or real-entry gates are involved.
51
88
 
89
+ ## Embedded Deep Clarification
90
+
91
+ When the router selects embedded deep clarification, follow these rules inside
92
+ `superflow-clarify`:
93
+
94
+ - Do not activate it for a clear, bounded hotfix or tweak whose intended behavior
95
+ and acceptance result are already evidenced. Do not turn routine work into an
96
+ interview.
97
+ - Establish facts from the requirement, repository, configuration, tests, logs,
98
+ or available tools before asking the user. Ask only for a decision the user or
99
+ owner must make.
100
+ - Ask exactly one decision question at a time. State the recommended option and
101
+ its important consequence, then wait for the answer before the next question.
102
+ - After each answer, update `.sdd/handoff/brainstorm-summary.md` with
103
+ `confirmed`, `candidate`, `pending`, and `rejected` entries. Do not rely on
104
+ chat memory for a resolved decision.
105
+ - Do not create or change proposal, spec, design, tasks, tests, or implementation
106
+ artifacts until all decisions that affect the current feature are confirmed or
107
+ explicitly marked blocked.
108
+ - Exit deep clarification once only repository-verifiable facts remain and the
109
+ user confirms the current feature understanding. Continue through the existing
110
+ clarify workflow without invoking an external skill dependency.
111
+
52
112
  ## Required Artifacts
53
113
 
114
+ ### Canonical OpenSpec Change Directory (Blocking)
115
+
116
+ - Superflow must use the OpenSpec CLI single-level layout:
117
+ `openspec/changes/<change-name>/`.
118
+ - The release version belongs in the change name, not an intermediate
119
+ directory. Encode `v1.1.1` as `v1-1-1-<feature-slug>` and never create
120
+ `changes/v1.1.1/<feature-slug>/`.
121
+ - Keep exactly one physical directory for each change. Do not create a
122
+ compatibility symlink, copied directory, or second canonical document tree.
123
+ - Run `openspec new change <change-name>` first, then reuse that same physical
124
+ directory for status, instructions, strict validation, state, handoff, and
125
+ every Superflow guard.
126
+ - If a nested version directory or symlinked change is found, stop document
127
+ generation, migrate it to one flat physical directory, and rerun
128
+ `openspec validate <change-name> --strict`.
129
+
54
130
  For a full change, the docs phase must create or refresh:
55
131
 
56
132
  - proposal.md
@@ -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
@@ -22,6 +22,11 @@
22
22
  - Source-of-truth contracts
23
23
  - Architecture boundary
24
24
  - Data model
25
+ - Minimal Design Review: reuse evidence, necessity, simplest implementation,
26
+ removed/rejected complexity, and blockers
27
+ - Count every new table, field, API, service, cache, async flow, scheduled job,
28
+ and compatibility layer; remove items without evidence
29
+ - New-item counts: tables 0; fields 0; APIs 0; services/components 0; caches 0; MQ/events 0; scheduled jobs 0; compatibility layers 0. Replace each count.
25
30
  - Field semantics
26
31
  - Write/read loop
27
32
  - No-fallback decisions
@@ -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
@@ -0,0 +1,34 @@
1
+ # Managed Work Rules
2
+
3
+ Managed work is built into `superflow-pipeline`. The user only says to use
4
+ Superflow and provides an implementation prompt, change directory, or direct
5
+ task. Direct tasks receive a minimal contract. SDD work freezes the generated
6
+ implementation prompt and never substitutes `tasks.md` for the execution prompt.
7
+
8
+ Always dispatch through:
9
+
10
+ ```bash
11
+ superflow pipeline "<implementation-prompt|change-dir|task>" --managed --project "<root>" \
12
+ --supervisor <codex|claude> --executor <claude|codex> --language <en|zh>
13
+ ```
14
+
15
+ The command always starts the independent background service and follows the
16
+ local event journal to a terminal state. Losing the follower does not stop the
17
+ task. After return, the current agent reads the report and summarizes it in the
18
+ original conversation.
19
+
20
+ Hard gates:
21
+
22
+ - Claim the 5/7/12 budgets before an Agent call.
23
+ - Freeze the selected language into the contract; prompts, journals, reports, notifications, errors, and resumed rounds must use that same language.
24
+ - Revalidate the frozen contract hash, non-overridable permissions, and 5/7/12 hard limits on every start and resume. Fail closed if persisted contract data changed.
25
+ - Resolve change directories through `.sdd/state.yaml` `implementation_prompt`; treat `tasks.md` as a checklist only. Copy the prompt into a managed snapshot and freeze its SHA-256 for both agents.
26
+ - Persist and resume exact supervisor and executor session IDs.
27
+ - Treat `progress.jsonl`, the task contract, review results, and evidence as truth.
28
+ - Executor cannot edit managed state or commit, push, publish, deploy, or bypass sandbox.
29
+ - Supervisor cannot modify target files.
30
+ - Non-zero exits, invalid JSON, missing session IDs, and review-time workspace drift block pass.
31
+ - Engineering and SDD tasks need successful command evidence from at least two categories among build, test, and runtime/real invocation. Compile-only or unit-test-only delivery cannot enter formal review.
32
+ - Run `superflow-managed-work-check.mjs <root> <task-id>` before delivery-ready.
33
+ - Append the single `run.delivery_ready` event only after the integrity script passes. On failure, require human attention without leaving false delivery-ready evidence.
34
+ - A passing run waits for explicit Git approval.
@@ -9,13 +9,38 @@
9
9
  - Handoff files exist and hash is current.
10
10
  - design.md records OpenSpec/SDD as WHAT and Superpowers as HOW.
11
11
  - sdd-quality-gate.md records guard command and result.
12
+ - design.md and sdd-quality-gate.md include a Minimal Design Review with reuse
13
+ evidence, necessity, simplest implementation, removed/rejected complexity,
14
+ counts of new tables/fields/APIs/services/caches/async flows/jobs/compatibility
15
+ layers, and a PASS/BLOCKED verdict. Only PASS may leave docs/design.
12
16
 
13
17
  ## Design Gate
14
18
 
15
19
  - Technical design exists for full workflow.
20
+ - Technical design repeats the Minimal Design Review at source level. It extends
21
+ existing modules first and rejects speculative abstractions, parallel APIs or
22
+ models, derivable persistence, premature caches, and async compensation when
23
+ a direct synchronous design satisfies the contract.
16
24
  - Field/status reverse impact matrix exists when risky fields or states change.
17
25
  - Architecture boundary and call-direction matrix exists for cross-service or
18
26
  external flows.
27
+ - External Integration Configuration And Deployment Contract exists for
28
+ third-party platforms/tools, SDKs, MQ/Kafka, callbacks, payment providers,
29
+ cloud services, or other external integrations. It inventories environment
30
+ sources and provisioning for endpoints, app/tenant/project IDs,
31
+ Topic/Tag/Consumer Group, namespace, webhook, ACL/role, switches, timeouts,
32
+ and credential references; names runtime/provisioning owners, timing,
33
+ readiness evidence, rollback, secret handling, and blockers; and forbids
34
+ environment-dependent hard-coded values. Test auto-creation, existing test
35
+ resources, or local startup do not prove production readiness.
36
+ - Concurrency And Idempotency Ownership exists for concurrent requests, batch
37
+ issue/activation/renewal, duplicate callbacks/consumption, or repeated
38
+ external delivery. It defines the business idempotency key,
39
+ application-layer atomic claim owner, short transaction boundary,
40
+ PENDING/SUCCESS/FAILED state machine, retry code reuse, external-call
41
+ boundary, and uncertain-result reconciliation. A unique index is not the
42
+ default; it is only an optional fallback with explicit natural uniqueness,
43
+ historical cleanup, NULL/soft-delete behavior, and conflict handling.
19
44
  - Money precision boundary exists when amount, fee, discount, deduction,
20
45
  refund, sharing, payment, invoice, balance, electricity fee, service fee,
21
46
  package settlement, proration, allocation, reconciliation, or financial
@@ -35,6 +35,17 @@ canonical_sources:
35
35
  |---|---|---|---|---|---|
36
36
  | <R1/S1> | `<file>:<line>` | <observed fact> | <implementation approach> | <files> | <risk> |
37
37
 
38
+ ## Minimal Design Review
39
+
40
+ | Design item | Existing capability/reuse evidence | Necessary? | Simplest implementation | Removed/rejected complexity | Evidence/blocker |
41
+ | ----------- | ---------------------------------- | ---------- | ----------------------- | --------------------------- | ---------------- |
42
+ | `<table/API/service/component/sync>` | `<existing source/API/table/dependency>` | `keep/remove/blocked` | `<minimum implementation>` | `<no parallel abstraction/cache/async/compat layer>` | `<anchor or blocker>` |
43
+
44
+ New-item counts: tables 0; fields 0; APIs 0; services/components 0; caches 0; MQ/events 0; scheduled jobs 0; compatibility layers 0. Replace each count with the actual design total. Extend existing modules first. Do not persist values
45
+ that can be derived safely, and do not add async compensation or caching when a
46
+ single synchronous transaction closes the contract. Every retained item must
47
+ explain why a simpler option fails; remove it when there is no evidence.
48
+
38
49
  ## Architecture Boundary And Call Direction
39
50
 
40
51
  Use this whenever the change crosses repositories, services, SDKs, MQ,
@@ -59,6 +70,52 @@ orchestrator unless the OpenSpec/SDD contract explicitly says that module owns
59
70
  the new entry point and records the owner approval. If the correct owner is
60
71
  unclear, mark the design blocked.
61
72
 
73
+ ## External Integration Configuration And Deployment Contract
74
+
75
+ Use this whenever the change integrates with a third-party platform/tool, SDK,
76
+ MQ/Kafka, callback, payment gateway, cloud service, or other external system.
77
+
78
+ | 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 |
79
+ | ---------------------------- | -------------------- | ------------------------- | ------------------------ | ------------------------------ | ------------------------- | ------------- | ----------------------- | ------------------ | -------- | --------------- | ------- |
80
+ | `<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>` |
81
+
82
+ Required checks:
83
+
84
+ ```bash
85
+ 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>
86
+ rg -ni "@.*Listener|new.*Client|builder\(|System\.getenv|ConfigurationProperties|Value\(" <source-and-config-paths>
87
+ ```
88
+
89
+ Do not hard-code environment-dependent endpoints, resource names, identifiers,
90
+ credentials, ACLs, or operational switches in annotations, constants, or
91
+ business code. Stable protocol constants may remain code constants only when
92
+ the design proves they are not environment-specific and no server-side
93
+ resource must be provisioned. Test auto-creation, a successful local startup,
94
+ or an already-existing test resource is not evidence that production is
95
+ ready. Every server-side resource must have an explicit production owner,
96
+ creation timing, readiness check, and rollback path. Missing production
97
+ provisioning evidence is a blocker.
98
+
99
+ ## Concurrency And Idempotency Ownership
100
+
101
+ Complete this section for concurrent requests, batch issue/activation/renewal,
102
+ duplicate callbacks, duplicate consumption, or repeated external delivery.
103
+
104
+ | 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 |
105
+ | -------- | ------------------------ | -------------------- | ------------------------------ | -------------------------- | ------------- | ---------------- | ---------------------- | ------------------------- | ----------------- | ------------- |
106
+ | `<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>` |
107
+
108
+ Application-layer atomic claim is the default: use a stable business
109
+ idempotency key, lock an explicit owner resource in a short transaction,
110
+ persist `PENDING`, commit, and release the database lock before the external
111
+ call. Update the state after the call; every retry reuses the original business
112
+ code. An uncertain result blocks duplicate delivery and remains reconcilable.
113
+ Do not use check-then-insert, process-local locks, or random IDs as cross-instance
114
+ idempotency, and do not hold a database lock across an external call. A unique
115
+ index is not the default; it is only an optional database fallback when natural
116
+ uniqueness, historical cleanup, NULL/soft-delete behavior, and conflict handling
117
+ are explicitly contracted.
118
+
62
119
  ## Field And Status Reverse Impact
63
120
 
64
121
  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:
@@ -131,7 +131,7 @@ GUARD="$SCRIPT_DIR/superflow-guard.sh"
131
131
  VALIDATE="$SCRIPT_DIR/superflow-yaml-validate.sh"
132
132
  CHANGE_DIR="$(cd "$CHANGE_DIR" && pwd)"
133
133
  CHANGE_NAME="$(basename "$CHANGE_DIR")"
134
- PROJECT_ROOT="$(cd "$CHANGE_DIR/../.." && pwd)"
134
+ PROJECT_ROOT="$(cd "$CHANGE_DIR/../../.." && pwd)"
135
135
  ARCHIVE_ROOT="$PROJECT_ROOT/openspec/changes/archive"
136
136
  ARCHIVE_NAME="$CHANGE_NAME"
137
137