@educa-corp/sdd-framework 0.6.0 → 0.7.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 (205) hide show
  1. package/bin/gate-trace.js +25 -2
  2. package/bin/index.js +32 -5
  3. package/bin/lint-trace.js +41 -0
  4. package/bin/self-check.js +430 -3
  5. package/bin/trace-schema.json +391 -30
  6. package/core/FRAMEWORK_VERSION +1 -1
  7. package/{commands/extend-prd.md → core/commands/amend-prd.md} +205 -173
  8. package/core/commands/dev-run-test.md +47 -9
  9. package/core/commands/extend-prd.md +39 -12
  10. package/core/commands/generate-bdd.md +43 -4
  11. package/core/commands/generate-code.md +33 -0
  12. package/core/commands/generate-tech-docs.md +34 -2
  13. package/core/commands/qc-run-test.md +29 -3
  14. package/core/commands/refine-prd.md +13 -2
  15. package/core/commands/review-context.md +43 -8
  16. package/core/commands/sync.md +105 -1
  17. package/core/commands/validate-traces.md +284 -11
  18. package/core/rules/workflow.md +34 -0
  19. package/core/steps/context-loader.md +26 -5
  20. package/core/templates/feature.template +1 -1
  21. package/docs/02-concepts/architecture.md +36 -0
  22. package/docs/04-reference/commands.md +148 -134
  23. package/docs/04-reference/trace-schema.md +39 -0
  24. package/docs/explain/02b-extend-prd.md +1 -1
  25. package/docs/explain/02c-amend-prd.md +152 -0
  26. package/docs/explain/28-sync.md +25 -0
  27. package/docs/explain/README.md +136 -135
  28. package/package.json +1 -8
  29. package/commands/debug.md +0 -529
  30. package/commands/debug.tmpl +0 -260
  31. package/commands/define-product.md +0 -438
  32. package/commands/define-product.tmpl +0 -225
  33. package/commands/dev-gen-test.md +0 -700
  34. package/commands/dev-gen-test.tmpl +0 -490
  35. package/commands/dev-run-test.md +0 -435
  36. package/commands/dev-run-test.tmpl +0 -225
  37. package/commands/dev-smoke-test.md +0 -374
  38. package/commands/dev-smoke-test.tmpl +0 -217
  39. package/commands/extend-prd.tmpl +0 -273
  40. package/commands/fix-bug.md +0 -519
  41. package/commands/fix-bug.tmpl +0 -197
  42. package/commands/generate-architecture.md +0 -354
  43. package/commands/generate-architecture.tmpl +0 -197
  44. package/commands/generate-bdd.md +0 -923
  45. package/commands/generate-bdd.tmpl +0 -590
  46. package/commands/generate-code.md +0 -859
  47. package/commands/generate-code.tmpl +0 -649
  48. package/commands/generate-design-spec.md +0 -737
  49. package/commands/generate-design-spec.tmpl +0 -524
  50. package/commands/generate-prd.md +0 -722
  51. package/commands/generate-prd.tmpl +0 -226
  52. package/commands/generate-spec-manifest.md +0 -321
  53. package/commands/generate-spec-manifest.tmpl +0 -164
  54. package/commands/generate-tech-docs.md +0 -920
  55. package/commands/generate-tech-docs.tmpl +0 -273
  56. package/commands/learn.md +0 -399
  57. package/commands/learn.tmpl +0 -130
  58. package/commands/map-testids.md +0 -238
  59. package/commands/map-testids.tmpl +0 -81
  60. package/commands/propose-scenario.md +0 -359
  61. package/commands/propose-scenario.tmpl +0 -202
  62. package/commands/qc-analyze.md +0 -269
  63. package/commands/qc-analyze.tmpl +0 -112
  64. package/commands/qc-design-test.md +0 -226
  65. package/commands/qc-design-test.tmpl +0 -69
  66. package/commands/qc-plan.md +0 -206
  67. package/commands/qc-plan.tmpl +0 -49
  68. package/commands/qc-report.md +0 -217
  69. package/commands/qc-report.tmpl +0 -60
  70. package/commands/qc-review.md +0 -210
  71. package/commands/qc-review.tmpl +0 -53
  72. package/commands/qc-run-test.md +0 -326
  73. package/commands/qc-run-test.tmpl +0 -116
  74. package/commands/refine-prd.md +0 -653
  75. package/commands/refine-prd.tmpl +0 -281
  76. package/commands/report-bug.md +0 -305
  77. package/commands/report-bug.tmpl +0 -148
  78. package/commands/review-code.md +0 -415
  79. package/commands/review-code.tmpl +0 -146
  80. package/commands/review-context.md +0 -902
  81. package/commands/review-context.tmpl +0 -530
  82. package/commands/review-tech-docs.md +0 -561
  83. package/commands/review-tech-docs.tmpl +0 -404
  84. package/commands/setup-ai-first.md +0 -602
  85. package/commands/setup-ai-first.tmpl +0 -450
  86. package/commands/sync.md +0 -430
  87. package/commands/sync.tmpl +0 -429
  88. package/commands/update-framework.md +0 -203
  89. package/commands/update-framework.tmpl +0 -202
  90. package/commands/validate-traces.md +0 -1077
  91. package/commands/validate-traces.tmpl +0 -920
  92. package/hooks/data-guard.js +0 -232
  93. package/hooks/settings.json +0 -19
  94. package/modules/android-compose/module.yaml +0 -13
  95. package/modules/android-compose/stack-profile.yaml +0 -57
  96. package/modules/angular/architecture-snippets/component-patterns.md +0 -187
  97. package/modules/angular/module.yaml +0 -6
  98. package/modules/angular/stack-profile.yaml +0 -38
  99. package/modules/context-engineering/architecture-snippets/context-design.md +0 -119
  100. package/modules/context-engineering/module.yaml +0 -9
  101. package/modules/context-engineering/stack-profile.yaml +0 -61
  102. package/modules/dotnet/architecture-snippets/clean-arch.md +0 -160
  103. package/modules/dotnet/module.yaml +0 -6
  104. package/modules/dotnet/stack-profile.yaml +0 -50
  105. package/modules/flutter/module.yaml +0 -14
  106. package/modules/flutter/stack-profile.yaml +0 -59
  107. package/modules/golang/architecture-snippets/domain-layout.md +0 -283
  108. package/modules/golang/module.yaml +0 -6
  109. package/modules/golang/stack-profile.yaml +0 -40
  110. package/modules/ios-swiftui/module.yaml +0 -13
  111. package/modules/ios-swiftui/stack-profile.yaml +0 -55
  112. package/modules/java-spring/architecture-snippets/layered-arch.md +0 -201
  113. package/modules/java-spring/module.yaml +0 -15
  114. package/modules/java-spring/stack-profile.yaml +0 -28
  115. package/modules/nextjs/architecture-snippets/app-router-patterns.md +0 -269
  116. package/modules/nextjs/module.yaml +0 -14
  117. package/modules/nextjs/stack-profile.yaml +0 -74
  118. package/modules/nuxt/module.yaml +0 -14
  119. package/modules/nuxt/stack-profile.yaml +0 -58
  120. package/modules/phaser-game/architecture-snippets/phaser-scene-patterns.md +0 -646
  121. package/modules/phaser-game/module.yaml +0 -15
  122. package/modules/phaser-game/stack-profile.yaml +0 -90
  123. package/modules/php-laravel/architecture-snippets/service-repository.md +0 -302
  124. package/modules/php-laravel/module.yaml +0 -15
  125. package/modules/php-laravel/stack-profile.yaml +0 -56
  126. package/modules/qc-playwright/stack-profile.yaml +0 -66
  127. package/modules/react/architecture-snippets/hooks-query-patterns.md +0 -254
  128. package/modules/react/module.yaml +0 -14
  129. package/modules/react/stack-profile.yaml +0 -63
  130. package/modules/react-native/module.yaml +0 -14
  131. package/modules/react-native/stack-profile.yaml +0 -56
  132. package/modules/vue/module.yaml +0 -14
  133. package/modules/vue/stack-profile.yaml +0 -65
  134. package/rules/data-protection.md +0 -80
  135. package/rules/workflow.md +0 -99
  136. package/skills/code/SKILL.md +0 -19
  137. package/skills/code/SKILL.tmpl +0 -19
  138. package/skills/debug/SKILL.md +0 -19
  139. package/skills/debug/SKILL.tmpl +0 -19
  140. package/skills/design-spec/SKILL.md +0 -11
  141. package/skills/design-spec/SKILL.tmpl +0 -11
  142. package/skills/discovery/SKILL.md +0 -14
  143. package/skills/discovery/SKILL.tmpl +0 -14
  144. package/skills/prd/SKILL.md +0 -19
  145. package/skills/prd/SKILL.tmpl +0 -19
  146. package/skills/qc/qa-analyst/DOC_GAPS.template.md +0 -63
  147. package/skills/qc/qa-analyst/acceptance-criteria.md +0 -60
  148. package/skills/qc/qa-analyst/business-rules.md +0 -59
  149. package/skills/qc/qa-analyst/data-flow.md +0 -64
  150. package/skills/qc/qa-analyst/spec-breakdown.md +0 -61
  151. package/skills/qc/qa-designer/e2e/journey.md +0 -41
  152. package/skills/qc/qa-designer/exploratory/charter.md +0 -68
  153. package/skills/qc/qa-designer/exploratory/explore-to-functional.md +0 -43
  154. package/skills/qc/qa-designer/functional/api.md +0 -45
  155. package/skills/qc/qa-designer/functional/gui-feature.md +0 -46
  156. package/skills/qc/qa-designer/functional/gui-screen.md +0 -52
  157. package/skills/qc/qa-designer/integration/api.md +0 -42
  158. package/skills/qc/qa-designer/integration/db.md +0 -39
  159. package/skills/qc/qa-designer/integration/gui.md +0 -40
  160. package/skills/qc/qa-designer/integration/kafka.md +0 -40
  161. package/skills/qc/qa-designer/non-functional.md +0 -40
  162. package/skills/qc/qa-planner/test-plan.md +0 -120
  163. package/skills/qc/qa-reviewer/script/e2e.md +0 -87
  164. package/skills/qc/qa-reviewer/script/exploratory.md +0 -45
  165. package/skills/qc/qa-reviewer/script/functional.md +0 -101
  166. package/skills/qc/qa-reviewer/script/integration.md +0 -91
  167. package/skills/qc/qa-reviewer/script/non-functional.md +0 -126
  168. package/skills/qc/qa-reviewer/test-case/e2e.md +0 -73
  169. package/skills/qc/qa-reviewer/test-case/exploratory.md +0 -43
  170. package/skills/qc/qa-reviewer/test-case/functional.md +0 -76
  171. package/skills/qc/qa-reviewer/test-case/integration.md +0 -69
  172. package/skills/qc/qa-reviewer/test-case/non-functional.md +0 -73
  173. package/skills/qc/qa-runner/e2e.md +0 -49
  174. package/skills/qc/qa-runner/exploratory/session.md +0 -36
  175. package/skills/qc/qa-runner/functional/api.md +0 -35
  176. package/skills/qc/qa-runner/functional/gui-feature.md +0 -51
  177. package/skills/qc/qa-runner/functional/gui-screen.md +0 -55
  178. package/skills/qc/qa-runner/integration.md +0 -47
  179. package/skills/qc/qa-runner/non-functional.md +0 -49
  180. package/skills/qc/qa-runner/report/report.md +0 -37
  181. package/skills/setup-ai-first/SKILL.md +0 -19
  182. package/skills/setup-ai-first/SKILL.tmpl +0 -19
  183. package/skills/spec/SKILL.md +0 -19
  184. package/skills/spec/SKILL.tmpl +0 -19
  185. package/skills/test/SKILL.md +0 -18
  186. package/skills/test/SKILL.tmpl +0 -18
  187. package/steps/business-language.md +0 -56
  188. package/steps/capture-lesson.md +0 -112
  189. package/steps/context-loader.md +0 -406
  190. package/steps/gate.md +0 -151
  191. package/steps/report-footer.md +0 -125
  192. package/steps/review-fanout.md +0 -159
  193. package/steps/spawn-agent.md +0 -129
  194. package/steps/trace-mirror.md +0 -53
  195. package/templates/README.md +0 -70
  196. package/templates/architecture.template.md +0 -394
  197. package/templates/ci/trace-gate.yml +0 -146
  198. package/templates/design-spec.template.md +0 -217
  199. package/templates/feature.template +0 -123
  200. package/templates/hooks/pre-push +0 -61
  201. package/templates/platform-guide.template.md +0 -145
  202. package/templates/prd.template.md +0 -283
  203. package/templates/product-definition.template.md +0 -188
  204. package/templates/project-context.yaml +0 -212
  205. package/templates/tech-design.template.md +0 -490
@@ -1,700 +0,0 @@
1
- # /dev-gen-test — Sinh Dev Self-Check Tests
2
-
3
- > **Scope — dev self-check (smoke), không phải bộ test chính thức.** Các test này để
4
- > dev nhanh chóng kiểm chứng code mình sinh ra so với các BDD scenario. Đây là một
5
- > self-check của dev, **không** phải bộ test authoritative của QC/dev-team (cái đó có
6
- > flow riêng, implement ở nơi khác). Kết quả hiện lên dashboard Living Docs như một tín hiệu
7
- > **dev self-test** để QC thấy dev đã tự chạy check của mình.
8
-
9
- ## Gate
10
- # Gate — Quy trình vào chuẩn cho mọi lệnh
11
-
12
- Mọi lệnh PHẢI chạy gate này trước khi thực thi phần logic riêng của nó.
13
-
14
- ## Bước 0 — Kiểm tra chế độ Sub-Agent
15
-
16
- Trước tiên, kiểm tra xem `$ARGUMENTS` có phải là payload JSON từ một orchestrator hay không:
17
-
18
- 1. Thử parse `$ARGUMENTS` dưới dạng JSON.
19
- 2. Nếu parse thành công **và** chứa `"_agent_mode": true`:
20
- - **Bỏ qua hoàn toàn Bước 1, 2 và 3 của Gate này.**
21
- - Đặt target file = `payload.target_file`
22
- - Đặt loaded context = `payload.context` (KHÔNG chạy context-loader.md)
23
- - Đặt phạm vi UC = `payload.uc_id` (chỉ xử lý UC này)
24
- - Đặt line range = `payload.uc_section` (chỉ đọc đúng section đó của PRD)
25
- - Đặt dimension = `payload.dimension` nếu có (lệnh review per-UC: chỉ review đúng lăng kính này)
26
- - Đi thẳng tới phần logic riêng của lệnh.
27
- 3. Nếu `$ARGUMENTS` không phải JSON hoặc không có `_agent_mode` → tiếp tục sang Bước 1 (chế độ thường).
28
-
29
- ## Bước 0-B — Ghi nhận Model *(KHÔNG chặn)*
30
-
31
- *Bỏ qua nếu `_agent_mode: true` (sub-agent — orchestrator đã ghi nhận rồi).*
32
-
33
- Ghi lại **model mà bạn — agent đang chạy lệnh này — thực sự đang dùng**, rồi mang nó vào
34
- dòng `Model:` của report cuối (xem `report-footer`). Nếu bạn biết mình **không** phải một
35
- model Opus, gắn thêm cảnh báo ngay ở dòng đó.
36
-
37
- **KHÔNG hỏi người dùng. KHÔNG chờ. KHÔNG dừng.**
38
-
39
- > **Vì sao bước này từng là prompt chặn, và vì sao bỏ (GAPS-v3 G41):** bản cũ hiện khối
40
- > `⚙️ MODEL CHECK` rồi chờ `Y/S/N`. Ba vấn đề cùng chỉ một hướng:
41
- > **(1)** nó hỏi người dùng thứ mà **agent đã biết chính xác**;
42
- > **(2)** câu trả lời **không kiểm chứng được** — gõ `Y` xong vẫn đang chạy Haiku thì không
43
- > gì phát hiện;
44
- > **(3)** **cả `Y` lẫn `S` đều đi tiếp** — cách duy nhất để nó dừng là tự nguyện gõ `N`.
45
- > Tức nó **không chặn được ai**, mà tốn một lần chặn ở **mọi** lệnh. Một feature đi hết
46
- > pipeline dùng 20 lệnh; 30/32 lệnh chạy gate. Hai mươi lần bấm cho một tín hiệu tự-khai
47
- > không kiểm chứng được — và chính cái giá đó làm mòn CHECKPOINT ở Bước 3, cổng có giá trị thật.
48
- >
49
- > Khai báo trong report **mạnh hơn** hỏi: đúng nguồn (agent, không phải người), và nằm
50
- > **cạnh kết quả** để cân nhắc, thay vì nằm trước khi có kết quả để bấm cho xong.
51
-
52
- **Vẫn khuyến nghị Opus:** phân tích spec, review kiến trúc và sinh code đòi hỏi suy luận sâu;
53
- model nhỏ hơn dễ bỏ sót edge case và vi phạm kiến trúc. Đổi: `/model` → chọn Opus.
54
-
55
- ## Bước 1 — Xác định Target File
56
-
57
- 0. **Tách cờ trước khi resolve target.** `$ARGUMENTS` có thể lẫn các `--flag` (vd `--phase=integration`, `--comment`, `--fix`). **Loại bỏ mọi token bắt đầu bằng `--`** ra khỏi phần dùng để tìm target — chỉ giữ phần path/UC-ID/ticket. (Các flag đó do phần logic riêng của lệnh parse ở bước sau, KHÔNG phải tên file.)
58
- 1. Nếu `$ARGUMENTS` (đã tách cờ) được cung cấp và trỏ tới một file tồn tại → dùng trực tiếp làm target.
59
- 2. Nếu `$ARGUMENTS` là một **UC-ID / ticket ID / tên rút gọn** (không có path) → phân giải thành file bằng cách glob theo bố cục feature-package. `{prd-slug}` lúc này **chưa biết**, nên dùng wildcard `*` cho segment đó, và `**` đệ quy dưới `bdd/` để phủ hết các thư mục con theo platform (`bdd/web/`, `bdd/app/`, `bdd/system/`):
60
- - **Lệnh BDD** (target là `.feature`): `{specs_dir}/{domain}/*/bdd/**/{UC-ID}*.feature` — hoặc `{specs_dir}/*/*/bdd/**/{UC-ID}*.feature` nếu domain cũng chưa biết. Nếu lệnh ngụ ý một platform/scope cụ thể (vd: system tech-doc cần BDD `system/`), ưu tiên kết quả trong thư mục con platform đó.
61
- - **Lệnh PRD** (target là file PRD `{TICKET-ID}-{prd-slug}.md` — file `.md` duy nhất ở gốc feature folder, cạnh `bdd/`): `{specs_dir}/{domain}/*/{TICKET-ID}*.md` nếu biết TICKET-ID; nếu không, `{specs_dir}/{domain}/*/*.md` (khớp feature folder có id tương ứng), hoặc `{specs_dir}/*/*/*.md` nếu domain cũng chưa biết. *(Glob `*/*.md` ở cấp gốc folder chỉ khớp PRD — tech-docs/design-spec `.md` nằm sâu hơn trong thư mục con.)*
62
- - **Lệnh tech-docs** — target là tech-doc **gộp cấp PRD** `{TICKET-ID}-tech-design.md` (MỘT doc phủ nhiều UC; danh sách UC nằm ở `@trace.ucs`). Vì tên file mang `{TICKET-ID}` chứ **không** mang `{UC-ID}`, phải tách trước khi glob:
63
- - `$ARGUMENTS` là **UC-ID** (`{TICKET-ID}-UC{N}`) → lấy `{TICKET-ID}` = phần **trước** `-UC`, rồi glob `{specs_dir}/{domain}/*/tech-docs/{TICKET-ID}-tech-design.md`.
64
- - `$ARGUMENTS` là **TICKET-ID** → glob trực tiếp như trên.
65
- - Chưa biết domain → `{specs_dir}/*/*/tech-docs/{TICKET-ID}-tech-design.md`.
66
- - Vẫn không khớp → glob rộng `{specs_dir}/*/*/tech-docs/*tech-design*.md` rồi liệt kê để người dùng chọn.
67
- *(Đừng glob `{UC-ID}*-tech-design*.md` — nó nở thành `FT-001-UC1*-tech-design*.md` và **không bao giờ** khớp `FT-001-tech-design.md`.)*
68
- - **Lệnh design-spec**: `{specs_dir}/{domain}/*/design-spec/{TICKET-ID}*.md`.
69
-
70
- Khi một file khớp: đặt nó làm target **và** ghi lại `domain` + `prd_slug` từ path của nó (theo quy tắc trích xuất trong `context-loader.md` Bước 1 — `prd_slug` = segment đầu tiên sau `{specs_dir}/{domain}/`). Mọi path mà lệnh đọc/ghi về sau (BDD/tech-docs/design-spec/trace cùng cấp) đều dùng **`prd_slug` đã phân giải đó**, nên tất cả artifact nằm chung một feature package. Nếu nhiều file khớp (vd: nhiều platform), chọn theo platform/scope của lệnh hoặc liệt kê ra và hỏi.
71
- 3. Nếu `$ARGUMENTS` rỗng hoặc không tìm thấy file khớp:
72
- - Liệt kê các file trong thư mục liên quan của lệnh này (vd: `specs/*/*/*.md` — file PRD ở gốc mỗi feature folder — cho lệnh PRD, `specs/*/*/bdd/**/*.feature` cho lệnh BDD).
73
- - Hiển thị danh sách cho người dùng và hỏi: "Bạn muốn làm việc với file nào? (Nhập số thứ tự hoặc tên file)"
74
- - Chờ người dùng chọn rồi mới tiếp tục.
75
-
76
- ## Bước 2 — Chạy Context Loader
77
-
78
- Nạp toàn bộ context của dự án bằng cách làm theo quy trình trong `steps/context-loader.md`.
79
- Lưu toàn bộ context đã nạp vào bộ nhớ để dùng xuyên suốt phiên làm việc của lệnh.
80
-
81
- ## Bước 3 — CHECKPOINT
82
-
83
- *Bỏ qua nếu `_agent_mode: true`.*
84
-
85
- ### 3a — Lệnh này có phải chặn không?
86
-
87
- | Mức | Lệnh nào | `--yes` bỏ qua được? |
88
- |---|---|:---:|
89
- | **Không chặn** | Lệnh read-only: `/review-code` · `/validate-traces` · `/debug` · `/review-context` · `/review-tech-docs` | — (vốn không có) |
90
- | **Chặn thường** | Mọi lệnh sinh/sửa artifact | ✅ |
91
- | **Chặn CỨNG** | Ghi đè file đã tồn tại · `--resume` áp findings · migrate · prune | ❌ **không bao giờ** |
92
-
93
- `--yes` trong `$ARGUMENTS` → bỏ qua CHECKPOINT mức *chặn thường*. (Bước 1 đã tách mọi token
94
- `--` khỏi phần resolve target, nên cờ này không ảnh hưởng việc tìm file.) Mở đường chạy
95
- headless: `claude -p "/generate-code UC1 --yes"`.
96
-
97
- > **KHÔNG tự suy mức từ bảng này.** Mỗi lệnh **tự khai** mức của nó ở một dòng `*Checkpoint: …*`
98
- > ngay dưới `## Gate` của chính nó — đọc dòng đó, đừng suy diễn. Bảng trên chỉ giải thích ba mức
99
- > **nghĩa là gì**.
100
- > Nguồn máy đọc: `bin/trace-schema.json` → `gate.checkpoint_levels`; `self-check` **R11** fail
101
- > build nếu nhãn trong file lệnh lệch với schema, hoặc nếu một lệnh `hard`/`none` thiếu nhãn.
102
- > *(Lệnh không có dòng nào = mức **chặn thường**, mặc định.)*
103
-
104
- > **Mức *không chặn* là thực thi đúng miễn trừ mà `rules/workflow.md` đã cấp từ trước** —
105
- > trước G41 file đó viết *"read-only commands may skip CHECKPOINT"* còn gate thì luôn đòi.
106
- > Hai file cùng được nạp vào mọi lệnh mà nói ngược nhau; agent theo cái nào là tuỳ lúc.
107
-
108
- ### 3b — In gì
109
-
110
- **KHÔNG lặp lại những gì `[CTX LOADED]` vừa in.** Recap của context-loader (Bước 7) đã hiện
111
- Stack · Platform · Layers · CLAUDE.md · Dict · Entities · Lessons · Service · Status ngay phía
112
- trên. CHECKPOINT chỉ thêm **một** thông tin mới là `Target`.
113
-
114
- **Mọi thứ sạch** — recap báo `Status: FULL`, không cờ nào bật → in đúng hai dòng:
115
-
116
- ```
117
- CHECKPOINT — Target: {resolved file path}
118
- Tiếp tục? (Y/N)
119
- ```
120
-
121
- **Có bất thường** → thêm một dòng cho **mỗi** trạng thái, nặng nhất lên đầu:
122
-
123
- ```
124
- CHECKPOINT
125
- 🔴 Service : unresolved — {lý do context-loader đã ghi}
126
- ⚠️ CLAUDE.md: service overlay THIẾU — dùng root (code sinh ra có thể sai stack)
127
- ⚠️ Target : resolve bằng wildcard — {n} file khớp, chọn {file}
128
- ⚠️ Module : not configured — code sinh ra sẽ dùng default
129
- Status : PARTIAL — thiếu: {danh sách}
130
- Target : {resolved file path}
131
- Tiếp tục? (Y/N)
132
- ```
133
-
134
- ### 3c — Cờ nào bật, cờ nào KHÔNG
135
-
136
- Mỗi dòng ⚠️/🔴 phải ứng với một trạng thái **context-loader đã tính rồi** — không phát minh
137
- điều kiện mới, chỉ mang thứ đang bị giấu lên chỗ người dùng phải quyết định:
138
-
139
- | Bật cờ khi | Nguồn | Mức |
140
- |---|---|:---:|
141
- | `active_service = unresolved` | context-loader Bước 2b/2c/Fallback | 🔴 |
142
- | `Status = MINIMAL` | recap Bước 7 | 🔴 |
143
- | `Status = PARTIAL` | recap Bước 7 | ⚠️ |
144
- | CLAUDE.md thiếu, hoặc service overlay thiếu | context-loader Bước 3 | ⚠️ |
145
- | Target resolve qua wildcard, hoặc nhiều file khớp mà lệnh tự chọn | Bước 1 ở trên | ⚠️ |
146
- | `module` không cấu hình | recap Bước 7 | ⚠️ |
147
-
148
- **KHÔNG bật cờ cho:** `Lessons: chưa có` · `Dict: missing` · `Entities: missing`. Đó là
149
- *"dự án chưa điền"*, không phải *"có gì đó sai"* — chúng ở lại trong recap.
150
-
151
- > **Nguyên tắc một câu:** cờ dành cho thứ **framework không chắc chắn hoặc đã phải đoán**,
152
- > không dành cho thứ **người dùng chưa làm**. Đẩy hết mọi thứ lên thì CHECKPOINT lại đầy như
153
- > cũ, và ta quay về đúng chỗ xuất phát: một cổng luôn giống nhau thì bị lướt qua.
154
-
155
- ### 3d — Chờ trả lời
156
-
157
- - "Y" → tiếp tục sang các bước riêng của lệnh.
158
- - "N" → dừng, hỏi người dùng muốn thay đổi gì.
159
- - Có `--yes` và mức *chặn thường* → coi như "Y", **nhưng vẫn IN khối CHECKPOINT** nếu có cờ
160
- 🔴/⚠️ (không chặn ≠ không báo — người đọc log sau này vẫn cần thấy).
161
-
162
-
163
- *Lưu ý: Với lệnh này, target ở Bước 1 là một UC-ID hoặc path file `.feature`. Tìm file feature tại `{paths.specs_dir}/{domain}/*/bdd/**/{UC-ID}-*.feature` (glob khớp xuyên các PRD — filename gồm hậu tố slug) và các file implementation gắn tag `@trace.implements={UC-ID}`.*
164
-
165
- ## Context
166
- **BẮT BUỘC — đọc `.agent/steps/context-loader.md` và thực thi TOÀN BỘ quy trình trong đó**,
167
- rồi mới tiếp tục phần bên dưới.
168
-
169
- Bỏ qua bước này thì `{paths.*}`, `{tech_stack.*}`, `{conventions.*}`, guardrail từ
170
- `project-lessons`, và routing service (chế độ umbrella) đều **chưa được phân giải** — mọi
171
- placeholder bên dưới sẽ rỗng và lệnh sẽ đọc/ghi sai chỗ.
172
-
173
- ---
174
-
175
- ## Service Detection
176
-
177
- Đọc `@trace.service` và `@trace.module` từ header file feature.
178
-
179
- | Điều kiện | Hành động |
180
- |---|---|
181
- | `@trace.module` có mặt | Dùng làm `active_module` |
182
- | `@trace.module` vắng | Dùng `tech_stack.module` từ project-context.yaml |
183
- | `@trace.service` có mặt | Lưu làm `active_service` |
184
- | `@trace.service` vắng | Dùng domain của `{UC-ID}` làm fallback |
185
-
186
- **Phân loại platform type:**
187
-
188
- | Platform | Modules |
189
- |---|---|
190
- | `backend` | `java-spring`, `golang`, `dotnet`, `php-laravel`, `context-engineering` |
191
- | `web-frontend` | `react`, `nextjs`, `vue`, `nuxt`, `angular` |
192
- | `mobile` | `flutter`, `react-native`, `ios-swiftui`, `android-compose` |
193
-
194
- ---
195
-
196
- ## CHECKPOINT — Test Plan
197
-
198
- Trước khi sinh, quét file feature tìm scenario và các file implementation tìm class/function. Hiện:
199
-
200
- ```
201
- Test Plan — {UC-ID} ({active_module})
202
- ──────────────────────────────────────
203
- Platform : {backend | web-frontend | mobile}
204
- Scenarios : {N} scenario từ file .feature
205
- Impl files : {danh sách file gắn tag @trace.implements={UC-ID}}
206
-
207
- Test cần sinh:
208
- {danh sách riêng theo platform — xem template bên dưới}
209
-
210
- Proceed? (Y/N)
211
- ```
212
-
213
- Chờ "Y" rõ ràng trước khi sinh.
214
-
215
- ---
216
-
217
- ## Generate
218
-
219
- ### Nếu `platform_type = backend`
220
-
221
- #### java-spring
222
-
223
- ```java
224
- // @trace.verifies={UC-ID}
225
- // @trace.service={active_service}
226
- // @trace.test_type=unit
227
- class {Resource}ServiceImplTest {
228
- @Mock {Repository} {repository};
229
- @InjectMocks {Resource}ServiceImpl service;
230
-
231
- // methodName_whenValid_shouldReturnExpected()
232
- // Given — mock repository returns data
233
- // When — call service method
234
- // Then — assert result matches expected
235
-
236
- // methodName_whenNotFound_shouldThrowException()
237
- // Given — mock returns Optional.empty()
238
- // When & Then — assertThrows({NotFoundException}.class, ...)
239
- }
240
-
241
- // @trace.verifies={UC-ID}
242
- // @trace.service={active_service}
243
- // @trace.test_type=integration
244
- @WebMvcTest({Resource}Controller.class)
245
- class {Resource}ControllerTest {
246
- @MockBean {Facade | Service} facade;
247
-
248
- // endpoint_shouldReturn200WhenValid()
249
- // endpoint_shouldReturn400WhenInvalid()
250
- // endpoint_shouldReturn404WhenNotFound()
251
- // endpoint_shouldReturn401WhenUnauthenticated()
252
- }
253
- ```
254
-
255
- Rules:
256
- - Unit test: mock ở layer Repository, test logic Service
257
- - Integration test: mock ở layer Facade/Service, chỉ test HTTP contract
258
- - Không bao giờ mock class đang được test
259
- - Theo naming: `methodName_whenCondition_shouldOutcome` (từ CLAUDE.md §6)
260
-
261
- #### golang
262
-
263
- ```go
264
- // @trace.verifies={UC-ID}
265
- // Unit: table-driven tests for service layer
266
- func Test{Resource}Service_{Method}(t *testing.T) {
267
- tests := []struct {
268
- name string
269
- input {InputType}
270
- want {OutputType}
271
- wantErr bool
272
- }{
273
- {"valid input", ..., ..., false},
274
- {"not found", ..., nil, true},
275
- }
276
- for _, tt := range tests {
277
- t.Run(tt.name, func(t *testing.T) { ... })
278
- }
279
- }
280
-
281
- // @trace.verifies={UC-ID}
282
- // Integration: HTTP handler tests using httptest
283
- func Test{Resource}Handler_{Endpoint}(t *testing.T) {
284
- // setup router, mock service, fire request
285
- // assert status code and response body
286
- }
287
- ```
288
-
289
- #### dotnet
290
-
291
- ```csharp
292
- // @trace.verifies={UC-ID}
293
- // Unit: xUnit + Moq
294
- public class {Resource}ServiceTests {
295
- private readonly Mock<I{Repository}> _repoMock = new();
296
- private readonly {Resource}Service _sut;
297
-
298
- [Fact]
299
- public async Task {Method}_WhenValid_Returns{Expected}() { }
300
-
301
- [Fact]
302
- public async Task {Method}_WhenNotFound_ThrowsNotFoundException() { }
303
- }
304
-
305
- // @trace.verifies={UC-ID}
306
- // Integration: WebApplicationFactory
307
- public class {Resource}ControllerTests : IClassFixture<WebApplicationFactory<Program>> {
308
- [Fact]
309
- public async Task {Endpoint}_Returns200_WhenValid() { }
310
-
311
- [Fact]
312
- public async Task {Endpoint}_Returns400_WhenInvalid() { }
313
- }
314
- ```
315
-
316
- #### php-laravel
317
-
318
- ```php
319
- // @trace.verifies={UC-ID}
320
- // Unit: PHPUnit
321
- class {Resource}ServiceTest extends TestCase {
322
- public function test_{method}_when_valid_should_return_expected(): void { }
323
- public function test_{method}_when_not_found_should_throw(): void { }
324
- }
325
-
326
- // @trace.verifies={UC-ID}
327
- // Feature: Laravel HTTP tests
328
- class {Resource}ControllerTest extends TestCase {
329
- use RefreshDatabase;
330
- public function test_{endpoint}_returns_200_when_valid(): void {
331
- $response = $this->getJson('/api/{resource}');
332
- $response->assertStatus(200)->assertJsonStructure([...]);
333
- }
334
- }
335
- ```
336
-
337
- #### context-engineering
338
-
339
- Kiểm tra `tech_stack.language` từ project-context.yaml để chọn đúng cú pháp test:
340
-
341
- **Nếu language = Python** (mặc định):
342
-
343
- ```python
344
- # @trace.verifies={UC-ID}
345
- # @trace.test_type=unit
346
- # Unit: test prompt orchestration functions
347
-
348
- import pytest
349
- from unittest.mock import patch, MagicMock
350
-
351
- class Test{Resource}Prompt:
352
- # test_{function}_when_valid_input_should_return_expected_output()
353
- # Given — mock LLM client returns controlled response
354
- # When — call prompt function with valid input
355
- # Then — assert output matches expected structure/content
356
-
357
- # test_{function}_when_llm_unavailable_should_raise()
358
- # Given — mock LLM client raises connection error
359
- # When & Then — assert specific exception is raised
360
-
361
- # test_{function}_trace_assertions()
362
- # Given — run function with trace capture enabled
363
- # Then — assert @trace.implements tag present in function definition
364
- # assert output conforms to expected schema
365
-
366
- def test_{function}_when_valid_should_return_expected(self, mock_llm):
367
- # Arrange
368
- mock_llm.complete.return_value = "{expected response}"
369
- # Act
370
- result = {function}(input={test_input})
371
- # Assert
372
- assert result == {expected_output}
373
- mock_llm.complete.assert_called_once_with(...)
374
-
375
- def test_{function}_when_invalid_input_should_raise(self):
376
- with pytest.raises({ExpectedError}):
377
- {function}(input=None)
378
- ```
379
-
380
- **Nếu language = TypeScript / JavaScript** (Node.js LangChain.js, v.v.):
381
-
382
- ```typescript
383
- // @trace.verifies={UC-ID}
384
- // @trace.test_type=unit
385
- import { jest } from '@jest/globals'
386
-
387
- describe('{Resource}Prompt', () => {
388
- const mockLlm = { complete: jest.fn() }
389
-
390
- it('{scenario description}', async () => {
391
- mockLlm.complete.mockResolvedValue('{expected response}')
392
- const result = await {function}({ input: '{test_input}', llm: mockLlm })
393
- expect(result).toEqual({expected_output})
394
- expect(mockLlm.complete).toHaveBeenCalledWith(expect.objectContaining({ ... }))
395
- })
396
-
397
- it('throws when input is invalid', async () => {
398
- await expect({function}({ input: null, llm: mockLlm })).rejects.toThrow('{ExpectedError}')
399
- })
400
- })
401
- ```
402
-
403
- **Nếu language = Java** (LangChain4j, v.v.): dùng JUnit 5 + Mockito, cùng pattern như unit test java-spring ở trên — mock interface `ChatLanguageModel`.
404
-
405
- Rules:
406
- - Mock LLM client ở boundary — không bao giờ gọi LLM thật trong unit test
407
- - Validate input schema và output schema riêng biệt
408
- - Mỗi scenario trong `.feature` map sang một test function
409
- - Dùng parameterized test cho nhiều biến thể input
410
-
411
- ---
412
-
413
- ### Nếu `platform_type = web-frontend`
414
-
415
- #### react / nextjs / vue / nuxt / angular
416
-
417
- ```typescript
418
- // @trace.verifies={UC-ID}
419
- // @trace.service={active_service}
420
- // @trace.test_type=component
421
-
422
- // Component tests (Vitest + Testing Library)
423
- describe('{ComponentName}', () => {
424
- it('renders correctly when data is loaded', () => {
425
- render(<{ComponentName} {...props} />)
426
- expect(screen.getByText('...')).toBeInTheDocument()
427
- })
428
-
429
- it('shows loading state while fetching', () => { })
430
-
431
- it('shows error message on API failure', () => { })
432
-
433
- it('calls handler when user interacts', async () => {
434
- await userEvent.click(screen.getByRole('button', { name: '...' }))
435
- expect(mockHandler).toHaveBeenCalledWith(...)
436
- })
437
- })
438
-
439
- // @trace.verifies={UC-ID}
440
- // @trace.test_type=e2e
441
-
442
- // E2E tests (Playwright or Cypress — use whichever is in project)
443
- test('{scenario from .feature}', async ({ page }) => {
444
- await page.goto('/{route}')
445
- await page.getByRole('button', { name: '...' }).click()
446
- await expect(page.getByText('...')).toBeVisible()
447
- })
448
- ```
449
-
450
- Rules:
451
- - Một file component test cho mỗi component liên quan tới UC
452
- - Một file E2E test cho mỗi UC, phủ happy path + các error scenario chính
453
- - Mock API call ở network layer (MSW hoặc cy.intercept), không phải ở component props
454
- - Dùng accessible query (`getByRole`, `getByLabelText`) — tránh `getByTestId` trừ khi cần
455
- - Mỗi test map đúng một scenario trong file `.feature`
456
-
457
- ---
458
-
459
- ### Nếu `platform_type = mobile`
460
-
461
- #### flutter
462
-
463
- ```dart
464
- // @trace.verifies={UC-ID}
465
- // @trace.service={active_service}
466
- // @trace.test_type=widget
467
-
468
- // Widget tests
469
- group('{FeatureName} widget tests', () {
470
- testWidgets('renders correctly when state is loaded', (tester) async {
471
- await tester.pumpWidget(MaterialApp(home: {Widget}()));
472
- await tester.pumpAndSettle();
473
- expect(find.text('...'), findsOneWidget);
474
- });
475
-
476
- testWidgets('shows loading indicator while fetching', (tester) async { });
477
- testWidgets('shows error widget on failure', (tester) async { });
478
- testWidgets('calls handler on tap', (tester) async {
479
- await tester.tap(find.byType(ElevatedButton));
480
- await tester.pumpAndSettle();
481
- verify(() => mockBloc.add({Event}())).called(1);
482
- });
483
- });
484
-
485
- // @trace.verifies={UC-ID}
486
- // @trace.test_type=integration
487
- // Integration test (flutter_test / integration_test package)
488
- void main() {
489
- IntegrationTestWidgetsFlutterBinding.ensureInitialized();
490
- testWidgets('{scenario from .feature}', (tester) async {
491
- app.main();
492
- await tester.pumpAndSettle();
493
- // Navigate, interact, assert
494
- });
495
- }
496
- ```
497
-
498
- #### react-native
499
-
500
- ```typescript
501
- // @trace.verifies={UC-ID}
502
- // @trace.service={active_service}
503
- // @trace.test_type=component
504
-
505
- // Jest + React Native Testing Library
506
- describe('{ComponentName}', () => {
507
- it('{scenario description}', () => {
508
- const { getByText, getByRole } = render(<{ComponentName} {...props} />)
509
- expect(getByText('...')).toBeTruthy()
510
- })
511
-
512
- it('calls navigation on button press', () => {
513
- const mockNavigate = jest.fn()
514
- const { getByRole } = render(<{ComponentName} navigation={{ navigate: mockNavigate }} />)
515
- fireEvent.press(getByRole('button'))
516
- expect(mockNavigate).toHaveBeenCalledWith('...')
517
- })
518
- })
519
- ```
520
-
521
- #### ios-swiftui
522
-
523
- ```swift
524
- // @trace.verifies={UC-ID}
525
- // @trace.service={active_service}
526
- // @trace.test_type=unit
527
-
528
- // XCTest — ViewModel unit tests
529
- @MainActor
530
- final class {Feature}ViewModelTests: XCTestCase {
531
- var sut: {Feature}ViewModel!
532
- var mockRepo: Mock{Repository}!
533
-
534
- override func setUp() async throws {
535
- mockRepo = Mock{Repository}()
536
- sut = {Feature}ViewModel(repository: mockRepo)
537
- }
538
-
539
- func test_{method}_whenValid_shouldUpdate{State}() async throws {
540
- // Given
541
- mockRepo.stub{Method}Result = {expected}
542
- // When
543
- await sut.{method}()
544
- // Then
545
- XCTAssertEqual(sut.{state}, {expected})
546
- }
547
-
548
- func test_{method}_whenError_shouldSetErrorState() async throws { }
549
- }
550
- ```
551
-
552
- #### android-compose
553
-
554
- ```kotlin
555
- // @trace.verifies={UC-ID}
556
- // @trace.service={active_service}
557
- // @trace.test_type=unit
558
-
559
- // Unit test — ViewModel
560
- class {Feature}ViewModelTest {
561
- @get:Rule val mainDispatcherRule = MainDispatcherRule()
562
- private val mockRepo: {Repository} = mockk()
563
- private lateinit var sut: {Feature}ViewModel
564
-
565
- @Before fun setup() { sut = {Feature}ViewModel(mockRepo) }
566
-
567
- @Test fun `{method} when valid should emit success state`() = runTest {
568
- coEvery { mockRepo.{method}(any()) } returns Result.success({data})
569
- sut.{method}({input})
570
- assertEquals(UiState.Success({data}), sut.uiState.value)
571
- }
572
- }
573
-
574
- // @trace.verifies={UC-ID}
575
- // @trace.test_type=ui
576
-
577
- // UI test — Compose
578
- @HiltAndroidTest
579
- class {Feature}ScreenTest {
580
- @get:Rule(order = 0) val hiltRule = HiltAndroidRule(this)
581
- @get:Rule(order = 1) val composeRule = createAndroidComposeRule<MainActivity>()
582
-
583
- @Test fun {scenario}_displaysExpectedUi() {
584
- composeRule.onNodeWithText("...").assertIsDisplayed()
585
- composeRule.onNodeWithContentDescription("...").performClick()
586
- composeRule.onNodeWithText("...").assertIsDisplayed()
587
- }
588
- }
589
- ```
590
-
591
- ---
592
-
593
- ## Checklist
594
-
595
- **Mọi platform:**
596
- - [ ] `@trace.verifies` trên mỗi test class / test group
597
- - [ ] `@trace.service` trên mỗi test class / test group
598
- - [ ] Mỗi scenario trong file `.feature` có ≥ 1 test tương ứng
599
- - [ ] Phủ happy path
600
- - [ ] Phủ các scenario error / edge case chính
601
-
602
- **Chỉ backend:**
603
- - [ ] Mock đúng layer (Repository trong unit test, Facade/Service trong controller test)
604
- - [ ] Không gọi DB thật trong unit test
605
- - [ ] Test naming theo `methodName_whenCondition_shouldOutcome` (CLAUDE.md §6)
606
-
607
- **Chỉ Frontend / Mobile:**
608
- - [ ] Không hardcode delay (`sleep`, `setTimeout`) trong test — dùng `waitFor` / `pumpAndSettle`
609
- - [ ] Dùng accessible query (role, label) không phải selector phụ thuộc implementation
610
- - [ ] Mock API call ở network layer, không phải ở component level
611
-
612
- ---
613
-
614
- ## Write Trace State
615
-
616
- Sau khi sinh tất cả file test, cập nhật **sổ của platform đang test** `{paths.trace_dir}/{domain}/{prd-slug}/{UC-ID}-{platform}.tsv` (`{platform}` = platform của code/`.feature` đang test) — với mỗi scenario, tìm row có sẵn theo `sc_id` và cập nhật:
617
-
618
- | Cột | Giá trị |
619
- |--------|-------|
620
- | `test_count` | số test method phủ SC này |
621
- | `test_classes` | tên test class / describe-block, ngăn cách bởi dấu phẩy |
622
- | `dev_selftest` | `not_run` (test giờ đã tồn tại nhưng chưa chạy — `/dev-run-test` set pass/fail) |
623
- | `last_updated` | hôm nay `YYYY-MM-DD` |
624
-
625
- Giữ nguyên mọi cột khác (gồm `dev_selftest_at`, do `/dev-run-test` sở hữu, và `qc_status`/`qc_run_at`, do `/qc-run-test` sở hữu).
626
-
627
- ---
628
-
629
- ## Refresh Panel Mirror
630
- # Làm mới panel mirror của Living Docs *(local)*
631
-
632
- > **Hai vị trí, HAI TÊN KHÁC NHAU — đọc trước khi sửa gì ở đây.**
633
- >
634
- > | Đường dẫn | Vai trò | Git |
635
- > |---|---|---|
636
- > | `{paths.trace_dir}` (`.trace/` hoặc `{spec_source}/.trace/`) | **AUTHORITATIVE** — TSV + `trace-history.jsonl`. Không regenerate được. | **PHẢI commit** |
637
- > | `./.trace-mirror/` ở gốc workspace hiện tại | **MIRROR** — bản sao tiện cho panel VS Code. Sinh lại được bất cứ lúc nào. | **Luôn gitignore** |
638
- >
639
- > Trước v0.4.3 cả hai đều tên `.trace`, nên một luật gitignore theo tên có thể **xoá sạch sổ gốc**
640
- > khi dev mở thẳng spec repo làm workspace (lúc đó hai path bằng nhau). Hai tên khác nhau làm
641
- > luật git đọc được bằng mắt và **không còn ca nhập nhằng nào**: `.trace-mirror/` không bao giờ
642
- > commit, `.trace/` không bao giờ gitignore.
643
-
644
- ## Khi nào CÓ mirror
645
-
646
- Mirror chỉ tồn tại khi **`{paths.trace_dir}` nằm NGOÀI workspace hiện tại** — panel đọc từ workspace đang mở nên cần một bản sao ở đây.
647
-
648
- | Tình huống | `{paths.trace_dir}` | Có mirror? |
649
- |---|---|---|
650
- | Single-service | `./.trace` — **trong** workspace | ❌ Không. Panel đọc thẳng `.trace/trace-report.json`. Bỏ qua cả file này. |
651
- | Dev mở thẳng **spec repo** | `./.trace` — **trong** workspace | ❌ Không. Như trên. |
652
- | Umbrella + `spec_source`, dev đứng ở umbrella hoặc service submodule | `{spec_source}/.trace` — **ngoài** workspace | ✅ Có |
653
- | Umbrella legacy (không `spec_source`) | `.trace` theo từng service | ✅ Có |
654
-
655
- Quy tắc một dòng: **phân giải `panel_mirror = ./.trace-mirror` ở gốc workspace hiện tại; nếu `{paths.trace_dir}` đã nằm trong workspace này thì bỏ qua toàn bộ bước mirror.**
656
-
657
- ---
658
-
659
- Sau khi cập nhật TSV authoritative tại `{paths.trace_dir}`:
660
-
661
- **Khi `setup.spec_source` được đặt (trace gộp — trường hợp phổ biến):**
662
- `{paths.trace_dir}` phân giải về `{spec_source}/.trace` — vị trí authoritative duy nhất.
663
- Lệnh này chạy từ `service_root`, nên thao tác ghi là **liên-repo vào spec submodule**;
664
- commit/push spec submodule cho lần cập nhật trace (giống như `feedback/`).
665
-
666
- 1. Phân giải `panel_mirror = ./.trace-mirror` tại **gốc workspace hiện tại**.
667
- 2. Nếu `{paths.trace_dir}` **không** nằm trong workspace hiện tại, copy mỗi
668
- `{UC-ID}-{platform}.tsv` vừa cập nhật → `{panel_mirror}/{UC-ID}-{platform}.tsv` (tạo thư mục; ghi đè).
669
- Không namespace theo service — chỉ có một bộ trace; service sở hữu được mang ở
670
- **cột `service` (cột 23)** của chính từng row, do `/generate-bdd` ghi từ `@trace.service`.
671
- 3. **KHÔNG copy `trace-history.jsonl`.** Nó là dữ liệu tích luỹ, không phải thứ sinh lại được —
672
- nhân bản nó ra một thư mục gitignore là tạo hai lịch sử lệch nhau rồi mất bản thật.
673
-
674
- **Legacy (không có `spec_source` — trace theo service):**
675
- Copy mỗi `{UC-ID}-{platform}.tsv` vừa cập nhật → `{panel_mirror}/{service-name}/{UC-ID}-{platform}.tsv`
676
- (namespace theo `active_service`).
677
-
678
- Cách này giữ panel Living Docs của workspace đang mở luôn mới **giữa các lần sync** — nó chỉ là
679
- một **mirror tiện lợi cục bộ**. File `trace-report.json` đã merge (canonical, trong
680
- `{spec_source}/.living-docs/`) được build lại bởi `/sync` hoặc `/validate-traces`. Với các lệnh
681
- được orchestrate, làm việc này một lần trong orchestrator sau khi tất cả sub-agent trả về — không phải
682
- bên trong từng sub-agent.
683
-
684
-
685
- ---
686
-
687
- ## Output
688
-
689
- **Đọc `.agent/steps/report-footer.md`** và áp đúng khuôn footer trong đó (Status Badge ·
690
- Output Artifacts · Next) cho report cuối, kèm khối bên dưới.
691
-
692
- ```
693
- /dev-gen-test Hoàn tất — {UC-ID} ({active_module})
694
- ✅ {TestClass1} ({N} tests)
695
- ✅ {TestClass2} ({N} tests)
696
- Trace: {paths.trace_dir}/{domain}/{prd-slug}/{UC-ID}-{platform}.tsv updated
697
- Next: /dev-run-test {UC-ID}
698
-
699
- 📊 Living Docs: chạy /validate-traces (hoặc /sync) để push trace này lên dashboard spec-module.
700
- ```