@relipa/ai-flow-kit 0.1.9 → 0.2.0-beta.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 (55) hide show
  1. package/README.md +65 -0
  2. package/bin/aiflow.js +74 -4
  3. package/custom/rules/output-language.md +36 -0
  4. package/custom/rules/project-conventions.md +16 -0
  5. package/custom/skills/automation-testing/SKILL.md +1 -1
  6. package/custom/skills/ba-skills/skill-ba-build-business-rules-v1.md +2 -0
  7. package/custom/skills/ba-skills/skill-ba-initial-analysis-v1.md +2 -0
  8. package/custom/skills/ba-skills/skill-ba-mermaid-flowchart-v1.md +2 -0
  9. package/custom/skills/ba-skills/skill-ba-qna-v1.md +2 -0
  10. package/custom/skills/ba-skills/skill-ba-ui-prototype-v1.md +2 -0
  11. package/custom/skills/ba-skills/skill-ba-write-uc-spec-v1.md +2 -0
  12. package/custom/skills/coverage-check/SKILL.md +2 -0
  13. package/custom/skills/create-system-requirement/SKILL.md +252 -0
  14. package/custom/skills/deploy-model/SKILL.md +2 -0
  15. package/custom/skills/design-experiment/SKILL.md +2 -0
  16. package/custom/skills/evaluate-model/SKILL.md +2 -0
  17. package/custom/skills/evidence-aggregation/SKILL.md +2 -0
  18. package/custom/skills/execute-flow/SKILL.md +2 -0
  19. package/custom/skills/explore-data/SKILL.md +2 -0
  20. package/custom/skills/frame-ml-problem/SKILL.md +2 -0
  21. package/custom/skills/gate-review/SKILL.md +2 -0
  22. package/custom/skills/generate-spec/SKILL.md +2 -0
  23. package/custom/skills/generate-test-report/SKILL.md +2 -0
  24. package/custom/skills/generate-testcase/SKILL.md +2 -0
  25. package/custom/skills/impact-analysis/SKILL.md +2 -0
  26. package/custom/skills/improve-algorithm/SKILL.md +2 -0
  27. package/custom/skills/ingest-data/SKILL.md +226 -0
  28. package/custom/skills/log-bug/SKILL.md +2 -0
  29. package/custom/skills/pr-impact-analysis/SKILL.md +2 -0
  30. package/custom/skills/read-study-requirement/SKILL.md +41 -2
  31. package/custom/skills/report-customer/SKILL.md +6 -2
  32. package/custom/skills/retest-orchestration/SKILL.md +2 -0
  33. package/custom/skills/review-plan/SKILL.md +2 -0
  34. package/custom/skills/script-sync/SKILL.md +1 -1
  35. package/custom/skills/test-analysis/SKILL.md +2 -0
  36. package/custom/skills/test-skills/rules/qa-writing-standards.md +2 -2
  37. package/custom/skills/train-model/SKILL.md +2 -0
  38. package/custom/templates/shared/create-testcase-workflow.md +32 -1
  39. package/custom/templates/shared/gate-workflow.md +64 -0
  40. package/docs/common/BA-Specs-Structure.md +3 -0
  41. package/docs/common/CHANGELOG.md +39 -0
  42. package/docs/common/Docs-Management-Flow.md +1 -1
  43. package/docs/common/INDEX.md +1 -0
  44. package/docs/common/Memory-Architecture-v1.0.md +1 -0
  45. package/docs/common/Project-Structure.md +5 -2
  46. package/package.json +1 -1
  47. package/scripts/create-score-excel.js +4 -111
  48. package/scripts/detect.js +22 -0
  49. package/scripts/hooks/session-start.js +1 -0
  50. package/scripts/init.js +24 -1
  51. package/scripts/link-resolver.js +194 -7
  52. package/scripts/prompt.js +144 -0
  53. package/scripts/task.js +22 -6
  54. package/scripts/ticket-writer.js +247 -0
  55. package/scripts/use.js +402 -135
@@ -83,6 +83,8 @@ evidence/
83
83
 
84
84
  Với mỗi TC, tạo `evidence/TC_[ID]-[scenario]/result.md`:
85
85
 
86
+ Ngôn ngữ output: auto-detect theo ngôn ngữ của ticket/testcase input — xem `custom/rules/output-language.md` và `custom/skills/test-skills/rules/qa-writing-standards.md` (input tiếng Việt → output tiếng Việt; ngược lại mặc định tiếng Anh; tiêu đề cột bảng vẫn giữ tiếng Anh).
87
+
86
88
  **Template khi PASS:**
87
89
 
88
90
  ```markdown
@@ -213,6 +213,8 @@ Với mỗi TC:
213
213
 
214
214
  Với `kebab-scenario` = Test Case Name lowercase, dấu cách thành `-`, bỏ ký tự đặc biệt.
215
215
 
216
+ Ngôn ngữ output: auto-detect theo ngôn ngữ của ticket/testcase input — xem `custom/rules/output-language.md` và `custom/skills/test-skills/rules/qa-writing-standards.md` (input tiếng Việt → output tiếng Việt; ngược lại mặc định tiếng Anh; tiêu đề cột bảng vẫn giữ tiếng Anh).
217
+
216
218
  **Copy files từ Playwright output:**
217
219
  - Screenshots → `step-NN-{desc}.png`
218
220
  - Trace file → `trace.zip`
@@ -71,6 +71,8 @@ Write the EDA results into the `ml-problem.md` file created by `frame-ml-problem
71
71
  - Leakage assessment — one paragraph per leakage type stating what was checked and what was found
72
72
  - Cleaning actions required before training (drop columns, impute, clip outliers, re-encode)
73
73
 
74
+ Output language: auto-detect from the ticket/task input — see `custom/rules/output-language.md` (Vietnamese input → Vietnamese output; otherwise English).
75
+
74
76
  ---
75
77
 
76
78
  ## Completion Checklist
@@ -86,3 +86,5 @@ If any of the above cannot be answered from the ticket, ask exactly **one questi
86
86
  - [ ] Success threshold quantified (not "as high as possible")
87
87
  - [ ] Constraints listed (latency, memory, interpretability, data volume, compliance)
88
88
  - [ ] Findings written to `AK-Docs/04.Coding/01.Requirements/[functionId]/[ticketId].md` (see `custom/rules/ml-conventions.md` — do NOT use the legacy `plan/[ticket-id]/` path)
89
+
90
+ Output language: auto-detect from the ticket/task input — see `custom/rules/output-language.md` (Vietnamese input → Vietnamese output; otherwise English).
@@ -57,6 +57,8 @@ When generating the output for a gate (e.g. `requirement.md` or `plan.md`), foll
57
57
  ### Step 2: Write the gate output file
58
58
  Write the gate output file (e.g. `AK-Docs/04.Coding/01.Requirements/[functionId]/[ticketId].md`, `AK-Docs/04.Coding/02.Plans/[functionId]/[ticketId].md`, or `docs/ak-[project]/...`) as specified by the gate instructions.
59
59
 
60
+ Output language: auto-detect from the ticket/task input — see `custom/rules/output-language.md` (Vietnamese input → Vietnamese output; otherwise English).
61
+
60
62
  ### Step 3: Display gate pause message
61
63
 
62
64
  Instruct the user to review the generated document. Tell them that they can hover over any line and add inline comments in VS Code using the native commenting UI, or edit the file to add standard HTML comments `<!-- comment -->` if they are not using the VS Code extension.
@@ -75,6 +75,8 @@ Create a detailed step-by-step plan based on the requirement document:
75
75
  ```
76
76
  ```
77
77
 
78
+ Output language: auto-detect from the ticket/task input — see `custom/rules/output-language.md` (Vietnamese input → Vietnamese output; otherwise English).
79
+
78
80
  > For UI tasks, reference the exact node/component from `design-context.md` in the Task column
79
81
  > (e.g. "Build UserCard — nodeId 78-910"). Add an image-copy task when the Image Map is non-empty.
80
82
  >
@@ -61,6 +61,8 @@ Tổng hợp per module theo format template (R1/R2 tracking từ testcase files
61
61
 
62
62
  Output: `test-plan/test-report.md`
63
63
 
64
+ Ngôn ngữ output: auto-detect theo ngôn ngữ của ticket/testcase input — xem `custom/rules/output-language.md` và `custom/skills/test-skills/rules/qa-writing-standards.md` (input tiếng Việt → output tiếng Việt; ngược lại mặc định tiếng Anh; tiêu đề cột bảng vẫn giữ tiếng Anh).
65
+
64
66
  ---
65
67
 
66
68
  ## Gate 4 Display
@@ -65,6 +65,8 @@ Xác định phạm vi ảnh hưởng thật từ code dev **trước khi** gene
65
65
 
66
66
  Liệt kê scenarios theo nhóm, output vào `test-plan/checklist.md`:
67
67
 
68
+ Ngôn ngữ output: auto-detect theo ngôn ngữ của ticket/testcase input — xem `custom/rules/output-language.md` và `custom/skills/test-skills/rules/qa-writing-standards.md` (input tiếng Việt → output tiếng Việt; ngược lại mặc định tiếng Anh; tiêu đề cột bảng vẫn giữ tiếng Anh).
69
+
68
70
  | ID | Scenario/Checklist Item | Mục đích kiểm tra | Expected Result |
69
71
 
70
72
  **Nhóm cần cover:**
@@ -91,6 +91,8 @@ List all:
91
91
  [Specific points QA should pay attention to]
92
92
  ```
93
93
 
94
+ Output language: auto-detect from the ticket/task input — see `custom/rules/output-language.md` (Vietnamese input → Vietnamese output; otherwise English).
95
+
94
96
  ---
95
97
 
96
98
  ## Completion Checklist
@@ -61,6 +61,8 @@ Revert if it does not satisfy the above. Log the failure reason; failed experime
61
61
 
62
62
  Repeat steps 3–5 for the next bottleneck. Log every attempt — including reversions — so the improvement story is fully reproducible. The final state must be explainable: "we tried X (failed because Y), then tried Z (improved metric by W%)."
63
63
 
64
+ Output language: auto-detect from the ticket/task input — see `custom/rules/output-language.md` (Vietnamese input → Vietnamese output; otherwise English).
65
+
64
66
  ---
65
67
 
66
68
  ## Completion Checklist
@@ -0,0 +1,226 @@
1
+ ---
2
+ name: ingest-data
3
+ description: Use when taskType is "ingest-data" — PM/BrSE/Comtor ingesting customer communication (Backlog ticket/comment/Document/Wiki link, Jira link, SharePoint link, or pasted text) into AK-Docs/01.QnA/ logs. Covers fetching the source, classifying it into QnA-Log/Meetings-Log/Confirmations-Log, drafting the entry for self-review before Gate 2 opens the MR, and — auto right after Gate 2 — analyzing the entry to propose a PM-approved task list that gets created as real Backlog/Jira tickets.
4
+ keywords: ingest data, comtor, brse, pm workflow, meeting minutes, qna log, confirmations log, backlog document, backlog wiki, sharepoint, gate 1, gate 2, gate 3, sinh task, tạo ticket
5
+ ---
6
+
7
+ # Ingest Data — Gate 1 (fetch/classify/draft)
8
+
9
+ > **Vai trò:** PM · BrSE · Comtor. **Bối cảnh đầy đủ:** `docs/internal/PM Workflow_v1.0.md` (Flow A + Flow B).
10
+ > Gate mechanics (khi nào chạy Gate 1 vs Gate 2) nằm ở `custom/templates/shared/gate-workflow.md` § "ingest-data Task Type". File này chỉ mô tả **cách làm** của Gate 1: fetch nguồn → phân loại → soạn draft.
11
+
12
+ ---
13
+
14
+ ## 1. Input được hỗ trợ
15
+
16
+ | Input | Cách xử lý |
17
+ |---|---|
18
+ | Backlog ticket link (`/view/PROJ-N`) hoặc comment (`#comment-N`) | `ak fetch-links "<url>"` → JSON `{ sourceType: "ticket" \| "comment", ... }` |
19
+ | Backlog Document link (`/document/{id}` hoặc `/alias/document/{id}`) | `ak fetch-links "<url>"` → JSON `{ sourceType: "document" \| "document-comment", ... }`. ⚠️ API Document của Nulab còn mới (2026) — nếu lệnh trả lỗi HTTP 404, báo lại cho người dùng, đây là dấu hiệu endpoint cần điều chỉnh, không phải lỗi ở phía bạn. |
20
+ | Backlog Wiki link (`/alias/wiki/{id}`) | `ak fetch-links "<url>"` → JSON `{ sourceType: "wiki", ... }` |
21
+ | Jira ticket/comment link | `ak fetch-links "<url>"` → JSON `{ sourceType: "ticket" \| "comment", ... }` |
22
+ | SharePoint link (`*.sharepoint.com`) | `ak fetch-links "<url>"` → `{ sourceType: "unsupported", reason: "sharepoint-not-configured" }`. **Không có connector** (cần Microsoft Graph API + OAuth, xem PM Workflow doc "Vấn đề 4" — chưa làm POC). Hiển thị `message` trong JSON cho người dùng, và đề nghị: "Paste trực tiếp nội dung comment/tài liệu vào chat, mình sẽ dùng luôn." |
23
+ | Plain text (paste trực tiếp trong chat, hoặc `ak use --manual`) | Dùng nguyên văn `description` từ `.aiflow/context/current.json` — không cần fetch gì thêm. |
24
+
25
+ Nếu input không khớp bất kỳ dạng nào ở trên (`ak fetch-links` trả lỗi "Not a recognized... URL", exit code 1) → hỏi lại người dùng: link có đúng không, hoặc paste nội dung trực tiếp.
26
+
27
+ ---
28
+
29
+ ## 2. Phân loại — QnA-Log / Meetings-Log / Confirmations-Log
30
+
31
+ | Log | Khi nào dùng | Nguồn điển hình |
32
+ |---|---|---|
33
+ | `QnA-Log.md` | Trao đổi hỏi-đáp thông thường với khách hàng | Backlog ticket/comment, Jira ticket/comment, SharePoint comment (paste text), text ngắn |
34
+ | `Meetings-Log.md` | Tổng hợp nội dung 1 buổi họp (khách hoặc nội bộ) | Backlog Document, Backlog Wiki, text dài có cấu trúc (attendees/agenda/action items) |
35
+ | `Confirmations-Log.md` | Mốc khách hàng **CHỐT chính thức** một spec/thay đổi | Bất kỳ nguồn nào, miễn nội dung là 1 xác nhận dứt điểm |
36
+
37
+ **Heuristic gợi ý** (không phải luật cứng):
38
+ - Nội dung có "họp", "meeting", "kickoff", "sprint review", danh sách người tham dự → nghiêng về **Meetings-Log**.
39
+ - Nội dung có "confirm", "chốt", "OK approved", "đồng ý chính thức", đi kèm 1 quyết định rõ ràng, dứt điểm → nghiêng về **Confirmations-Log**.
40
+ - Còn lại (hỏi/đáp, feedback, trao đổi qua lại chưa dứt điểm) → **QnA-Log**.
41
+
42
+ > ⚠️ **Quy tắc phân biệt "confirm chính thức" vs "trao đổi thường" CHƯA được PM chốt** (xem `PM Workflow_v1.0.md` § "Vấn đề còn mở" #1). Khi không chắc content nào — **luôn hỏi lại người dùng** để chọn log đích, không tự quyết định âm thầm. Một khi PM ra quy tắc rõ ràng, cập nhật heuristic ở đây.
43
+
44
+ ---
45
+
46
+ ## 3. Template từng file (dùng đúng, không tự đổi cấu trúc)
47
+
48
+ Cả 3 file nằm trong `AK-Docs/01.QnA/` (giữ nguyên tên thư mục hiện có — **không** đổi thành `01.Communications/` như một phương án còn đang chờ PM chốt trong `PM Workflow_v1.0.md`; nếu PM sau này quyết định đổi tên thư mục, đó là một task migration riêng).
49
+
50
+ Nếu file đích **chưa tồn tại**, tạo file mới với đúng header dưới đây rồi mới append entry.
51
+
52
+ ### 3.1 `QnA-Log.md` (file có sẵn — mở rộng thêm cột `Nguồn`)
53
+
54
+ Header hiện tại của file có thể chỉ có 5 cột (`Date | Asked By | Question | Answer | Status`). Nếu vậy, **thêm cột `Nguồn` vào cuối** (sửa header + backfill các dòng cũ bằng `—`) rồi mới append dòng mới — để mọi entry từ giờ đều trace được nguồn gốc (yêu cầu traceability, xem PM Workflow doc § "Vấn đề 6"):
55
+
56
+ ```markdown
57
+ | Date | Asked By | Question | Answer | Status | Nguồn |
58
+ |---|---|---|---|---|---|
59
+ | 2026-08-04 | Khách hàng ABC | <tóm tắt câu hỏi> | <tóm tắt câu trả lời, hoặc "—" nếu chưa có> | Pending / Answered | [<mô tả ngắn>](<url hoặc "pasted text">) |
60
+ ```
61
+
62
+ ### 3.2 `Meetings-Log.md` (file mới — tạo nếu chưa có)
63
+
64
+ ```markdown
65
+ # Meetings Log
66
+
67
+ > Meeting minutes với khách hàng hoặc nội bộ — tổng hợp bởi Comtor/BrSE, PM approve tại nguồn trước khi ingest vào đây (xem Flow A trong PM Workflow_v1.0.md).
68
+
69
+ ---
70
+
71
+ ## [YYYY-MM-DD] <Tiêu đề buổi họp>
72
+
73
+ | Trường | Giá trị |
74
+ |---|---|
75
+ | **Nguồn** | [<mô tả ngắn>](<url Backlog Document/Wiki, hoặc "pasted text">) |
76
+ | **functionId** | <functionId, hoặc `general` nếu không gắn riêng 1 feature> |
77
+ | **Người tổng hợp** | <Comtor/BrSE — tên người chạy lệnh ingest> |
78
+ | **Người approve tại nguồn** | PM — <ngày approve, nếu biết; nếu không biết, hỏi người dùng> |
79
+
80
+ **Tóm tắt nội dung:**
81
+ <nội dung — giữ đủ ý, không rút gọn quá mức>
82
+
83
+ **Action items:**
84
+ - [ ] <action item 1, nếu có>
85
+
86
+ ---
87
+ ```
88
+
89
+ Mỗi lần ingest thêm 1 buổi họp mới → append 1 block `## [YYYY-MM-DD] ...` mới vào cuối file (chronological).
90
+
91
+ ### 3.3 `Confirmations-Log.md` (file mới — tạo nếu chưa có)
92
+
93
+ ```markdown
94
+ # Confirmations Log
95
+
96
+ > Mốc khách hàng CHỐT chính thức — trích từ Meeting Minutes (Backlog) hoặc comment "OK confirm" (SharePoint/Backlog).
97
+ > ⚠️ Quy tắc phân biệt "confirm chính thức" vs "trao đổi thường" CHƯA được PM chốt (xem PM Workflow_v1.0.md § "Vấn đề còn mở" #1) — khi chưa rõ, hỏi lại người ingest trước khi ghi vào đây.
98
+
99
+ | Date | Nội dung chốt | functionId | Nguồn |
100
+ |---|---|---|---|
101
+ | 2026-08-04 | <mô tả ngắn mốc chốt> | <functionId hoặc general> | [<mô tả ngắn>](<url hoặc "pasted text">) |
102
+ ```
103
+
104
+ ---
105
+
106
+ ## 4. Soạn draft — hiển thị đầy đủ, không tóm tắt
107
+
108
+ Sau khi fetch + phân loại, soạn đúng 1 entry theo template tương ứng ở mục 3, rồi hiển thị **nguyên văn** entry đó cho người dùng (không tóm tắt, không giấu bớt nội dung) kèm footer theo mẫu trong `gate-workflow.md` § "ingest-data" Gate 1 bước 5.
109
+
110
+ **Không tự ghi file, không tự tạo branch** ở bước này — chỉ hiển thị draft trong hội thoại. Việc ghi file + branch + MR chỉ chạy ở Gate 2, sau khi người dùng gõ **APPROVED**.
111
+
112
+ Nếu người dùng yêu cầu sửa (thêm/bớt ý, đổi log đích, sửa functionId...) → cập nhật lại draft, hiển thị lại toàn bộ, chờ APPROVED lại — lặp cho tới khi được duyệt.
113
+
114
+ ---
115
+
116
+ ## 5. Gate 3 — Sinh & Duyệt Task List, Tạo Ticket (auto, ngay sau Gate 2)
117
+
118
+ > Implement "Vấn đề 5" trong `docs/internal/PM Workflow_v1.0.md`. **Trigger đã chốt: TỰ ĐỘNG** — chạy ngay tiếp theo Gate 2 (MR ingest vừa mở xong), không cần lệnh riêng, không chờ PM merge MR trước (merge MR là việc của PM ở luồng riêng, không block bước này).
119
+ > Gate mechanics chi tiết (khi nào gọi lệnh nào) nằm ở `custom/templates/shared/gate-workflow.md` § "ingest-data Task Type" → GATE 3. File này chỉ mô tả **cách phân tích và đề xuất**.
120
+
121
+ ### 5.1 Bước 1 — Đọc lại entry + điều tra phạm vi ảnh hưởng
122
+
123
+ Đọc lại đúng entry vừa ghi ở Gate 2 (Meetings-Log.md / QnA-Log.md / Confirmations-Log.md — nguyên văn nội dung người dùng đã input ở Gate 1, không phải bản tóm tắt). Sau đó:
124
+
125
+ 1. Xác định `functionId` liên quan (đã có trong entry, hoặc `general`).
126
+ 2. Đọc source code + tài liệu hiện có liên quan đến `functionId` đó (UC Spec ở `AK-Docs/02.BA-Specs/04.UC-Specs/[functionId]/`, code trong repo source, `AK-Docs/04.Coding/00.Overview/_Index.md`) để hiểu **hệ thống hiện tại đang làm gì**, từ đó đánh giá nội dung mới vừa ingest tác động tới đâu.
127
+ 3. Nếu nội dung có Action items rõ ràng trong template Meeting Minutes (mục 3.2) — đây là gợi ý mạnh cho danh sách task, không bỏ qua.
128
+
129
+ ### 5.2 Bước 2 — Quyết định: có cần task hay không
130
+
131
+ **Không phải mọi entry đều sinh ra task.** Trước khi đề xuất bất kỳ task nào, tự hỏi: nội dung này có yêu cầu một hành động cụ thể (thay đổi spec, code, test, tài liệu...) hay chỉ là thông tin tham khảo/FYI (cập nhật tiến độ, thông tin không đổi hành vi hệ thống, trả lời một câu hỏi đã đóng)?
132
+
133
+ - **Chỉ là tham khảo** → hiển thị: `ℹ️ Nội dung này không phát sinh task — chỉ lưu làm tài liệu tham khảo. Gate 3 kết thúc.` rồi dừng, không hỏi thêm, không chạy `ak gate 3 start`.
134
+ - **Có hành động cụ thể** → tiếp tục Bước 3. Khi không chắc (ví dụ nội dung vừa có FYI vừa có 1 ý cần sửa code) — nghiêng về đề xuất task cho phần cần hành động, bỏ qua phần FYI, không tự bịa task cho phần không rõ.
135
+
136
+ ### 5.3 Bước 3 — Đề xuất danh sách task
137
+
138
+ Mỗi task gồm:
139
+
140
+ | Trường | Ghi chú |
141
+ |---|---|
142
+ | `type` | `spec` (tạo/update UC Spec) · `coding` · `test` · `other` (update tài liệu không thuộc BA/QA/Dev, vd Rules) |
143
+ | `title` | Ngắn, hành động rõ (vd "Cập nhật flow OTP theo feedback khách — tăng thời hạn 30s → 90s") |
144
+ | `track` | BA / Dev / QA — để PM biết ai sẽ nhận task này |
145
+ | `description` | Theo đúng template mục 6.1 `PM Workflow_v1.0.md`: |
146
+
147
+ ```text
148
+ ## Nội dung task
149
+ [Mô tả task do AI đề xuất]
150
+
151
+ ## Nguồn tham chiếu
152
+ - Văn bản gốc: [<mô tả ngắn>](<url hoặc "pasted text">)
153
+ - Log AK-Docs: AK-Docs/01.QnA/[QnA-Log.md | Meetings-Log.md | Confirmations-Log.md] (entry ngày <ngày>)
154
+ ```
155
+
156
+ Riêng task `type: "spec"` — thêm 2 mục bắt buộc theo mục 6.1, và **hỏi PM xin link hồ sơ cam kết thay đổi nếu chưa có sẵn** (không tự suy luận):
157
+
158
+ ```text
159
+ ## Tổng quan nội dung thay đổi
160
+ [Tóm tắt: thay đổi gì, vì sao thay đổi]
161
+
162
+ ## Nguồn tham chiếu
163
+ - Hồ sơ cam kết thay đổi: [<mô tả ngắn>](<URL do PM cung cấp>)
164
+ - Log AK-Docs (nếu có): AK-Docs/01.QnA/Meetings-Log.md (entry ngày <ngày>)
165
+ ```
166
+
167
+ Hiển thị toàn bộ danh sách cho PM xem — đủ cả `type`/`title`/`track`/`description`, không tóm tắt.
168
+
169
+ ### 5.4 Bước 4 — PM review, sửa trực tiếp trong hội thoại
170
+
171
+ PM có thể **thêm / sửa / xoá từng task** ngay trong lượt review này (không phải chỉ APPROVED/reject toàn bộ) — cập nhật lại danh sách theo đúng yêu cầu, hiển thị lại toàn bộ, lặp lại cho tới khi PM hài lòng. Task nào type là `spec` mà thiếu "Nguồn tham chiếu" (hồ sơ cam kết thay đổi) → coi như chưa đủ điều kiện, phải hỏi PM bổ sung trước khi cho vào vòng xác nhận tạo ticket ở Bước 5.
172
+
173
+ ### 5.5 Bước 5 — Điểm dừng xác nhận tạo ticket
174
+
175
+ Hỏi đúng 1 câu, không tự thêm `--yes`:
176
+
177
+ ```text
178
+ Danh sách task như trên (N task) — đồng ý tạo trên [Backlog/Jira]?
179
+ ```
180
+
181
+ - Xác định target `backlog`/`jira` theo đúng adapter của ticket/document gốc đã ingest ở Gate 1/2 (Backlog → target backlog; Jira → target jira). Nếu nguồn là pasted text/SharePoint (không rõ adapter) → hỏi PM muốn tạo trên hệ thống nào.
182
+ - **KHÔNG ĐỒNG Ý** → dừng, để PM tự chỉnh sửa rồi yêu cầu lại (quay lại Bước 4).
183
+ - **ĐỒNG Ý** → sang Bước 6.
184
+
185
+ ### 5.6 Bước 6 — Xác định project đích
186
+
187
+ Check LOCAL trước, chỉ hỏi khi thật sự chưa biết (Vấn đề 5.1):
188
+
189
+ 1. Backlog: kiểm tra `BACKLOG_DEFAULT_PROJECT_ID` đã lưu chưa (chạy `ak backlog-projects --json`, đọc field `defaultProjectId`). Jira: `ak jira-projects --json`, đọc `defaultProjectKey`.
190
+ 2. Đã có → dùng luôn, hiển thị rõ cho PM biết đang dùng project nào + nguồn (đã lưu từ lần trước).
191
+ 3. Chưa có → hiển thị danh sách project vừa fetch được, PM chọn 1 → lưu lại bằng `ak backlog-set-default-project <id> <key>` hoặc `ak jira-set-default-project <key>` — để lần sau không hỏi lại.
192
+
193
+ ### 5.7 Bước 7 — Tạo ticket
194
+
195
+ 1. Ghi danh sách task đã duyệt ra 1 file JSON tạm (vd `.aiflow/tmp/tasks-[ticketId].json`), đúng shape mà `ak tasks create-tickets` đọc (xem `scripts/ticket-writer.js`):
196
+ ```json
197
+ {
198
+ "target": "backlog",
199
+ "tasks": [
200
+ { "type": "coding", "title": "...", "description": "..." }
201
+ ]
202
+ }
203
+ ```
204
+ 2. Chạy `ak tasks create-tickets <file> --json`.
205
+ 3. Đọc kết quả JSON trả về:
206
+ - `{"error":"missing-write-credentials", "field": "...", "message": "..."}` → **đây không phải lỗi hệ thống** — hiển thị đúng `message` cho PM, hỏi PM nhập giá trị key ngay trong hội thoại (dùng luôn khung chat làm nơi PM "nhập & submit"), nhận giá trị → chạy `ak credentials set <field> "<giá trị PM vừa nhập>"` → chạy lại bước 2 (retry đúng 1 lần; nếu vẫn lỗi, báo PM key có thể sai/chưa đủ quyền, không tự thử lại vô hạn).
207
+ - `{"error":"missing-project", ...}` → quay lại Bước 6 (chưa xác định được project).
208
+ - Thành công (`ok: true`) → mỗi task có `ticketId` + `url` riêng; task nào `ok: false` (lỗi phía Backlog/Jira, vd thiếu field) → báo rõ cho PM, các task khác đã tạo vẫn giữ nguyên (không rollback).
209
+
210
+ ### 5.8 Bước 8 — Ghi ngược liên kết + đóng Gate
211
+
212
+ 1. Append vào cuối đúng entry gốc (Meetings-Log/QnA-Log/Confirmations-Log) 1 dòng:
213
+ ```text
214
+ → Tasks created: TICKET-101 (coding), TICKET-102 (test)
215
+ ```
216
+ Việc sửa file này đi qua đúng branch đang dùng ở Gate 2 (không tạo MR riêng — gộp vào cùng thay đổi, hoặc nếu MR đã mở/merge thì tạo 1 commit nhỏ tiếp theo trên cùng branch/1 MR mới tuỳ trạng thái branch lúc đó).
217
+ 2. Hiển thị tổng kết:
218
+ ```text
219
+ ✅ GATE 3 DONE — Đã tạo N/N ticket trên [Backlog/Jira]:
220
+ - TICKET-101 (coding) — <url>
221
+ - TICKET-102 (test) — <url>
222
+ → Dev/QA chạy `ak use TICKET-XXX` trên từng ticket để bắt đầu Gate tương ứng (Coding/QA workflow hiện có).
223
+ ```
224
+ 3. Run: `ak gate 3 approved --ticket [ticket-id]`.
225
+
226
+ > **Telemetry:** Run `ak gate 3 start --ticket [ticket-id]` khi bắt đầu Bước 1 (bỏ qua nếu Bước 2 kết luận không cần task — không start gate cho trường hợp "chỉ tham khảo"). Run `ak gate 3 approved --ticket [ticket-id]` khi Bước 8 xong.
@@ -44,6 +44,8 @@ Thu thập ngay khi test fail:
44
44
  **File naming:** `bugs/BUG-[số thứ tự 3 chữ số]-[tên ngắn kebab-case].md`
45
45
  **Ví dụ:** `bugs/BUG-001-login-button-not-disabled-on-submit.md`
46
46
 
47
+ Ngôn ngữ output: auto-detect theo ngôn ngữ của ticket/testcase input — xem `custom/rules/output-language.md` và `custom/skills/test-skills/rules/qa-writing-standards.md` (input tiếng Việt → output tiếng Việt; ngược lại mặc định tiếng Anh; tiêu đề cột bảng vẫn giữ tiếng Anh).
48
+
47
49
  **Dùng template bên dưới.**
48
50
 
49
51
  ### Bước 4 — Thông báo TESTER
@@ -142,6 +142,8 @@ Ngoài TCs gốc của feature, cần test thêm:
142
142
  | Verify Admin User list không bị cache stale | Shared service thay đổi |
143
143
  ```
144
144
 
145
+ Ngôn ngữ output: auto-detect theo ngôn ngữ của ticket/task input — xem `custom/rules/output-language.md` (input tiếng Việt → output tiếng Việt; ngược lại mặc định tiếng Anh).
146
+
145
147
  ---
146
148
 
147
149
  ## Guard Rails (bắt buộc)
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: read-study-requirement
3
- description: Gate 1 — AI reads ticket from Backlog/Jira + reads source code, then uses collaborative Q&A and solution proposal. Adds impact analysis and effort estimate. Outputs requirement.md for DEV to approve.
4
- keywords: ticket, requirement, study, read, context, backlog, jira, analyze, understand, solution, estimate
3
+ description: Gate 1 — AI reads ticket from Backlog/Jira + reads source code, then uses collaborative Q&A and solution proposal. Adds impact analysis and effort estimate. Outputs requirement.md for DEV to approve. Checks that System Requirement (bridged from UC Spec via `create-system-requirement`) exists and matches the current UC Spec version — shows a non-blocking ⚠️ warning and continues otherwise.
4
+ keywords: ticket, requirement, study, read, context, backlog, jira, analyze, understand, solution, estimate, system requirement, uc spec
5
5
  ---
6
6
 
7
7
  # Analyze Requirement — Gate 1
@@ -12,6 +12,23 @@ keywords: ticket, requirement, study, read, context, backlog, jira, analyze, und
12
12
 
13
13
  ---
14
14
 
15
+ ## Step 0: System Requirement Check (Pre-flight, non-blocking warning — runs before Mode Selection)
16
+
17
+ Before reading the ticket in depth, verify the bridge document from UC Spec — this applies to **every mode**, including Fast Track (it's a 2-file header check, not a heavy investigation). **This check never cancels Gate 1** — any gap only produces a ⚠️ yellow warning; Gate 1 always continues with whatever context is available:
18
+
19
+ 1. Resolve `functionId` from `.aiflow/context/current.json` (or ask DEV once if absent).
20
+ 2. Locate the current UC Spec: `AK-Docs/02.BA-Specs/04.UC-Specs/[functionId]/UC-Spec_v{N}.md` (highest non-archived version).
21
+ - **Not found** → `⚠️ CẢNH BÁO: Không tìm thấy UC Spec cho [functionId] — Gate 1 tiếp tục chỉ dựa trên ticket/source code, thiếu ngữ cảnh nghiệp vụ BA đã chốt.` Continue to step 3.
22
+ 3. Check `AK-Docs/02.BA-Specs/00.Requirements/[functionId]/System-Requirement_v*.md`:
23
+ - **Missing** → `⚠️ CẢNH BÁO: Không tìm thấy System Requirement cho [functionId]. Khuyến nghị chạy "ak use" → "📐 Create System Requirement" trước ticket kế tiếp — Gate 1 vẫn tiếp tục ngay bây giờ dựa trên UC Spec/ticket.`
24
+ - **Exists, but its `UC-Spec-Version` header doesn't match the UC Spec found in step 2** → `⚠️ CẢNH BÁO: System Requirement đang trace theo UC Spec v[X], UC Spec hiện tại là v[Y] — nội dung có thể lỗi thời.` Treat its items as Assumption rather than Fact in Step 1.75.
25
+ - **Exists, matches, but its `Status` header is not `✅ Approved`** → `⚠️ CẢNH BÁO: System Requirement cho [functionId] chưa Approved (Status: [giá trị hiện tại]) — nội dung có thể còn thay đổi.`
26
+ - **Exists, matches, and Approved** → continue silently. Keep this file's path — Step 1 must read it as mandatory input.
27
+
28
+ Any warning raised above must also be written into this ticket's requirement doc (Section 1, Facts/Assumptions/Gaps in Step 4) — not just printed and forgotten. If DEV wants the gap closed properly, they can run `ak use` → "📐 Create System Requirement" for `[functionId]` at any point (before or after this ticket) — it's a separate 2-gate task type, not an inline sub-skill here.
29
+
30
+ ---
31
+
15
32
  ## Mode Selection
16
33
 
17
34
  Check `mode` in `.aiflow/context/current.json` before starting:
@@ -43,6 +60,7 @@ When creating `AK-Docs/04.Coding/04.Reviews/[functionId]/[ticketId].md` during G
43
60
  - Uncommitted changes detected → SKIP pull and notify DEV: `⚠️ Uncommitted changes detected — skipping git pull. Analysing local state.`
44
61
  - `git pull --ff-only` fails (branch diverged from remote) → notify DEV: `⚠️ Local branch diverged from remote — skipping pull. Resolve manually before next ticket.` Then continue with local state.
45
62
  1. Read `.aiflow/context/current.json` — ticket title, description, acceptance criteria
63
+ 1b. Read `System-Requirement_v{N}.md` for this functionId (confirmed to exist by Step 0) — the authoritative WHAT. Reference its item IDs (`FR-*`, `VR-*`, `ER-*`) instead of restating them.
46
64
  2. Identify **directly affected files** from ticket text and file names only.
47
65
  DO NOT trace data flow or read unrelated source files.
48
66
  3. Q&A: Ask at most **ONE** question if there is a blocking ambiguity.
@@ -74,6 +92,8 @@ When creating `AK-Docs/04.Coding/04.Reviews/[functionId]/[ticketId].md` during G
74
92
  | **Total** | **S/M/L** |
75
93
  ```
76
94
 
95
+ Output language: auto-detect from the ticket/task input — see `custom/rules/output-language.md` (Vietnamese input → Vietnamese output; otherwise English).
96
+
77
97
  5. Display Gate 1 prompt and wait for `APPROVED`.
78
98
 
79
99
  > After APPROVED, proceed to Gate 2.
@@ -93,6 +113,7 @@ When creating `AK-Docs/04.Coding/04.Reviews/[functionId]/[ticketId].md` during G
93
113
  - `git pull --ff-only` fails because the branch has diverged → notify DEV: `⚠️ Local branch diverged from remote — skipping pull. Resolve manually before next ticket.` Continue with local state.
94
114
  - Repo has no remote tracking branch (detached HEAD or local-only branch) → skip silently and proceed.
95
115
  1. Read `.aiflow/context/current.json` — ticket info from Backlog/Jira
116
+ 1b. Read `System-Requirement_v{N}.md` for this functionId (confirmed to exist and in-sync by Step 0) — this is the authoritative WHAT for the whole functionId. Reference its item IDs (`FR-*`, `NFR-*`, `VR-*`, `ER-*`) in your analysis instead of re-deriving requirements it already covers.
96
117
  2. **Supplementary Context:** If `current.json` has a `supplementaryContext[]` array, read each item and integrate it as supporting context for your analysis. Items may be:
97
118
  - `[ticket]` — linked tickets (related features, dependencies, parent tickets)
98
119
  - `[comment]` — specific comments from PM/QA/stakeholders
@@ -237,6 +258,18 @@ After the developer confirms the design direction (Step 2), run full impact anal
237
258
 
238
259
  ---
239
260
 
261
+ ### Step 3.5: Reconcile with System Requirement
262
+
263
+ Compare this ticket's confirmed scope (Steps 1–3) against `System-Requirement_v{N}.md` (read in Step 1):
264
+
265
+ - Scope already covered by an existing item → reference its ID (e.g. `FR-03`, `ER-02`) in Section 1 of the requirement doc below. Do not restate it.
266
+ - Investigation surfaces a case, rule, or exception the UC Spec supports but System Requirement missed → **propose** an addition: show DEV the exact diff (which section, new row) before writing anything.
267
+ - DEV confirms → append to `System-Requirement_v{N}.md` (same version — this does **not** bump `System-Requirement-Version`) + add a `Change Log` row citing this ticket.
268
+ - DEV declines/unsure → leave System Requirement untouched; note the discrepancy in this ticket's own requirement doc (Section 1, Facts/Assumptions/Gaps) instead.
269
+ - Scope doesn't trace to System Requirement **or** UC Spec at all → this is the fabrication risk proposal #7 targets. STOP and ask DEV: is this actually in scope for this functionId, or does the UC Spec need a BA update first? Do not proceed on a guess.
270
+
271
+ ---
272
+
240
273
  ### Step 4: Write Requirement Document
241
274
 
242
275
  Save to `AK-Docs/04.Coding/01.Requirements/[functionId]/[ticketId].md`:
@@ -432,11 +465,17 @@ Please review the requirement document.
432
465
  | Effort estimate | This skill |
433
466
  | requirement.md template & output | This skill |
434
467
  | Gate 1 APPROVED gate | This skill |
468
+ | System Requirement creation/versioning/sync | `create-system-requirement` task type (separate, own 2 gates) |
469
+ | Mid-ticket addition proposal (Step 3.5 triggers it) | `create-system-requirement` owns the write contract (its Step 8) |
435
470
 
436
471
  ---
437
472
 
438
473
  ## Mandatory Rules
439
474
 
475
+ - ✅ **MUST** verify System Requirement exists and matches the current UC Spec version (Step 0) before proceeding — show a ⚠️ non-blocking warning and continue otherwise (never cancels Gate 1); record the gap in the requirement doc (Step 4).
476
+ - ✅ **MUST** read System Requirement as mandatory input (Step 1) — not optional context.
477
+ - ❌ **DO NOT** restate content already covered in System Requirement — reference its item ID instead.
478
+ - ❌ **DO NOT** silently accept ticket scope that doesn't trace to System Requirement or UC Spec (Step 3.5) — stop and ask instead of guessing.
440
479
  - ❌ **DO NOT** invoke `superpowers:brainstorming` — its terminal state calls `writing-plans` and bypasses Gate 1 approval
441
480
  - ❌ **DO NOT** invoke `superpowers:writing-plans` — that belongs to Gate 2 (`generate-spec` skill)
442
481
  - ❌ **DO NOT** proceed past Step 2 if design is not confirmed by developer
@@ -31,7 +31,11 @@ Fill in the structure below. **Use simple language, avoiding technical jargon.**
31
31
 
32
32
  ---
33
33
 
34
- ## Standard Structure (English)
34
+ ## Standard Structure
35
+
36
+ Output language: auto-detect from the ticket/task input — see `custom/rules/output-language.md`
37
+ (Vietnamese ticket → Vietnamese report; otherwise English). CS can request a specific language
38
+ explicitly, which overrides auto-detect. Structure below is shown in English.
35
39
 
36
40
  ```markdown
37
41
  ## 📋 Incident Verification Report
@@ -92,4 +96,4 @@ If problems persist, please contact our support hotline..."]
92
96
  - ❌ Do not blame third parties unless certain
93
97
  - ❌ Do not commit to specific deadlines unless certain
94
98
 
95
- Present clearly and professionally. Default is English unless otherwise requested.
99
+ Present clearly and professionally, in the language determined above.
@@ -84,6 +84,8 @@ BASE_URL=<baseUrl> npx playwright test --grep "AD10_002|AD10_005" --headed
84
84
 
85
85
  Invoke `evidence-aggregation` skill cho RETEST results:
86
86
 
87
+ Ngôn ngữ output: auto-detect theo ngôn ngữ của ticket/testcase input — xem `custom/rules/output-language.md` và `custom/skills/test-skills/rules/qa-writing-standards.md` (input tiếng Việt → output tiếng Việt; ngược lại mặc định tiếng Anh; tiêu đề cột bảng vẫn giữ tiếng Anh).
88
+
87
89
  **Không xóa evidence cũ** — tạo subfolder theo run:
88
90
 
89
91
  ```
@@ -143,6 +143,8 @@ Create file `AK-Docs/04.Coding/04.Reviews/[functionId]/[ticketId].md`:
143
143
  **Breaking changes:** None / [description if any]
144
144
  ```
145
145
 
146
+ Output language: auto-detect from the ticket/task input — see `custom/rules/output-language.md` (Vietnamese input → Vietnamese output; otherwise English).
147
+
146
148
  ### Step 2.5: Retrospect + propose memory drafts
147
149
 
148
150
  Synthesize what was learned this task. **Priority order — human corrections first:** if this is a repeat pass through Gate 4 (the developer already sent "BUG: ..." at least once this task), the developer's own correction is the single highest-value lesson — scan back through this session for it and draft it even if you already drafted something for the earlier BUG at Step 4 (dedup will catch an exact repeat; don't skip capturing it out of caution). Only after that, add anything else genuinely new: architecture facts discovered, decisions made and why. For each candidate, create a **local draft** (no approval needed yet — `_pending/` is local-only, doc `docs/common/Memory-Architecture-v1.0.md`):
@@ -205,4 +205,4 @@ Trả về danh sách kết quả cho `execute-flow`:
205
205
  - ❌ **Không overwrite** test block có hash match — skip hoàn toàn
206
206
  - ✅ Ưu tiên locator: `getByRole` > `getByLabel` > `getByPlaceholder` > `getByText` > `getByTestId` > CSS
207
207
  - ✅ Không tạo lại `BasePage.ts` / `fixtures/test.ts` nếu đã tồn tại
208
- - ✅ Viết test names comments bằng tiếng Việt
208
+ - ✅ Test names/comments theo ngôn ngữ của TC input (xem `custom/rules/output-language.md`) — TC tiếng Việt → tiếng Việt, TC tiếng Anh → tiếng Anh
@@ -107,6 +107,8 @@ Dựa trên ticket/description, phân tích:
107
107
 
108
108
  Tạo `test-plan/test-analysis.md`:
109
109
 
110
+ Ngôn ngữ output: auto-detect theo ngôn ngữ của ticket/testcase input — xem `custom/rules/output-language.md` và `custom/skills/test-skills/rules/qa-writing-standards.md` (input tiếng Việt → output tiếng Việt; ngược lại mặc định tiếng Anh; tiêu đề cột bảng vẫn giữ tiếng Anh).
111
+
110
112
  ```markdown
111
113
  # Test Analysis: [Ticket ID / Feature Name]
112
114
 
@@ -8,8 +8,8 @@
8
8
 
9
9
  ## 1. Ngôn ngữ & văn phong
10
10
 
11
- - Nội dung mô tả/diễn giải bằng **tiếng Việt**.
12
- - **Tiêu đề cột của bảng (checklist, testcase) viết bằng tiếng Anh** theo quy ước team; **nội dung trong ô viết tiếng Việt**.
11
+ - Ngôn ngữ nội dung mô tả/diễn giải **auto-detect theo ngôn ngữ của ticket/input** — xem `custom/rules/output-language.md`: input tiếng Việt → viết tiếng Việt (mặc định trước đây); input tiếng Anh → viết tiếng Anh.
12
+ - **Tiêu đề cột của bảng (checklist, testcase) luôn viết bằng tiếng Anh** theo quy ước team, bất kể ngôn ngữ nội dung ô; **nội dung trong ô theo ngôn ngữ đã xác định ở trên**.
13
13
  - Thuật ngữ kỹ thuật/test có thể giữ tiếng Anh trong ngoặc khi cần (vd: kiểm thử biên (boundary)).
14
14
  - Viết ngắn gọn, rõ ràng, không lan man. Ưu tiên gạch đầu dòng và bảng.
15
15
 
@@ -49,6 +49,8 @@ Log the following to MLflow or wandb for every run:
49
49
 
50
50
  Do not leave runs unnamed or untracked.
51
51
 
52
+ Output language: auto-detect from the ticket/task input — see `custom/rules/output-language.md` (Vietnamese input → Vietnamese output; otherwise English).
53
+
52
54
  ### 5. Checkpointing
53
55
 
54
56
  Save the best checkpoint by the primary validation metric (not the final epoch). Store the config file alongside the artifact so the checkpoint is self-contained. Use the model registry (MLflow Model Registry or equivalent) when available.
@@ -90,7 +90,7 @@ Ví dụ: `functionId = AD06` → thư mục gốc là `03.Testing/`
90
90
  ```
91
91
  (AI-Artifacts/ = 03.Testing/07.AI-Artifacts/ — viết tắt cho ngắn gọn)
92
92
 
93
- [Input: SRS / Jira / Backlog / Spec file] → Pre-flight: BẮT BUỘC xác định functionId
93
+ [Input: UC Spec + System Requirement (bắt buộc, cảnh báo nếu thiếu) / SRS / Jira / Backlog / Spec file] → Pre-flight: BẮT BUỘC xác định functionId
94
94
 
95
95
  Gate 1: Phân tích yêu cầu & Đánh giá rủi ro → AI-Artifacts/[functionId]/
96
96
  ↓ APPROVED
@@ -169,8 +169,37 @@ Trước khi ghi bất kỳ file nào vào `03.Testing/`, đảm bảo AK-Docs
169
169
 
170
170
  > ❌ Không tự thêm `--yes` khi chưa thấy QA gõ xác nhận rõ ràng trong hội thoại.
171
171
 
172
+ #### Bước 0.6: Kiểm tra UC Spec & System Requirement (input bắt buộc, cảnh báo non-blocking)
173
+
174
+ **Mục tiêu:** Test Case phải được thiết kế dựa trên cả UC Spec (yêu cầu nghiệp vụ do BA chốt) **và** System Requirement (bản dịch kỹ thuật cho Dev — Validation Rule, Exception/Error Handling, Acceptance Test) — thiếu một trong hai, TC dễ bỏ sót case mà Dev đã implement hoặc case BA đã đặc tả.
175
+
176
+ 1. Tìm UC Spec: `AK-Docs/02.BA-Specs/04.UC-Specs/[functionId]/UC-Spec_v{N}.md` (version cao nhất, không phải bản archive).
177
+ 2. Tìm System Requirement: `AK-Docs/02.BA-Specs/00.Requirements/[functionId]/System-Requirement_v*.md` (version cao nhất).
178
+ 3. Nếu tìm thấy System Requirement, đọc 2 header của nó: `UC-Spec-Version` (phải khớp version UC Spec tìm được ở bước 1) và `Status` (phải là `✅ Approved`).
179
+
180
+ Nếu **bất kỳ** điều kiện sau không thỏa mãn → hiển thị cảnh báo tương ứng, **không dừng/không cancel Gate 1** — vẫn tiếp tục với dữ liệu hiện có:
181
+
182
+ | Tình huống | Cảnh báo hiển thị |
183
+ |---|---|
184
+ | Không tìm thấy UC Spec | `⚠️ CẢNH BÁO: Không tìm thấy UC Spec cho [functionId] — Test Case sẽ chỉ dựa trên System Requirement (nếu có) + input khác, thiếu ngữ cảnh nghiệp vụ gốc.` |
185
+ | Không tìm thấy System Requirement | `⚠️ CẢNH BÁO: Không tìm thấy System Requirement cho [functionId] — Test Case sẽ chỉ dựa trên UC Spec, có thể thiếu Validation Rule/Exception Handling/Acceptance Test mà Dev đã chốt riêng.` |
186
+ | Có System Requirement nhưng `UC-Spec-Version` không khớp UC Spec hiện tại | `⚠️ CẢNH BÁO: System Requirement đang trace theo UC Spec v[X], nhưng UC Spec hiện tại là v[Y] — nội dung có thể lỗi thời.` |
187
+ | Có System Requirement, khớp version, nhưng `Status` ≠ `✅ Approved` | `⚠️ CẢNH BÁO: System Requirement cho [functionId] chưa Approved (Status: [giá trị hiện tại]) — nội dung có thể còn thay đổi.` |
188
+
189
+ → Với mọi cảnh báo trên: ghi lại tình huống này vào `[functionId]_01_Requirement_Analysis_QA.md` (mục Assumptions, Bước 4) để QA/Dev biết rõ giới hạn của phân tích — không chỉ hiển thị rồi bỏ qua.
190
+
191
+ Nếu tất cả điều kiện thỏa mãn → thông báo ngắn rồi tiếp tục:
192
+
193
+ ```
194
+ ✓ UC Spec: v[N]
195
+ ✓ System Requirement: v[N] (✅ Approved, khớp UC Spec v[N])
196
+ → Tiếp tục Gate 1...
197
+ ```
198
+
172
199
  #### Bước 1: Đọc và tổng hợp đầu vào
173
200
  - Đọc `.aiflow/context/current.json` — tiêu đề, mô tả, acceptance criteria, liên kết tài liệu
201
+ - Đọc `UC-Spec_v{N}.md` (tìm thấy ở Bước 0.6) — yêu cầu nghiệp vụ gốc: Main/Alternative/Exception Flow, Business Rules (BR-NNN), UI Components
202
+ - Nếu tìm thấy `System-Requirement_v{N}.md` ở Bước 0.6 → đọc toàn bộ, dùng làm input kỹ thuật bổ sung cho Bước 2 (Phân tích yêu cầu): đối chiếu Functional/Non-Functional Requirements (`FR-*`, `NFR-*`), Validation Rules (`VR-*`), Exception & Error Handling (`ER-*`), Acceptance Test Scenarios (`AT-*`) — TC ở Gate 3 phải bao phủ cả các `AT-*`/`ER-*` này, không chỉ Business Rules trong UC Spec
174
203
  - Nếu description có URL → chạy `ak fetch-links <url>` để tải nội dung
175
204
  - Nếu có `supplementaryContext[]` → đọc từng item (SRS file, Figma link, API spec, spec MD file)
176
205
  - Nếu có file yêu cầu thô được chỉ định → đọc file đó
@@ -227,6 +256,7 @@ Trước khi ghi bất kỳ file nào vào `03.Testing/`, đảm bảo AK-Docs
227
256
 
228
257
  **Definition of Done:**
229
258
  - [ ] `functionId` đã được xác định, thư mục đầu ra đã sẵn sàng
259
+ - [ ] Đã chạy Bước 0.6 (kiểm tra UC Spec + System Requirement); nếu có cảnh báo, đã ghi vào `01_Requirement_Analysis_QA.md`
230
260
  - [ ] File `01_Requirement_Analysis_Result.md` có đủ 16 mục + Risk Matrix + Test Scope
231
261
  - [ ] Toàn bộ Critical/Major đã được hỏi trực tiếp (từng câu một) và có câu trả lời từ QA — không còn nghi vấn bỏ ngỏ
232
262
  - [ ] File `01_Requirement_Analysis_QA.md` đã tạo nếu có issue, ghi lại đầy đủ câu hỏi + câu trả lời (Bước 2b)
@@ -530,6 +560,7 @@ Sau khi Gate 4 đã APPROVED (bộ Test Case hoàn thành):
530
560
  - ❌ **KHÔNG** tiến gate tiếp theo khi còn issue Critical hoặc Major chưa giải quyết
531
561
  - ✅ **BẮT BUỘC** chạy Bước 0 ở Gate 1 — xác nhận `functionId` và thư mục đầu ra trước khi làm bất cứ điều gì
532
562
  - ✅ **BẮT BUỘC** chạy Bước 0.5 ở Gate 1 — đảm bảo AK-Docs đang ở branch `feature/[functionId]/[taskId]` trước khi ghi file đầu tiên
563
+ - ✅ **BẮT BUỘC** chạy Bước 0.6 ở Gate 1 — kiểm tra UC Spec + System Requirement (tồn tại, khớp version, Approved); thiếu/lệch → cảnh báo yellow **không chặn Gate**, ghi vào QA artifact
533
564
  - ✅ **BẮT BUỘC** đọc skill từ `.claude/skills/test-skills/` — không suy luận từ bộ nhớ
534
565
  - ✅ **BẮT BUỘC** invoke `gate-review` cuối mỗi gate và chờ APPROVED
535
566
  - ✅ **BẮT BUỘC** tuân thủ 100% `testcase-template.md` ở Gate 3 và Gate 4