@edupia-tutor/spec-driven-docs 0.14.0 → 0.14.1

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 (141) hide show
  1. package/commands/debug.md +435 -435
  2. package/commands/debug.tmpl +111 -111
  3. package/commands/define-product.md +330 -327
  4. package/commands/define-product.tmpl +50 -47
  5. package/commands/dev-gen-test.md +364 -364
  6. package/commands/dev-gen-test.tmpl +63 -63
  7. package/commands/dev-run-test.md +375 -375
  8. package/commands/dev-run-test.tmpl +74 -74
  9. package/commands/dev-smoke-test.md +340 -340
  10. package/commands/dev-smoke-test.tmpl +60 -60
  11. package/commands/fix-bug.md +402 -402
  12. package/commands/fix-bug.tmpl +78 -78
  13. package/commands/generate-bdd.md +512 -512
  14. package/commands/generate-bdd.tmpl +211 -211
  15. package/commands/generate-code.md +480 -482
  16. package/commands/generate-code.tmpl +179 -181
  17. package/commands/generate-design-spec.md +495 -495
  18. package/commands/generate-design-spec.tmpl +219 -219
  19. package/commands/generate-prd.md +445 -396
  20. package/commands/generate-prd.tmpl +45 -198
  21. package/commands/generate-spec-manifest.md +337 -337
  22. package/commands/generate-spec-manifest.tmpl +57 -57
  23. package/commands/generate-tech-docs.md +364 -364
  24. package/commands/generate-tech-docs.tmpl +84 -84
  25. package/commands/learn.md +346 -346
  26. package/commands/learn.tmpl +22 -22
  27. package/commands/map-testids.md +321 -321
  28. package/commands/map-testids.tmpl +41 -41
  29. package/commands/propose-scenario.md +334 -334
  30. package/commands/propose-scenario.tmpl +54 -54
  31. package/commands/qc-analyze.md +322 -323
  32. package/commands/qc-analyze.tmpl +42 -43
  33. package/commands/qc-design-test.md +303 -303
  34. package/commands/qc-design-test.tmpl +23 -23
  35. package/commands/qc-plan.md +296 -296
  36. package/commands/qc-plan.tmpl +16 -16
  37. package/commands/qc-report.md +301 -301
  38. package/commands/qc-report.tmpl +21 -21
  39. package/commands/qc-review.md +297 -297
  40. package/commands/qc-review.tmpl +17 -17
  41. package/commands/qc-run-test.md +336 -336
  42. package/commands/qc-run-test.tmpl +35 -35
  43. package/commands/refine-prd.md +426 -428
  44. package/commands/refine-prd.tmpl +61 -61
  45. package/commands/report-bug.md +350 -350
  46. package/commands/report-bug.tmpl +70 -70
  47. package/commands/review-code.md +363 -363
  48. package/commands/review-code.tmpl +39 -39
  49. package/commands/review-context.md +577 -579
  50. package/commands/review-context.tmpl +212 -212
  51. package/commands/review-tech-docs.md +426 -426
  52. package/commands/review-tech-docs.tmpl +146 -146
  53. package/commands/setup-ai-first.md +237 -237
  54. package/commands/setup-ai-first.tmpl +131 -131
  55. package/commands/sync.md +145 -145
  56. package/commands/sync.tmpl +93 -93
  57. package/commands/update-framework.md +88 -88
  58. package/commands/update-framework.tmpl +36 -36
  59. package/commands/validate-traces.md +379 -379
  60. package/commands/validate-traces.tmpl +99 -99
  61. package/core/FRAMEWORK_VERSION +1 -1
  62. package/core/commands/debug.md +435 -435
  63. package/core/commands/define-product.md +330 -327
  64. package/core/commands/dev-gen-test.md +364 -364
  65. package/core/commands/dev-run-test.md +375 -375
  66. package/core/commands/dev-smoke-test.md +340 -340
  67. package/core/commands/fix-bug.md +402 -402
  68. package/core/commands/generate-bdd.md +512 -512
  69. package/core/commands/generate-code.md +480 -482
  70. package/core/commands/generate-design-spec.md +495 -495
  71. package/core/commands/generate-prd.md +445 -396
  72. package/core/commands/generate-spec-manifest.md +337 -337
  73. package/core/commands/generate-tech-docs.md +364 -364
  74. package/core/commands/learn.md +346 -346
  75. package/core/commands/map-testids.md +321 -321
  76. package/core/commands/propose-scenario.md +334 -334
  77. package/core/commands/qc-analyze.md +322 -323
  78. package/core/commands/qc-design-test.md +303 -303
  79. package/core/commands/qc-plan.md +296 -296
  80. package/core/commands/qc-report.md +301 -301
  81. package/core/commands/qc-review.md +297 -297
  82. package/core/commands/qc-run-test.md +336 -336
  83. package/core/commands/refine-prd.md +426 -428
  84. package/core/commands/report-bug.md +350 -350
  85. package/core/commands/review-code.md +363 -363
  86. package/core/commands/review-context.md +577 -579
  87. package/core/commands/review-tech-docs.md +426 -426
  88. package/core/commands/setup-ai-first.md +237 -237
  89. package/core/commands/sync.md +145 -145
  90. package/core/commands/update-framework.md +88 -88
  91. package/core/commands/validate-traces.md +379 -379
  92. package/core/skills/code/SKILL.md +388 -388
  93. package/core/skills/debug/SKILL.md +390 -390
  94. package/core/skills/design-spec/SKILL.md +316 -316
  95. package/core/skills/discovery/SKILL.md +7 -547
  96. package/core/skills/prd/SKILL.md +298 -394
  97. package/core/skills/setup-ai-first/SKILL.md +79 -79
  98. package/core/skills/spec/SKILL.md +176 -176
  99. package/core/skills/test/SKILL.md +602 -602
  100. package/core/steps/capture-lesson.md +44 -44
  101. package/core/steps/context-loader.md +174 -174
  102. package/core/steps/gate.md +54 -54
  103. package/core/steps/report-footer.md +52 -52
  104. package/core/steps/review-fanout.md +85 -87
  105. package/core/steps/spawn-agent.md +45 -45
  106. package/core/steps/trace-mirror.md +21 -21
  107. package/core/templates/architecture.template.md +37 -37
  108. package/core/templates/design-spec.template.md +77 -77
  109. package/core/templates/platform-guide.template.md +47 -47
  110. package/core/templates/prd.template.md +106 -231
  111. package/core/templates/product-definition.template.md +101 -88
  112. package/docs/04-operations/publishing.md +20 -3
  113. package/package.json +1 -1
  114. package/skills/code/SKILL.md +388 -388
  115. package/skills/code/SKILL.tmpl +56 -56
  116. package/skills/debug/SKILL.md +390 -390
  117. package/skills/debug/SKILL.tmpl +60 -60
  118. package/skills/design-spec/SKILL.md +316 -316
  119. package/skills/design-spec/SKILL.tmpl +36 -36
  120. package/skills/discovery/SKILL.md +7 -547
  121. package/skills/discovery/SKILL.tmpl +7 -140
  122. package/skills/prd/SKILL.md +298 -394
  123. package/skills/prd/SKILL.tmpl +40 -151
  124. package/skills/setup-ai-first/SKILL.md +79 -79
  125. package/skills/setup-ai-first/SKILL.tmpl +27 -27
  126. package/skills/spec/SKILL.md +176 -176
  127. package/skills/spec/SKILL.tmpl +18 -18
  128. package/skills/test/SKILL.md +602 -602
  129. package/skills/test/SKILL.tmpl +44 -44
  130. package/steps/capture-lesson.md +44 -44
  131. package/steps/context-loader.md +174 -174
  132. package/steps/gate.md +54 -54
  133. package/steps/report-footer.md +52 -52
  134. package/steps/review-fanout.md +85 -87
  135. package/steps/spawn-agent.md +45 -45
  136. package/steps/trace-mirror.md +21 -21
  137. package/templates/architecture.template.md +37 -37
  138. package/templates/design-spec.template.md +77 -77
  139. package/templates/platform-guide.template.md +47 -47
  140. package/templates/prd.template.md +106 -231
  141. package/templates/product-definition.template.md +101 -88
@@ -1,4 +1,4 @@
1
- # /generate-bdd — Generate BDD Feature Files
1
+ # /generate-bdd — Sinh BDD Feature Files
2
2
 
3
3
  ## Gate
4
4
  {{include:steps/gate.md}}
@@ -6,57 +6,57 @@
6
6
  ## Context
7
7
  {{include:steps/context-loader.md}}
8
8
 
9
- > **Tester proposals (optional input):** before generating, check `{paths.bdd_proposals_dir}/` (default `{spec_source}/feedback/bdd-proposals/`) for scenarios proposed by testers via `/propose-scenario` that map to this UC's ACs. Incorporate any the PO/Dev has acceptedthen the tester's draft is removed/archived from `feedback/`. Skip if the folder is empty.
9
+ > **Proposal của tester (input tuỳ chọn):** trước khi sinh, kiểm tra `{paths.bdd_proposals_dir}/` (mặc định `{spec_source}/feedback/bdd-proposals/`) tìm các scenario tester đề xuất qua `/propose-scenario` ứng với AC của UC này. Đưa vào những cái PO/Dev đã chấp nhận rồi draft của tester được xoá/lưu trữ khỏi `feedback/`. Bỏ qua nếu folder rỗng.
10
10
 
11
11
  ---
12
12
 
13
- ## Repo Mode Detection
13
+ ## Phát hiện Repo Mode
14
14
 
15
- After loading context, determine which mode to operate in:
15
+ Sau khi nạp context, xác định chế độ hoạt động:
16
16
 
17
- - **Spec repo mode**: `project-context.yaml` has NO `services` section OR `setup.mode: spec`
18
- - **Umbrella mode**: `project-context.yaml` HAS `services` section AND `setup.mode: umbrella`
17
+ - **Spec repo mode**: `project-context.yaml` KHÔNG section `services` HOẶC `setup.mode: spec`
18
+ - **Umbrella mode**: `project-context.yaml` section `services` `setup.mode: umbrella`
19
19
 
20
- → Spec repo mode → proceed to **Platform Selection** below (skip Service Detection)
21
- → Umbrella mode → proceed to **Service Detection** below (skip Platform Selection)
20
+ → Spec repo mode → tới **Platform Selection** bên dưới (bỏ qua Service Detection)
21
+ → Umbrella mode → tới **Service Detection** bên dưới (bỏ qua Platform Selection)
22
22
 
23
23
  ---
24
24
 
25
- ## Platform Selection (Spec Repo Mode Only)
25
+ ## Platform Selection (chỉ Spec Repo Mode)
26
26
 
27
- *Skip this section if running in umbrella mode.*
27
+ *Bỏ qua section này nếu đang chạy umbrella mode.*
28
28
 
29
- Ask the user to select the target platform:
29
+ Hỏi người dùng chọn platform target:
30
30
 
31
31
  ```
32
- Which platform is this BDD for?
32
+ BDD này dành cho platform nào?
33
33
  1. web — FE/Web (React, Next.js, Angular, Vue, Nuxt)
34
34
  2. app — Mobile (Flutter, React Native, iOS, Android)
35
- 3. system — System/BE BDD (synthesized from existing web + app BDDs)
35
+ 3. system — System/BE BDD (tổng hợp từ web + app BDD có sẵn)
36
36
  ```
37
37
 
38
- Wait for user selection. Set `active_platform` = chosen value.
38
+ Chờ người dùng chọn. Set `active_platform` = giá trị đã chọn.
39
39
 
40
40
  **Output path (spec repo mode):**
41
41
  `{paths.specs_dir}/{domain}/{prd-slug}/bdd/{active_platform}/{TICKET-ID}-UC{N}-{slug}.feature`
42
42
 
43
- **Platform vocabulary:**
43
+ **Từ vựng theo platform:**
44
44
 
45
45
  | Platform | "user action" | "type/input" | "observe" | "navigate" |
46
46
  |---|---|---|---|---|
47
47
  | web | "clicks" | "types into" / "enters" | "sees" / "the page shows" | "navigates to" / "goes to" |
48
48
  | app | "taps" | "enters" / "inputs" | "sees" / "the screen shows" | "navigates to" / "opens" |
49
- | system | N/A — use business events | — | "the system returns" / "receives response" | — |
49
+ | system | N/A — dùng business event | — | "the system returns" / "receives response" | — |
50
50
 
51
51
  ---
52
52
 
53
53
  ## System BDD Synthesis (active_platform = system)
54
54
 
55
- *Only applies when platform = system. Skip for web and app.*
55
+ *Chỉ áp dụng khi platform = system. Bỏ qua với web app.*
56
56
 
57
57
  ### Step S0 — Brownfield Check
58
58
 
59
- Check the source PRD Metadata table for `| **API Source** | existing |`.
59
+ Kiểm tra bảng Metadata của PRD nguồn tìm `| **API Source** | existing |`.
60
60
 
61
61
  **Nếu `API Source: existing`:**
62
62
  - API contract đã được PO ghi trong phần "Existing API Contract" của PRD.
@@ -69,47 +69,47 @@ Check the source PRD Metadata table for `| **API Source** | existing |`.
69
69
 
70
70
  ---
71
71
 
72
- ### Step S1 — Scan available FE/App BDDs
72
+ ### Step S1 — Scan các BDD FE/App có sẵn
73
73
 
74
- Search for existing BDDs for this TICKET-ID:
75
- - Web BDDs: `{paths.specs_dir}/{domain}/{prd-slug}/bdd/web/{TICKET-ID}-*.feature`
76
- - App BDDs: `{paths.specs_dir}/{domain}/{prd-slug}/bdd/app/{TICKET-ID}-*.feature`
74
+ Tìm các BDD sẵn cho TICKET-ID này:
75
+ - Web BDD: `{paths.specs_dir}/{domain}/{prd-slug}/bdd/web/{TICKET-ID}-*.feature`
76
+ - App BDD: `{paths.specs_dir}/{domain}/{prd-slug}/bdd/app/{TICKET-ID}-*.feature`
77
77
 
78
- Classify the feature:
78
+ Phân loại feature:
79
79
 
80
- | Condition | Mode |
80
+ | Điều kiện | Mode |
81
81
  |---|---|
82
- | Both web + app BDDs found | **Multi-platform** — synthesize from both |
83
- | Only web BDD found | **Web-only** — synthesize from web |
84
- | Only app BDD found | **App-only** — synthesize from app |
85
- | No FE/App BDDs found | **Backend-only** — gen directly from PRD |
82
+ | Tìm thấy cả web + app BDD | **Multi-platform** — tổng hợp từ cả hai |
83
+ | Chỉ tìm thấy web BDD | **Web-only** — tổng hợp từ web |
84
+ | Chỉ tìm thấy app BDD | **App-only** — tổng hợp từ app |
85
+ | Không tìm thấy FE/App BDD | **Backend-only** — gen trực tiếp từ PRD |
86
86
 
87
87
  ---
88
88
 
89
- ### Step S2 — Extract expected contracts per platform
89
+ ### Step S2 — Trích contract kỳ vọng theo từng platform
90
90
 
91
- For each found BDD file, extract:
92
- - **Triggers**: what user actions call the backend? (map to logical "request" events)
93
- - **Expected response data**: what fields/shape does each `Then` clause need from the system?
94
- - **Error signals**: what error states must the backend signal?
95
- - **Business rules**: what invariants does each platform assume the system enforces?
91
+ Với mỗi file BDD tìm thấy, trích:
92
+ - **Triggers**: hành động người dùng nào gọi backend? (map sang event "request" logic)
93
+ - **Expected response data**: mỗi mệnh đề `Then` cần field/shape từ hệ thống?
94
+ - **Error signals**: backend phải báo hiệu các trạng thái lỗi nào?
95
+ - **Business rules**: mỗi platform giả định hệ thống thực thi các invariant nào?
96
96
 
97
97
  ---
98
98
 
99
- ### Step S3 — Cross-Platform Conflict Check (multi-platform mode only)
99
+ ### Step S3 — Cross-Platform Conflict Check (chỉ multi-platform mode)
100
100
 
101
- *Skip if web-only, app-only, or backend-only.*
101
+ *Bỏ qua nếu web-only, app-only, hoặc backend-only.*
102
102
 
103
- Compare the extracted contracts across platforms. Flag a conflict if any of these differ:
103
+ So sánh các contract đã trích giữa các platform. Gắn cờ conflict nếu bất kỳ cái nào khác nhau:
104
104
 
105
- | Conflict type | Example |
105
+ | Loại conflict | dụ |
106
106
  |---|---|
107
- | **Response shape mismatch** | Web expects `{ token, redirect_url }`, App expects `{ token, user_profile }` |
108
- | **Error semantics mismatch** | Web expects HTTP 423 for lock, App expects custom error code `ACC_LOCKED` |
109
- | **Business rule contradiction** | Web BDD says "lock after 5 attempts", App BDD says "lock after 3 attempts" |
110
- | **Data field conflict** | Web expects `expires_in: seconds`, App expects `expires_at: ISO timestamp` |
107
+ | **Response shape mismatch** | Web mong `{ token, redirect_url }`, App mong `{ token, user_profile }` |
108
+ | **Error semantics mismatch** | Web mong HTTP 423 cho lock, App mong custom error code `ACC_LOCKED` |
109
+ | **Business rule contradiction** | Web BDD nói "lock sau 5 lần", App BDD nói "lock sau 3 lần" |
110
+ | **Data field conflict** | Web mong `expires_in: seconds`, App mong `expires_at: ISO timestamp` |
111
111
 
112
- **If conflicts detected → CHECKPOINT (mandatory, cannot skip):**
112
+ **Nếu phát hiện conflict → CHECKPOINT (bắt buộc, không bỏ qua được):**
113
113
 
114
114
  ```
115
115
  ⚠️ CROSS-PLATFORM CONTRACT CONFLICT
@@ -122,103 +122,103 @@ Conflict 1: Response shape mismatch
122
122
 
123
123
  Resolution options:
124
124
  A — Union response
125
- BE returns all fields: { token, redirect_url, user_profile }
126
- Clients ignore fields they don't use. Simple, slight over-fetch.
127
- B — Platform hint in request
128
- Client sends X-Platform: web|app in header, BE tailors response.
129
- Cleaner responses, more BE logic.
130
- C — Separate endpoints
131
- POST /auth/login/web and POST /auth/login/app
132
- Maximum flexibility, more endpoints to maintain.
133
- D — Custom: describe your approach
125
+ BE trả về tất cả field: { token, redirect_url, user_profile }
126
+ Client bỏ qua field không dùng. Đơn giản, hơi over-fetch.
127
+ B — Platform hint trong request
128
+ Client gửi X-Platform: web|app trong header, BE tuỳ biến response.
129
+ Response gọn hơn, nhiều BE logic hơn.
130
+ C — Endpoint riêng
131
+ POST /auth/login/web POST /auth/login/app
132
+ Linh hoạt tối đa, nhiều endpoint phải bảo trì hơn.
133
+ D — Custom: tả cách của bạn
134
134
  ──────────────────────────────────────────────────────────────────
135
- Choose resolution for each conflict (A/B/C/D):
135
+ Chọn resolution cho mỗi conflict (A/B/C/D):
136
136
  ```
137
137
 
138
- Wait for PO's resolution per conflict. Record each decision as a `# @system.resolution:` annotation in the generated system BDD file.
138
+ Chờ PO giải quyết từng conflict. Ghi mỗi quyết định thành annotation `# @system.resolution:` trong file system BDD được gen.
139
139
 
140
- **If no conflictsproceed to Step S4 directly.**
140
+ **Nếu không conflict tới Step S4 trực tiếp.**
141
141
 
142
142
  ---
143
143
 
144
- ### Step S4 — Generate System BDD scenarios
144
+ ### Step S4 — Sinh các scenario System BDD
145
145
 
146
- Generate scenarios based on mode and resolved conflicts:
146
+ Sinh scenario dựa trên mode các conflict đã giải quyết:
147
147
 
148
- - **Multi-platform**: synthesize from both web + app contracts, applying resolved resolutions
149
- - **Web-only / App-only**: derive from the single platform's contracts
150
- - **Backend-only**: derive directly from PRD AC/BR using business event language (not HTTP)
148
+ - **Multi-platform**: tổng hợp từ cả contract web + app, áp dụng các resolution đã chọn
149
+ - **Web-only / App-only**: suy ra từ contract của một platform
150
+ - **Backend-only**: suy ra trực tiếp từ AC/BR của PRD dùng ngôn ngữ business event (không phải HTTP)
151
151
 
152
- System BDD step vocabulary (always useregardless of FE/App vocabulary):
152
+ Từ vựng step của System BDD (luôn dùngbất kể từ vựng FE/App):
153
153
  - Triggers: "the system receives {event}" / "a {actor} submits {action}"
154
154
  - Assertions: "the system returns {data}" / "the system signals {error}" / "the system stores {state}"
155
- - Do NOT use UI words (click, tap, see, navigate) in system BDD
155
+ - KHÔNG dùng từ UI (click, tap, see, navigate) trong system BDD
156
156
 
157
- **If multi-platform with resolution A (union):**
158
- - System BDD shows the full response contract: all fields from all platforms
159
- - Add comment: `# @system.resolution: union — clients receive all fields`
157
+ **Nếu multi-platform với resolution A (union):**
158
+ - System BDD thể hiện contract response đầy đủ: tất cả field từ mọi platform
159
+ - Thêm comment: `# @system.resolution: union — clients receive all fields`
160
160
 
161
- **If resolution B (platform hint):**
162
- - Write separate `Scenario Outline` using Examples table for `web` vs `app` response variants
163
- - Add comment: `# @system.resolution: platform-hint — X-Platform header determines response shape`
161
+ **Nếu resolution B (platform hint):**
162
+ - Viết `Scenario Outline` riêng dùng Examples table cho biến thể response `web` vs `app`
163
+ - Thêm comment: `# @system.resolution: platform-hint — X-Platform header determines response shape`
164
164
 
165
- **If resolution C (separate endpoints):**
166
- - Write separate Scenarios for each endpoint
167
- - Note the endpoint split explicitly in the SCOPE section
165
+ **Nếu resolution C (endpoint riêng):**
166
+ - Viết Scenario riêng cho mỗi endpoint
167
+ - Ghi việc tách endpoint trong phần SCOPE
168
168
 
169
169
  ---
170
170
 
171
- ## Service Detection (Umbrella Mode Only)
171
+ ## Service Detection (chỉ Umbrella Mode)
172
172
 
173
- *Skip this section if running in spec repo mode.*
173
+ *Bỏ qua section này nếu đang chạy spec repo mode.*
174
174
 
175
- Read the PRD Metadata table for `| **Service** |` and `| **Module** |` rows.
175
+ Đọc bảng Metadata của PRD tìm row `| **Service** |` `| **Module** |`.
176
176
 
177
- | Condition | Action |
177
+ | Điều kiện | Hành động |
178
178
  |---|---|
179
- | PRD has `Service` row AND value is not "default" | Use it as `active_service` + `active_module`. Load catalog for that module. |
180
- | PRD has no `Service` row AND `services` defined in project-context.yaml | Ask: "Which service is this BDD for?" (list services, wait for selection) |
181
- | Single-service project (no `services` array) | `active_service = "default"`, `active_module = tech_stack.module` |
179
+ | PRD row `Service` giá trị không phải "default" | Dùng làm `active_service` + `active_module`. Nạp catalog cho module đó. |
180
+ | PRD không row `Service` `services` được định nghĩa trong project-context.yaml | Hỏi: "BDD này dành cho service nào?" (liệt kê service, chờ chọn) |
181
+ | Dự án single-service (không có mảng `services`) | `active_service = "default"`, `active_module = tech_stack.module` |
182
182
 
183
183
  **Output path (umbrella mode):**
184
184
  - `active_service = "default"` → `{paths.specs_dir}/{domain}/{prd-slug}/bdd/{TICKET-ID}-UC{N}-{slug}.feature`
185
185
  - `active_service ≠ "default"` → `{paths.specs_dir}/{domain}/{prd-slug}/bdd/{active_service}/{TICKET-ID}-UC{N}-{slug}.feature`
186
186
 
187
- **Platform vocabulary** — adapt BDD step wording based on `active_module`:
187
+ **Từ vựng theo platform** — điều chỉnh cách viết step BDD theo `active_module`:
188
188
 
189
189
  | Platform type | Modules | "click" | "type" | "see" | "navigate" |
190
190
  |---|---|---|---|---|---|
191
191
  | Web | react, nextjs, vue, nuxt, angular | "clicks" | "types into" / "enters" | "sees" / "the page shows" | "navigates to" / "goes to" |
192
192
  | Mobile | flutter, react-native, ios-swiftui, android-compose | "taps" | "enters" / "inputs" | "sees" / "the screen shows" | "navigates to" / "opens" |
193
- | Backend / API | java-spring, golang, dotnet, php-laravel | *(no UI stepsuse)* "submits a request" / "calls the API" | — | "receives response" / "the system returns" | — |
193
+ | Backend / API | java-spring, golang, dotnet, php-laravel | *(không UI stepdùng)* "submits a request" / "calls the API" | — | "receives response" / "the system returns" | — |
194
194
 
195
- Apply this vocabulary silently when writing Gherkin steps. Do NOT mix web and mobile terms in the same feature file.
195
+ Áp dụng từ vựng này âm thầm khi viết step Gherkin. KHÔNG trộn từ web mobile trong cùng một file feature.
196
196
 
197
197
  ---
198
198
 
199
199
  ## Orchestration Check
200
200
 
201
- *Skip this section if already in sub-agent mode (Step 0 of Gate was triggered).*
201
+ *Bỏ qua section này nếu đã sub-agent mode (Step 0 của Gate đã kích hoạt).*
202
202
 
203
- After loading context, check if the target PRD is large enough to warrant sub-agents:
203
+ Sau khi nạp context, kiểm tra PRD target đủ lớn để cần sub-agent không:
204
204
 
205
- 1. Count `#### {TICKET-ID}-UC` headings in the PRD → **UC count**.
206
- 2. Count total lines in the PRD → **line count**.
207
- 3. If **UC count > 3** OR **line count > 300**:
208
- - Switch to orchestration mode — follow `steps/spawn-agent.md`.
209
- - The main session becomes the orchestrator: spawn 1 sub-agent per UC.
210
- - Each sub-agent runs `/generate-bdd` with `_agent_mode: true` payload.
211
- - Collect results and show merged report.
212
- - **Do NOT continue with the steps below.**
213
- 4. If UC count ≤ 3 AND line count ≤ 300 → continue with Version Check below (single-session mode).
205
+ 1. Đếm các heading `#### {TICKET-ID}-UC` trong PRD → **UC count**.
206
+ 2. Đếm tổng số dòng trong PRD → **line count**.
207
+ 3. Nếu **UC count > 3** HOẶC **line count > 300**:
208
+ - Chuyển sang orchestration mode — theo `steps/spawn-agent.md`.
209
+ - Session chính trở thành orchestrator: spawn 1 sub-agent cho mỗi UC.
210
+ - Mỗi sub-agent chạy `/generate-bdd` với payload `_agent_mode: true`.
211
+ - Thu thập kết quả hiện report đã merge.
212
+ - **KHÔNG tiếp tục các bước bên dưới.**
213
+ 4. Nếu UC count ≤ 3 line count ≤ 300 → tiếp tục Version Check bên dưới (single-session mode).
214
214
 
215
215
  ---
216
216
 
217
217
  ## Sub-Agent Return Format
218
218
 
219
- *This section applies when running as a sub-agent (Gate Step 0 detected `_agent_mode: true`).*
219
+ *Section này áp dụng khi chạy như sub-agent (Gate Step 0 phát hiện `_agent_mode: true`).*
220
220
 
221
- After generating all `.feature` and `.tsv` files for the assigned UC, return the structured result JSON (as specified in `steps/spawn-agent.md` Step E):
221
+ Sau khi sinh tất cả file `.feature` `.tsv` cho UC được giao, trả về JSON kết quả cấu trúc (theo `steps/spawn-agent.md` Step E):
222
222
 
223
223
  ```json
224
224
  { "uc_id": "{TICKET-ID}-UC{N}", "files_created": ["path/to/file1", "path/to/file2"], "status": "success | error", "errors": [] }
@@ -228,83 +228,83 @@ After generating all `.feature` and `.tsv` files for the assigned UC, return the
228
228
 
229
229
  ## Version Check
230
230
 
231
- Before generating, check for existing `.feature` files for this PRD:
231
+ Trước khi sinh, kiểm tra các file `.feature` sẵn cho PRD này:
232
232
 
233
- 1. Resolve the search path based on mode:
233
+ 1. Phân giải search path theo mode:
234
234
  - **Spec repo mode**: `{paths.specs_dir}/{domain}/{prd-slug}/bdd/{active_platform}/{TICKET-ID}-UC*.feature`
235
- - **Umbrella mode**: `{paths.specs_dir}/{domain}/{prd-slug}/bdd/{TICKET-ID}-UC*.feature` (or with `{active_service}/` if multi-service)
236
- 2. Read current PRD `| **Version** |` from metadata (e.g., `1.2`).
237
-
238
- **If no existing feature files** → fresh generation, proceed normally. Use PRD version as `@trace.prd_version`.
239
-
240
- **If existing feature files found**:
241
- - Read `# @trace.prd_version:` from the existing feature file header.
242
- - Compare with current PRD version.
243
- - If **same** → ask: "BDD already generated from PRD v{version}. Regenerate? (Y/N)"
244
- - If **different** (PRD was updated):
245
- 1. Read `## Changelog` from the PRD — extract all rows newer than the existing BDD's `@trace.prd_version`.
246
- 2. Show CHECKPOINT:
235
+ - **Umbrella mode**: `{paths.specs_dir}/{domain}/{prd-slug}/bdd/{TICKET-ID}-UC*.feature` (hoặc với `{active_service}/` nếu multi-service)
236
+ 2. Đọc `| **Version** |` hiện tại của PRD từ metadata (vd: `1.2`).
237
+
238
+ **Nếu không file feature nào** → gen mới, tiếp tục bình thường. Dùng version PRD làm `@trace.prd_version`.
239
+
240
+ **Nếu tìm thấy file feature sẵn**:
241
+ - Đọc `# @trace.prd_version:` từ header file feature sẵn.
242
+ - So với version PRD hiện tại.
243
+ - Nếu **giống** → hỏi: "BDD đã sinh từ PRD v{version}. Gen lại? (Y/N)"
244
+ - Nếu **khác** (PRD đã cập nhật):
245
+ 1. Đọc `## Changelog` từ PRD — trích tất cả row mới hơn `@trace.prd_version` của BDD hiện có.
246
+ 2. Hiện CHECKPOINT:
247
247
  ```
248
- ⚠️ PRD version drift detected
249
- BDD was generated from PRD v{old}
250
- PRD is now at v{new}
248
+ ⚠️ Phát hiện PRD version drift
249
+ BDD được sinh từ PRD v{old}
250
+ PRD giờ v{new}
251
251
 
252
- Changes since v{old}:
252
+ Thay đổi kể từ v{old}:
253
253
  {changelog rows}
254
254
 
255
255
  Options:
256
- Y — update only affected scenarios
257
- F — full regeneration of all scenarios
258
- N — cancel
256
+ Y — chỉ cập nhật các scenario bị ảnh hưởng
257
+ F — gen lại toàn bộ scenario
258
+ N — huỷ
259
259
  ```
260
- 3. Proceed based on user choice.
260
+ 3. Tiếp tục theo lựa chọn của người dùng.
261
261
 
262
262
  ---
263
263
 
264
- ## BDD Writing Rules (R1-R10 — enforce strictly)
264
+ ## BDD Writing Rules (R1-R10 — enforce nghiêm)
265
265
 
266
- | Rule | Name | Requirement |
266
+ | Rule | Name | Yêu cầu |
267
267
  |------|------|-------------|
268
- | R1 | Given/When/Then Semantics | Given=state, When=action, Then=outcome. Every SC needs full G/W/T. |
269
- | R2 | One Behavior Per Scenario | 1 SC = 1 behavior. Do NOT chain When→Then→When→Then. |
270
- | R3 | Ubiquitous Language | Do NOT use UI selectors / API names / tech terms in steps. |
271
- | R4 | Outside-in Naming | SC name describes business outcome. No "click" / "(Case X)" / component names. |
272
- | R5 | Declarative over Imperative | Describe WHAT (business intent), NOT HOW (UI mechanic). |
273
- | R6 | Observable Outcomes Only | Then asserts observable outcome. Not UI intermediate state / internal state. |
274
- | R7 | Key Examples / Concrete | Use concrete values. Not vague "valid data". |
275
- | R8 | Independence | SC runs independently. Does not depend on state from another SC. |
276
- | R9 | Test Data Completeness | Data table has enough fields to derive expected Then. |
277
- | R10 | Scope Boundary Explicit | Cross-UC reference uses navigation wording + Note comment. |
278
-
279
- ## Project Compliance (fail review if missing — C.1-C.5)
268
+ | R1 | Given/When/Then Semantics | Given=state, When=action, Then=outcome. Mỗi SC cần đủ G/W/T. |
269
+ | R2 | One Behavior Per Scenario | 1 SC = 1 behavior. KHÔNG chain When→Then→When→Then. |
270
+ | R3 | Ubiquitous Language | KHÔNG dùng UI selector / tên API / tech term trong step. |
271
+ | R4 | Outside-in Naming | Tên SC tả business outcome. Không "click" / "(Case X)" / tên component. |
272
+ | R5 | Declarative over Imperative | tả WHAT (ý định nghiệp vụ), KHÔNG phải HOW (cơ chế UI). |
273
+ | R6 | Observable Outcomes Only | Then khẳng định outcome quan sát được. Không phải trạng thái UI trung gian / internal state. |
274
+ | R7 | Key Examples / Concrete | Dùng giá trị cụ thể. Không "valid data" mơ hồ. |
275
+ | R8 | Independence | SC chạy độc lập. Không phụ thuộc state từ SC khác. |
276
+ | R9 | Test Data Completeness | Data table đủ field để suy ra Then kỳ vọng. |
277
+ | R10 | Scope Boundary Explicit | Cross-UC reference dùng cách diễn đạt navigation + comment Note. |
278
+
279
+ ## Project Compliance (fail review nếu thiếu — C.1-C.5)
280
280
 
281
281
  | Check | Rule |
282
282
  |-------|------|
283
- | C.1 Wireframe Coverage | Every component/action in Wireframe has ≥1 SC. |
284
- | C.2 PRD Traceability | Every AC and every BR (including each logic bullet) maps to ≥1 SC. |
285
- | C.3 Business Dictionary | Use correct canonical terms from business-dictionary.md. |
286
- | C.4 Banned Terms | 0 banned terms in file — grep before generating. |
287
- | C.5 NHÓM Grouping | Feature ≥3 SCsMUST have NHÓM grouping by business theme. |
283
+ | C.1 Wireframe Coverage | Mỗi component/action trong Wireframe ≥1 SC. |
284
+ | C.2 PRD Traceability | Mỗi AC mỗi BR (gồm từng bullet logic) map tới ≥1 SC. |
285
+ | C.3 Business Dictionary | Dùng đúng canonical term từ business-dictionary.md. |
286
+ | C.4 Banned Terms | 0 banned term trong file — grep trước khi gen. |
287
+ | C.5 NHÓM Grouping | Feature ≥3 SCPHẢI NHÓM grouping theo business theme. |
288
288
 
289
289
  ---
290
290
 
291
- ## NHÓM Grouping Convention (C.5 — mandatory for ≥3 scenarios)
291
+ ## NHÓM Grouping Convention (C.5 — bắt buộc cho ≥3 scenario)
292
292
 
293
- Group by business theme, NOT by happy/negative/edge.
293
+ Gom theo business theme, KHÔNG theo happy/negative/edge.
294
294
 
295
- Format header (indent 2 spaces, same level as Background):
295
+ Format header (thụt 2 space, cùng cấp với Background):
296
296
  ```
297
297
  # ==========================================================
298
- # NHÓM N: <Business theme> (<BR refs if applicable>)
298
+ # NHÓM N: <Business theme> (<BR refs nếu áp dụng>)
299
299
  # ==========================================================
300
300
  ```
301
301
 
302
302
  Rules:
303
- - Number sequentially NHÓM 1 → N. SC IDs sequential across lifecycle (do not reset per NHÓM).
304
- - Each NHÓM can contain @happy + @edge + @negative of the same theme.
305
- - SCs in NHÓM do not need to be in ID order (NHÓM 2 can contain SC4, SC8, SC11 if same theme).
303
+ - Đánh số tuần tự NHÓM 1 → N. SC ID tuần tự xuyên suốt lifecycle (không reset theo từng NHÓM).
304
+ - Mỗi NHÓM thể chứa @happy + @edge + @negative cùng theme.
305
+ - SC trong NHÓM không cần theo thứ tự ID (NHÓM 2 thể chứa SC4, SC8, SC11 nếu cùng theme).
306
306
 
307
- Suggested patterns (adjust per UC):
307
+ Pattern gợi ý (điều chỉnh theo UC):
308
308
  - `Init / Save success — valid data combinations`
309
309
  - `Validation / Block when invalid`
310
310
  - `Error handling — API fail / system error`
@@ -316,7 +316,7 @@ Suggested patterns (adjust per UC):
316
316
 
317
317
  ## UC Decomposition
318
318
 
319
- For each UC in the PRD, present the SC outline **before generating**:
319
+ Với mỗi UC trong PRD, trình bày outline SC **trước khi sinh**:
320
320
  ```
321
321
  {TICKET-ID}-UC1: {Use Case Name}
322
322
  NHÓM 1: {Theme} (BR1, BR2)
@@ -329,52 +329,52 @@ For each UC in the PRD, present the SC outline **before generating**:
329
329
  BRs covered: {TICKET-ID}-UC1-BR1, BR2, BR3
330
330
  ```
331
331
 
332
- CHECKPOINT: "Does this outline look correct? Do you want to add or remove any SCs?" → **Wait for confirm before generating.**
332
+ CHECKPOINT: "Outline này đúng chưa? Bạn muốn thêm hay bớt SC nào không?" → **Chờ confirm trước khi sinh.**
333
333
 
334
334
  ---
335
335
 
336
336
  ## Generate
337
337
 
338
- **Output path by mode:**
338
+ **Output path theo mode:**
339
339
  - **Spec repo mode**: `{paths.specs_dir}/{domain}/{prd-slug}/bdd/{active_platform}/{TICKET-ID}-UC{N}-{slug}.feature`
340
340
  - **Umbrella mode (single-service)**: `{paths.specs_dir}/{domain}/{prd-slug}/bdd/{TICKET-ID}-UC{N}-{slug}.feature`
341
341
  - **Umbrella mode (multi-service)**: `{paths.specs_dir}/{domain}/{prd-slug}/bdd/{active_service}/{TICKET-ID}-UC{N}-{slug}.feature`
342
342
 
343
- For each UC, write to the resolved path above. Use vocabulary for the active platform (from Platform Selection or Service Detection).
343
+ Với mỗi UC, ghi vào path đã phân giải ở trên. Dùng từ vựng cho active platform (từ Platform Selection hoặc Service Detection).
344
344
 
345
345
  ```gherkin
346
346
  # ============================================================
347
347
  # @trace.id: {TICKET-ID}-UC{N}
348
348
  # @trace.title: <Feature name>
349
- # @trace.revision: 1 ← static field; use @trace.bdd_version for version tracking (incremented by /review-context --fix or --resume)
349
+ # @trace.revision: 1 ← field tĩnh; dùng @trace.bdd_version để theo dõi version (tăng bởi /review-context --fix hoặc --resume)
350
350
  # @trace.domain: <domain>
351
- # @trace.platform: {active_platform — web | app | system | (omit in umbrella mode)}
352
- # @trace.service: {active_service — omit in spec repo mode}
353
- # @trace.module: {active_module in umbrella mode; "unknown" in spec repo mode}
351
+ # @trace.platform: {active_platform — web | app | system | (bỏ trong umbrella mode)}
352
+ # @trace.service: {active_service — bỏ trong spec repo mode}
353
+ # @trace.module: {active_module trong umbrella mode; "unknown" trong spec repo mode}
354
354
  # @trace.status: draft
355
355
  # @trace.author: AI-generated
356
356
  # @trace.created_at: {YYYY-MM-DD}
357
357
  # @trace.prd: {TICKET-ID}
358
- # @trace.prd_version: {read from PRD metadata "| **Version** |"}
359
- # @trace.bdd_version: {1.0 if fresh generation; increment by 0.1 on re-generatione.g. 1.0 → 1.1}
358
+ # @trace.prd_version: {đọc từ metadata PRD "| **Version** |"}
359
+ # @trace.bdd_version: {1.0 nếu gen mới; tăng 0.1 khi gen lại vd 1.0 → 1.1}
360
360
  # @trace.business_rules: {TICKET-ID}-UC{N}-BR1, {TICKET-ID}-UC{N}-BR2
361
361
  # @trace.dataset: {domain}.testdata.yaml
362
362
  # ============================================================
363
363
 
364
364
  # === CONTEXT ===
365
- # Actor: <role performing the action, e.g., Consumer, Staff, System>
366
- # Screens: <related screens, e.g., Cart → Confirm Order → Order Detail>
367
- # Entities: <business entities, e.g., Order, OrderItem, Consumer>
368
- # Pre-state: <shared state before entering scenarios>
365
+ # Actor: <vai trò thực hiện hành động, vd: Consumer, Staff, System>
366
+ # Screens: <các màn liên quan, vd: Cart → Confirm Order → Order Detail>
367
+ # Entities: <business entity, vd: Order, OrderItem, Consumer>
368
+ # Pre-state: <state dùng chung trước khi vào các scenario>
369
369
 
370
370
  # === SCOPE ===
371
- # In: <what this UC covers>
372
- # Out: <what is NOT in this UC — link to other UC/feature (R10)>
371
+ # In: <UC này phủ gì>
372
+ # Out: <cái KHÔNG thuộc UC này — link tới UC/feature khác (R10)>
373
373
 
374
374
  # === BUSINESS DEFINITION ===
375
- # Quick reference for terms used in this feature. SoT details: business-dictionary.md
376
- # <Term 1>: <short definition>
377
- # <Term 2>: <short definition>
375
+ # Tham chiếu nhanh các term dùng trong feature này. Chi tiết SoT: business-dictionary.md
376
+ # <Term 1>: <định nghĩa ngắn>
377
+ # <Term 2>: <định nghĩa ngắn>
378
378
 
379
379
  Feature: <Feature name>
380
380
  As a <role>
@@ -382,29 +382,29 @@ Feature: <Feature name>
382
382
  So that <business value>
383
383
 
384
384
  Background:
385
- Given <shared precondition — use aliases from dataset, not technical IDs>
385
+ Given <precondition dùng chung dùng alias từ dataset, không phải ID kỹ thuật>
386
386
 
387
387
  # ==========================================================
388
388
  # NHÓM 1: <Business theme> (<BR refs>)
389
389
  # ==========================================================
390
390
 
391
- # Side-effects: <list brief Then side-effects to verify>
391
+ # Side-effects: <liệt ngắn các Then side-effect cần verify>
392
392
  # @trace.scenario: {TICKET-ID}-UC{N}-SC1
393
393
  # @trace.sc_version: 1.0
394
394
  # @trace.business_rules: {TICKET-ID}-UC{N}-BR1
395
395
  @happy
396
- Scenario: <describe business outcome — use precise verb: create/receive/assign/block>
397
- Given <input state — alias from dataset>
396
+ Scenario: < tả business outcome — dùng động từ chính xác: create/receive/assign/block>
397
+ Given <input state — alias từ dataset>
398
398
  When <single action>
399
399
  Then <main observable outcome>
400
- And <side-effect 1 declared in header>
400
+ And <side-effect 1 khai báo trong header>
401
401
 
402
402
  # Side-effects: <...>
403
403
  # @trace.scenario: {TICKET-ID}-UC{N}-SC2
404
404
  # @trace.sc_version: 1.0
405
405
  # @trace.business_rules: {TICKET-ID}-UC{N}-BR1
406
406
  @happy @alternative
407
- Scenario: <same NHÓM 1 theme but different path e.g., different enum value>
407
+ Scenario: <cùng theme NHÓM 1 nhưng path khácvd: giá trị enum khác>
408
408
  Given <state>
409
409
  When <action>
410
410
  Then <outcome>
@@ -418,85 +418,85 @@ Feature: <Feature name>
418
418
  # @trace.sc_version: 1.0
419
419
  # @trace.business_rules: {TICKET-ID}-UC{N}-BR2
420
420
  @edge
421
- Scenario: <boundary / error scenario>
421
+ Scenario: <scenario boundary / error>
422
422
  Given <state>
423
423
  When <action>
424
424
  Then <expected error handling>
425
425
  ```
426
426
 
427
- ### Coverage Matrix & Pre-merge Checklist *(appended to end of each file)*
427
+ ### Coverage Matrix & Pre-merge Checklist *(thêm vào cuối mỗi file)*
428
428
 
429
429
  ```gherkin
430
430
  # === PRD COVERAGE (C.1 + C.2) ===
431
431
  # AC mapping:
432
432
  # AC1 (...) → SC1, SC2
433
433
  # AC2 (...) → SC3
434
- # BR mapping (each bullet MUST have ≥1 SC — C.2):
434
+ # BR mapping (mỗi bullet PHẢI ≥1 SC — C.2):
435
435
  # {TICKET-ID}-UC{N}-BR1 (...) → SC1, SC2
436
436
  # {TICKET-ID}-UC{N}-BR2 (...) → SC3
437
- # Wireframe mapping (every component/action ≥1 SC — C.1):
437
+ # Wireframe mapping (mỗi component/action ≥1 SC — C.1):
438
438
  # Screen "<screen name>":
439
439
  # [x] <action 1> → SC1
440
440
  # [x] <action 2> → SC2
441
441
  # [ ] <action 3> → MISSING ← BLOCK MERGE
442
442
 
443
443
  # === PRE-MERGE CHECKLIST ===
444
- # - [ ] Every SC has Side-effects + @trace.scenario + @trace.sc_version + @trace.business_rules
445
- # - [ ] Coverage Matrix: 0 MISSING lines (C.1)
446
- # - [ ] Every AC/BR maps to ≥1 SC (C.2)
447
- # - [ ] 0 banned terms (C.4) — grep file before merging
448
- # - [ ] Feature ≥3 SCs has NHÓM grouping by business theme (C.5)
449
- # - [ ] If popup/modal: Popup/Modal Lifecycle declared in BUSINESS DEFINITION
450
- # - [ ] If display logic ≥2 dimensions: Display Logic Matrix in BUSINESS DEFINITION
444
+ # - [ ] Mỗi SC Side-effects + @trace.scenario + @trace.sc_version + @trace.business_rules
445
+ # - [ ] Coverage Matrix: 0 dòng MISSING (C.1)
446
+ # - [ ] Mỗi AC/BR map tới ≥1 SC (C.2)
447
+ # - [ ] 0 banned term (C.4) — grep file trước khi merge
448
+ # - [ ] Feature ≥3 SC NHÓM grouping theo business theme (C.5)
449
+ # - [ ] Nếu popup/modal: khai báo Popup/Modal Lifecycle trong BUSINESS DEFINITION
450
+ # - [ ] Nếu display logic ≥2 chiều: Display Logic Matrix trong BUSINESS DEFINITION
451
451
  ```
452
452
 
453
453
  ---
454
454
 
455
455
  ## Write Trace State
456
456
 
457
- After generating all `.feature` files, create or update `{paths.trace_dir}/{domain}/{prd-slug}/{UC-ID}.tsv` for each UC.
457
+ Sau khi sinh tất cả file `.feature`, tạo hoặc cập nhật `{paths.trace_dir}/{domain}/{prd-slug}/{UC-ID}.tsv` cho mỗi UC.
458
458
 
459
- > **Umbrella + `spec_source`:** both the `.feature` files **and** the trace `.tsv` write to the **spec repo** (`{spec_source}/specs/{domain}/{prd-slug}/bdd/…` and `{spec_source}/.trace/{domain}/{prd-slug}/…`, resolved by context-loader) — a **single-repo** write, committed/pushed to the spec submodule. (Trace is consolidated in the spec repo so the PM manages all status in one place; code-side commands update it cross-repo later.)
459
+ > **Umbrella + `spec_source`:** cả file `.feature` **và** trace `.tsv` đều ghi vào **spec repo** (`{spec_source}/specs/{domain}/{prd-slug}/bdd/…` `{spec_source}/.trace/{domain}/{prd-slug}/…`, do context-loader phân giải) — một thao tác ghi **single-repo**, commit/push vào spec submodule. (Trace được gộp trong spec repo để PM quản mọi status một chỗ; các lệnh phía code cập nhật liên-repo sau.)
460
460
 
461
- **TSV columns (tab-separated, one header row + one data row per scenario):**
461
+ **Cột TSV (tab-separated, một header row + một data row cho mỗi scenario):**
462
462
  ```
463
463
  sc_id\tsc_title\tspec_ver\tgen_ver\timplemented_by\ttest_count\ttest_classes\tdev_selftest\tdev_selftest_at\tqc_status\tqc_run_at\tqc_owner\tqc_blocked_by\tprd_version\tbdd_version\ttech_doc_revision\tfe_tech_doc_revision\tprd_status\tuc_status\tfe_phase\tstatus\tlast_updated
464
464
  ```
465
465
 
466
466
  **Rules:**
467
- - If file does not existcreate with header row + all scenario rows.
468
- - If file exists (re-generation) → for each SC in the new `.feature`:
469
- - SC already in `.tsv` AND `spec_ver` is unchangedupdate only: `sc_title`, `prd_version`, `bdd_version`, `prd_status`, `uc_status`, `last_updated`. Leave all other columns unchanged.
470
- - SC already in `.tsv` AND `spec_ver` changed (scenario was modified) → update: `sc_title`, `spec_ver`, `prd_version`, `bdd_version`, `prd_status`, `uc_status`, `last_updated` AND set `status = DRIFT` immediately (so the TSV reflects drift without waiting for `/validate-traces`). Leave `gen_ver`, `implemented_by`, `test_count`, `test_classes`, `tech_doc_revision`, `fe_tech_doc_revision` unchanged.
471
- - SC is new (added in this re-gen) → append new row with `gen_ver`, `implemented_by`, `test_count`, `test_classes`, `dev_selftest`, `dev_selftest_at`, `qc_status`, `qc_run_at`, `qc_owner`, `qc_blocked_by`, `tech_doc_revision`, `fe_tech_doc_revision` all set to `—`.
472
- - SC no longer in `.feature` (removed) → delete its row.
467
+ - Nếu file chưa tồn tạitạo với header row + tất cả scenario row.
468
+ - Nếu file tồn tại (gen lại) → với mỗi SC trong `.feature` mới:
469
+ - SC đã trong `.tsv` `spec_ver` không đổichỉ cập nhật: `sc_title`, `prd_version`, `bdd_version`, `prd_status`, `uc_status`, `last_updated`. Giữ nguyên các cột khác.
470
+ - SC đã trong `.tsv` `spec_ver` đổi (scenario bị sửa) → cập nhật: `sc_title`, `spec_ver`, `prd_version`, `bdd_version`, `prd_status`, `uc_status`, `last_updated` set `status = DRIFT` ngay (để TSV phản ánh drift không cần đợi `/validate-traces`). Giữ nguyên `gen_ver`, `implemented_by`, `test_count`, `test_classes`, `tech_doc_revision`, `fe_tech_doc_revision`.
471
+ - SC mới (thêm trong lần gen lại này) → append row mới với `gen_ver`, `implemented_by`, `test_count`, `test_classes`, `dev_selftest`, `dev_selftest_at`, `qc_status`, `qc_run_at`, `qc_owner`, `qc_blocked_by`, `tech_doc_revision`, `fe_tech_doc_revision` đều set `—`.
472
+ - SC không còn trong `.feature` (bị xoá) → xoá row của nó.
473
473
 
474
- **Values to write for each scenario:**
474
+ **Giá trị ghi cho mỗi scenario:**
475
475
 
476
- | Column | Value |
476
+ | Cột | Giá trị |
477
477
  |--------|-------|
478
478
  | `sc_id` | `{UC-ID}-SC{N}` |
479
- | `sc_title` | scenario title text |
480
- | `spec_ver` | `@trace.sc_version` of this scenario |
481
- | `gen_ver` | `—` (not yet generated) |
479
+ | `sc_title` | text title của scenario |
480
+ | `spec_ver` | `@trace.sc_version` của scenario này |
481
+ | `gen_ver` | `—` (chưa gen) |
482
482
  | `implemented_by` | `—` |
483
483
  | `test_count` | `—` |
484
484
  | `test_classes` | `—` |
485
- | `dev_selftest` | `—` (no tests run yet) |
485
+ | `dev_selftest` | `—` (chưa chạy test) |
486
486
  | `dev_selftest_at` | `—` |
487
- | `qc_status` | `—` (official QC automation result — set by `/qc-run-test`) |
487
+ | `qc_status` | `—` (kết quả QC automation chính thức — set bởi `/qc-run-test`) |
488
488
  | `qc_run_at` | `—` |
489
- | `qc_owner` | `—` (who a non-passing SC waits on: `dev` / `po` — set by `/qc-run-test` + `/report-bug`) |
490
- | `qc_blocked_by` | `—` (linked `BUG-{id}` / `GAP-{id}` — set by `/qc-run-test` + `/report-bug`) |
491
- | `prd_version` | `@trace.prd_version` from `.feature` header |
492
- | `bdd_version` | `@trace.bdd_version` from `.feature` header |
493
- | `tech_doc_revision` | `—` (BE API contract revision — set by `/generate-code` + `/review-tech-docs`) |
494
- | `fe_tech_doc_revision` | `—` (FE client tech-design revision `{UC-ID}-tech-design-{platform}.md` — set by `/generate-code --phase=integration` + `/review-tech-docs` on an FE doc) |
495
- | `prd_status` | read `\| **Status** \|` from PRD metadata |
496
- | `uc_status` | `draft` for new UCs; keep existing value for re-gen |
497
- | `fe_phase` | `—` (set by `/generate-code --phase` when FE implements) |
489
+ | `qc_owner` | `—` (SC chưa pass đang chờ ai: `dev` / `po` — set bởi `/qc-run-test` + `/report-bug`) |
490
+ | `qc_blocked_by` | `—` (`BUG-{id}` / `GAP-{id}` liên kết — set bởi `/qc-run-test` + `/report-bug`) |
491
+ | `prd_version` | `@trace.prd_version` từ header `.feature` |
492
+ | `bdd_version` | `@trace.bdd_version` từ header `.feature` |
493
+ | `tech_doc_revision` | `—` (revision API contract BE — set bởi `/generate-code` + `/review-tech-docs`) |
494
+ | `fe_tech_doc_revision` | `—` (revision FE client tech-design `{UC-ID}-tech-design-{platform}.md` — set bởi `/generate-code --phase=integration` + `/review-tech-docs` trên doc FE) |
495
+ | `prd_status` | đọc `\| **Status** \|` từ metadata PRD |
496
+ | `uc_status` | `draft` cho UC mới; giữ giá trị hiện có khi gen lại |
497
+ | `fe_phase` | `—` (set bởi `/generate-code --phase` khi FE implement) |
498
498
  | `status` | `UNTRACKED` |
499
- | `last_updated` | today `YYYY-MM-DD` |
499
+ | `last_updated` | hôm nay `YYYY-MM-DD` |
500
500
 
501
501
  ## Refresh Panel Mirror
502
502
  {{include:steps/trace-mirror.md}}
@@ -506,7 +506,7 @@ sc_id\tsc_title\tspec_ver\tgen_ver\timplemented_by\ttest_count\ttest_classes\tde
506
506
  {{include:steps/report-footer.md}}
507
507
 
508
508
  ```
509
- /generate-bdd Complete
509
+ /generate-bdd Hoàn tất
510
510
 
511
511
  [Spec repo mode — platform: {active_platform}]
512
512
  Files:
@@ -516,9 +516,9 @@ Trace:
516
516
  {paths.trace_dir}/{domain}/{prd-slug}/{TICKET-ID}-UC1.tsv ({N} rows)
517
517
  {paths.trace_dir}/{domain}/{prd-slug}/{TICKET-ID}-UC2.tsv ({N} rows)
518
518
  Next (spec repo):
519
- Run /generate-bdd again for other platforms (web → app → system)
520
- After all platforms generated: commit + push + notify dev team
521
- Dev team reads BDD from spec submodule — no /generate-bdd on their side
519
+ Chạy /generate-bdd lại cho các platform khác (web → app → system)
520
+ Sau khi gen hết platform: commit + push + báo team dev
521
+ Team dev đọc BDD từ spec submodule — không chạy /generate-bdd phía họ
522
522
 
523
523
  [Umbrella mode — service: {active_service}]
524
524
  Files:
@@ -526,9 +526,9 @@ Files:
526
526
  Trace:
527
527
  {paths.trace_dir}/{domain}/{prd-slug}/{TICKET-ID}-UC1.tsv ({N} rows)
528
528
  Next (umbrella):
529
- → /review-context {feature-file} to verify coverage
529
+ → /review-context {feature-file} để kiểm tra coverage
530
530
  → /generate-tech-docs {feature-file}
531
531
  → /generate-code {feature-file}
532
532
 
533
- 📊 Living Docs: run /validate-traces (or /sync) to push this trace to the spec-module dashboard.
533
+ 📊 Living Docs: chạy /validate-traces (hoặc /sync) để push trace này lên dashboard spec-module.
534
534
  ```