dflow-sdd-ddd 0.11.0 → 0.12.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 (28) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/bin/dflow.js +0 -0
  3. package/package.json +1 -1
  4. package/templates/brownfield/references/finish-feature-flow.md +85 -29
  5. package/templates/brownfield/references/git-integration.md +29 -9
  6. package/templates/brownfield/references/modify-existing-flow.md +23 -0
  7. package/templates/brownfield/references/new-feature-flow.md +34 -1
  8. package/templates/brownfield/references/new-phase-flow.md +12 -1
  9. package/templates/brownfield/scaffolding/AI-AGENT-GUIDE.md +40 -5
  10. package/templates/brownfield/scaffolding/Git-principles-gitflow.md +1 -1
  11. package/templates/brownfield/scaffolding/Git-principles-trunk.md +2 -2
  12. package/templates/brownfield/templates/_index.md +23 -4
  13. package/templates/brownfield/templates/lightweight-spec.md +3 -3
  14. package/templates/brownfield/templates/phase-spec.md +3 -3
  15. package/templates/common/references/ddd-modeling-guide.md +197 -3
  16. package/templates/greenfield/references/finish-feature-flow.md +86 -29
  17. package/templates/greenfield/references/git-integration.md +29 -9
  18. package/templates/greenfield/references/modify-existing-flow.md +23 -0
  19. package/templates/greenfield/references/new-feature-flow.md +35 -1
  20. package/templates/greenfield/references/new-phase-flow.md +11 -0
  21. package/templates/greenfield/scaffolding/AI-AGENT-GUIDE.md +40 -5
  22. package/templates/greenfield/scaffolding/Git-principles-gitflow.md +1 -1
  23. package/templates/greenfield/scaffolding/Git-principles-trunk.md +4 -2
  24. package/templates/greenfield/templates/_index.md +23 -4
  25. package/templates/greenfield/templates/aggregate-design.md +2 -1
  26. package/templates/greenfield/templates/events.md +2 -1
  27. package/templates/greenfield/templates/lightweight-spec.md +3 -3
  28. package/templates/greenfield/templates/phase-spec.md +3 -3
package/CHANGELOG.md CHANGED
@@ -6,6 +6,42 @@
6
6
 
7
7
  ---
8
8
 
9
+ ## 0.12.0 — 2026-07-09 — 模型生命週期閉環(長時流程 + 模型重審)+ 收尾守門與跨 session 連續性
10
+
11
+ **Proposals**:PROPOSAL-067(skill source 舊制 ID 與範例正確性清理)、PROPOSAL-068(finish-feature 收尾完整性守門)、PROPOSAL-069(跨分支 / 跨 session 連續性 Phase 1)、PROPOSAL-070(Long-Running Processes 判準與最簡階梯)、PROPOSAL-071(模型修正判準)
12
+
13
+ 本版兩條主線:
14
+
15
+ 1. **DDD 指引優化線收官**(070 / 071)——modeling guide 補上模型生命週期的最後兩塊:跨 Aggregate 多步驟流程的協調與補償邏輯住哪(Long-Running Processes),以及既有模型何時該被重審(Revising an Established Model)。至此生命週期閉環:形成(061 萌芽)→ 使用 → 漂移偵測(verify)→ 重審(071)。
16
+ 2. **Workflow 收尾與連續性**(068 / 069)——finish-feature 收尾產物守門 + 跨分支 / 跨 session 的在途工作可見性。
17
+
18
+ ### 新功能 / 行為改善(DDD 建模指引)
19
+
20
+ - **Long-Running Processes(長時流程)**(PROPOSAL-070):guide 新段——判準先行(「後面失敗需要撤銷前面 → 你要的是 process,不是 event chain」+ 訊號清單與 fire-and-forget 負向守句)、三階梯(owning aggregate status 欄位 → 專責 process aggregate → workflow framework = ADR 決策,比照 outbox / Event Sourcing 防呆先例)、補償 BR 化(補償是新的 domain fact,非 rollback)、deadline 分層(偵測是排程、決策是 domain 規則)。同檔補 Pattern Selection flowchart 與 Domain Services 的 stateful-process 守句、Common Mistakes #11(補償邏輯散落 handler);greenfield `events.md` 模板加指路一句。
21
+ - **Revising an Established Model(重審既有模型)**(PROPOSAL-071):guide 新段——重讀規則(擴充既有 Aggregate 前重讀其 Design Decisions 與再評估條件)、六個「模型在抵抗」訊號(生命週期必填欄位 nullable 化、判別欄增生、同軸第 3+ 業務分支、術語加限定詞、再評估條件命中、跨 instance 交易壓力)+ 無界集合 cross-ref、兩階梯(spec 內具名記錄「照舊 / 拆分 / 改名 + 理由」→ 修正當獨立變更走 T1)、雙反空轉守句(訊號是觸發器不是排程;觸發的是重審不是重設計)。Design Questions 加第 7 問(把再評估條件寫進 worksheet)、Common Mistakes #12;兩軌 new-feature / modify-existing flow 在 Aggregate 歸屬時刻加完整重讀掛鉤(brownfield 與 061 萌芽判準成對)、兩軌 new-phase 加一句指路;`aggregate-design.md` 模板提示再評估條件。
22
+
23
+ ### Workflow 強化
24
+
25
+ - **finish-feature 收尾完整性守門**(PROPOSAL-068):closeout 產物順序重排與雙驗證——closeout 列先寫(明文無 hash 例外)→ 整目錄 `git add` → commit → `git show HEAD:` 單 blob 同時驗 status 與 closeout 列,gate 以驗證通過為準;lightweight / BUG spec 驗證補進 Step 1;選配 `Dflow-Checkpoint` trailer 與 checkpoint 帳原則明文化(dist issue #5 的 skill 面收斂)。
26
+ - **跨分支 / 跨 session 連續性 Phase 1**(PROPOSAL-069):`_index.md` Resume Pointer 加持久化 workflow cursor(Active Workflow / Current Step / Gates Passed / Awaiting;宣告與推導證據交叉、證據優先);`/dflow:status` 改兩段式——在途總覽(本分支 active features + 跨分支 git 掃描分類)+ 當前 feature 細節;intake 重疊掃描(dist issue #4 部分收)。
27
+
28
+ ### 清理 / 修正
29
+
30
+ - **skill source 舊制 ID 與範例正確性**(PROPOSAL-067):flow / 模板殘留的 pre-SPEC-ID 舊制全面換為 SPEC-format(frontmatter、branch 命名、範例 ID)、greenfield trunk Hotfixes 依 severity 雙軌命名、guide 內 `DateRange` 範例改合法 C#。
31
+ - `scripts/check-cross-refs.mjs` Windows 路徑 bug 修正(dev-only,不影響套件使用者)。
32
+
33
+ ### 升級提醒
34
+
35
+ - 既有專案重跑 `dflow configure-agents` 後,bundle 內 `ddd-modeling-guide.md` 取得兩個新段落(Long-Running Processes、Revising an Established Model),六個 flow 檔取得既有模型重讀掛鉤,`aggregate-design.md` / `events.md` 模板取得新提示句。
36
+
37
+ ### 驗證
38
+
39
+ - P-067〜071 全程 proposal-stage + implementation-stage cross-model review 收斂(各案 1〜3 輪迭代至 zero findings);cold-eye gate 依風險分級 skip(純散文、不動 runtime,user 逐案核可)。
40
+ - **P-071 為證據驅動成案**:sim-test R4(seeded 既有專案 + 事前登錄 per-signal rubric)判定「AI 不回頭質疑既有模型決策」盲區成立(H1)後才寫指引;P-070 於同一 R4 中獲落地當日後驗(dev session 主動引用並正確應用其負向守句)。
41
+ - `npm test` + `scripts/check-repo-consistency.sh`(含 cross-refs + source↔mirror diff + `npm pack --dry-run`)全綠。
42
+
43
+ ---
44
+
9
45
  ## 0.11.0 — 2026-06-27 — DDD 指引深化 + pre-V1 退役 + docs 刷新
10
46
 
11
47
  **Proposals**:PROPOSAL-059(modeling-guide 盲區補強)、PROPOSAL-060(Subdomain 分類)、PROPOSAL-061(Brownfield aggregate 萌芽判準)、PROPOSAL-062(戰術補遺)、PROPOSAL-064(Brownfield modeling-guide reachability)、PROPOSAL-065(檢查機械化)、PROPOSAL-066(context-map 語彙補完)、PROPOSAL-063(退役 pre-V1 migration story)
package/bin/dflow.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dflow-sdd-ddd",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "Spec-first SDD/DDD workflow kit for AI-assisted development",
5
5
  "type": "commonjs",
6
6
  "bin": {
@@ -55,6 +55,10 @@ proceeding (do not flip status, do not archive, do not emit summary).
55
55
  - [ ] Every phase-spec file referenced in the Phase Specs table exists at
56
56
  the path the table claims
57
57
  - [ ] Every phase-spec file's frontmatter has `status: completed`
58
+ - [ ] Every Tier = T2 row in `_index.md` Lightweight Changes references an
59
+ existing `lightweight-*.md` / `BUG-*.md` file in the feature directory
60
+ - [ ] Every such lightweight / BUG spec file's frontmatter has
61
+ `status: completed`
58
62
  - [ ] `_index.md` has no obvious open items in Resume Pointer (e.g. "phase-N
59
63
  drafting" / "implementation pending" / "TODO" markers)
60
64
  - [ ] Current BR Snapshot table is non-empty (or feature is intentionally
@@ -65,6 +69,7 @@ If any check fails:
65
69
  > found:
66
70
  > ✗ phase-spec-2026-04-15-foo.md status is still `in-progress`
67
71
  > ✗ Phase Specs table row 3 references missing file phase-spec-...
72
+ > ✗ lightweight-2026-06-20-rounding.md frontmatter status is still `in-progress`
68
73
  >
69
74
  > Address these (run `/dflow:new-phase` to add missing work, or fix the
70
75
  > stale status manually), then re-run `/dflow:finish-feature`."
@@ -92,11 +97,17 @@ branch: feature/{SPEC-ID}-{slug}
92
97
  ---
93
98
  ```
94
99
 
95
- Also update the **Resume Pointer** to reflect closeout:
100
+ Also update the **Resume Pointer** to reflect closeout — this writes the
101
+ cursor's terminal state (after closeout no workflow is active on this
102
+ feature; do not edit the cursor again after the Step 4 closeout commit):
96
103
 
97
104
  ```
98
105
  **Current Progress**: feature completed ({date}); all phase-specs status = completed.
99
106
  **Next Action**: integration — push / merge / PR per the selected Git policy.
107
+ **Active Workflow**: none
108
+ **Current Step**: n/a
109
+ **Gates Passed**: n/a
110
+ **Awaiting**: none
100
111
  ```
101
112
 
102
113
  **→ Transition (step-internal)**: Step 2 complete. Announce "Step 2 complete (status flipped). Entering Step 3: Sync BR Snapshot to BC layer." and continue.
@@ -170,7 +181,8 @@ AI runs:
170
181
  ```bash
171
182
  git mv dflow/specs/features/active/{SPEC-ID}-{slug} \
172
183
  dflow/specs/features/completed/{SPEC-ID}-{slug}
173
- git status # confirm rename detection
184
+ git status # confirm rename detection AND check for `RM` — an `M` next to
185
+ # a rename means unstaged edits you must re-add before committing
174
186
  ```
175
187
 
176
188
  `git mv` is mandatory — never use plain `mv` + `git add`. This preserves
@@ -179,37 +191,74 @@ PR diff quality stays intact across the move. See
179
191
  `references/git-integration.md` § "Directory Moves Must Use git mv" for
180
192
  the full rule set.
181
193
 
182
- After the move, also `git add` any modified files from Step 3 (the
183
- updated `rules.md`, `behavior.md`, `glossary.md`, `tech-debt.md`, etc.)
184
- into the same stage.
185
-
186
194
  **Closeout commit checkpoint** (completes the offline Local-closeout gate):
187
195
 
188
196
  ```
189
- ✓ Feature archived to completed/ and closeout files staged
197
+ ✓ Feature archived to completed/ and closeout ready to stage
190
198
  Commit this closeout now?
191
199
  [Y] Yes — the AI commits with your Git identity (marker per _conventions.md § AI Commit Policy)
192
200
  [N] No — skip; you commit yourself
193
201
  ```
194
202
 
195
- Whether you choose Y or N, record one row in the feature `_index.md`
196
- Checkpoint Log (`closeout | committed ({hash})` or `closeout | skipped`). Only
197
- write a hash after the commit actually succeeds; if a pre-commit hook rejects it
198
- or the commit fails, record `failed` and surface the error — never write a fake
199
- hash.
200
-
201
- The Local-closeout gate is satisfied **only when the closeout is committed**:
202
- closeout complete, Checkpoint Log updated, and the working tree clean (no
203
- uncommitted changes). If you declined the commit (chose N) or it failed,
204
- Local-closeout is **not** satisfied yet — commit the staged closeout yourself
205
- before continuing; do not enter the Integration / PR gate with uncommitted
206
- changes. Once committed, the gate stands on its own offline; integration happens
207
- in Step 5 when you have network.
208
-
209
- **→ Transition (step-internal)**: Step 4 complete. Branch on whether the closeout commit landed:
210
-
211
- - **Closeout commit landed (working tree clean)** → announce "Step 4 complete (feature archived; Local-closeout gate satisfied). Entering Step 5: Integration / PR gate." and continue.
212
- - **Closeout commit was declined (N) or failed** → **stop here.** Announce "Step 4 complete (feature archived), but the Local-closeout gate is not satisfied yet — the closeout is staged but uncommitted. Commit those changes (or address the failure), then resume to Step 5." Do **not** enter Step 5 with uncommitted closeout changes.
203
+ Then, in this order:
204
+
205
+ 1. **Record the checkpoint row first.** Write one row in the moved
206
+ `_index.md` Checkpoint Log — `closeout | committed` for Y, `closeout |
207
+ skipped` for N. The closeout row carries **no commit hash**: the closeout
208
+ commit cannot contain its own hash. Trace it later via
209
+ `git log -1 -- dflow/specs/features/completed/{SPEC-ID}-{slug}` (or the
210
+ optional `Dflow-Checkpoint` trailer). The "hash only after success" rule
211
+ still applies to spec / implementation rows — closeout is the documented
212
+ exception (see `references/git-integration.md` § Commit Checkpoints,
213
+ Branch Gate & AI Commits).
214
+ 2. **Stage the whole archived feature directory:**
215
+
216
+ ```bash
217
+ git add dflow/specs/features/completed/{SPEC-ID}-{slug}
218
+ ```
219
+
220
+ This is required, not optional: `git mv` stages the rename with the
221
+ **last-committed** content, so working-tree edits made earlier in this
222
+ flow to the moved files — the Step 2 status flip and Resume Pointer
223
+ update, plus the checkpoint row you just wrote — stay **unstaged** until
224
+ this `git add`. In `git status`, the moved `_index.md` showing `RM`
225
+ instead of plain `R` is exactly this signal. Then also `git add` the
226
+ files updated in Step 3 (the updated `rules.md`, `behavior.md`,
227
+ `glossary.md`, `tech-debt.md`, etc.) into the same stage.
228
+ 3. **Commit (Y) or stop (N).** For Y the AI commits. If a pre-commit hook
229
+ rejects it or the commit fails, flip the checkpoint row to `failed` (the
230
+ row is not committed yet — edit it directly), surface the error, and
231
+ treat the gate as unsatisfied.
232
+
233
+ **Post-commit closeout verification** — after a successful commit, and before
234
+ declaring the Local-closeout gate satisfied, AI runs and reports `✓` / `✗` for
235
+ every item:
236
+
237
+ - [ ] `git show HEAD:dflow/specs/features/completed/{SPEC-ID}-{slug}/_index.md`
238
+ — one blob read verifying **two** things: frontmatter `status: completed`
239
+ **and** the Checkpoint Log contains the closeout row. This reads the
240
+ **committed** content, not the working tree — the former catches "rename
241
+ carried stale content", the latter catches "row never made it into the
242
+ commit".
243
+ - [ ] `dflow/specs/features/active/{SPEC-ID}-{slug}/` no longer exists (the
244
+ directory was moved, not copied)
245
+ - [ ] `git status --short` shows no leftovers related to this feature
246
+ (working tree clean; identify any unrelated dirty files explicitly)
247
+
248
+ If any item fails, do **not** declare closeout complete — fix it (re-add and
249
+ amend, or a follow-up commit; the developer chooses) and re-verify.
250
+
251
+ The Local-closeout gate is satisfied **only when the closeout is committed and
252
+ the verification above passes**. If you declined the commit (chose N) or it
253
+ failed, Local-closeout is **not** satisfied yet — commit the staged closeout
254
+ yourself before continuing; do not enter the Integration / PR gate with
255
+ uncommitted changes. Once committed and verified, the gate stands on its own
256
+ offline; integration happens in Step 5 when you have network.
257
+
258
+ **→ Transition (step-internal)**: Step 4 complete. Branch on the verification result:
259
+
260
+ - **Closeout commit landed and post-commit verification passed** → announce "Step 4 complete (feature archived; Local-closeout gate satisfied). Entering Step 5: Integration / PR gate." and continue.
261
+ - **Closeout commit was declined (N), failed, or verification reported `✗`** → **stop here.** Announce "Step 4 complete (feature archived), but the Local-closeout gate is not satisfied yet — the closeout is staged but uncommitted, or the committed content failed verification. Commit the staged changes (or fix the failure), then resume to Step 5." Do **not** enter Step 5 with uncommitted or unverified closeout changes.
213
262
 
214
263
  ## Step 5: Emit Integration Summary (Git-strategy-neutral)
215
264
 
@@ -266,10 +315,17 @@ the developer:
266
315
 
267
316
  If no `follow-up-of` field, skip Step 6 and announce closeout complete:
268
317
  > "`/dflow:finish-feature` complete for `{SPEC-ID}-{slug}`. Feature
269
- > directory is now at `dflow/specs/features/completed/{SPEC-ID}-{slug}/`.
270
- > If you skipped the closeout commit, commit the staged changes first to
271
- > finish the Local-closeout gate. Then integration — merge / push / PR —
272
- > follows the selected Git policy, at your discretion."
318
+ > directory is now at `dflow/specs/features/completed/{SPEC-ID}-{slug}/`,
319
+ > with the Local-closeout gate satisfied (closeout committed and verified).
320
+ > Integration — merge / push / PR — follows the selected Git policy, at
321
+ > your discretion."
322
+
323
+ **In-flight reminder** — after the closeout announcement (with or without
324
+ Step 6), run the in-flight overview scan (see `AI-AGENT-GUIDE.md` § Status /
325
+ Control Commands) and list any other unfinished features in `active/` and any
326
+ in-flight feature / bugfix branches. Surfacing them at closeout is deliberate:
327
+ attention is about to move elsewhere, and this is exactly where half-done work
328
+ sinks.
273
329
 
274
330
  ## Step 6: Reverse-Update Follow-up Tracking (only if follow-up)
275
331
 
@@ -37,9 +37,9 @@ main (or your project's base branch)
37
37
  ```
38
38
  feature/{SPEC-ID}-{slug}
39
39
  Examples:
40
- feature/EXP-001-jpy-currency-support
41
- feature/HR-003-leave-approval-workflow
42
- feature/SHARED-002-audit-logging
40
+ feature/SPEC-20260424-001-jpy-currency-support
41
+ feature/SPEC-20260430-001-leave-approval-workflow
42
+ feature/SPEC-20260502-002-audit-logging
43
43
 
44
44
  bugfix/{BUG-ID}-{slug}
45
45
  Examples:
@@ -148,10 +148,30 @@ existing Step Gate prompt (it does not add a separate question):
148
148
  Tier sets how many checkpoints a change has: T1 three (spec / implementation /
149
149
  closeout), T2 two (spec+implementation merged / closeout), T3 a single commit.
150
150
  Whether you choose Y or N, the AI records one row in the feature `_index.md`
151
- Checkpoint Log. A commit hash is written only after the commit succeeds; a hook
152
- rejection or failed commit is recorded as `failed` (never a fake hash). After
153
- several consecutive skips in a project the AI mentions you can turn checkpoints
154
- off in config — it does not turn them off for you.
151
+ Checkpoint Log — every checkpoint is accounted for (`committed` / `skipped` /
152
+ `failed`), even when no commit happens. A commit hash is written only after the
153
+ commit succeeds; a hook rejection or failed commit is recorded as `failed`
154
+ (never a fake hash). **Exception — the closeout row**: the closeout commit
155
+ cannot contain its own hash, so the closeout row is written before the commit
156
+ as `closeout | committed` with **no hash** (see
157
+ `references/finish-feature-flow.md` Step 4); trace that commit via
158
+ `git log -1 -- dflow/specs/features/completed/{SPEC-ID}-{slug}` or the optional
159
+ `Dflow-Checkpoint` trailer below. After several consecutive skips in a project
160
+ the AI mentions you can turn checkpoints off in config — it does not turn them
161
+ off for you.
162
+
163
+ **Optional machine-greppable trailer.** Teams that want cross-flow checkpoint
164
+ accounting can append a commit trailer at checkpoint commits:
165
+
166
+ ```
167
+ Dflow-Checkpoint: {SPEC-ID} {spec|impl|closeout}
168
+ ```
169
+
170
+ The `_index.md` Checkpoint Log **remains the source of truth**; the trailer is
171
+ a cheap derived mirror (`git log --grep 'Dflow-Checkpoint: {SPEC-ID}'`). Use
172
+ role names, not (k/N) counts — the checkpoint total can change mid-feature
173
+ (tier escalation, follow-ups), and a role gap ("impl exists but no closeout for
174
+ this SPEC-ID") is detectable without predicting N, even across flows.
155
175
 
156
176
  ### AI commits
157
177
 
@@ -325,8 +345,8 @@ Tie commits to specs:
325
345
  [SPEC-ID] Short description
326
346
 
327
347
  Examples:
328
- [EXP-001] Add JPY currency support to Money value object
329
- [EXP-001] Extract exchange rate logic to Domain service
348
+ [SPEC-20260424-001] Add JPY currency support to Money value object
349
+ [SPEC-20260424-001] Extract exchange rate logic to Domain service
330
350
  [BUG-042] Fix rounding inconsistency, extract to Money.Round()
331
351
  ```
332
352
 
@@ -7,6 +7,8 @@ Step-by-step guide for when a developer triggers `/dflow:modify-existing` or `/d
7
7
  - Step 4 → Step 5 (extraction decision → start implementation)
8
8
  - Step 5 → Step 6 (implementation done → update artifacts)
9
9
 
10
+ Crossing any step gate above also updates the host feature's `_index.md` Resume Pointer cursor (Active Workflow / Current Step / Gates Passed / Awaiting) once the host feature directory exists — fold it into that gate's existing `_index.md` / Resume Pointer edit, no separate ceremony (see the `_index.md` template's Resume Pointer notes).
11
+
10
12
  All other step transitions are **step-internal**: announce "Step N complete, entering Step N+1" and proceed without waiting. See AI-AGENT-GUIDE.md § Workflow Transparency for the full transparency protocol and confirmation signals.
11
13
 
12
14
  **Ceremony adjustment when triggered by `/dflow:bug-fix`**: treat as lightweight — use the Lightweight Spec Template (see `templates/lightweight-spec.md`) instead of the full spec, and Step 4 (extraction) may default to "defer and record in tech-debt.md" unless the bug itself is in extractable logic. T2 still generates a concise `Implementation Tasks` checklist (see Step 4).
@@ -63,6 +65,16 @@ Walk through these in order:
63
65
  this is a new concern. For T1, use `/dflow:new-feature`. For T2 / T3
64
66
  on a standalone bug, see Step 1.5 — `/dflow:bug-fix` will create a
65
67
  minimal feature directory to host the lightweight-spec.
68
+ 4. **In-flight overlap scan (cross-branch)**: this branch's `active/` is not
69
+ everything in flight. Run the in-flight scan (classification and dedup
70
+ rules in `AI-AGENT-GUIDE.md` § Status / Control Commands) — `git fetch`
71
+ when the network allows, then
72
+ `git branch --all --list '*feature/*' --list '*bugfix/*'` — and also list
73
+ other unfinished features in this branch's `active/` (one cursor line
74
+ each). If a scanned branch classified as in flight elsewhere, closed out
75
+ awaiting integration, or unknown — or an unfinished feature — semantically
76
+ overlaps this change, surface it and wait for the developer to decide
77
+ before creating anything new (stale branches are non-blocking).
66
78
 
67
79
  > **Why scan completed too?** Completed features are frozen history
68
80
  > and **cannot accept** any T2 / T3 directly
@@ -316,6 +328,17 @@ has no separate Aggregates section, do not invent one; update the Repository
316
328
  row if one exists. If the developer defers, **record the emergence observation
317
329
  in `tech-debt.md`** so the boundary decision is not silently lost.
318
330
 
331
+ **Established-model re-read (the emergence check's mirror).** When the rule
332
+ you are extracting lands on an **already-modeled** Aggregate / concept,
333
+ re-read what was recorded when it was shaped (its `models.md` row + Notes
334
+ and the relevant `rules.md` entries) before extending it. If this change
335
+ matches a recorded re-evaluation condition ("revisit when …") or trips a
336
+ model-resistance signal, follow `references/ddd-modeling-guide.md`
337
+ § "Revising an Established Model": record one short passage in the spec's
338
+ design decisions / open questions — proceed as-is, split, or rename, with
339
+ the reason. Deciding to keep the current model, recorded, is a valid
340
+ outcome; extending silently is not.
341
+
319
342
  If the context is **`generic`** (Subdomain Type), emergence is usually a
320
343
  *replacement / adapter-boundary* debt signal, not a cue for deep T1 modeling —
321
344
  record the replacement intent (consistent with the generic extraction fallback
@@ -8,6 +8,8 @@ Step-by-step guide for when a developer triggers `/dflow:new-feature` (or natura
8
8
  - Step 6 → Step 7 (branch ready → start implementation)
9
9
  - Step 7 → Step 8 (implementation done → completion)
10
10
 
11
+ Crossing any step gate above also updates the host feature's `_index.md` Resume Pointer cursor (Active Workflow / Current Step / Gates Passed / Awaiting) once the feature directory exists — fold it into that gate's existing `_index.md` / Resume Pointer edit, no separate ceremony (see the `_index.md` template's Resume Pointer notes).
12
+
11
13
  All other step transitions are **step-internal**: announce "Step N complete, entering Step N+1" and proceed without waiting. See AI-AGENT-GUIDE.md § Workflow Transparency for the full transparency protocol and confirmation signals.
12
14
 
13
15
  **Ceremony**: this flow always defaults to **T1 Heavy** — the first phase of a brand-new feature is by definition a full SDD cycle. Tier judgement (T1 / T2 / T3) only applies to `/dflow:modify-existing` (see `references/modify-existing-flow.md` and AI-AGENT-GUIDE.md § Ceremony Scaling).
@@ -30,6 +32,27 @@ Then check existing assets:
30
32
  - Search `dflow/specs/features/` for related or overlapping features
31
33
  - Check `dflow/specs/domain/glossary.md` for relevant terms
32
34
 
35
+ **In-flight overlap scan (cross-branch + other unfinished features)** — this
36
+ branch's `dflow/specs/` does not show everything in flight. Run the in-flight
37
+ scan (classification and dedup rules in `AI-AGENT-GUIDE.md` § Status / Control
38
+ Commands):
39
+
40
+ ```bash
41
+ git fetch # when the network allows; skip gracefully offline
42
+ git branch --all --list '*feature/*' --list '*bugfix/*'
43
+ ```
44
+
45
+ - List other unfinished features already in this branch's `active/` (one
46
+ cursor line each, from their `_index.md` Resume Pointer).
47
+ - Classify every listed branch by the guide's rules — in flight elsewhere /
48
+ closed out awaiting integration / stale (completed here) / unknown — do
49
+ not shortcut the classification. If a branch classified as **in flight
50
+ elsewhere, closed out awaiting integration, or unknown** has an ID / slug
51
+ that semantically overlaps this request, surface it and wait for the
52
+ developer to decide — continue there / integrate it first / treat as
53
+ related / unrelated — **before creating any new directory, spec, or
54
+ branch**. Only stale (completed here) branches are non-blocking.
55
+
33
56
  Share what you found: "I see we already have [X] documented. This new feature seems to extend
34
57
  that — is that right?"
35
58
 
@@ -90,6 +113,16 @@ classification, set-based / uniqueness rules, value objects, aggregate sizing
90
113
  read `references/ddd-modeling-guide.md` (its **Edition note** maps recording
91
114
  surfaces to brownfield's `models.md` / `rules.md`).
92
115
 
116
+ The mirror case — the concept is **already modeled**: when extending an
117
+ existing Aggregate / modeled concept, re-read what was recorded when it was
118
+ shaped (its `models.md` row + Notes and the relevant `rules.md` entries)
119
+ before extending it. If this change matches a recorded re-evaluation
120
+ condition ("revisit when …") or trips a model-resistance signal, follow
121
+ `references/ddd-modeling-guide.md` § "Revising an Established Model":
122
+ record one short passage in the spec's design decisions / open questions —
123
+ proceed as-is, split, or rename, with the reason. Deciding to keep the
124
+ current model, recorded, is a valid outcome; extending silently is not.
125
+
93
126
  For each new concept:
94
127
  1. Check glossary — add if missing
95
128
  2. Check if it already exists in models.md — extend if needed
@@ -170,7 +203,7 @@ dflow/specs/features/active/{SPEC-ID}-{slug}/
170
203
  - Current BR Snapshot: initialise from the first phase's planned BRs
171
204
  (will be refreshed when the phase-spec finalises)
172
205
  - Lightweight Changes: empty table at start
173
- - Resume Pointer: "phase-1 in progress: drafting phase-spec." / "Next Action: finish phase-spec, then implement."
206
+ - Resume Pointer: "phase-1 in progress: drafting phase-spec." / "Next Action: finish phase-spec, then implement." / cursor fields: Active Workflow `new-feature`, Current Step `Step 4 — write the spec`, Gates Passed `3→3.5`, Awaiting `none (mid-step)`
174
207
  3. **Create the first phase-spec** at `phase-spec-{YYYY-MM-DD}-{slug}.md`
175
208
  using `templates/phase-spec.md`. The "Delta from prior phases" section
176
209
  is filled with "首 phase,無前置 Delta" (first phase has nothing to
@@ -19,6 +19,8 @@ adds a new phase to an in-progress feature only.
19
19
  - Step 5 → Step 6 (`_index.md` refreshed → start implementation)
20
20
  - Step 6 → Step 7 (implementation done → complete the phase)
21
21
 
22
+ Crossing any step gate above also updates the feature's `_index.md` Resume Pointer cursor (Active Workflow / Current Step / Gates Passed / Awaiting) — fold it into that gate's existing `_index.md` / Resume Pointer edit, no separate ceremony (see the `_index.md` template's Resume Pointer notes).
23
+
22
24
  All other step transitions are **step-internal**: announce "Step N complete,
23
25
  entering Step N+1" and proceed without waiting. See AI-AGENT-GUIDE.md § Workflow
24
26
  Transparency for the full transparency protocol and confirmation signals.
@@ -63,6 +65,11 @@ AI must locate the target feature and load its current state:
63
65
  - Read the most recent phase-spec to understand where the prior phase
64
66
  left off (its Business Rules and Delta-from-prior-phases sections in
65
67
  particular)
68
+ - Run the in-flight overlap scan (classification and dedup rules in
69
+ `AI-AGENT-GUIDE.md` § Status / Control Commands): list other unfinished
70
+ features in `active/` and any feature / bugfix branches whose work is
71
+ not visible on this branch — if the incoming phase scope overlaps one
72
+ of them, surface it before writing the phase-spec.
66
73
 
67
74
  4. **Branch gate — ensure you are on this feature's branch (before any commit)**
68
75
 
@@ -99,7 +106,11 @@ Walk the developer through what the new phase covers:
99
106
  Entity row (no separate Aggregates section). For how to model it (invariant
100
107
  classification, set-based / uniqueness rules, aggregate sizing), read
101
108
  `references/ddd-modeling-guide.md` (its **Edition note** maps recording
102
- surfaces to brownfield's `models.md` / `rules.md`).
109
+ surfaces to brownfield's `models.md` / `rules.md`). If the phase **extends
110
+ an already-modeled Aggregate / concept**, apply the established-model
111
+ re-read from `references/ddd-modeling-guide.md` § "Revising an Established
112
+ Model" (match recorded re-evaluation conditions; record proceed / split /
113
+ rename in the phase-spec).
103
114
  4. **Data structure impact?** New tables, columns, indices?
104
115
  5. **Why now?** Priority — informs sequencing relative to other phases.
105
116
 
@@ -118,10 +118,43 @@ input like this (supporting files live in the workflow bundle at
118
118
 
119
119
  ## Status / Control Commands
120
120
 
121
- `/dflow:status` reports active workflow state. Include these fields: workflow,
122
- step, completed, in-progress, remaining, pending decision, and next valid action.
123
- If no workflow is active, say that no workflow is active and list valid flow-entry
124
- or standalone commands.
121
+ `/dflow:status` reports in two parts.
122
+
123
+ **Part 1 — in-flight overview (always shown, workflow active or not).**
124
+ Aggregate every in-flight feature so unfinished work surfaces without anyone
125
+ remembering to look:
126
+
127
+ - Scan this branch's `dflow/specs/features/active/*/_index.md` and print one
128
+ line per feature: SPEC-ID / Active Workflow / Current Step / Awaiting / last
129
+ Checkpoint Log row (read from each Resume Pointer cursor).
130
+ - Cross-branch: run `git fetch` when the network allows (skip gracefully
131
+ offline), then `git branch --all --list '*feature/*' --list '*bugfix/*'`,
132
+ deduplicating local and remote refs of the same branch (prefer local). For
133
+ each branch, classify in order: (1) its feature directory exists in this
134
+ branch's `active/` → already covered above; (2) exists in this branch's
135
+ `completed/` → a stale undeleted branch — list as "completed; branch can be
136
+ deleted", **not** in-flight; (3)
137
+ `git show {branch}:dflow/specs/features/active/{dir}/_index.md` is readable
138
+ → in flight on that branch, print its cursor line (no branch switching);
139
+ (4) the `completed/` path is readable on that branch → closed out there,
140
+ awaiting integration; (5) nothing readable → list the branch as unknown
141
+ state.
142
+ - If `features/backlog/` is non-empty, append one count line.
143
+ - Inherent limit: work never committed anywhere is invisible to any git scan.
144
+
145
+ **Part 2 — current feature detail (when a workflow is active).** Read the
146
+ Resume Pointer cursor as the **declared** state, then cross-check it against
147
+ derived evidence (Checkpoint Log, phase-spec statuses, recent git log). On
148
+ mismatch, report both sides explicitly and ask the developer to correct the
149
+ cursor — the cursor is a claim; evidence wins. If the cursor fields are absent
150
+ (an older `_index.md`), fall back to pure derivation. For readability you may
151
+ expand the cursor into a step checklist (done / in progress / not started)
152
+ derived live from the flow file — display only, never stored.
153
+
154
+ Include these fields: workflow, step, completed, in-progress, remaining,
155
+ pending decision, and next valid action. If no workflow is active, say so and
156
+ list valid flow-entry or standalone commands (Part 1 still shows the
157
+ in-flight overview).
125
158
 
126
159
  `/dflow:next` is valid only at a step gate in an active workflow. Treat it as
127
160
  developer confirmation equivalent to "OK" or "continue", then move to the next
@@ -129,7 +162,9 @@ workflow step.
129
162
 
130
163
  `/dflow:cancel` aborts the current workflow and returns to free conversation.
131
164
  Do not rollback changes, delete artifacts, or rewrite specs merely because the
132
- workflow was cancelled.
165
+ workflow was cancelled. If the feature directory exists, set the Resume
166
+ Pointer cursor's Active Workflow to `none` (keep Current Progress as a trace
167
+ of where the cancellation happened).
133
168
 
134
169
  When no workflow is active, `/dflow:next` and `/dflow:cancel` must report that
135
170
  there is no active workflow to advance or cancel.
@@ -140,7 +140,7 @@ When applicable, prefix with a type (conventional commits-style):
140
140
  | test | tests only |
141
141
  | chore | build / tooling |
142
142
 
143
- Example: `[EXP-001] feat: add JPY currency support to Money VO`
143
+ Example: `[SPEC-20260424-001] feat: add JPY currency support to Money VO`
144
144
 
145
145
  ---
146
146
 
@@ -95,8 +95,8 @@ adopted, the format is:
95
95
  | test | tests only |
96
96
  | chore | build / tooling |
97
97
 
98
- Example: `feat(expense): add JPY currency support` with `[EXP-001]` in
99
- the body.
98
+ Example: `feat(expense): add JPY currency support` with
99
+ `[SPEC-20260424-001]` in the body.
100
100
 
101
101
  ---
102
102
 
@@ -97,23 +97,42 @@ Template note (for AI):
97
97
  > T3 單一 commit。
98
98
  >
99
99
  > commit hash 只在 commit 實際成功後填入;pre-commit hook reject 或 commit
100
- > 失敗記 `failed`、不寫假 hash。
100
+ > 失敗記 `failed`、不寫假 hash。**例外:closeout 列不填 hash**——closeout
101
+ > commit 無法自含自身 hash,該列於 commit 前寫入、隨歸檔目錄一起進 commit;
102
+ > 溯源用 `git log -1 -- completed/{SPEC-ID}-{slug}` 或選配的
103
+ > `Dflow-Checkpoint` trailer(見 references/git-integration.md)。
101
104
 
102
105
  | Timestamp | Checkpoint | Result |
103
106
  |---|---|---|
104
107
  | {YYYY-MM-DD HH:MM} | spec-baseline | committed ({hash}) / skipped / failed |
105
108
  | {YYYY-MM-DD HH:MM} | implementation | committed ({hash}) / skipped / failed |
106
- | {YYYY-MM-DD HH:MM} | closeout | committed ({hash}) / skipped / failed |
109
+ | {YYYY-MM-DD HH:MM} | closeout | committed / skipped / failed |
107
110
 
108
111
  ## Resume Pointer
109
112
 
110
- > 一句話:目前進展到哪?下一個動作是什麼?
111
- > 開新對話接續工作時,從這裡讀起。
113
+ > 目前進展到哪?下一個動作是什麼?開新對話接續工作時,從這裡讀起。
114
+ >
115
+ > 下方四個 cursor 欄位是 workflow 進度的**存放層(宣告,claim)**:
116
+ > 進入 flow 時設 Active Workflow;**每過一個 step gate** 更新 Current Step /
117
+ > Gates Passed / Awaiting(與該 gate 既有的 `_index.md` 更新合併,不另加儀式);
118
+ > closeout / `/dflow:cancel` 時 Active Workflow 設回 `none`。
119
+ > `/dflow:status` 讀 cursor 後會與推導證據(Checkpoint Log、phase-spec
120
+ > status、git log)交叉,不一致會明確報 mismatch——cursor 是宣告、證據優先。
121
+ > Phase 粒度進度由上方 Phase Specs 表承載;cursor 只補 workflow step / gate
122
+ > 粒度,不展開成 per-step 全表(步驟線性,游標可推導每一步的完成/未做)。
112
123
 
113
124
  **Current Progress**: {one-line summary}
114
125
 
115
126
  **Next Action**: {suggested next action}
116
127
 
128
+ **Active Workflow**: {new-feature | modify-existing | bug-fix | new-phase | finish-feature | none}
129
+
130
+ **Current Step**: {Step N — short step name | n/a}
131
+
132
+ **Gates Passed**: {e.g. "3→3.5, 4→5" | n/a}
133
+
134
+ **Awaiting**: {step-gate description | none}
135
+
117
136
  <!--
118
137
  ## Follow-up Tracking
119
138
  >(選用段;只有當本 feature 衍生出 follow-up feature 時才填)
@@ -1,10 +1,10 @@
1
1
  ---
2
- id: BUG-{NUMBER}
2
+ id: BUG-{NUMBER} # bug-type T2 only; a non-bug T2 (lightweight-{date}-{slug}.md) carries no id — the filename identifies it
3
3
  title: {簡述問題}
4
- status: in-progress
4
+ status: in-progress # in-progress | completed
5
5
  bounded-context: {ContextName}
6
6
  created: {YYYY-MM-DD}
7
- branch: bugfix/BUG-{NUMBER}-{short-description}
7
+ branch: bugfix/BUG-{NUMBER}-{slug}
8
8
  ---
9
9
 
10
10
  <!--
@@ -1,11 +1,11 @@
1
1
  ---
2
- id: {CONTEXT}-{NUMBER}
2
+ spec-id: SPEC-{YYYYMMDD}-{NNN} # the owning feature's SPEC-ID (matches the feature directory name)
3
3
  title: Feature title
4
- status: draft | in-progress | completed
4
+ status: in-progress # in-progress | completed
5
5
  bounded-context: {ContextName}
6
6
  created: {YYYY-MM-DD}
7
7
  author: {developer-name}
8
- branch: feature/{CONTEXT}-{NUMBER}-{short-description}
8
+ branch: feature/{SPEC-ID}-{slug}
9
9
  ---
10
10
 
11
11
  # {Feature Title}