@educa-corp/sdd-framework 0.6.0 → 0.7.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.
- package/bin/gate-trace.js +25 -2
- package/bin/index.js +32 -5
- package/bin/lint-trace.js +41 -0
- package/bin/self-check.js +430 -3
- package/bin/trace-schema.json +418 -31
- package/core/FRAMEWORK_VERSION +1 -1
- package/{commands/extend-prd.md → core/commands/amend-prd.md} +206 -173
- package/core/commands/dev-run-test.md +48 -10
- package/core/commands/extend-prd.md +39 -12
- package/core/commands/generate-bdd.md +52 -10
- package/core/commands/generate-code.md +35 -2
- package/core/commands/generate-tech-docs.md +36 -4
- package/core/commands/map-testids.md +1 -1
- package/core/commands/qc-run-test.md +29 -3
- package/core/commands/refine-prd.md +13 -2
- package/core/commands/review-context.md +43 -8
- package/core/commands/sync.md +105 -1
- package/core/commands/validate-traces.md +289 -16
- package/core/rules/workflow.md +34 -0
- package/core/steps/context-loader.md +27 -6
- package/core/templates/feature.template +1 -1
- package/core/templates/project-context.yaml +3 -3
- package/core/templates/tech-design.template.md +2 -2
- package/docs/02-concepts/architecture.md +37 -1
- package/docs/02-concepts/overview.md +1 -1
- package/docs/02-concepts/pipeline-steps/02-specification.md +13 -7
- package/docs/02-concepts/pipeline-steps/07-dev-selftest.md +2 -0
- package/docs/02-concepts/pipeline-steps/08-qc-automation.md +1 -0
- package/docs/02-concepts/pipeline-steps/09-validate-traces.md +34 -3
- package/docs/02-concepts/pipeline-steps/10-feedback-loop.md +10 -1
- package/docs/02-concepts/traceability.md +187 -183
- package/docs/03-guides/architect.md +13 -4
- package/docs/03-guides/developer.md +1 -0
- package/docs/03-guides/product-owner.md +89 -72
- package/docs/03-guides/tester-qa.md +81 -81
- package/docs/04-reference/commands.md +148 -134
- package/docs/04-reference/trace-schema.md +45 -1
- package/docs/explain/02b-extend-prd.md +1 -1
- package/docs/explain/02c-amend-prd.md +152 -0
- package/docs/explain/06-generate-bdd.md +1 -1
- package/docs/explain/13-dev-run-test.md +15 -1
- package/docs/explain/19-qc-run-test.md +91 -87
- package/docs/explain/21-validate-traces.md +79 -75
- package/docs/explain/28-sync.md +25 -0
- package/docs/explain/README.md +136 -135
- package/package.json +1 -8
- package/commands/debug.md +0 -529
- package/commands/debug.tmpl +0 -260
- package/commands/define-product.md +0 -438
- package/commands/define-product.tmpl +0 -225
- package/commands/dev-gen-test.md +0 -700
- package/commands/dev-gen-test.tmpl +0 -490
- package/commands/dev-run-test.md +0 -435
- package/commands/dev-run-test.tmpl +0 -225
- package/commands/dev-smoke-test.md +0 -374
- package/commands/dev-smoke-test.tmpl +0 -217
- package/commands/extend-prd.tmpl +0 -273
- package/commands/fix-bug.md +0 -519
- package/commands/fix-bug.tmpl +0 -197
- package/commands/generate-architecture.md +0 -354
- package/commands/generate-architecture.tmpl +0 -197
- package/commands/generate-bdd.md +0 -923
- package/commands/generate-bdd.tmpl +0 -590
- package/commands/generate-code.md +0 -859
- package/commands/generate-code.tmpl +0 -649
- package/commands/generate-design-spec.md +0 -737
- package/commands/generate-design-spec.tmpl +0 -524
- package/commands/generate-prd.md +0 -722
- package/commands/generate-prd.tmpl +0 -226
- package/commands/generate-spec-manifest.md +0 -321
- package/commands/generate-spec-manifest.tmpl +0 -164
- package/commands/generate-tech-docs.md +0 -920
- package/commands/generate-tech-docs.tmpl +0 -273
- package/commands/learn.md +0 -399
- package/commands/learn.tmpl +0 -130
- package/commands/map-testids.md +0 -238
- package/commands/map-testids.tmpl +0 -81
- package/commands/propose-scenario.md +0 -359
- package/commands/propose-scenario.tmpl +0 -202
- package/commands/qc-analyze.md +0 -269
- package/commands/qc-analyze.tmpl +0 -112
- package/commands/qc-design-test.md +0 -226
- package/commands/qc-design-test.tmpl +0 -69
- package/commands/qc-plan.md +0 -206
- package/commands/qc-plan.tmpl +0 -49
- package/commands/qc-report.md +0 -217
- package/commands/qc-report.tmpl +0 -60
- package/commands/qc-review.md +0 -210
- package/commands/qc-review.tmpl +0 -53
- package/commands/qc-run-test.md +0 -326
- package/commands/qc-run-test.tmpl +0 -116
- package/commands/refine-prd.md +0 -653
- package/commands/refine-prd.tmpl +0 -281
- package/commands/report-bug.md +0 -305
- package/commands/report-bug.tmpl +0 -148
- package/commands/review-code.md +0 -415
- package/commands/review-code.tmpl +0 -146
- package/commands/review-context.md +0 -902
- package/commands/review-context.tmpl +0 -530
- package/commands/review-tech-docs.md +0 -561
- package/commands/review-tech-docs.tmpl +0 -404
- package/commands/setup-ai-first.md +0 -602
- package/commands/setup-ai-first.tmpl +0 -450
- package/commands/sync.md +0 -430
- package/commands/sync.tmpl +0 -429
- package/commands/update-framework.md +0 -203
- package/commands/update-framework.tmpl +0 -202
- package/commands/validate-traces.md +0 -1077
- package/commands/validate-traces.tmpl +0 -920
- package/hooks/data-guard.js +0 -232
- package/hooks/settings.json +0 -19
- package/modules/android-compose/module.yaml +0 -13
- package/modules/android-compose/stack-profile.yaml +0 -57
- package/modules/angular/architecture-snippets/component-patterns.md +0 -187
- package/modules/angular/module.yaml +0 -6
- package/modules/angular/stack-profile.yaml +0 -38
- package/modules/context-engineering/architecture-snippets/context-design.md +0 -119
- package/modules/context-engineering/module.yaml +0 -9
- package/modules/context-engineering/stack-profile.yaml +0 -61
- package/modules/dotnet/architecture-snippets/clean-arch.md +0 -160
- package/modules/dotnet/module.yaml +0 -6
- package/modules/dotnet/stack-profile.yaml +0 -50
- package/modules/flutter/module.yaml +0 -14
- package/modules/flutter/stack-profile.yaml +0 -59
- package/modules/golang/architecture-snippets/domain-layout.md +0 -283
- package/modules/golang/module.yaml +0 -6
- package/modules/golang/stack-profile.yaml +0 -40
- package/modules/ios-swiftui/module.yaml +0 -13
- package/modules/ios-swiftui/stack-profile.yaml +0 -55
- package/modules/java-spring/architecture-snippets/layered-arch.md +0 -201
- package/modules/java-spring/module.yaml +0 -15
- package/modules/java-spring/stack-profile.yaml +0 -28
- package/modules/nextjs/architecture-snippets/app-router-patterns.md +0 -269
- package/modules/nextjs/module.yaml +0 -14
- package/modules/nextjs/stack-profile.yaml +0 -74
- package/modules/nuxt/module.yaml +0 -14
- package/modules/nuxt/stack-profile.yaml +0 -58
- package/modules/phaser-game/architecture-snippets/phaser-scene-patterns.md +0 -646
- package/modules/phaser-game/module.yaml +0 -15
- package/modules/phaser-game/stack-profile.yaml +0 -90
- package/modules/php-laravel/architecture-snippets/service-repository.md +0 -302
- package/modules/php-laravel/module.yaml +0 -15
- package/modules/php-laravel/stack-profile.yaml +0 -56
- package/modules/qc-playwright/stack-profile.yaml +0 -66
- package/modules/react/architecture-snippets/hooks-query-patterns.md +0 -254
- package/modules/react/module.yaml +0 -14
- package/modules/react/stack-profile.yaml +0 -63
- package/modules/react-native/module.yaml +0 -14
- package/modules/react-native/stack-profile.yaml +0 -56
- package/modules/vue/module.yaml +0 -14
- package/modules/vue/stack-profile.yaml +0 -65
- package/rules/data-protection.md +0 -80
- package/rules/workflow.md +0 -99
- package/skills/code/SKILL.md +0 -19
- package/skills/code/SKILL.tmpl +0 -19
- package/skills/debug/SKILL.md +0 -19
- package/skills/debug/SKILL.tmpl +0 -19
- package/skills/design-spec/SKILL.md +0 -11
- package/skills/design-spec/SKILL.tmpl +0 -11
- package/skills/discovery/SKILL.md +0 -14
- package/skills/discovery/SKILL.tmpl +0 -14
- package/skills/prd/SKILL.md +0 -19
- package/skills/prd/SKILL.tmpl +0 -19
- package/skills/qc/qa-analyst/DOC_GAPS.template.md +0 -63
- package/skills/qc/qa-analyst/acceptance-criteria.md +0 -60
- package/skills/qc/qa-analyst/business-rules.md +0 -59
- package/skills/qc/qa-analyst/data-flow.md +0 -64
- package/skills/qc/qa-analyst/spec-breakdown.md +0 -61
- package/skills/qc/qa-designer/e2e/journey.md +0 -41
- package/skills/qc/qa-designer/exploratory/charter.md +0 -68
- package/skills/qc/qa-designer/exploratory/explore-to-functional.md +0 -43
- package/skills/qc/qa-designer/functional/api.md +0 -45
- package/skills/qc/qa-designer/functional/gui-feature.md +0 -46
- package/skills/qc/qa-designer/functional/gui-screen.md +0 -52
- package/skills/qc/qa-designer/integration/api.md +0 -42
- package/skills/qc/qa-designer/integration/db.md +0 -39
- package/skills/qc/qa-designer/integration/gui.md +0 -40
- package/skills/qc/qa-designer/integration/kafka.md +0 -40
- package/skills/qc/qa-designer/non-functional.md +0 -40
- package/skills/qc/qa-planner/test-plan.md +0 -120
- package/skills/qc/qa-reviewer/script/e2e.md +0 -87
- package/skills/qc/qa-reviewer/script/exploratory.md +0 -45
- package/skills/qc/qa-reviewer/script/functional.md +0 -101
- package/skills/qc/qa-reviewer/script/integration.md +0 -91
- package/skills/qc/qa-reviewer/script/non-functional.md +0 -126
- package/skills/qc/qa-reviewer/test-case/e2e.md +0 -73
- package/skills/qc/qa-reviewer/test-case/exploratory.md +0 -43
- package/skills/qc/qa-reviewer/test-case/functional.md +0 -76
- package/skills/qc/qa-reviewer/test-case/integration.md +0 -69
- package/skills/qc/qa-reviewer/test-case/non-functional.md +0 -73
- package/skills/qc/qa-runner/e2e.md +0 -49
- package/skills/qc/qa-runner/exploratory/session.md +0 -36
- package/skills/qc/qa-runner/functional/api.md +0 -35
- package/skills/qc/qa-runner/functional/gui-feature.md +0 -51
- package/skills/qc/qa-runner/functional/gui-screen.md +0 -55
- package/skills/qc/qa-runner/integration.md +0 -47
- package/skills/qc/qa-runner/non-functional.md +0 -49
- package/skills/qc/qa-runner/report/report.md +0 -37
- package/skills/setup-ai-first/SKILL.md +0 -19
- package/skills/setup-ai-first/SKILL.tmpl +0 -19
- package/skills/spec/SKILL.md +0 -19
- package/skills/spec/SKILL.tmpl +0 -19
- package/skills/test/SKILL.md +0 -18
- package/skills/test/SKILL.tmpl +0 -18
- package/steps/business-language.md +0 -56
- package/steps/capture-lesson.md +0 -112
- package/steps/context-loader.md +0 -406
- package/steps/gate.md +0 -151
- package/steps/report-footer.md +0 -125
- package/steps/review-fanout.md +0 -159
- package/steps/spawn-agent.md +0 -129
- package/steps/trace-mirror.md +0 -53
- package/templates/README.md +0 -70
- package/templates/architecture.template.md +0 -394
- package/templates/ci/trace-gate.yml +0 -146
- package/templates/design-spec.template.md +0 -217
- package/templates/feature.template +0 -123
- package/templates/hooks/pre-push +0 -61
- package/templates/platform-guide.template.md +0 -145
- package/templates/prd.template.md +0 -283
- package/templates/product-definition.template.md +0 -188
- package/templates/project-context.yaml +0 -212
- package/templates/tech-design.template.md +0 -490
package/commands/dev-run-test.md
DELETED
|
@@ -1,435 +0,0 @@
|
|
|
1
|
-
# /dev-run-test — Chạy Dev Self-Check Tests & Report kết quả
|
|
2
|
-
|
|
3
|
-
> **Scope — dev self-check (smoke), không phải bộ test chính thức.** Chạy các test do
|
|
4
|
-
> `/dev-gen-test` sinh ra để dev xác nhận code mình chạy được trước khi review. Đây là một
|
|
5
|
-
> self-check của dev, **không** phải lần chạy test authoritative của QC/dev-team (flow riêng).
|
|
6
|
-
> Pass/fail được publish lên Living Docs như tín hiệu **dev self-test** — nó cho QC biết
|
|
7
|
-
> dev đã chạy check của họ; KHÔNG phải tuyên bố về độ phủ test chính thức.
|
|
8
|
-
|
|
9
|
-
## Gate
|
|
10
|
-
# Gate — Quy trình vào chuẩn cho mọi lệnh
|
|
11
|
-
|
|
12
|
-
Mọi lệnh PHẢI chạy gate này trước khi thực thi phần logic riêng của nó.
|
|
13
|
-
|
|
14
|
-
## Bước 0 — Kiểm tra chế độ Sub-Agent
|
|
15
|
-
|
|
16
|
-
Trước tiên, kiểm tra xem `$ARGUMENTS` có phải là payload JSON từ một orchestrator hay không:
|
|
17
|
-
|
|
18
|
-
1. Thử parse `$ARGUMENTS` dưới dạng JSON.
|
|
19
|
-
2. Nếu parse thành công **và** chứa `"_agent_mode": true`:
|
|
20
|
-
- **Bỏ qua hoàn toàn Bước 1, 2 và 3 của Gate này.**
|
|
21
|
-
- Đặt target file = `payload.target_file`
|
|
22
|
-
- Đặt loaded context = `payload.context` (KHÔNG chạy context-loader.md)
|
|
23
|
-
- Đặt phạm vi UC = `payload.uc_id` (chỉ xử lý UC này)
|
|
24
|
-
- Đặt line range = `payload.uc_section` (chỉ đọc đúng section đó của PRD)
|
|
25
|
-
- Đặt dimension = `payload.dimension` nếu có (lệnh review per-UC: chỉ review đúng lăng kính này)
|
|
26
|
-
- Đi thẳng tới phần logic riêng của lệnh.
|
|
27
|
-
3. Nếu `$ARGUMENTS` không phải JSON hoặc không có `_agent_mode` → tiếp tục sang Bước 1 (chế độ thường).
|
|
28
|
-
|
|
29
|
-
## Bước 0-B — Ghi nhận Model *(KHÔNG chặn)*
|
|
30
|
-
|
|
31
|
-
*Bỏ qua nếu `_agent_mode: true` (sub-agent — orchestrator đã ghi nhận rồi).*
|
|
32
|
-
|
|
33
|
-
Ghi lại **model mà bạn — agent đang chạy lệnh này — thực sự đang dùng**, rồi mang nó vào
|
|
34
|
-
dòng `Model:` của report cuối (xem `report-footer`). Nếu bạn biết mình **không** phải một
|
|
35
|
-
model Opus, gắn thêm cảnh báo ngay ở dòng đó.
|
|
36
|
-
|
|
37
|
-
**KHÔNG hỏi người dùng. KHÔNG chờ. KHÔNG dừng.**
|
|
38
|
-
|
|
39
|
-
> **Vì sao bước này từng là prompt chặn, và vì sao bỏ (GAPS-v3 G41):** bản cũ hiện khối
|
|
40
|
-
> `⚙️ MODEL CHECK` rồi chờ `Y/S/N`. Ba vấn đề cùng chỉ một hướng:
|
|
41
|
-
> **(1)** nó hỏi người dùng thứ mà **agent đã biết chính xác**;
|
|
42
|
-
> **(2)** câu trả lời **không kiểm chứng được** — gõ `Y` xong vẫn đang chạy Haiku thì không
|
|
43
|
-
> gì phát hiện;
|
|
44
|
-
> **(3)** **cả `Y` lẫn `S` đều đi tiếp** — cách duy nhất để nó dừng là tự nguyện gõ `N`.
|
|
45
|
-
> Tức nó **không chặn được ai**, mà tốn một lần chặn ở **mọi** lệnh. Một feature đi hết
|
|
46
|
-
> pipeline dùng 20 lệnh; 30/32 lệnh chạy gate. Hai mươi lần bấm cho một tín hiệu tự-khai
|
|
47
|
-
> không kiểm chứng được — và chính cái giá đó làm mòn CHECKPOINT ở Bước 3, cổng có giá trị thật.
|
|
48
|
-
>
|
|
49
|
-
> Khai báo trong report **mạnh hơn** hỏi: đúng nguồn (agent, không phải người), và nằm
|
|
50
|
-
> **cạnh kết quả** để cân nhắc, thay vì nằm trước khi có kết quả để bấm cho xong.
|
|
51
|
-
|
|
52
|
-
**Vẫn khuyến nghị Opus:** phân tích spec, review kiến trúc và sinh code đòi hỏi suy luận sâu;
|
|
53
|
-
model nhỏ hơn dễ bỏ sót edge case và vi phạm kiến trúc. Đổi: `/model` → chọn Opus.
|
|
54
|
-
|
|
55
|
-
## Bước 1 — Xác định Target File
|
|
56
|
-
|
|
57
|
-
0. **Tách cờ trước khi resolve target.** `$ARGUMENTS` có thể lẫn các `--flag` (vd `--phase=integration`, `--comment`, `--fix`). **Loại bỏ mọi token bắt đầu bằng `--`** ra khỏi phần dùng để tìm target — chỉ giữ phần path/UC-ID/ticket. (Các flag đó do phần logic riêng của lệnh parse ở bước sau, KHÔNG phải tên file.)
|
|
58
|
-
1. Nếu `$ARGUMENTS` (đã tách cờ) được cung cấp và trỏ tới một file tồn tại → dùng trực tiếp làm target.
|
|
59
|
-
2. Nếu `$ARGUMENTS` là một **UC-ID / ticket ID / tên rút gọn** (không có path) → phân giải thành file bằng cách glob theo bố cục feature-package. `{prd-slug}` lúc này **chưa biết**, nên dùng wildcard `*` cho segment đó, và `**` đệ quy dưới `bdd/` để phủ hết các thư mục con theo platform (`bdd/web/`, `bdd/app/`, `bdd/system/`):
|
|
60
|
-
- **Lệnh BDD** (target là `.feature`): `{specs_dir}/{domain}/*/bdd/**/{UC-ID}*.feature` — hoặc `{specs_dir}/*/*/bdd/**/{UC-ID}*.feature` nếu domain cũng chưa biết. Nếu lệnh ngụ ý một platform/scope cụ thể (vd: system tech-doc cần BDD `system/`), ưu tiên kết quả trong thư mục con platform đó.
|
|
61
|
-
- **Lệnh PRD** (target là file PRD `{TICKET-ID}-{prd-slug}.md` — file `.md` duy nhất ở gốc feature folder, cạnh `bdd/`): `{specs_dir}/{domain}/*/{TICKET-ID}*.md` nếu biết TICKET-ID; nếu không, `{specs_dir}/{domain}/*/*.md` (khớp feature folder có id tương ứng), hoặc `{specs_dir}/*/*/*.md` nếu domain cũng chưa biết. *(Glob `*/*.md` ở cấp gốc folder chỉ khớp PRD — tech-docs/design-spec `.md` nằm sâu hơn trong thư mục con.)*
|
|
62
|
-
- **Lệnh tech-docs** — target là tech-doc **gộp cấp PRD** `{TICKET-ID}-tech-design.md` (MỘT doc phủ nhiều UC; danh sách UC nằm ở `@trace.ucs`). Vì tên file mang `{TICKET-ID}` chứ **không** mang `{UC-ID}`, phải tách trước khi glob:
|
|
63
|
-
- `$ARGUMENTS` là **UC-ID** (`{TICKET-ID}-UC{N}`) → lấy `{TICKET-ID}` = phần **trước** `-UC`, rồi glob `{specs_dir}/{domain}/*/tech-docs/{TICKET-ID}-tech-design.md`.
|
|
64
|
-
- `$ARGUMENTS` là **TICKET-ID** → glob trực tiếp như trên.
|
|
65
|
-
- Chưa biết domain → `{specs_dir}/*/*/tech-docs/{TICKET-ID}-tech-design.md`.
|
|
66
|
-
- Vẫn không khớp → glob rộng `{specs_dir}/*/*/tech-docs/*tech-design*.md` rồi liệt kê để người dùng chọn.
|
|
67
|
-
*(Đừng glob `{UC-ID}*-tech-design*.md` — nó nở thành `FT-001-UC1*-tech-design*.md` và **không bao giờ** khớp `FT-001-tech-design.md`.)*
|
|
68
|
-
- **Lệnh design-spec**: `{specs_dir}/{domain}/*/design-spec/{TICKET-ID}*.md`.
|
|
69
|
-
|
|
70
|
-
Khi một file khớp: đặt nó làm target **và** ghi lại `domain` + `prd_slug` từ path của nó (theo quy tắc trích xuất trong `context-loader.md` Bước 1 — `prd_slug` = segment đầu tiên sau `{specs_dir}/{domain}/`). Mọi path mà lệnh đọc/ghi về sau (BDD/tech-docs/design-spec/trace cùng cấp) đều dùng **`prd_slug` đã phân giải đó**, nên tất cả artifact nằm chung một feature package. Nếu nhiều file khớp (vd: nhiều platform), chọn theo platform/scope của lệnh hoặc liệt kê ra và hỏi.
|
|
71
|
-
3. Nếu `$ARGUMENTS` rỗng hoặc không tìm thấy file khớp:
|
|
72
|
-
- Liệt kê các file trong thư mục liên quan của lệnh này (vd: `specs/*/*/*.md` — file PRD ở gốc mỗi feature folder — cho lệnh PRD, `specs/*/*/bdd/**/*.feature` cho lệnh BDD).
|
|
73
|
-
- Hiển thị danh sách cho người dùng và hỏi: "Bạn muốn làm việc với file nào? (Nhập số thứ tự hoặc tên file)"
|
|
74
|
-
- Chờ người dùng chọn rồi mới tiếp tục.
|
|
75
|
-
|
|
76
|
-
## Bước 2 — Chạy Context Loader
|
|
77
|
-
|
|
78
|
-
Nạp toàn bộ context của dự án bằng cách làm theo quy trình trong `steps/context-loader.md`.
|
|
79
|
-
Lưu toàn bộ context đã nạp vào bộ nhớ để dùng xuyên suốt phiên làm việc của lệnh.
|
|
80
|
-
|
|
81
|
-
## Bước 3 — CHECKPOINT
|
|
82
|
-
|
|
83
|
-
*Bỏ qua nếu `_agent_mode: true`.*
|
|
84
|
-
|
|
85
|
-
### 3a — Lệnh này có phải chặn không?
|
|
86
|
-
|
|
87
|
-
| Mức | Lệnh nào | `--yes` bỏ qua được? |
|
|
88
|
-
|---|---|:---:|
|
|
89
|
-
| **Không chặn** | Lệnh read-only: `/review-code` · `/validate-traces` · `/debug` · `/review-context` · `/review-tech-docs` | — (vốn không có) |
|
|
90
|
-
| **Chặn thường** | Mọi lệnh sinh/sửa artifact | ✅ |
|
|
91
|
-
| **Chặn CỨNG** | Ghi đè file đã tồn tại · `--resume` áp findings · migrate · prune | ❌ **không bao giờ** |
|
|
92
|
-
|
|
93
|
-
`--yes` trong `$ARGUMENTS` → bỏ qua CHECKPOINT mức *chặn thường*. (Bước 1 đã tách mọi token
|
|
94
|
-
`--` khỏi phần resolve target, nên cờ này không ảnh hưởng việc tìm file.) Mở đường chạy
|
|
95
|
-
headless: `claude -p "/generate-code UC1 --yes"`.
|
|
96
|
-
|
|
97
|
-
> **KHÔNG tự suy mức từ bảng này.** Mỗi lệnh **tự khai** mức của nó ở một dòng `*Checkpoint: …*`
|
|
98
|
-
> ngay dưới `## Gate` của chính nó — đọc dòng đó, đừng suy diễn. Bảng trên chỉ giải thích ba mức
|
|
99
|
-
> **nghĩa là gì**.
|
|
100
|
-
> Nguồn máy đọc: `bin/trace-schema.json` → `gate.checkpoint_levels`; `self-check` **R11** fail
|
|
101
|
-
> build nếu nhãn trong file lệnh lệch với schema, hoặc nếu một lệnh `hard`/`none` thiếu nhãn.
|
|
102
|
-
> *(Lệnh không có dòng nào = mức **chặn thường**, mặc định.)*
|
|
103
|
-
|
|
104
|
-
> **Mức *không chặn* là thực thi đúng miễn trừ mà `rules/workflow.md` đã cấp từ trước** —
|
|
105
|
-
> trước G41 file đó viết *"read-only commands may skip CHECKPOINT"* còn gate thì luôn đòi.
|
|
106
|
-
> Hai file cùng được nạp vào mọi lệnh mà nói ngược nhau; agent theo cái nào là tuỳ lúc.
|
|
107
|
-
|
|
108
|
-
### 3b — In gì
|
|
109
|
-
|
|
110
|
-
**KHÔNG lặp lại những gì `[CTX LOADED]` vừa in.** Recap của context-loader (Bước 7) đã hiện
|
|
111
|
-
Stack · Platform · Layers · CLAUDE.md · Dict · Entities · Lessons · Service · Status ngay phía
|
|
112
|
-
trên. CHECKPOINT chỉ thêm **một** thông tin mới là `Target`.
|
|
113
|
-
|
|
114
|
-
**Mọi thứ sạch** — recap báo `Status: FULL`, không cờ nào bật → in đúng hai dòng:
|
|
115
|
-
|
|
116
|
-
```
|
|
117
|
-
CHECKPOINT — Target: {resolved file path}
|
|
118
|
-
Tiếp tục? (Y/N)
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
**Có bất thường** → thêm một dòng cho **mỗi** trạng thái, nặng nhất lên đầu:
|
|
122
|
-
|
|
123
|
-
```
|
|
124
|
-
CHECKPOINT
|
|
125
|
-
🔴 Service : unresolved — {lý do context-loader đã ghi}
|
|
126
|
-
⚠️ CLAUDE.md: service overlay THIẾU — dùng root (code sinh ra có thể sai stack)
|
|
127
|
-
⚠️ Target : resolve bằng wildcard — {n} file khớp, chọn {file}
|
|
128
|
-
⚠️ Module : not configured — code sinh ra sẽ dùng default
|
|
129
|
-
Status : PARTIAL — thiếu: {danh sách}
|
|
130
|
-
Target : {resolved file path}
|
|
131
|
-
Tiếp tục? (Y/N)
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
### 3c — Cờ nào bật, cờ nào KHÔNG
|
|
135
|
-
|
|
136
|
-
Mỗi dòng ⚠️/🔴 phải ứng với một trạng thái **context-loader đã tính rồi** — không phát minh
|
|
137
|
-
điều kiện mới, chỉ mang thứ đang bị giấu lên chỗ người dùng phải quyết định:
|
|
138
|
-
|
|
139
|
-
| Bật cờ khi | Nguồn | Mức |
|
|
140
|
-
|---|---|:---:|
|
|
141
|
-
| `active_service = unresolved` | context-loader Bước 2b/2c/Fallback | 🔴 |
|
|
142
|
-
| `Status = MINIMAL` | recap Bước 7 | 🔴 |
|
|
143
|
-
| `Status = PARTIAL` | recap Bước 7 | ⚠️ |
|
|
144
|
-
| CLAUDE.md thiếu, hoặc service overlay thiếu | context-loader Bước 3 | ⚠️ |
|
|
145
|
-
| Target resolve qua wildcard, hoặc nhiều file khớp mà lệnh tự chọn | Bước 1 ở trên | ⚠️ |
|
|
146
|
-
| `module` không cấu hình | recap Bước 7 | ⚠️ |
|
|
147
|
-
|
|
148
|
-
**KHÔNG bật cờ cho:** `Lessons: chưa có` · `Dict: missing` · `Entities: missing`. Đó là
|
|
149
|
-
*"dự án chưa điền"*, không phải *"có gì đó sai"* — chúng ở lại trong recap.
|
|
150
|
-
|
|
151
|
-
> **Nguyên tắc một câu:** cờ dành cho thứ **framework không chắc chắn hoặc đã phải đoán**,
|
|
152
|
-
> không dành cho thứ **người dùng chưa làm**. Đẩy hết mọi thứ lên thì CHECKPOINT lại đầy như
|
|
153
|
-
> cũ, và ta quay về đúng chỗ xuất phát: một cổng luôn giống nhau thì bị lướt qua.
|
|
154
|
-
|
|
155
|
-
### 3d — Chờ trả lời
|
|
156
|
-
|
|
157
|
-
- "Y" → tiếp tục sang các bước riêng của lệnh.
|
|
158
|
-
- "N" → dừng, hỏi người dùng muốn thay đổi gì.
|
|
159
|
-
- Có `--yes` và mức *chặn thường* → coi như "Y", **nhưng vẫn IN khối CHECKPOINT** nếu có cờ
|
|
160
|
-
🔴/⚠️ (không chặn ≠ không báo — người đọc log sau này vẫn cần thấy).
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
*Lưu ý: Với lệnh này, target ở Bước 1 là một UC-ID hoặc tên service. Context loading cung cấp `conventions.test_command` và `tech_stack.module`.*
|
|
164
|
-
|
|
165
|
-
## Context
|
|
166
|
-
**BẮT BUỘC — đọc `.agent/steps/context-loader.md` và thực thi TOÀN BỘ quy trình trong đó**,
|
|
167
|
-
rồi mới tiếp tục phần bên dưới.
|
|
168
|
-
|
|
169
|
-
Bỏ qua bước này thì `{paths.*}`, `{tech_stack.*}`, `{conventions.*}`, guardrail từ
|
|
170
|
-
`project-lessons`, và routing service (chế độ umbrella) đều **chưa được phân giải** — mọi
|
|
171
|
-
placeholder bên dưới sẽ rỗng và lệnh sẽ đọc/ghi sai chỗ.
|
|
172
|
-
|
|
173
|
-
---
|
|
174
|
-
|
|
175
|
-
## Service Detection
|
|
176
|
-
|
|
177
|
-
Đọc `active_module` từ context (đã phân giải ở context-loader Bước 1).
|
|
178
|
-
Dùng nó để chọn đúng lệnh chạy và bảng phân tích lỗi bên dưới.
|
|
179
|
-
|
|
180
|
-
---
|
|
181
|
-
|
|
182
|
-
## Submodule Working Directory
|
|
183
|
-
|
|
184
|
-
*Bỏ qua section này nếu `service_root` chưa được set (single-service mode).*
|
|
185
|
-
|
|
186
|
-
Khi chạy ở **umbrella/submodule mode** (`service_root` được phân giải ở context-loader Bước 1.6):
|
|
187
|
-
|
|
188
|
-
- Mọi lệnh trong section **Run** bên dưới phải thực thi từ trong `{service_root}/`
|
|
189
|
-
- `conventions.test_command` được nạp từ `{service_root}/.agent/project-context.yaml` — đã riêng theo service
|
|
190
|
-
- Prefix mọi lệnh shell bằng `cd {service_root} &&`:
|
|
191
|
-
|
|
192
|
-
```bash
|
|
193
|
-
cd {service_root}
|
|
194
|
-
|
|
195
|
-
# Then run any of the commands in the Run section below, e.g.:
|
|
196
|
-
{conventions.test_command}
|
|
197
|
-
mvn test -Dtest={ClassName} # java-spring
|
|
198
|
-
go test ./... -run Test{FunctionName} # golang
|
|
199
|
-
npx vitest run src/... # web-frontend
|
|
200
|
-
flutter test test/{domain}/... # flutter
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
> **Vì sao cd?** Session Claude Code mở ở umbrella root. Mỗi service submodule có build tool, test runner, và cây dependency riêng — test phải chạy từ trong thư mục service.
|
|
204
|
-
|
|
205
|
-
---
|
|
206
|
-
|
|
207
|
-
## Run
|
|
208
|
-
|
|
209
|
-
### Nếu `platform_type = backend`
|
|
210
|
-
|
|
211
|
-
```bash
|
|
212
|
-
# Run all tests for this UC
|
|
213
|
-
{conventions.test_command}
|
|
214
|
-
|
|
215
|
-
# Scoped to specific class (faster feedback)
|
|
216
|
-
# java-spring:
|
|
217
|
-
mvn test -Dtest={ClassName}
|
|
218
|
-
# golang:
|
|
219
|
-
go test ./... -run Test{FunctionName}
|
|
220
|
-
# dotnet:
|
|
221
|
-
dotnet test --filter "FullyQualifiedName~{ClassName}"
|
|
222
|
-
# php-laravel:
|
|
223
|
-
php artisan test --filter {ClassName}
|
|
224
|
-
# context-engineering (pytest):
|
|
225
|
-
pytest tests/{domain}/{test_file}.py -v
|
|
226
|
-
pytest tests/{domain}/{test_file}.py::{TestClass}::{test_method} -v
|
|
227
|
-
pytest tests/ --cov={source_dir} --cov-report=term-missing
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
### Nếu `platform_type = web-frontend`
|
|
231
|
-
|
|
232
|
-
```bash
|
|
233
|
-
# Run all tests
|
|
234
|
-
{conventions.test_command}
|
|
235
|
-
|
|
236
|
-
# Scoped (Vitest / Jest):
|
|
237
|
-
npx vitest run src/features/{domain}/{Component}.test.tsx
|
|
238
|
-
npx jest src/features/{domain}/{Component}.test.tsx
|
|
239
|
-
|
|
240
|
-
# E2E (Playwright):
|
|
241
|
-
npx playwright test {UC-ID}
|
|
242
|
-
# E2E (Cypress):
|
|
243
|
-
npx cypress run --spec "cypress/e2e/{UC-ID}*"
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
### Nếu `platform_type = mobile`
|
|
247
|
-
|
|
248
|
-
```bash
|
|
249
|
-
# Flutter:
|
|
250
|
-
flutter test test/{domain}/{UC-ID}_test.dart
|
|
251
|
-
flutter test integration_test/{UC-ID}_test.dart # integration
|
|
252
|
-
|
|
253
|
-
# React Native:
|
|
254
|
-
npx jest {UC-ID}
|
|
255
|
-
|
|
256
|
-
# iOS (Xcode command line):
|
|
257
|
-
xcodebuild test -scheme {Scheme} -destination 'platform=iOS Simulator,name=iPhone 15'
|
|
258
|
-
|
|
259
|
-
# Android:
|
|
260
|
-
./gradlew test # unit tests
|
|
261
|
-
./gradlew connectedAndroidTest # instrumented (device/emulator required)
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
> **Lưu ý cho Android instrumented test:** cần một emulator đang chạy hoặc device kết nối trước khi chạy `connectedAndroidTest`. Khởi động qua Android Studio hoặc: `emulator -avd {AVD_NAME} &`
|
|
265
|
-
|
|
266
|
-
---
|
|
267
|
-
|
|
268
|
-
## Analyze Failures
|
|
269
|
-
|
|
270
|
-
### Backend failure patterns
|
|
271
|
-
|
|
272
|
-
#### java-spring / golang / dotnet / php-laravel
|
|
273
|
-
|
|
274
|
-
| Error Pattern | Nguyên nhân thường gặp | Suggested Fix |
|
|
275
|
-
|---|---|---|
|
|
276
|
-
| `NullPointerException` | Thiếu setup mock | Kiểm tra `given(...)`/`coEvery`/`mockk` cho dependency null |
|
|
277
|
-
| `Bean not found` | Thiếu khai báo mock | Thêm `@MockBean` / inject mock |
|
|
278
|
-
| `Expected 200, got 401` | Thiếu setup auth | Thêm auth token/user vào test context |
|
|
279
|
-
| `Expected 200, got 400` | Request body fail validation | Kiểm tra field bắt buộc trong DTO |
|
|
280
|
-
| `Expected 200, got 403` | Sai role | Thêm đúng role cho test user |
|
|
281
|
-
| `LazyInitializationException` | Lazy collection ngoài transaction | Thêm `@Transactional` hoặc eager fetch |
|
|
282
|
-
| `Mapper not found` | Code chưa compile | Chạy build trước khi test |
|
|
283
|
-
| `DataIntegrityViolationException` | Trùng key trong DB setup | Dùng `@Transactional` + rollback, hoặc clean DB giữa các test |
|
|
284
|
-
| Assertion mismatch | Sai giá trị mock return | Đọc lại setup `given(...).willReturn(...)` |
|
|
285
|
-
|
|
286
|
-
#### context-engineering (AI/LLM pipelines)
|
|
287
|
-
|
|
288
|
-
| Error Pattern | Nguyên nhân thường gặp | Suggested Fix |
|
|
289
|
-
|---|---|---|
|
|
290
|
-
| `AssertionError` trên output mock LLM | Giá trị mock return không khớp schema | Kiểm tra lại setup `mock_llm.return_value` / `mock_llm.complete.return_value` |
|
|
291
|
-
| `ValidationError` trên response | Cấu trúc output LLM không khớp schema kỳ vọng | Siết schema check hoặc thêm retry logic trong test |
|
|
292
|
-
| `ConnectionError` / `APIError` | LLM API thật bị gọi trong test | Đảm bảo mock `patch('...')` được áp dụng — không bao giờ gọi LLM thật trong unit test |
|
|
293
|
-
| `TimeoutError` | Test gọi LLM endpoint live | Thêm mock; kiểm tra test fixture |
|
|
294
|
-
| Kết quả flaky / non-deterministic | Response LLM thật dùng trong assertion | Thay bằng giá trị mock return tất định |
|
|
295
|
-
|
|
296
|
-
### Web frontend failure patterns
|
|
297
|
-
|
|
298
|
-
| Error Pattern | Nguyên nhân thường gặp | Suggested Fix |
|
|
299
|
-
|---|---|---|
|
|
300
|
-
| `Unable to find role "..."` | Element chưa render | Bọc trong `await waitFor(() => ...)` |
|
|
301
|
-
| `TestingLibraryElementError: Found multiple elements` | Selector quá rộng | Dùng `getByRole(..., { name: '...' })` để thu hẹp |
|
|
302
|
-
| `Network request not intercepted` | Thiếu MSW handler / `cy.intercept` | Thêm handler cho endpoint |
|
|
303
|
-
| `act(...)` warning | State update sau khi test kết thúc | Await async event / `await userEvent.click(...)` |
|
|
304
|
-
| `Cannot read properties of undefined` | Component render trước khi data load | Thêm loading state hoặc mock data đã resolve |
|
|
305
|
-
| Playwright timeout | Page chưa navigate / element ẩn | Kiểm tra route, thêm `waitForSelector` |
|
|
306
|
-
| `expect(page.locator(...)).toBeVisible` fail | Sai selector | Dùng Playwright Inspector để tìm đúng locator |
|
|
307
|
-
|
|
308
|
-
### Mobile failure patterns
|
|
309
|
-
|
|
310
|
-
#### Flutter
|
|
311
|
-
| Error Pattern | Nguyên nhân thường gặp | Suggested Fix |
|
|
312
|
-
|---|---|---|
|
|
313
|
-
| `pumpAndSettle timed out` | Async operation chưa hoàn thành | Dùng `pump(Duration(...))` cho delay cụ thể |
|
|
314
|
-
| `No widget found` | Widget chưa render / sai finder | Kiểm tra `find.byType`, `find.text`, `find.byKey` |
|
|
315
|
-
| `setState called after dispose` | Widget bị dispose trước khi async xong | Cancel async trong `dispose()` |
|
|
316
|
-
| BLoC state mismatch | Sai event emit | Verify `mockBloc` nhận đúng event |
|
|
317
|
-
|
|
318
|
-
#### React Native
|
|
319
|
-
| Error Pattern | Nguyên nhân thường gặp | Suggested Fix |
|
|
320
|
-
|---|---|---|
|
|
321
|
-
| `Unable to find element` | Thiếu `testID` hoặc sai query | Thêm `accessibilityLabel` hoặc `testID` vào component |
|
|
322
|
-
| `act(...)` warning | Async state update | Bọc trong `act(async () => { ... })` |
|
|
323
|
-
| Thiếu navigation mock | `useNavigation` chưa mock | Thêm jest mock cho `@react-navigation/native` |
|
|
324
|
-
|
|
325
|
-
#### iOS / Android
|
|
326
|
-
| Error Pattern | Nguyên nhân thường gặp | Suggested Fix |
|
|
327
|
-
|---|---|---|
|
|
328
|
-
| `XCTAssertEqual failed` | Sai giá trị kỳ vọng | Kiểm tra output ViewModel cho mock đã cho |
|
|
329
|
-
| `Compose node not found` | Sai `contentDescription` / `testTag` | Thêm `Modifier.testTag(...)` vào composable |
|
|
330
|
-
| `Hilt injection failed` | Thiếu test module | Thêm `@UninstallModules` + `@BindValue` trong test class |
|
|
331
|
-
| Emulator not available | `connectedAndroidTest` không có device | Khởi động emulator trước, chờ nó boot |
|
|
332
|
-
|
|
333
|
-
---
|
|
334
|
-
|
|
335
|
-
## Write Trace State
|
|
336
|
-
|
|
337
|
-
Sau khi chạy, lưu kết quả vào **TSV authoritative** trong service để chúng tới được
|
|
338
|
-
report Living Docs ở spec module (qua `/sync` + `/validate-traces`). Các file test
|
|
339
|
-
ở lại trong service — chỉ *status* của lần chạy được report.
|
|
340
|
-
|
|
341
|
-
Cập nhật **sổ của platform đang test** `{paths.trace_dir}/{domain}/{prd-slug}/{UC-ID}-{platform}.tsv` (`{platform}` = platform của code/`.feature` đang test — `system` cho backend, `web`/`app` cho FE/App; nếu `domain`/`prd_slug` không phân giải được từ spec target, định vị TSV bằng cách glob `{paths.trace_dir}/**/{UC-ID}-{platform}.tsv` — nó được tạo trước đó bởi `/generate-bdd`) — cho mỗi scenario row (khớp `sc_id` qua tag
|
|
342
|
-
`@trace.verifies={UC-ID}-SC{N}` của test). *(Umbrella + `spec_source`: `trace_dir` là `{spec_source}/.trace` — test chạy từ `service_root` nhưng update `dev_selftest` ghi vào **spec repo**; commit/push spec submodule cho nó.)*
|
|
343
|
-
|
|
344
|
-
| Cột | Giá trị |
|
|
345
|
-
|--------|-------|
|
|
346
|
-
| `dev_selftest` | `pass` nếu mọi test của SC này pass · `fail` nếu có cái fail · `not_run` nếu test của nó bị skip/vắng |
|
|
347
|
-
| `dev_selftest_at` | hôm nay `YYYY-MM-DD` |
|
|
348
|
-
| `last_updated` | hôm nay `YYYY-MM-DD` |
|
|
349
|
-
|
|
350
|
-
Giữ nguyên mọi cột khác — đặc biệt **không bao giờ** đụng `qc_status`/`qc_run_at`
|
|
351
|
-
(kết quả QC automation chính thức, do `/qc-run-test` sở hữu). `dev_selftest` (dev smoke)
|
|
352
|
-
và `qc_status` (QC chính thức) là hai tín hiệu riêng. `dev_selftest`/`dev_selftest_at` cũng
|
|
353
|
-
trực giao với `status` (OK/GAP/DRIFT/UNTRACKED/ORPHANED): `status` theo dõi *coverage*, `dev_selftest`
|
|
354
|
-
theo dõi *kết quả chạy* gần nhất của dev.
|
|
355
|
-
|
|
356
|
-
## Refresh Panel Mirror
|
|
357
|
-
# Làm mới panel mirror của Living Docs *(local)*
|
|
358
|
-
|
|
359
|
-
> **Hai vị trí, HAI TÊN KHÁC NHAU — đọc trước khi sửa gì ở đây.**
|
|
360
|
-
>
|
|
361
|
-
> | Đường dẫn | Vai trò | Git |
|
|
362
|
-
> |---|---|---|
|
|
363
|
-
> | `{paths.trace_dir}` (`.trace/` hoặc `{spec_source}/.trace/`) | **AUTHORITATIVE** — TSV + `trace-history.jsonl`. Không regenerate được. | **PHẢI commit** |
|
|
364
|
-
> | `./.trace-mirror/` ở gốc workspace hiện tại | **MIRROR** — bản sao tiện cho panel VS Code. Sinh lại được bất cứ lúc nào. | **Luôn gitignore** |
|
|
365
|
-
>
|
|
366
|
-
> Trước v0.4.3 cả hai đều tên `.trace`, nên một luật gitignore theo tên có thể **xoá sạch sổ gốc**
|
|
367
|
-
> khi dev mở thẳng spec repo làm workspace (lúc đó hai path bằng nhau). Hai tên khác nhau làm
|
|
368
|
-
> luật git đọc được bằng mắt và **không còn ca nhập nhằng nào**: `.trace-mirror/` không bao giờ
|
|
369
|
-
> commit, `.trace/` không bao giờ gitignore.
|
|
370
|
-
|
|
371
|
-
## Khi nào CÓ mirror
|
|
372
|
-
|
|
373
|
-
Mirror chỉ tồn tại khi **`{paths.trace_dir}` nằm NGOÀI workspace hiện tại** — panel đọc từ workspace đang mở nên cần một bản sao ở đây.
|
|
374
|
-
|
|
375
|
-
| Tình huống | `{paths.trace_dir}` | Có mirror? |
|
|
376
|
-
|---|---|---|
|
|
377
|
-
| Single-service | `./.trace` — **trong** workspace | ❌ Không. Panel đọc thẳng `.trace/trace-report.json`. Bỏ qua cả file này. |
|
|
378
|
-
| Dev mở thẳng **spec repo** | `./.trace` — **trong** workspace | ❌ Không. Như trên. |
|
|
379
|
-
| Umbrella + `spec_source`, dev đứng ở umbrella hoặc service submodule | `{spec_source}/.trace` — **ngoài** workspace | ✅ Có |
|
|
380
|
-
| Umbrella legacy (không `spec_source`) | `.trace` theo từng service | ✅ Có |
|
|
381
|
-
|
|
382
|
-
Quy tắc một dòng: **phân giải `panel_mirror = ./.trace-mirror` ở gốc workspace hiện tại; nếu `{paths.trace_dir}` đã nằm trong workspace này thì bỏ qua toàn bộ bước mirror.**
|
|
383
|
-
|
|
384
|
-
---
|
|
385
|
-
|
|
386
|
-
Sau khi cập nhật TSV authoritative tại `{paths.trace_dir}`:
|
|
387
|
-
|
|
388
|
-
**Khi `setup.spec_source` được đặt (trace gộp — trường hợp phổ biến):**
|
|
389
|
-
`{paths.trace_dir}` phân giải về `{spec_source}/.trace` — vị trí authoritative duy nhất.
|
|
390
|
-
Lệnh này chạy từ `service_root`, nên thao tác ghi là **liên-repo vào spec submodule**;
|
|
391
|
-
commit/push spec submodule cho lần cập nhật trace (giống như `feedback/`).
|
|
392
|
-
|
|
393
|
-
1. Phân giải `panel_mirror = ./.trace-mirror` tại **gốc workspace hiện tại**.
|
|
394
|
-
2. Nếu `{paths.trace_dir}` **không** nằm trong workspace hiện tại, copy mỗi
|
|
395
|
-
`{UC-ID}-{platform}.tsv` vừa cập nhật → `{panel_mirror}/{UC-ID}-{platform}.tsv` (tạo thư mục; ghi đè).
|
|
396
|
-
Không namespace theo service — chỉ có một bộ trace; service sở hữu được mang ở
|
|
397
|
-
**cột `service` (cột 23)** của chính từng row, do `/generate-bdd` ghi từ `@trace.service`.
|
|
398
|
-
3. **KHÔNG copy `trace-history.jsonl`.** Nó là dữ liệu tích luỹ, không phải thứ sinh lại được —
|
|
399
|
-
nhân bản nó ra một thư mục gitignore là tạo hai lịch sử lệch nhau rồi mất bản thật.
|
|
400
|
-
|
|
401
|
-
**Legacy (không có `spec_source` — trace theo service):**
|
|
402
|
-
Copy mỗi `{UC-ID}-{platform}.tsv` vừa cập nhật → `{panel_mirror}/{service-name}/{UC-ID}-{platform}.tsv`
|
|
403
|
-
(namespace theo `active_service`).
|
|
404
|
-
|
|
405
|
-
Cách này giữ panel Living Docs của workspace đang mở luôn mới **giữa các lần sync** — nó chỉ là
|
|
406
|
-
một **mirror tiện lợi cục bộ**. File `trace-report.json` đã merge (canonical, trong
|
|
407
|
-
`{spec_source}/.living-docs/`) được build lại bởi `/sync` hoặc `/validate-traces`. Với các lệnh
|
|
408
|
-
được orchestrate, làm việc này một lần trong orchestrator sau khi tất cả sub-agent trả về — không phải
|
|
409
|
-
bên trong từng sub-agent.
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
## Output
|
|
413
|
-
|
|
414
|
-
**Đọc `.agent/steps/report-footer.md`** và áp đúng khuôn footer trong đó (Status Badge ·
|
|
415
|
-
Output Artifacts · Next) cho report cuối, kèm khối bên dưới.
|
|
416
|
-
|
|
417
|
-
```
|
|
418
|
-
/dev-run-test Report — {UC-ID} ({active_module})
|
|
419
|
-
✅ Passed: {N} | ❌ Failed: {M} | ⏭️ Skipped: {K} | Duration: {X}s
|
|
420
|
-
|
|
421
|
-
## Failed Tests
|
|
422
|
-
| Test | Error | Root Cause |
|
|
423
|
-
|------|-------|------------|
|
|
424
|
-
|
|
425
|
-
## Recommendations
|
|
426
|
-
{fix cụ thể cho từng failure}
|
|
427
|
-
|
|
428
|
-
Trace: {paths.trace_dir}/{domain}/{prd-slug}/{UC-ID}-{platform}.tsv updated (dev_selftest, dev_selftest_at)
|
|
429
|
-
|
|
430
|
-
Next:
|
|
431
|
-
Mọi test pass → /review-code {UC-ID}
|
|
432
|
-
Test fail → /fix-bug {TICKET_ID} (bug thật) hoặc fix test (sai expectation)
|
|
433
|
-
|
|
434
|
-
📊 Living Docs: chạy /validate-traces (hoặc /sync) để push trace này lên dashboard spec-module.
|
|
435
|
-
```
|
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
# /dev-run-test — Chạy Dev Self-Check Tests & Report kết quả
|
|
2
|
-
|
|
3
|
-
> **Scope — dev self-check (smoke), không phải bộ test chính thức.** Chạy các test do
|
|
4
|
-
> `/dev-gen-test` sinh ra để dev xác nhận code mình chạy được trước khi review. Đây là một
|
|
5
|
-
> self-check của dev, **không** phải lần chạy test authoritative của QC/dev-team (flow riêng).
|
|
6
|
-
> Pass/fail được publish lên Living Docs như tín hiệu **dev self-test** — nó cho QC biết
|
|
7
|
-
> dev đã chạy check của họ; KHÔNG phải tuyên bố về độ phủ test chính thức.
|
|
8
|
-
|
|
9
|
-
## Gate
|
|
10
|
-
{{include:steps/gate.md}}
|
|
11
|
-
|
|
12
|
-
*Lưu ý: Với lệnh này, target ở Bước 1 là một UC-ID hoặc tên service. Context loading cung cấp `conventions.test_command` và `tech_stack.module`.*
|
|
13
|
-
|
|
14
|
-
## Context
|
|
15
|
-
{{include:steps/context-loader.md}}
|
|
16
|
-
|
|
17
|
-
---
|
|
18
|
-
|
|
19
|
-
## Service Detection
|
|
20
|
-
|
|
21
|
-
Đọc `active_module` từ context (đã phân giải ở context-loader Bước 1).
|
|
22
|
-
Dùng nó để chọn đúng lệnh chạy và bảng phân tích lỗi bên dưới.
|
|
23
|
-
|
|
24
|
-
---
|
|
25
|
-
|
|
26
|
-
## Submodule Working Directory
|
|
27
|
-
|
|
28
|
-
*Bỏ qua section này nếu `service_root` chưa được set (single-service mode).*
|
|
29
|
-
|
|
30
|
-
Khi chạy ở **umbrella/submodule mode** (`service_root` được phân giải ở context-loader Bước 1.6):
|
|
31
|
-
|
|
32
|
-
- Mọi lệnh trong section **Run** bên dưới phải thực thi từ trong `{service_root}/`
|
|
33
|
-
- `conventions.test_command` được nạp từ `{service_root}/.agent/project-context.yaml` — đã riêng theo service
|
|
34
|
-
- Prefix mọi lệnh shell bằng `cd {service_root} &&`:
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
cd {service_root}
|
|
38
|
-
|
|
39
|
-
# Then run any of the commands in the Run section below, e.g.:
|
|
40
|
-
{conventions.test_command}
|
|
41
|
-
mvn test -Dtest={ClassName} # java-spring
|
|
42
|
-
go test ./... -run Test{FunctionName} # golang
|
|
43
|
-
npx vitest run src/... # web-frontend
|
|
44
|
-
flutter test test/{domain}/... # flutter
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
> **Vì sao cd?** Session Claude Code mở ở umbrella root. Mỗi service submodule có build tool, test runner, và cây dependency riêng — test phải chạy từ trong thư mục service.
|
|
48
|
-
|
|
49
|
-
---
|
|
50
|
-
|
|
51
|
-
## Run
|
|
52
|
-
|
|
53
|
-
### Nếu `platform_type = backend`
|
|
54
|
-
|
|
55
|
-
```bash
|
|
56
|
-
# Run all tests for this UC
|
|
57
|
-
{conventions.test_command}
|
|
58
|
-
|
|
59
|
-
# Scoped to specific class (faster feedback)
|
|
60
|
-
# java-spring:
|
|
61
|
-
mvn test -Dtest={ClassName}
|
|
62
|
-
# golang:
|
|
63
|
-
go test ./... -run Test{FunctionName}
|
|
64
|
-
# dotnet:
|
|
65
|
-
dotnet test --filter "FullyQualifiedName~{ClassName}"
|
|
66
|
-
# php-laravel:
|
|
67
|
-
php artisan test --filter {ClassName}
|
|
68
|
-
# context-engineering (pytest):
|
|
69
|
-
pytest tests/{domain}/{test_file}.py -v
|
|
70
|
-
pytest tests/{domain}/{test_file}.py::{TestClass}::{test_method} -v
|
|
71
|
-
pytest tests/ --cov={source_dir} --cov-report=term-missing
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
### Nếu `platform_type = web-frontend`
|
|
75
|
-
|
|
76
|
-
```bash
|
|
77
|
-
# Run all tests
|
|
78
|
-
{conventions.test_command}
|
|
79
|
-
|
|
80
|
-
# Scoped (Vitest / Jest):
|
|
81
|
-
npx vitest run src/features/{domain}/{Component}.test.tsx
|
|
82
|
-
npx jest src/features/{domain}/{Component}.test.tsx
|
|
83
|
-
|
|
84
|
-
# E2E (Playwright):
|
|
85
|
-
npx playwright test {UC-ID}
|
|
86
|
-
# E2E (Cypress):
|
|
87
|
-
npx cypress run --spec "cypress/e2e/{UC-ID}*"
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### Nếu `platform_type = mobile`
|
|
91
|
-
|
|
92
|
-
```bash
|
|
93
|
-
# Flutter:
|
|
94
|
-
flutter test test/{domain}/{UC-ID}_test.dart
|
|
95
|
-
flutter test integration_test/{UC-ID}_test.dart # integration
|
|
96
|
-
|
|
97
|
-
# React Native:
|
|
98
|
-
npx jest {UC-ID}
|
|
99
|
-
|
|
100
|
-
# iOS (Xcode command line):
|
|
101
|
-
xcodebuild test -scheme {Scheme} -destination 'platform=iOS Simulator,name=iPhone 15'
|
|
102
|
-
|
|
103
|
-
# Android:
|
|
104
|
-
./gradlew test # unit tests
|
|
105
|
-
./gradlew connectedAndroidTest # instrumented (device/emulator required)
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
> **Lưu ý cho Android instrumented test:** cần một emulator đang chạy hoặc device kết nối trước khi chạy `connectedAndroidTest`. Khởi động qua Android Studio hoặc: `emulator -avd {AVD_NAME} &`
|
|
109
|
-
|
|
110
|
-
---
|
|
111
|
-
|
|
112
|
-
## Analyze Failures
|
|
113
|
-
|
|
114
|
-
### Backend failure patterns
|
|
115
|
-
|
|
116
|
-
#### java-spring / golang / dotnet / php-laravel
|
|
117
|
-
|
|
118
|
-
| Error Pattern | Nguyên nhân thường gặp | Suggested Fix |
|
|
119
|
-
|---|---|---|
|
|
120
|
-
| `NullPointerException` | Thiếu setup mock | Kiểm tra `given(...)`/`coEvery`/`mockk` cho dependency null |
|
|
121
|
-
| `Bean not found` | Thiếu khai báo mock | Thêm `@MockBean` / inject mock |
|
|
122
|
-
| `Expected 200, got 401` | Thiếu setup auth | Thêm auth token/user vào test context |
|
|
123
|
-
| `Expected 200, got 400` | Request body fail validation | Kiểm tra field bắt buộc trong DTO |
|
|
124
|
-
| `Expected 200, got 403` | Sai role | Thêm đúng role cho test user |
|
|
125
|
-
| `LazyInitializationException` | Lazy collection ngoài transaction | Thêm `@Transactional` hoặc eager fetch |
|
|
126
|
-
| `Mapper not found` | Code chưa compile | Chạy build trước khi test |
|
|
127
|
-
| `DataIntegrityViolationException` | Trùng key trong DB setup | Dùng `@Transactional` + rollback, hoặc clean DB giữa các test |
|
|
128
|
-
| Assertion mismatch | Sai giá trị mock return | Đọc lại setup `given(...).willReturn(...)` |
|
|
129
|
-
|
|
130
|
-
#### context-engineering (AI/LLM pipelines)
|
|
131
|
-
|
|
132
|
-
| Error Pattern | Nguyên nhân thường gặp | Suggested Fix |
|
|
133
|
-
|---|---|---|
|
|
134
|
-
| `AssertionError` trên output mock LLM | Giá trị mock return không khớp schema | Kiểm tra lại setup `mock_llm.return_value` / `mock_llm.complete.return_value` |
|
|
135
|
-
| `ValidationError` trên response | Cấu trúc output LLM không khớp schema kỳ vọng | Siết schema check hoặc thêm retry logic trong test |
|
|
136
|
-
| `ConnectionError` / `APIError` | LLM API thật bị gọi trong test | Đảm bảo mock `patch('...')` được áp dụng — không bao giờ gọi LLM thật trong unit test |
|
|
137
|
-
| `TimeoutError` | Test gọi LLM endpoint live | Thêm mock; kiểm tra test fixture |
|
|
138
|
-
| Kết quả flaky / non-deterministic | Response LLM thật dùng trong assertion | Thay bằng giá trị mock return tất định |
|
|
139
|
-
|
|
140
|
-
### Web frontend failure patterns
|
|
141
|
-
|
|
142
|
-
| Error Pattern | Nguyên nhân thường gặp | Suggested Fix |
|
|
143
|
-
|---|---|---|
|
|
144
|
-
| `Unable to find role "..."` | Element chưa render | Bọc trong `await waitFor(() => ...)` |
|
|
145
|
-
| `TestingLibraryElementError: Found multiple elements` | Selector quá rộng | Dùng `getByRole(..., { name: '...' })` để thu hẹp |
|
|
146
|
-
| `Network request not intercepted` | Thiếu MSW handler / `cy.intercept` | Thêm handler cho endpoint |
|
|
147
|
-
| `act(...)` warning | State update sau khi test kết thúc | Await async event / `await userEvent.click(...)` |
|
|
148
|
-
| `Cannot read properties of undefined` | Component render trước khi data load | Thêm loading state hoặc mock data đã resolve |
|
|
149
|
-
| Playwright timeout | Page chưa navigate / element ẩn | Kiểm tra route, thêm `waitForSelector` |
|
|
150
|
-
| `expect(page.locator(...)).toBeVisible` fail | Sai selector | Dùng Playwright Inspector để tìm đúng locator |
|
|
151
|
-
|
|
152
|
-
### Mobile failure patterns
|
|
153
|
-
|
|
154
|
-
#### Flutter
|
|
155
|
-
| Error Pattern | Nguyên nhân thường gặp | Suggested Fix |
|
|
156
|
-
|---|---|---|
|
|
157
|
-
| `pumpAndSettle timed out` | Async operation chưa hoàn thành | Dùng `pump(Duration(...))` cho delay cụ thể |
|
|
158
|
-
| `No widget found` | Widget chưa render / sai finder | Kiểm tra `find.byType`, `find.text`, `find.byKey` |
|
|
159
|
-
| `setState called after dispose` | Widget bị dispose trước khi async xong | Cancel async trong `dispose()` |
|
|
160
|
-
| BLoC state mismatch | Sai event emit | Verify `mockBloc` nhận đúng event |
|
|
161
|
-
|
|
162
|
-
#### React Native
|
|
163
|
-
| Error Pattern | Nguyên nhân thường gặp | Suggested Fix |
|
|
164
|
-
|---|---|---|
|
|
165
|
-
| `Unable to find element` | Thiếu `testID` hoặc sai query | Thêm `accessibilityLabel` hoặc `testID` vào component |
|
|
166
|
-
| `act(...)` warning | Async state update | Bọc trong `act(async () => { ... })` |
|
|
167
|
-
| Thiếu navigation mock | `useNavigation` chưa mock | Thêm jest mock cho `@react-navigation/native` |
|
|
168
|
-
|
|
169
|
-
#### iOS / Android
|
|
170
|
-
| Error Pattern | Nguyên nhân thường gặp | Suggested Fix |
|
|
171
|
-
|---|---|---|
|
|
172
|
-
| `XCTAssertEqual failed` | Sai giá trị kỳ vọng | Kiểm tra output ViewModel cho mock đã cho |
|
|
173
|
-
| `Compose node not found` | Sai `contentDescription` / `testTag` | Thêm `Modifier.testTag(...)` vào composable |
|
|
174
|
-
| `Hilt injection failed` | Thiếu test module | Thêm `@UninstallModules` + `@BindValue` trong test class |
|
|
175
|
-
| Emulator not available | `connectedAndroidTest` không có device | Khởi động emulator trước, chờ nó boot |
|
|
176
|
-
|
|
177
|
-
---
|
|
178
|
-
|
|
179
|
-
## Write Trace State
|
|
180
|
-
|
|
181
|
-
Sau khi chạy, lưu kết quả vào **TSV authoritative** trong service để chúng tới được
|
|
182
|
-
report Living Docs ở spec module (qua `/sync` + `/validate-traces`). Các file test
|
|
183
|
-
ở lại trong service — chỉ *status* của lần chạy được report.
|
|
184
|
-
|
|
185
|
-
Cập nhật **sổ của platform đang test** `{paths.trace_dir}/{domain}/{prd-slug}/{UC-ID}-{platform}.tsv` (`{platform}` = platform của code/`.feature` đang test — `system` cho backend, `web`/`app` cho FE/App; nếu `domain`/`prd_slug` không phân giải được từ spec target, định vị TSV bằng cách glob `{paths.trace_dir}/**/{UC-ID}-{platform}.tsv` — nó được tạo trước đó bởi `/generate-bdd`) — cho mỗi scenario row (khớp `sc_id` qua tag
|
|
186
|
-
`@trace.verifies={UC-ID}-SC{N}` của test). *(Umbrella + `spec_source`: `trace_dir` là `{spec_source}/.trace` — test chạy từ `service_root` nhưng update `dev_selftest` ghi vào **spec repo**; commit/push spec submodule cho nó.)*
|
|
187
|
-
|
|
188
|
-
| Cột | Giá trị |
|
|
189
|
-
|--------|-------|
|
|
190
|
-
| `dev_selftest` | `pass` nếu mọi test của SC này pass · `fail` nếu có cái fail · `not_run` nếu test của nó bị skip/vắng |
|
|
191
|
-
| `dev_selftest_at` | hôm nay `YYYY-MM-DD` |
|
|
192
|
-
| `last_updated` | hôm nay `YYYY-MM-DD` |
|
|
193
|
-
|
|
194
|
-
Giữ nguyên mọi cột khác — đặc biệt **không bao giờ** đụng `qc_status`/`qc_run_at`
|
|
195
|
-
(kết quả QC automation chính thức, do `/qc-run-test` sở hữu). `dev_selftest` (dev smoke)
|
|
196
|
-
và `qc_status` (QC chính thức) là hai tín hiệu riêng. `dev_selftest`/`dev_selftest_at` cũng
|
|
197
|
-
trực giao với `status` (OK/GAP/DRIFT/UNTRACKED/ORPHANED): `status` theo dõi *coverage*, `dev_selftest`
|
|
198
|
-
theo dõi *kết quả chạy* gần nhất của dev.
|
|
199
|
-
|
|
200
|
-
## Refresh Panel Mirror
|
|
201
|
-
{{include:steps/trace-mirror.md}}
|
|
202
|
-
|
|
203
|
-
## Output
|
|
204
|
-
|
|
205
|
-
{{include:steps/report-footer.md}}
|
|
206
|
-
|
|
207
|
-
```
|
|
208
|
-
/dev-run-test Report — {UC-ID} ({active_module})
|
|
209
|
-
✅ Passed: {N} | ❌ Failed: {M} | ⏭️ Skipped: {K} | Duration: {X}s
|
|
210
|
-
|
|
211
|
-
## Failed Tests
|
|
212
|
-
| Test | Error | Root Cause |
|
|
213
|
-
|------|-------|------------|
|
|
214
|
-
|
|
215
|
-
## Recommendations
|
|
216
|
-
{fix cụ thể cho từng failure}
|
|
217
|
-
|
|
218
|
-
Trace: {paths.trace_dir}/{domain}/{prd-slug}/{UC-ID}-{platform}.tsv updated (dev_selftest, dev_selftest_at)
|
|
219
|
-
|
|
220
|
-
Next:
|
|
221
|
-
Mọi test pass → /review-code {UC-ID}
|
|
222
|
-
Test fail → /fix-bug {TICKET_ID} (bug thật) hoặc fix test (sai expectation)
|
|
223
|
-
|
|
224
|
-
📊 Living Docs: chạy /validate-traces (hoặc /sync) để push trace này lên dashboard spec-module.
|
|
225
|
-
```
|