@longph2102/v-flow 1.5.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 (247) hide show
  1. package/AGENTS.md +265 -0
  2. package/CHANGELOG.md +318 -0
  3. package/LICENSE +21 -0
  4. package/README.md +326 -0
  5. package/agents/ba-agent.md +437 -0
  6. package/agents/ba-critic-agent.md +156 -0
  7. package/agents/ba-to-ptyc-agent.md +112 -0
  8. package/agents/bugfix-analyst-agent.md +221 -0
  9. package/agents/constitute-agent.md +155 -0
  10. package/agents/help-agent.md +168 -0
  11. package/agents/implement-agent.md +220 -0
  12. package/agents/import-ba-docs-agent.md +164 -0
  13. package/agents/master-check-agent.md +228 -0
  14. package/agents/metrics-agent.md +180 -0
  15. package/agents/operations-agent.md +123 -0
  16. package/agents/plan-agent.md +218 -0
  17. package/agents/prototype-agent.md +191 -0
  18. package/agents/retrospective-agent.md +196 -0
  19. package/agents/review-agent.md +210 -0
  20. package/agents/sprint-agent.md +191 -0
  21. package/agents/status-agent.md +186 -0
  22. package/agents/sync-agent.md +201 -0
  23. package/agents/test-agent.md +166 -0
  24. package/agents/understand-agent.md +339 -0
  25. package/cli/commands/check.js +96 -0
  26. package/cli/commands/dev-quiz.js +107 -0
  27. package/cli/commands/doctor.js +348 -0
  28. package/cli/commands/feature.js +259 -0
  29. package/cli/commands/hooks.js +163 -0
  30. package/cli/commands/init.js +189 -0
  31. package/cli/commands/log.js +199 -0
  32. package/cli/commands/plugin.js +230 -0
  33. package/cli/commands/score-card.js +203 -0
  34. package/cli/commands/status.js +269 -0
  35. package/cli/commands/sync.js +59 -0
  36. package/cli/commands/upgrade.js +150 -0
  37. package/cli/commands/validate.js +1259 -0
  38. package/cli/commands/watch.js +151 -0
  39. package/cli/index.js +46 -0
  40. package/cli/lib/ac-test-gate.js +89 -0
  41. package/cli/lib/activity-log.js +209 -0
  42. package/cli/lib/cli-error.js +183 -0
  43. package/cli/lib/constitution-lint.js +561 -0
  44. package/cli/lib/dev-quiz-grade.js +127 -0
  45. package/cli/lib/governance.js +78 -0
  46. package/cli/lib/hook-targets.js +167 -0
  47. package/cli/lib/i18n.js +375 -0
  48. package/cli/lib/knowledge-oracle.js +379 -0
  49. package/cli/lib/logger.js +203 -0
  50. package/cli/lib/module-card-lint.js +304 -0
  51. package/cli/lib/module-card-score.js +223 -0
  52. package/cli/lib/plugins.js +481 -0
  53. package/cli/lib/scanner.js +692 -0
  54. package/cli/lib/sync-core.js +232 -0
  55. package/cli/lib/sync-targets.js +84 -0
  56. package/cli/lib/templates.js +268 -0
  57. package/cli/lib/yaml-parser.js +203 -0
  58. package/commands/v.ba-critic.md +101 -0
  59. package/commands/v.ba-to-ptyc.md +71 -0
  60. package/commands/v.bugfix.md +86 -0
  61. package/commands/v.check.md +131 -0
  62. package/commands/v.constitute.md +87 -0
  63. package/commands/v.constitution.md +84 -0
  64. package/commands/v.fork.md +127 -0
  65. package/commands/v.help.md +73 -0
  66. package/commands/v.hotfix.md +200 -0
  67. package/commands/v.implement.md +92 -0
  68. package/commands/v.import-ba-docs.md +222 -0
  69. package/commands/v.metrics.md +74 -0
  70. package/commands/v.operations.md +70 -0
  71. package/commands/v.plan.md +78 -0
  72. package/commands/v.prototype.md +121 -0
  73. package/commands/v.quickfix.md +169 -0
  74. package/commands/v.retrospective.md +80 -0
  75. package/commands/v.review.md +78 -0
  76. package/commands/v.rewind.md +127 -0
  77. package/commands/v.specify.md +118 -0
  78. package/commands/v.sprint.md +75 -0
  79. package/commands/v.status.md +62 -0
  80. package/commands/v.sync.md +81 -0
  81. package/commands/v.test.md +67 -0
  82. package/commands/v.understand.md +112 -0
  83. package/package.json +65 -0
  84. package/skills/_shared/constitution-reader/SKILL.md +109 -0
  85. package/skills/_shared/constitution-reader/config.json +52 -0
  86. package/skills/_shared/constitution-reader/examples/good/b1-phase-output.md +48 -0
  87. package/skills/_shared/constitution-reader/gotchas.md +46 -0
  88. package/skills/_shared/context-reader/SKILL.md +111 -0
  89. package/skills/_shared/context-reader/config.json +54 -0
  90. package/skills/_shared/context-reader/examples/good/legacy-nodejs-output.md +35 -0
  91. package/skills/_shared/context-reader/gotchas.md +49 -0
  92. package/skills/_shared/ears-notation/SKILL.md +63 -0
  93. package/skills/_shared/ears-notation/config.json +55 -0
  94. package/skills/_shared/ears-notation/examples/good/plan-test-interpretation.md +29 -0
  95. package/skills/_shared/ears-notation/gotchas.md +43 -0
  96. package/skills/check/cross-validator/SKILL.md +206 -0
  97. package/skills/check/cross-validator/config.json +33 -0
  98. package/skills/check/cross-validator/examples/good/validation-report-pass-with-concerns.md +105 -0
  99. package/skills/check/cross-validator/gotchas.md +43 -0
  100. package/skills/implement/constitution-enforcer/SKILL.md +134 -0
  101. package/skills/implement/constitution-enforcer/config.json +16 -0
  102. package/skills/implement/constitution-enforcer/examples/bad/vague-report.md +42 -0
  103. package/skills/implement/constitution-enforcer/examples/good/compliance-report.md +57 -0
  104. package/skills/implement/constitution-enforcer/gotchas.md +26 -0
  105. package/skills/implement/constitution-enforcer/scripts/check-constitution.sh +88 -0
  106. package/skills/implement/no-go-zone-guard/SKILL.md +173 -0
  107. package/skills/implement/no-go-zone-guard/config.json +28 -0
  108. package/skills/implement/no-go-zone-guard/examples/good/adapter-workaround.md +46 -0
  109. package/skills/implement/no-go-zone-guard/gotchas.md +27 -0
  110. package/skills/implement/no-go-zone-guard/scripts/check-nogo-zones.sh +148 -0
  111. package/skills/implement/no-go-zone-guard/scripts/nogo-precommit.sh +96 -0
  112. package/skills/implement/tdd-driver/SKILL.md +159 -0
  113. package/skills/implement/tdd-driver/config.json +33 -0
  114. package/skills/implement/tdd-driver/examples/good/tdd-cycle-product-repo.md +81 -0
  115. package/skills/implement/tdd-driver/gotchas.md +34 -0
  116. package/skills/metrics/metrics-collector/SKILL.md +133 -0
  117. package/skills/metrics/metrics-collector/config.json +16 -0
  118. package/skills/metrics/metrics-collector/examples/bad/incomplete-report.md +48 -0
  119. package/skills/metrics/metrics-collector/examples/good/full-metrics-report.md +101 -0
  120. package/skills/metrics/metrics-collector/gotchas.md +26 -0
  121. package/skills/operations/incident-runbook/SKILL.md +167 -0
  122. package/skills/operations/incident-runbook/config.json +21 -0
  123. package/skills/operations/incident-runbook/examples/bad/vague-incident-report.md +48 -0
  124. package/skills/operations/incident-runbook/examples/good/p1-hotfix-response.md +119 -0
  125. package/skills/operations/incident-runbook/gotchas.md +26 -0
  126. package/skills/plan/architecture-designer/SKILL.md +228 -0
  127. package/skills/plan/architecture-designer/config.json +32 -0
  128. package/skills/plan/architecture-designer/examples/bad/vague-plan.md +62 -0
  129. package/skills/plan/architecture-designer/examples/good/expand-contract-migration.md +56 -0
  130. package/skills/plan/architecture-designer/examples/good/plan-structure.md +58 -0
  131. package/skills/plan/architecture-designer/gotchas.md +45 -0
  132. package/skills/plan/task-breakdown/SKILL.md +208 -0
  133. package/skills/plan/task-breakdown/config.json +26 -0
  134. package/skills/plan/task-breakdown/examples/bad/vague-tasks.md +77 -0
  135. package/skills/plan/task-breakdown/examples/good/spike-clarify-tasks.md +66 -0
  136. package/skills/plan/task-breakdown/examples/good/tasks-login-feature.md +111 -0
  137. package/skills/plan/task-breakdown/gotchas.md +39 -0
  138. package/skills/prototype/LOGIC.md +240 -0
  139. package/skills/prototype/SKILL.md +185 -0
  140. package/skills/prototype/UI.md +407 -0
  141. package/skills/prototype/config.json +104 -0
  142. package/skills/prototype/examples/bad/prototype-notes.md +68 -0
  143. package/skills/prototype/examples/good/prototype-notes-ui.md +109 -0
  144. package/skills/prototype/examples/good/prototype-notes.md +67 -0
  145. package/skills/prototype/gotchas.md +128 -0
  146. package/skills/prototype/scripts/check-flow-state.ps1 +112 -0
  147. package/skills/prototype/scripts/check-flow-state.sh +104 -0
  148. package/skills/prototype/scripts/check-prototype-cleanup.ps1 +124 -0
  149. package/skills/prototype/scripts/check-prototype-cleanup.sh +109 -0
  150. package/skills/prototype/scripts/check-prototype-notes.ps1 +107 -0
  151. package/skills/prototype/scripts/check-prototype-notes.sh +102 -0
  152. package/skills/review/adversarial-reviewer/SKILL.md +137 -0
  153. package/skills/review/adversarial-reviewer/config.json +32 -0
  154. package/skills/review/adversarial-reviewer/examples/good/review-report-template.md +56 -0
  155. package/skills/review/adversarial-reviewer/gotchas.md +46 -0
  156. package/skills/review/adversarial-reviewer/scripts/quick-security-scan.sh +52 -0
  157. package/skills/specify/ba-bpmn-doc-gen/SKILL.md +108 -0
  158. package/skills/specify/ba-bpmn-doc-gen/reference/reference-bpmn-generation.md +528 -0
  159. package/skills/specify/ba-bpmn-doc-gen/reference/reference-drawio-flowchart.md +466 -0
  160. package/skills/specify/ba-critic/SKILL.md +172 -0
  161. package/skills/specify/ba-critic/config.json +32 -0
  162. package/skills/specify/ba-critic/examples/good/critic-report-round1.md +51 -0
  163. package/skills/specify/ba-critic/gotchas.md +40 -0
  164. package/skills/specify/ba-critic/scripts/check-spec-quality.sh +72 -0
  165. package/skills/specify/ba-doc-generator/SKILL.md +102 -0
  166. package/skills/specify/ba-doc-generator/references/template-clevel.md +84 -0
  167. package/skills/specify/ba-doc-generator/references/template-compliance.md +83 -0
  168. package/skills/specify/ba-doc-generator/references/template-dev.md +138 -0
  169. package/skills/specify/ba-doc-generator/references/template-partner.md +167 -0
  170. package/skills/specify/ba-doc-generator/references/template-pm.md +92 -0
  171. package/skills/specify/ba-doc-generator/references/template-review.md +114 -0
  172. package/skills/specify/ba-doc-generator/references/template-tester.md +108 -0
  173. package/skills/specify/ba-doc-generator/references/template-user.md +98 -0
  174. package/skills/specify/bugfix-analyst/SKILL.md +296 -0
  175. package/skills/specify/bugfix-analyst/config.json +41 -0
  176. package/skills/specify/bugfix-analyst/examples/bad/common-mistakes.md +71 -0
  177. package/skills/specify/bugfix-analyst/examples/good/email-validation-bugfix.md +53 -0
  178. package/skills/specify/bugfix-analyst/gotchas.md +51 -0
  179. package/skills/specify/ears-writer/SKILL.md +129 -0
  180. package/skills/specify/ears-writer/config.json +20 -0
  181. package/skills/specify/ears-writer/examples/bad/common-mistakes.md +17 -0
  182. package/skills/specify/ears-writer/examples/good/login-requirements.md +41 -0
  183. package/skills/specify/ears-writer/gotchas.md +43 -0
  184. package/skills/specify/ears-writer/scripts/check-ears-compliance.sh +51 -0
  185. package/skills/test/test-case-generator/SKILL.md +161 -0
  186. package/skills/test/test-case-generator/config.json +33 -0
  187. package/skills/test/test-case-generator/examples/good/test-cases-login.md +104 -0
  188. package/skills/test/test-case-generator/gotchas.md +43 -0
  189. package/skills/understand/ba-docs-scanner/SKILL.md +239 -0
  190. package/skills/understand/ba-docs-scanner/config.json +47 -0
  191. package/skills/understand/ba-docs-scanner/examples/good/work-order-br-extract.md +28 -0
  192. package/skills/understand/ba-docs-scanner/gotchas.md +44 -0
  193. package/skills/understand/ba-docs-scanner/merge-rules.md +47 -0
  194. package/skills/understand/codebase-scanner/SKILL.md +260 -0
  195. package/skills/understand/codebase-scanner/config.json +56 -0
  196. package/skills/understand/codebase-scanner/examples/good/menu-module-output.md +44 -0
  197. package/skills/understand/codebase-scanner/gotchas.md +42 -0
  198. package/skills/understand/codebase-scanner/scripts/scan-project-structure.sh +64 -0
  199. package/templates/DESIGN.md +456 -0
  200. package/templates/agent-command-template.yaml +240 -0
  201. package/templates/agent-config-template.md +170 -0
  202. package/templates/agent-definition-template.md +145 -0
  203. package/templates/agent-metrics-template.md +150 -0
  204. package/templates/api-contract-template.md +72 -0
  205. package/templates/bugfix-report-template.md +195 -0
  206. package/templates/bugfix-spec-template.md +134 -0
  207. package/templates/code-review-report-template.md +119 -0
  208. package/templates/constitution-template.md +234 -0
  209. package/templates/context-template.md +94 -0
  210. package/templates/data-model-template.md +95 -0
  211. package/templates/decision-log-template.md +92 -0
  212. package/templates/flow-state-template.yaml +208 -0
  213. package/templates/github/workflows/v-flow-validate.yml +30 -0
  214. package/templates/knowledge/adr-template.md +70 -0
  215. package/templates/knowledge/api-contract-template.md +140 -0
  216. package/templates/knowledge/domain-glossary.md +29 -0
  217. package/templates/knowledge/golden-tests-readme.md +115 -0
  218. package/templates/knowledge/lessons-learned.md +41 -0
  219. package/templates/knowledge/patterns.md +103 -0
  220. package/templates/module-card/SKILL.md +85 -0
  221. package/templates/module-card/api-specs.md +96 -0
  222. package/templates/module-card/business-quiz.md +119 -0
  223. package/templates/module-card/cross-service.md +125 -0
  224. package/templates/module-card/db.md +85 -0
  225. package/templates/module-card/dev-quiz.md +62 -0
  226. package/templates/module-card/permissions.md +83 -0
  227. package/templates/module-card/state-diagram.md +64 -0
  228. package/templates/module-card/tech-context.md +90 -0
  229. package/templates/module-card/ui-flows.md +91 -0
  230. package/templates/module-card/use-cases.md +142 -0
  231. package/templates/module-template.yaml +161 -0
  232. package/templates/operations-report-template.md +108 -0
  233. package/templates/plan-template.md +308 -0
  234. package/templates/prototype-notes-template.md +116 -0
  235. package/templates/ptyc/PTYC.template.docx +0 -0
  236. package/templates/ptyc/ptyc.meta.example.yaml +44 -0
  237. package/templates/retrospective-report-template.md +136 -0
  238. package/templates/security-review-template.md +84 -0
  239. package/templates/session-template.md +167 -0
  240. package/templates/spec-review-log-template.md +75 -0
  241. package/templates/spec-template.md +229 -0
  242. package/templates/sprint-status-template.md +101 -0
  243. package/templates/tasks-template.md +275 -0
  244. package/templates/test-cases-template.md +124 -0
  245. package/templates/ux-checklist-template.md +79 -0
  246. package/templates/validation-report-template.md +125 -0
  247. package/templates/vflow-config-template.yaml +22 -0
@@ -0,0 +1,45 @@
1
+ # Gotchas — Architecture Designer
2
+
3
+ > Cập nhật liên tục khi Agent gặp edge case mới.
4
+ > Mỗi lỗi lặp lại 2 lần → BẮT BUỘC thêm vào đây.
5
+
6
+ ---
7
+
8
+ ## Anti-Patterns
9
+
10
+ 1. ❌ **Over-engineering** — Tạo abstraction layer cho feature đơn giản.
11
+ - **Signal**: Interface với chỉ 1 implementation, Factory cho 1 class.
12
+ - **Fix**: YAGNI — design cho REQ hiện tại, không cho REQ tương lai.
13
+
14
+ 2. ❌ **Ignore No-Go Zones** — Thiết kế modify legacy code mà không kiểm tra context.md.
15
+ - **Hậu quả**: Implement Agent bị block ở B.1, phải quay lại redesign.
16
+ - **Fix**: Check TRƯỚC khi design — tạo adapter nếu cần interact No-Go Zone.
17
+
18
+ 3. ❌ **Vague file paths** — "tạo component ở src/somewhere".
19
+ - **Hậu quả**: Implement Agent tự quyết path → inconsistent structure.
20
+ - **Fix**: Mỗi file path PHẢI chính xác: `src/features/auth/data/auth_repository.dart`.
21
+
22
+ 4. ❌ **Missing error architecture** — Design chỉ có happy path.
23
+ - **Hậu quả**: Error handling ad-hoc, inconsistent response format.
24
+ - **Fix**: Plan PHẢI có Error Architecture section (types, flow, response format).
25
+
26
+ 5. ❌ **Coupling quá chặt** — Component A import trực tiếp B, B import trực tiếp C.
27
+ - **Fix**: Dependency injection, interface tại boundary.
28
+
29
+ 6. ❌ **Circular dependency** — A → B → A hoặc A → B → C → A.
30
+ - **Signal**: Import từ sibling module, shared mutable state.
31
+ - **Fix**: Extract shared logic sang _shared module hoặc event-based communication.
32
+
33
+ 7. ❌ **Design không align constitution** — Plan nói Repository pattern nhưng constitution nói Active Record.
34
+ - **Check**: Đọc constitution trước khi design. Design PHẢI confirm pattern alignment.
35
+
36
+ 8. ❌ **Thiếu REQ traceability** — Component tồn tại mà không trace về REQ nào.
37
+ - **Rule**: Mỗi component trong plan PHẢI reference ≥1 REQ-xxx.
38
+
39
+ ---
40
+
41
+ ## Edge Cases
42
+
43
+ - ✅ Feature chỉ có 1-2 REQ → Plan đơn giản là OK. Không cần 8 sections nếu feature nhỏ.
44
+ - ✅ Constitution chưa có → Cảnh báo human, dùng industry best practices, ghi `[⚠️ No constitution]`.
45
+ - ✅ Greenfield (không có context.md) → Skip No-Go Zone checks, design tự do hơn.
@@ -0,0 +1,208 @@
1
+ ---
2
+ name: task-breakdown
3
+ description: "Hướng dẫn Plan Agent chia tasks từ plan.md. Agent PHẢI đọc skill này sau khi hoàn thành architecture design. Đảm bảo mọi task trace về REQ-xxx và có annotations đúng."
4
+ trigger: "Khi Plan Agent tạo tasks.md từ plan.md"
5
+ phase: "B.0a"
6
+ used_by:
7
+ - /v.plan
8
+ hooks:
9
+ pre_breakdown: "Load plan.md + spec.md → extract REQ-xxx list và component list"
10
+ post_breakdown: "Verify: mỗi REQ có task, mỗi task có REQ, annotations đúng"
11
+ ---
12
+
13
+ # Task Breakdown — Chia Tasks Có Traceability
14
+
15
+ > ⚠️ Đây là **Skill bắt buộc** cho Plan Agent khi tạo tasks.md.
16
+ > Mỗi task PHẢI trace về REQ-xxx. Task không có REQ = task thừa.
17
+ >
18
+ > → Xem `gotchas.md` cho lỗi phổ biến khi chia tasks.
19
+ > → Xem `examples/good/` cho mẫu tasks.md chuẩn — và `examples/bad/` cho anti-pattern (đối chứng).
20
+ > → Xem `config.json` để customize (max_task_size, annotation_rules).
21
+
22
+ ---
23
+
24
+ ## Khi nào KHÔNG cần task breakdown chi tiết
25
+
26
+ - Quick Fix (`/v.quickfix`) — 1-2 tasks trực tiếp từ spec
27
+ - Hotfix (`/v.hotfix`) — 1 task focus fix, 1 task test
28
+ - Task đã rõ ràng (chỉ 1-2 REQ, 1 component)
29
+
30
+ > **Lite profile**: `quickfix`/`hotfix` → được bỏ Dependency Graph / Execution Schedule nếu chỉ 1–2 task; nhưng mỗi task VẪN cần Type + `Done khi` (AC) + block TDD.
31
+
32
+ ---
33
+
34
+ ## Task Annotations — Hệ Thống Nhãn
35
+
36
+ > 💡 Annotations giúp Implement Agent biết THỨ TỰ và CÁCH implement.
37
+
38
+ | Annotation | Ý nghĩa | Ví dụ khi dùng |
39
+ |-----------|---------|-----------------|
40
+ | `[ENTRYPOINT]` | Bắt đầu từ task này | Task đầu tiên, không dependency |
41
+ | `[PARALLEL]` | Có thể làm song song với task khác | 2 tasks không share code |
42
+ | `[GATE]` | DỪNG chờ human review | Task modify sensitive area |
43
+ | `[CRITICAL]` | Ưu tiên cao nhất | Core business logic |
44
+ | `[RISKY]` | Cần test kỹ hơn | Touch legacy code, complex logic |
45
+ | `[DEPENDS: T-xxx]` | Chỉ start khi T-xxx xong | Data model trước, API sau |
46
+ | `[SPIKE]` | Điều tra/POC — chưa biết cách làm; output là quyết định, time-boxed | Đo benchmark 2 lib trước khi chọn |
47
+ | `[CLARIFY]` | Còn mơ hồ — Implement Agent hỏi human trước khi code | Spec thiếu business rule, edge case chưa rõ |
48
+
49
+ ### Quy tắc annotation
50
+
51
+ 1. Mỗi task list PHẢI có đúng 1 `[ENTRYPOINT]` (validator enforce — không 0, không >1)
52
+ 2. `[GATE]` tasks phải DỪNG — Implement Agent chờ human approve
53
+ 3. `[DEPENDS]` tạo DAG — KHÔNG được có circular dependency (validator detect cycle + dangling ref)
54
+ 4. `[PARALLEL]` chỉ khi tasks THỰC SỰ independent (không share state)
55
+ 5. `[CLARIFY]` khi còn điểm mơ hồ — kèm **Câu hỏi mở**; thà hỏi còn hơn đoán sai
56
+ 6. `[SPIKE]` khi cách làm chưa rõ — điều tra TRƯỚC, kết quả feed lại plan; đứng trước task phụ thuộc nó. Liên kết với mã rủi ro plan §7 (vd `Risk: R-01`)
57
+
58
+ > Mẫu `[SPIKE]` + `[CLARIFY]` + chia milestone: `examples/good/spike-clarify-tasks.md`.
59
+
60
+ ---
61
+
62
+ ## Task Type — Loại thay đổi (gắn kèm annotations)
63
+
64
+ > Annotations nói **THỨ TỰ**; Task Type nói task đụng **BỀ MẶT nào** → quyết định chi tiết bắt buộc trong body.
65
+
66
+ | Type | Bề mặt | Body task PHẢI có |
67
+ |------|--------|-------------------|
68
+ | `[UI]` | Màn hình, component | Màn hình, widget/component, trạng thái, token `DESIGN.md` |
69
+ | `[API]` | Endpoint | Method+path, field request/response thêm/đổi |
70
+ | `[DB]` | Schema, migration | Bảng (new/alter), cột (tên/kiểu/null/default), **DDL up+down (câu lệnh thật)**, rollback |
71
+ | `[LOGIC]` | Service, use case | Hàm/class, hiện trạng → mong muốn |
72
+ | `[REFACTOR]` | Cấu trúc (behavior giữ nguyên) | Phạm vi, đảm bảo test cũ vẫn pass |
73
+ | `[TEST]` | Test | Loại test, kịch bản |
74
+
75
+ > 1 task có thể có nhiều type nếu cùng 1 component (vd `[API]` + `[DB]`); nếu tách được nên tách để dễ review.
76
+
77
+ ---
78
+
79
+ ## Đặc Thù Và Quy Ước
80
+
81
+ ### 1. Task Granularity vs Specificity
82
+
83
+ > ⚠️ **Granularity ≠ Specificity**. Granularity = **KÍCH THƯỚC** task (≈ 1 component). Specificity = **ĐỘ CHI TIẾT bên trong** task (vị trí symbol, hiện trạng → mong muốn). Task đúng kích thước NHƯNG vẫn phải chi tiết bên trong — đây là chỗ hay bị bỏ sót khiến dev phải hỏi lại.
84
+
85
+ **Granularity — kích thước:**
86
+ - Quá lớn (❌): "T-001: Implement login feature" → quá rộng, không biết khi nào xong.
87
+ - Quá nhỏ (❌): "T-001: Create file login.dart" → micromanage từng file.
88
+ - Vừa đúng (✅): "T-001: Implement LoginUseCase — validate credentials, call repository" → 1 component, 1-2 REQs.
89
+ - **Rule of thumb**: 1 task ≈ 1 component ≈ 1-3 REQs ≈ 1 TDD cycle.
90
+
91
+ **Specificity — task SỬA code có sẵn** (granularity component, nhưng body PHẢI cụ thể):
92
+ - Vị trí (symbol): hàm / class / widget / endpoint
93
+ - Hiện trạng → Mong muốn
94
+ - ❌ "T-0X: Update ProductScreen" → dev không biết sửa gì.
95
+ - ✅ "T-0X: `ProductScreen.build()` — hiện render list phẳng → thêm `FilterBar` + cột `Trạng thái` (badge); filter theo status."
96
+
97
+ ### 2. Dependency Graph
98
+
99
+ Tasks phải có dependency rõ ràng:
100
+ ```
101
+ T-001 [ENTRYPOINT] [CRITICAL]: Data models
102
+ T-002 [DEPENDS: T-001]: Repository implementation
103
+ T-003 [DEPENDS: T-001] [PARALLEL]: API service (parallel với T-002)
104
+ T-004 [DEPENDS: T-002, T-003]: Use case layer
105
+ T-005 [DEPENDS: T-004]: UI/Presentation
106
+ T-006 [DEPENDS: T-005] [GATE]: Integration test + human review
107
+ ```
108
+
109
+ **Contract-first** (khi có cả `[UI]` và `[API]`): task chốt **data model + API contract** đứng sớm (entrypoint hoặc dependency chung); FE và BE đều `[DEPENDS]` vào nó rồi mới `[PARALLEL]`. Không để FE/BE chạy song song khi contract chưa đóng băng → tránh đoán field lệch nhau.
110
+
111
+ ### 3. REQ ↔ Task Traceability
112
+
113
+ ```markdown
114
+ Mỗi task PHẢI có:
115
+ **Gắn với**: REQ-xxx, REQ-yyy ← trace ngược về spec
116
+ **Component**: LoginUseCase ← trace về plan
117
+ **Test cases**: TC-xxx, TC-yyy ← trace về test-cases.md (sau B.0b)
118
+ ```
119
+
120
+ ### 4. Complexity Tiers (thay cho ước tính giờ)
121
+
122
+ > Executor là AI agent → "mất bao nhiêu giờ" không còn ý nghĩa. Gắn mỗi task một tier S/M/L để biết task nào cần tách / cần soi kỹ.
123
+
124
+ | Tier | Nghĩa | Dấu hiệu điển hình |
125
+ |:----:|-------|--------------------|
126
+ | **S** | Nhỏ, đường đi rõ | Data model/entity, 1 endpoint đơn giản, 1 widget thuần — ~1 TDD cycle |
127
+ | **M** | Vừa | Use case có validation + error, repository + mapping, UI nhiều trạng thái — 2–3 TDD cycle |
128
+ | **L** | Lớn | Logic nhiều edge case, tích hợp 3rd-party, đụng nhiều file liên quan |
129
+
130
+ - Task mức **L** → cân nhắc tách nhỏ. Không tách được → gắn `[RISKY]` + nêu lý do.
131
+ - **Sizing tổng** (quyết định chia milestone): quy đổi **S=1, M=2, L=4** điểm → Σ. Tổng **> ~24 điểm** (hoặc **> 20 task**) → đề xuất tách thành nhiều phase/milestone thay vì 1 feature khổng lồ.
132
+
133
+ ### 5. Calibration từ lịch sử
134
+
135
+ Trước khi chia task cho feature mới, đọc `task-history.log` (+ `plan-history.log`) của feature tương tự để hiệu chỉnh:
136
+ - Feature cùng loại thường ~bao nhiêu task? phân bố Complexity (S/M/L) ra sao?
137
+ - Rủi ro / `[RISKY]` nào hay lặp lại → chủ động gắn `[SPIKE]`/`[RISKY]` sớm.
138
+ - Sau khi xong, ghi 1 dòng vào `task-history.log` (format ở `config.json` → `memory`) để feature sau calibrate tiếp.
139
+
140
+ > 📒 Log này là **plaintext do agent tự ghi/đọc** (không có CLI enforce). Consumer chính là `/v.retrospective` — Retrospective Agent đọc `plan-history.log`/`task-history.log` để rút xu hướng giữa các feature.
141
+
142
+ ---
143
+
144
+ ## Task Template
145
+
146
+ > Dùng **đúng một** schema này — trùng với `.v-flow/templates/tasks-template.md` (nguồn chuẩn). Task ID `T-NNN`, Complexity S/M/L (không ghi giờ).
147
+ >
148
+ > **3 trường test/done bổ sung nhau** (không thay thế nhau): `Done khi` = bám **AC-NN spec §4** (ghi rõ mã AC, định nghĩa "xong" nghiệp vụ) · `Test liên quan: TC-xx` = **test chính thức** ở `test-cases.md` (Test Agent tạo B.0b) · `TDD` = checklist **Red→Green** ngay trong task. Implement chạy theo TDD → mỗi task `[LOGIC]`/`[UI]`/`[API]`/`[DB]` nên có block `TDD`.
149
+
150
+ ```markdown
151
+ #### T-NNN: {Tên task cụ thể} `[TYPE]` `[ANNOTATIONS]`
152
+ - **Mô tả**: {Mục tiêu — 1 câu}
153
+ - **Files**: `path/to/file.ext`
154
+ - **Vị trí (symbol)**: `Class.method()` / `Widget` / `METHOD /path` ← task SỬA
155
+ - **Thay đổi cụ thể**:
156
+ - Hiện trạng: {behavior hiện tại — bỏ trống nếu tạo mới}
157
+ - Mong muốn: {kết quả sau khi xong}
158
+ - Các bước: 1) … 2) …
159
+ - {Block theo Type — [UI]: màn hình/component/trạng thái/token · [API]: endpoint+field · [DB]: bảng+cột+migration+rollback}
160
+ - **Dependency**: T-{M} (hoặc Không)
161
+ - **REQ / UC mapping**: REQ-{xxx} (UC-{xx})
162
+ - **Done khi**: đáp ứng **AC-NN** tương ứng trong spec §4 (ghi rõ mã, không chỉ "test pass")
163
+ - **Test liên quan**: TC-{xx}
164
+ - **TDD** (Red→Green) — viết test TRƯỚC, rồi code cho pass:
165
+ - [ ] Test: {kịch bản 1 — chạy fail trước khi có code}
166
+ - [ ] Test: {kịch bản 2}
167
+ - [ ] Impl: {code tối thiểu để các test trên pass}
168
+ - **Complexity**: S / M / L
169
+ - **Câu hỏi mở** (chỉ khi `[CLARIFY]`): {điều cần làm rõ}
170
+ - **Trạng thái**: [ ]
171
+ ```
172
+
173
+ **Checklist "done" gợi ý** (bám theo Acceptance Criteria của REQ trong spec, không chỉ "tests pass"):
174
+ - [ ] Unit tests written + pass (TDD Red → Green)
175
+ - [ ] Đáp ứng AC cụ thể của REQ liên quan
176
+ - [ ] Code follows constitution naming/patterns
177
+ - [ ] No-Go Zones not violated
178
+ - [ ] _session.md updated
179
+
180
+ ---
181
+
182
+ ## Self-Review — soi lại danh sách task bằng "mắt mới" (bắt buộc)
183
+
184
+ > 💡 Chia xong → đọc lại tasks.md đối chiếu plan + spec, bắt gap ngữ nghĩa TRƯỚC khi giao Implement Agent. Checklist tự chạy (không subagent); KHÔNG đẩy validator sang semantics.
185
+
186
+ 1. **Phủ AC/REQ 2 chiều**: mỗi `AC-NN` & `REQ-xxx` của spec được ≥1 task phủ (thiếu = gap); **và** mỗi task trace ngược về ≥1 REQ (task không REQ = task thừa → bỏ).
187
+ 2. **Quét placeholder**: không còn task mơ hồ kiểu "Update X"/"xử lý sau" — task SỬA phải có `Vị trí` + `Hiện trạng → Mong muốn`.
188
+ 3. **Nhất quán ký hiệu giữa các task**: cùng một symbol gọi cùng một tên qua mọi task. `clearLayers()` ở T-003 nhưng `clearFullLayers()` ở T-007 = bug; `users` ở task này mà `user` ở task kia = bug.
189
+ 4. **DAG hợp lệ**: đúng 1 `[ENTRYPOINT]`; `[DEPENDS]` không vòng lặp, không trỏ task không tồn tại; task `[PARALLEL]` thật sự không share file/state.
190
+ 5. **Mỗi code task có block TDD + `Done khi` (AC-NN)**: không task `[LOGIC]/[UI]/[API]/[DB]` nào thiếu Red→Green hoặc thiếu mã AC cụ thể.
191
+
192
+ Thấy lỗi → sửa tại chỗ. Đây là tầng bắt sớm; validator lint cấu trúc, Master Check soi ngữ nghĩa sâu hơn ở hạ nguồn.
193
+
194
+ ---
195
+
196
+ ## V-Flow Integration Points
197
+
198
+ - **plan.md** (B.0a) → Input: component list, file structure
199
+ - **spec.md** (S.1) → Input: REQ-xxx list cho traceability
200
+ - **test-cases.md** (B.0b) → Test Agent sẽ map TC → TASK
201
+ - **_session.md** → Ghi task dependency rationale
202
+ - **Implement Agent** → Consumer: follow task order + annotations
203
+
204
+ ---
205
+
206
+ ## Gotchas
207
+
208
+ → Xem `gotchas.md` cho lỗi phổ biến khi chia tasks — cập nhật liên tục.
@@ -0,0 +1,26 @@
1
+ {
2
+ "setup_questions": [
3
+ {
4
+ "id": "split_above_complexity",
5
+ "question": "Tách task khi vượt mức complexity nào?",
6
+ "options": ["M", "L"],
7
+ "default": "L",
8
+ "description": "Task vượt mức này sẽ được suggest split thành nhiều task nhỏ hơn. Dùng tier S/M/L thay cho ước tính giờ."
9
+ },
10
+ {
11
+ "id": "require_gate_for_legacy",
12
+ "question": "Bắt buộc [GATE] cho task modify legacy code?",
13
+ "type": "boolean",
14
+ "default": true
15
+ }
16
+ ],
17
+ "hooks": {
18
+ "pre_breakdown": "Load plan.md → extract component list + REQ mapping",
19
+ "post_breakdown": "Verify: mỗi REQ có task, no circular DEPENDS, exactly 1 ENTRYPOINT"
20
+ },
21
+ "memory": {
22
+ "file": "task-history.log",
23
+ "format": "[date] | [feature] | [total_tasks] | [entry_points] | [gates] | [parallel_groups]",
24
+ "purpose": "Track task planning patterns — dùng cho /v.retrospective"
25
+ }
26
+ }
@@ -0,0 +1,77 @@
1
+ # Ví dụ XẤU — Tasks mơ hồ (KHÔNG làm theo)
2
+
3
+ > ⚠️ Đây là **anti-pattern**. Đối chiếu với `examples/good/tasks-login-feature.md`.
4
+ > Mỗi khối minh họa một lỗi trong `gotchas.md` hoặc thiếu trường bắt buộc trong schema.
5
+
6
+ ---
7
+
8
+ ## ❌ 1. Task quá lớn + thiếu ENTRYPOINT
9
+
10
+ ```markdown
11
+ #### T-001: Implement toàn bộ feature login `[LOGIC]`
12
+ - **Mô tả**: làm hết login.
13
+ ```
14
+
15
+ **Sai vì**: 1 task ôm cả feature → không biết khi nào xong, test khó viết; cả list không có `[ENTRYPOINT]`.
16
+ **Sửa**: tách theo component (model → repo → usecase → UI), đúng 1 task `[ENTRYPOINT]`. Rule: 1 task ≈ 1 component ≈ 1–3 REQ ≈ 1 TDD cycle.
17
+
18
+ ---
19
+
20
+ ## ❌ 2. Thiếu trường bắt buộc (Done khi / Complexity / Type / TDD)
21
+
22
+ ```markdown
23
+ #### T-002: Sửa màn product
24
+ - **Files**: lib/ui/product_page.dart
25
+ ```
26
+
27
+ **Sai vì**: không có Task Type, không Complexity, không `Done khi` (bám AC), không block TDD → validator cảnh báo, dev phải hỏi lại "xong là sao?".
28
+ **Sửa**: gắn `[UI]` · `Complexity: M` · `Done khi: AC REQ-xxx spec §4` · block `TDD` (Red→Green).
29
+
30
+ ---
31
+
32
+ ## ❌ 3. Sửa code chung chung (thiếu Vị trí + Hiện trạng→Mong muốn)
33
+
34
+ ```markdown
35
+ #### T-003: Update ProductScreen `[UI]`
36
+ - **Mô tả**: cải thiện màn product.
37
+ ```
38
+
39
+ **Sai vì**: "cải thiện" → không rõ sửa symbol nào, từ gì sang gì.
40
+ **Sửa**: Vị trí `ProductScreen.build()` · Hiện trạng: render list phẳng → Mong muốn: thêm `FilterBar` + cột `Trạng thái` (badge), filter theo status.
41
+
42
+ ---
43
+
44
+ ## ❌ 4. Fake `[PARALLEL]` (2 task cùng sửa 1 file)
45
+
46
+ ```markdown
47
+ #### T-004: Thêm filter `[UI]` `[PARALLEL]`
48
+ - **Files**: lib/ui/product_page.dart
49
+ #### T-005: Thêm cột trạng thái `[UI]` `[PARALLEL]`
50
+ - **Files**: lib/ui/product_page.dart
51
+ ```
52
+
53
+ **Sai vì**: hai task song song nhưng sửa **cùng** `product_page.dart` → xung đột.
54
+ **Sửa**: gộp thành 1 task, hoặc cho 1 task `[DEPENDS]` task kia (tuần tự). Validator sẽ cảnh báo "Fake [PARALLEL]".
55
+
56
+ ---
57
+
58
+ ## ❌ 5. Circular dependency / thiếu REQ
59
+
60
+ ```markdown
61
+ #### T-006: A `[DEPENDS: T-007]` (không REQ)
62
+ #### T-007: B `[DEPENDS: T-006]` (không REQ)
63
+ ```
64
+
65
+ **Sai vì**: T-006↔T-007 vòng lặp → không bao giờ chạy được; cả hai không trace REQ → task thừa.
66
+ **Sửa**: tách logic chung sang T-000, cả hai `[DEPENDS: T-000]`; mỗi task gắn REQ-xxx.
67
+
68
+ ---
69
+
70
+ ## ❌ 6. "Done" = chỉ test pass
71
+
72
+ ```markdown
73
+ - **Done khi**: tất cả test pass.
74
+ ```
75
+
76
+ **Sai vì**: test pass ≠ đáp ứng nghiệp vụ; có thể test sai/thiếu.
77
+ **Sửa**: `Done khi` bám **Acceptance Criteria** cụ thể trong spec §4 (vd: "nút submit disable khi form invalid + snackbar khi 401"). TDD là *cách* làm, AC là *đích*.
@@ -0,0 +1,66 @@
1
+ # Ví dụ — Tasks có `[SPIKE]` + `[CLARIFY]` + chia milestone
2
+
3
+ > Minh hoạ 3 pattern ít được demo: **`[SPIKE]`** (điều tra, output = quyết định), **`[CLARIFY]`** (chặn đoán mò), và **chia milestone** khi sizing lớn. Schema task khớp `.v-flow/templates/tasks-template.md`.
4
+
5
+ ## Task Overview
6
+
7
+ | Tổng tasks | `[SPIKE]` | `[CLARIFY]` | Sizing (Σ điểm) | Milestone |
8
+ |:----------:|:---------:|:-----------:|:---------------:|:---------:|
9
+ | 9 | 1 | 1 | 26 (>24 → tách) | M1, M2 |
10
+
11
+ > Σ 26 điểm > 24 → tách **M1** (chốt nền + spike) và **M2** (tích hợp). Xem skill task-breakdown §4 (sizing).
12
+
13
+ ---
14
+
15
+ ## Milestone 1 — Nền tảng + điều tra
16
+
17
+ #### T-001: SPIKE — chọn thư viện hàng đợi `[SPIKE]` `[ENTRYPOINT]`
18
+ - **Mô tả**: Chưa rõ dùng BullMQ hay native SQS cho job retry — điều tra trước khi thiết kế.
19
+ - **Files**: `docs/spikes/queue-choice.md` (output là **kết luận**, KHÔNG phải code production)
20
+ - **Thay đổi cụ thể**:
21
+ - Mong muốn: benchmark 2 lib (throughput, retry, ops), chốt 1 + ghi lý do vào `_session.md`.
22
+ - Các bước: 1) POC 2 lib 2) đo p95 + chi phí vận hành 3) ra quyết định.
23
+ - **Dependency**: Không
24
+ - **REQ / UC mapping**: REQ-E03 (UC-02)
25
+ - **Done khi**: có **quyết định** lib + lý do; nếu đổi hướng thiết kế → đề xuất quay lại `/v.plan` (AC-07, spec §4)
26
+ - **Risk**: R-01 (plan §7) — chọn sai lib → rework tích hợp
27
+ - **Complexity**: M (time-boxed 1 ngày)
28
+ - **Trạng thái**: [ ]
29
+
30
+ > `[SPIKE]`: output là **kết luận/quyết định**, time-boxed, đứng TRƯỚC task phụ thuộc nó. KHÔNG ép ra code production.
31
+
32
+ #### T-002: Schema job table `[DB]` `[DEPENDS: T-001]`
33
+ - **Mô tả**: Bảng lưu job + trạng thái retry.
34
+ - **Files**: `migrations/20260602_create_jobs.sql`
35
+ - **[DB]**: `jobs` NEW · cột `id, type, payload, status, attempts, created_at` · index `idx_jobs_status`
36
+ - **DDL**: `CREATE TABLE jobs (...); CREATE INDEX idx_jobs_status ON jobs(status);` (up) / `DROP TABLE jobs;` (down)
37
+ - **Dependency**: T-001
38
+ - **REQ / UC mapping**: REQ-E03 (UC-02)
39
+ - **Done khi**: bảng + index tồn tại, rollback chạy (AC-08, spec §4)
40
+ - **TDD** (Red→Green):
41
+ - [ ] Test: cột + index tồn tại sau migration
42
+ - [ ] Impl: DDL
43
+ - **Complexity**: S
44
+ - **Trạng thái**: [ ]
45
+
46
+ #### T-003: Business rule tính phí trễ hạn `[LOGIC]` `[CLARIFY]` `[DEPENDS: T-002]`
47
+ - **Mô tả**: Tính phí khi job quá hạn — nhưng spec chưa rõ mốc tính.
48
+ - **Files**: `src/billing/late_fee.ts`
49
+ - **Thay đổi cụ thể**:
50
+ - Mong muốn: hàm `lateFee(job)` theo đúng business rule (chốt sau khi human trả lời).
51
+ - Các bước: (chỉ bắt đầu sau khi có câu trả lời).
52
+ - **Dependency**: T-002
53
+ - **REQ / UC mapping**: REQ-E04 (UC-02)
54
+ - **Done khi**: khớp business rule đã chốt (AC-09, spec §4)
55
+ - **Complexity**: M
56
+ - **Câu hỏi mở**: Phí trễ tính theo **ngày lịch** hay **ngày làm việc**? Có trần tối đa không? → Implement Agent **DỪNG, hỏi human** trước khi code, KHÔNG tự đoán.
57
+ - **Trạng thái**: [ ]
58
+
59
+ > `[CLARIFY]`: kèm **Câu hỏi mở**; thà hỏi còn hơn giả định sai. Plan còn `[CLARIFY]` chưa coi là "ready" hoàn toàn.
60
+
61
+ ---
62
+
63
+ ## Milestone 2 — Tích hợp (sau khi M1 chốt spike + clarify)
64
+
65
+ #### T-004 … T-009: (worker, API trigger, retry, observability, integration test `[GATE]`)
66
+ > Lược — mỗi task vẫn đủ Type · Done khi (AC) · TDD · Complexity như schema chuẩn.
@@ -0,0 +1,111 @@
1
+ # Ví dụ — Tasks.md (User Login Feature)
2
+
3
+ > Đây là mẫu output chuẩn cho Plan Agent khi chia tasks (schema khớp `.v-flow/templates/tasks-template.md`).
4
+
5
+ ---
6
+
7
+ ## Tasks — Feature 001: User Login
8
+
9
+ #### T-001: Data Models & Entities `[LOGIC]` `[ENTRYPOINT]` `[CRITICAL]`
10
+ - **Mô tả**: Tạo data models cho authentication flow — user entity, request/response DTOs.
11
+ - **Files**: `lib/features/auth/domain/auth_models.dart`
12
+ - **Thay đổi cụ thể**:
13
+ - Mong muốn: AuthUser, LoginRequest, LoginResponse với serialization.
14
+ - Các bước: 1) Định nghĩa entity 2) DTO + fromJson/toJson 3) Unit test serialization.
15
+ - **Dependency**: Không
16
+ - **REQ / UC mapping**: REQ-E01, REQ-U01 (UC-01)
17
+ - **Done khi**: serialize/deserialize round-trip đúng cho AuthUser + DTOs (AC-01, spec §4)
18
+ - **Test liên quan**: TC-01
19
+ - **TDD** (Red→Green):
20
+ - [ ] Test: `LoginResponse.fromJson` parse đúng `token` + `refreshToken`
21
+ - [ ] Test: `LoginRequest.toJson` ra đúng `{email, password}`
22
+ - [ ] Impl: entity + DTO + fromJson/toJson
23
+ - **Complexity**: S
24
+ - **Trạng thái**: [ ]
25
+
26
+ #### T-002: Auth Repository Interface & Implementation `[LOGIC]` `[DEPENDS: T-001]`
27
+ - **Mô tả**: Repository interface tại domain layer, implementation tại data layer.
28
+ - **Files**: `lib/features/auth/domain/auth_repository.dart`, `lib/features/auth/data/auth_repository_impl.dart`
29
+ - **Thay đổi cụ thể**:
30
+ - Mong muốn: Interface defined trước implementation; map error types (InvalidCredentials, AccountLocked, NetworkError).
31
+ - Các bước: 1) Interface 2) Impl gọi API service (mock) 3) Unit test với mock.
32
+ - **Dependency**: T-001
33
+ - **REQ / UC mapping**: REQ-E01, REQ-E02 (UC-01)
34
+ - **Done khi**: repository map đúng error types (InvalidCredentials/AccountLocked/NetworkError) (AC-02, spec §4)
35
+ - **Test liên quan**: TC-02, TC-03
36
+ - **TDD** (Red→Green):
37
+ - [ ] Test: API trả 401 → throw `InvalidCredentials`
38
+ - [ ] Test: API trả 423 → throw `AccountLocked`
39
+ - [ ] Impl: interface + impl gọi api service (mock) + map error
40
+ - **Complexity**: M
41
+ - **Trạng thái**: [ ]
42
+
43
+ #### T-003: API Service `[API]` `[DEPENDS: T-001]` `[PARALLEL]`
44
+ - **Mô tả**: HTTP client cho auth endpoints. Song song với T-002 (không share code).
45
+ - **Files**: `lib/features/auth/data/auth_api_service.dart`
46
+ - **Thay đổi cụ thể**:
47
+ - Mong muốn: gọi `POST /api/auth/login`, parse response + error.
48
+ - Các bước: 1) Base URL từ config (không hardcode) 2) Timeout 10s (constitution §5.2) 3) Error parsing.
49
+ - **[API]**: `POST /api/auth/login` · request `{email, password}` · response `{token, refreshToken}`
50
+ - **Dependency**: T-001
51
+ - **REQ / UC mapping**: REQ-E01 (UC-01)
52
+ - **Done khi**: gọi đúng `POST /api/auth/login` + parse response/error (AC-03, spec §4)
53
+ - **Test liên quan**: TC-04
54
+ - **TDD** (Red→Green):
55
+ - [ ] Test: request hợp lệ → parse `{token, refreshToken}`
56
+ - [ ] Test: quá 10s → throw `NetworkError`
57
+ - [ ] Impl: http client + base URL từ config + timeout + parse
58
+ - **Complexity**: S
59
+ - **Trạng thái**: [ ]
60
+
61
+ #### T-004: Login Use Case `[LOGIC]` `[CRITICAL]` `[DEPENDS: T-002, T-003]`
62
+ - **Mô tả**: Core business logic — validate → authenticate → handle result + rate limiting.
63
+ - **Files**: `lib/features/auth/domain/login_usecase.dart`
64
+ - **Thay đổi cụ thể**:
65
+ - Mong muốn: rate limiting block sau 5 attempts; mọi error type được handle.
66
+ - Các bước: 1) Validate input 2) Call repository 3) Đếm attempts + lockout.
67
+ - **Dependency**: T-002, T-003
68
+ - **REQ / UC mapping**: REQ-E01, REQ-E02, REQ-U01, REQ-O01 (UC-01)
69
+ - **Done khi**: rate limiting chặn sau 5 lần sai + mọi error type được handle (AC-04, AC-05, spec §4)
70
+ - **Test liên quan**: TC-01 → TC-05
71
+ - **TDD** (Red→Green):
72
+ - [ ] Test: credential đúng → trả `AuthUser`
73
+ - [ ] Test: sai 5 lần → lockout; lần 6 bị chặn, KHÔNG gọi repository
74
+ - [ ] Impl: validate → call repo → đếm attempts + lockout
75
+ - **Complexity**: M
76
+ - **Trạng thái**: [ ]
77
+
78
+ #### T-005: Login UI `[UI]` `[DEPENDS: T-004]`
79
+ - **Mô tả**: Presentation layer — form UI, state management, error display.
80
+ - **Files**: `lib/features/auth/presentation/login_screen.dart`, `login_bloc.dart`
81
+ - **Thay đổi cụ thể**:
82
+ - Mong muốn: loading/success/error state; validate email; thông báo lỗi không lộ credential.
83
+ - Các bước: 1) Form widget 2) Bloc states 3) Error mapping.
84
+ - **[UI]**: Màn hình `LoginScreen` (UC-01) · component email/password field, submit button · trạng thái `loading/error-401` · token `input-default`, `button-primary`
85
+ - **Dependency**: T-004
86
+ - **REQ / UC mapping**: REQ-E01, REQ-E02, REQ-O01 (UC-01)
87
+ - **Done khi**: hiển thị loading/success/error; thông báo lỗi KHÔNG lộ credential (AC-06, spec §4)
88
+ - **Test liên quan**: TC-06, TC-07
89
+ - **TDD** (Red→Green):
90
+ - [ ] Test: submit → state `loading` → success chuyển màn
91
+ - [ ] Test: 401 → hiển thị lỗi chung, không tiết lộ field nào sai
92
+ - [ ] Impl: form widget + bloc states + error mapping
93
+ - **Complexity**: M
94
+ - **Trạng thái**: [ ]
95
+
96
+ #### T-006: Integration Test & Cleanup `[TEST]` `[GATE]` `[DEPENDS: T-005]`
97
+ - **Mô tả**: End-to-end test flow. DỪNG chờ human review trước khi merge.
98
+ - **Files**: `test/features/auth/login_integration_test.dart`
99
+ - **Thay đổi cụ thể**:
100
+ - Mong muốn: E2E pass cho login success + failure flow.
101
+ - Các bước: 1) Test success 2) Test failure 3) Human review.
102
+ - **Dependency**: T-005
103
+ - **REQ / UC mapping**: All REQs (UC-01)
104
+ - **Done khi**: E2E login success + failure pass; human review approved (AC-07, spec §4)
105
+ - **Test liên quan**: TC-08
106
+ - **TDD** (Red→Green):
107
+ - [ ] Test: happy path login → vào home
108
+ - [ ] Test: sai mật khẩu → ở lại màn + thông báo lỗi
109
+ - **Gate condition**: Human review approved trước khi merge.
110
+ - **Complexity**: S
111
+ - **Trạng thái**: [ ]
@@ -0,0 +1,39 @@
1
+ # Gotchas — Task Breakdown
2
+
3
+ > Cập nhật liên tục khi Agent gặp edge case mới.
4
+ > Mỗi lỗi lặp lại 2 lần → BẮT BUỘC thêm vào đây.
5
+
6
+ ---
7
+
8
+ ## Anti-Patterns
9
+
10
+ 1. ❌ **Task quá lớn** — "Implement toàn bộ feature" = 1 task.
11
+ - **Hậu quả**: Implement Agent không biết khi nào xong, test khó viết.
12
+ - **Fix**: 1 task ≈ 1 component ≈ 1 TDD cycle.
13
+
14
+ 2. ❌ **Task quá nhỏ** — "Tạo file X.dart", "Import package Y".
15
+ - **Hậu quả**: 50 tasks → overwhelming, overhead tracking lớn hơn work.
16
+ - **Fix**: Group related micro-tasks vào 1 task có meaning.
17
+
18
+ 3. ❌ **Thiếu ENTRYPOINT** — Task list không có task nào đánh dấu bắt đầu.
19
+ - **Fix**: Luôn có ĐÚNG 1 task `[ENTRYPOINT]`.
20
+
21
+ 4. ❌ **Circular dependency** — T-001 depends T-002, T-002 depends T-001.
22
+ - **Fix**: Tách shared logic sang T-000, cả T-001 và T-002 depend T-000.
23
+
24
+ 5. ❌ **Fake PARALLEL** — 2 tasks đánh dấu parallel nhưng share cùng file.
25
+ - **Fix**: Track file paths — nếu 2 tasks modify cùng file → sequential.
26
+
27
+ 6. ❌ **Thiếu REQ traceability** — Task tồn tại nhưng không gắn REQ nào.
28
+ - **Rule**: Task không có REQ = task thừa. Hỏi: "Task này serve req nào?"
29
+
30
+ 7. ❌ **Quên task testing cuối** — Implement xong nhưng không có integration test task.
31
+ - **Fix**: Luôn có task cuối: "T-N: Integration test + cleanup" với `[GATE]` nếu cần.
32
+
33
+ ---
34
+
35
+ ## Edge Cases
36
+
37
+ - ✅ Feature chỉ có 1 REQ → 2-3 tasks vẫn OK (setup, implement, test).
38
+ - ✅ Feature cross-cutting (auth, logging) → Tách task _shared trước, feature task sau.
39
+ - ✅ Legacy refactor → Mỗi task PHẢI check No-Go Zone, thêm `[RISKY]` nếu gần boundary.