@longph2102/v-flow 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +265 -0
- package/CHANGELOG.md +318 -0
- package/LICENSE +21 -0
- package/README.md +326 -0
- package/agents/ba-agent.md +437 -0
- package/agents/ba-critic-agent.md +156 -0
- package/agents/ba-to-ptyc-agent.md +112 -0
- package/agents/bugfix-analyst-agent.md +221 -0
- package/agents/constitute-agent.md +155 -0
- package/agents/help-agent.md +168 -0
- package/agents/implement-agent.md +220 -0
- package/agents/import-ba-docs-agent.md +164 -0
- package/agents/master-check-agent.md +228 -0
- package/agents/metrics-agent.md +180 -0
- package/agents/operations-agent.md +123 -0
- package/agents/plan-agent.md +218 -0
- package/agents/prototype-agent.md +191 -0
- package/agents/retrospective-agent.md +196 -0
- package/agents/review-agent.md +210 -0
- package/agents/sprint-agent.md +191 -0
- package/agents/status-agent.md +186 -0
- package/agents/sync-agent.md +201 -0
- package/agents/test-agent.md +166 -0
- package/agents/understand-agent.md +339 -0
- package/cli/commands/check.js +96 -0
- package/cli/commands/dev-quiz.js +107 -0
- package/cli/commands/doctor.js +348 -0
- package/cli/commands/feature.js +259 -0
- package/cli/commands/hooks.js +163 -0
- package/cli/commands/init.js +189 -0
- package/cli/commands/log.js +199 -0
- package/cli/commands/plugin.js +230 -0
- package/cli/commands/score-card.js +203 -0
- package/cli/commands/status.js +269 -0
- package/cli/commands/sync.js +59 -0
- package/cli/commands/upgrade.js +150 -0
- package/cli/commands/validate.js +1259 -0
- package/cli/commands/watch.js +151 -0
- package/cli/index.js +46 -0
- package/cli/lib/ac-test-gate.js +89 -0
- package/cli/lib/activity-log.js +209 -0
- package/cli/lib/cli-error.js +183 -0
- package/cli/lib/constitution-lint.js +561 -0
- package/cli/lib/dev-quiz-grade.js +127 -0
- package/cli/lib/governance.js +78 -0
- package/cli/lib/hook-targets.js +167 -0
- package/cli/lib/i18n.js +375 -0
- package/cli/lib/knowledge-oracle.js +379 -0
- package/cli/lib/logger.js +203 -0
- package/cli/lib/module-card-lint.js +304 -0
- package/cli/lib/module-card-score.js +223 -0
- package/cli/lib/plugins.js +481 -0
- package/cli/lib/scanner.js +692 -0
- package/cli/lib/sync-core.js +232 -0
- package/cli/lib/sync-targets.js +84 -0
- package/cli/lib/templates.js +268 -0
- package/cli/lib/yaml-parser.js +203 -0
- package/commands/v.ba-critic.md +101 -0
- package/commands/v.ba-to-ptyc.md +71 -0
- package/commands/v.bugfix.md +86 -0
- package/commands/v.check.md +131 -0
- package/commands/v.constitute.md +87 -0
- package/commands/v.constitution.md +84 -0
- package/commands/v.fork.md +127 -0
- package/commands/v.help.md +73 -0
- package/commands/v.hotfix.md +200 -0
- package/commands/v.implement.md +92 -0
- package/commands/v.import-ba-docs.md +222 -0
- package/commands/v.metrics.md +74 -0
- package/commands/v.operations.md +70 -0
- package/commands/v.plan.md +78 -0
- package/commands/v.prototype.md +121 -0
- package/commands/v.quickfix.md +169 -0
- package/commands/v.retrospective.md +80 -0
- package/commands/v.review.md +78 -0
- package/commands/v.rewind.md +127 -0
- package/commands/v.specify.md +118 -0
- package/commands/v.sprint.md +75 -0
- package/commands/v.status.md +62 -0
- package/commands/v.sync.md +81 -0
- package/commands/v.test.md +67 -0
- package/commands/v.understand.md +112 -0
- package/package.json +65 -0
- package/skills/_shared/constitution-reader/SKILL.md +109 -0
- package/skills/_shared/constitution-reader/config.json +52 -0
- package/skills/_shared/constitution-reader/examples/good/b1-phase-output.md +48 -0
- package/skills/_shared/constitution-reader/gotchas.md +46 -0
- package/skills/_shared/context-reader/SKILL.md +111 -0
- package/skills/_shared/context-reader/config.json +54 -0
- package/skills/_shared/context-reader/examples/good/legacy-nodejs-output.md +35 -0
- package/skills/_shared/context-reader/gotchas.md +49 -0
- package/skills/_shared/ears-notation/SKILL.md +63 -0
- package/skills/_shared/ears-notation/config.json +55 -0
- package/skills/_shared/ears-notation/examples/good/plan-test-interpretation.md +29 -0
- package/skills/_shared/ears-notation/gotchas.md +43 -0
- package/skills/check/cross-validator/SKILL.md +206 -0
- package/skills/check/cross-validator/config.json +33 -0
- package/skills/check/cross-validator/examples/good/validation-report-pass-with-concerns.md +105 -0
- package/skills/check/cross-validator/gotchas.md +43 -0
- package/skills/implement/constitution-enforcer/SKILL.md +134 -0
- package/skills/implement/constitution-enforcer/config.json +16 -0
- package/skills/implement/constitution-enforcer/examples/bad/vague-report.md +42 -0
- package/skills/implement/constitution-enforcer/examples/good/compliance-report.md +57 -0
- package/skills/implement/constitution-enforcer/gotchas.md +26 -0
- package/skills/implement/constitution-enforcer/scripts/check-constitution.sh +88 -0
- package/skills/implement/no-go-zone-guard/SKILL.md +173 -0
- package/skills/implement/no-go-zone-guard/config.json +28 -0
- package/skills/implement/no-go-zone-guard/examples/good/adapter-workaround.md +46 -0
- package/skills/implement/no-go-zone-guard/gotchas.md +27 -0
- package/skills/implement/no-go-zone-guard/scripts/check-nogo-zones.sh +148 -0
- package/skills/implement/no-go-zone-guard/scripts/nogo-precommit.sh +96 -0
- package/skills/implement/tdd-driver/SKILL.md +159 -0
- package/skills/implement/tdd-driver/config.json +33 -0
- package/skills/implement/tdd-driver/examples/good/tdd-cycle-product-repo.md +81 -0
- package/skills/implement/tdd-driver/gotchas.md +34 -0
- package/skills/metrics/metrics-collector/SKILL.md +133 -0
- package/skills/metrics/metrics-collector/config.json +16 -0
- package/skills/metrics/metrics-collector/examples/bad/incomplete-report.md +48 -0
- package/skills/metrics/metrics-collector/examples/good/full-metrics-report.md +101 -0
- package/skills/metrics/metrics-collector/gotchas.md +26 -0
- package/skills/operations/incident-runbook/SKILL.md +167 -0
- package/skills/operations/incident-runbook/config.json +21 -0
- package/skills/operations/incident-runbook/examples/bad/vague-incident-report.md +48 -0
- package/skills/operations/incident-runbook/examples/good/p1-hotfix-response.md +119 -0
- package/skills/operations/incident-runbook/gotchas.md +26 -0
- package/skills/plan/architecture-designer/SKILL.md +228 -0
- package/skills/plan/architecture-designer/config.json +32 -0
- package/skills/plan/architecture-designer/examples/bad/vague-plan.md +62 -0
- package/skills/plan/architecture-designer/examples/good/expand-contract-migration.md +56 -0
- package/skills/plan/architecture-designer/examples/good/plan-structure.md +58 -0
- package/skills/plan/architecture-designer/gotchas.md +45 -0
- package/skills/plan/task-breakdown/SKILL.md +208 -0
- package/skills/plan/task-breakdown/config.json +26 -0
- package/skills/plan/task-breakdown/examples/bad/vague-tasks.md +77 -0
- package/skills/plan/task-breakdown/examples/good/spike-clarify-tasks.md +66 -0
- package/skills/plan/task-breakdown/examples/good/tasks-login-feature.md +111 -0
- package/skills/plan/task-breakdown/gotchas.md +39 -0
- package/skills/prototype/LOGIC.md +240 -0
- package/skills/prototype/SKILL.md +185 -0
- package/skills/prototype/UI.md +407 -0
- package/skills/prototype/config.json +104 -0
- package/skills/prototype/examples/bad/prototype-notes.md +68 -0
- package/skills/prototype/examples/good/prototype-notes-ui.md +109 -0
- package/skills/prototype/examples/good/prototype-notes.md +67 -0
- package/skills/prototype/gotchas.md +128 -0
- package/skills/prototype/scripts/check-flow-state.ps1 +112 -0
- package/skills/prototype/scripts/check-flow-state.sh +104 -0
- package/skills/prototype/scripts/check-prototype-cleanup.ps1 +124 -0
- package/skills/prototype/scripts/check-prototype-cleanup.sh +109 -0
- package/skills/prototype/scripts/check-prototype-notes.ps1 +107 -0
- package/skills/prototype/scripts/check-prototype-notes.sh +102 -0
- package/skills/review/adversarial-reviewer/SKILL.md +137 -0
- package/skills/review/adversarial-reviewer/config.json +32 -0
- package/skills/review/adversarial-reviewer/examples/good/review-report-template.md +56 -0
- package/skills/review/adversarial-reviewer/gotchas.md +46 -0
- package/skills/review/adversarial-reviewer/scripts/quick-security-scan.sh +52 -0
- package/skills/specify/ba-bpmn-doc-gen/SKILL.md +108 -0
- package/skills/specify/ba-bpmn-doc-gen/reference/reference-bpmn-generation.md +528 -0
- package/skills/specify/ba-bpmn-doc-gen/reference/reference-drawio-flowchart.md +466 -0
- package/skills/specify/ba-critic/SKILL.md +172 -0
- package/skills/specify/ba-critic/config.json +32 -0
- package/skills/specify/ba-critic/examples/good/critic-report-round1.md +51 -0
- package/skills/specify/ba-critic/gotchas.md +40 -0
- package/skills/specify/ba-critic/scripts/check-spec-quality.sh +72 -0
- package/skills/specify/ba-doc-generator/SKILL.md +102 -0
- package/skills/specify/ba-doc-generator/references/template-clevel.md +84 -0
- package/skills/specify/ba-doc-generator/references/template-compliance.md +83 -0
- package/skills/specify/ba-doc-generator/references/template-dev.md +138 -0
- package/skills/specify/ba-doc-generator/references/template-partner.md +167 -0
- package/skills/specify/ba-doc-generator/references/template-pm.md +92 -0
- package/skills/specify/ba-doc-generator/references/template-review.md +114 -0
- package/skills/specify/ba-doc-generator/references/template-tester.md +108 -0
- package/skills/specify/ba-doc-generator/references/template-user.md +98 -0
- package/skills/specify/bugfix-analyst/SKILL.md +296 -0
- package/skills/specify/bugfix-analyst/config.json +41 -0
- package/skills/specify/bugfix-analyst/examples/bad/common-mistakes.md +71 -0
- package/skills/specify/bugfix-analyst/examples/good/email-validation-bugfix.md +53 -0
- package/skills/specify/bugfix-analyst/gotchas.md +51 -0
- package/skills/specify/ears-writer/SKILL.md +129 -0
- package/skills/specify/ears-writer/config.json +20 -0
- package/skills/specify/ears-writer/examples/bad/common-mistakes.md +17 -0
- package/skills/specify/ears-writer/examples/good/login-requirements.md +41 -0
- package/skills/specify/ears-writer/gotchas.md +43 -0
- package/skills/specify/ears-writer/scripts/check-ears-compliance.sh +51 -0
- package/skills/test/test-case-generator/SKILL.md +161 -0
- package/skills/test/test-case-generator/config.json +33 -0
- package/skills/test/test-case-generator/examples/good/test-cases-login.md +104 -0
- package/skills/test/test-case-generator/gotchas.md +43 -0
- package/skills/understand/ba-docs-scanner/SKILL.md +239 -0
- package/skills/understand/ba-docs-scanner/config.json +47 -0
- package/skills/understand/ba-docs-scanner/examples/good/work-order-br-extract.md +28 -0
- package/skills/understand/ba-docs-scanner/gotchas.md +44 -0
- package/skills/understand/ba-docs-scanner/merge-rules.md +47 -0
- package/skills/understand/codebase-scanner/SKILL.md +260 -0
- package/skills/understand/codebase-scanner/config.json +56 -0
- package/skills/understand/codebase-scanner/examples/good/menu-module-output.md +44 -0
- package/skills/understand/codebase-scanner/gotchas.md +42 -0
- package/skills/understand/codebase-scanner/scripts/scan-project-structure.sh +64 -0
- package/templates/DESIGN.md +456 -0
- package/templates/agent-command-template.yaml +240 -0
- package/templates/agent-config-template.md +170 -0
- package/templates/agent-definition-template.md +145 -0
- package/templates/agent-metrics-template.md +150 -0
- package/templates/api-contract-template.md +72 -0
- package/templates/bugfix-report-template.md +195 -0
- package/templates/bugfix-spec-template.md +134 -0
- package/templates/code-review-report-template.md +119 -0
- package/templates/constitution-template.md +234 -0
- package/templates/context-template.md +94 -0
- package/templates/data-model-template.md +95 -0
- package/templates/decision-log-template.md +92 -0
- package/templates/flow-state-template.yaml +208 -0
- package/templates/github/workflows/v-flow-validate.yml +30 -0
- package/templates/knowledge/adr-template.md +70 -0
- package/templates/knowledge/api-contract-template.md +140 -0
- package/templates/knowledge/domain-glossary.md +29 -0
- package/templates/knowledge/golden-tests-readme.md +115 -0
- package/templates/knowledge/lessons-learned.md +41 -0
- package/templates/knowledge/patterns.md +103 -0
- package/templates/module-card/SKILL.md +85 -0
- package/templates/module-card/api-specs.md +96 -0
- package/templates/module-card/business-quiz.md +119 -0
- package/templates/module-card/cross-service.md +125 -0
- package/templates/module-card/db.md +85 -0
- package/templates/module-card/dev-quiz.md +62 -0
- package/templates/module-card/permissions.md +83 -0
- package/templates/module-card/state-diagram.md +64 -0
- package/templates/module-card/tech-context.md +90 -0
- package/templates/module-card/ui-flows.md +91 -0
- package/templates/module-card/use-cases.md +142 -0
- package/templates/module-template.yaml +161 -0
- package/templates/operations-report-template.md +108 -0
- package/templates/plan-template.md +308 -0
- package/templates/prototype-notes-template.md +116 -0
- package/templates/ptyc/PTYC.template.docx +0 -0
- package/templates/ptyc/ptyc.meta.example.yaml +44 -0
- package/templates/retrospective-report-template.md +136 -0
- package/templates/security-review-template.md +84 -0
- package/templates/session-template.md +167 -0
- package/templates/spec-review-log-template.md +75 -0
- package/templates/spec-template.md +229 -0
- package/templates/sprint-status-template.md +101 -0
- package/templates/tasks-template.md +275 -0
- package/templates/test-cases-template.md +124 -0
- package/templates/ux-checklist-template.md +79 -0
- package/templates/validation-report-template.md +125 -0
- package/templates/vflow-config-template.yaml +22 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Incident Runbook — Bad Example
|
|
2
|
+
|
|
3
|
+
> Ví dụ output THIẾU SÓT — không nên làm theo.
|
|
4
|
+
|
|
5
|
+
## ❌ Bad Output — Quá sơ sài
|
|
6
|
+
|
|
7
|
+
```markdown
|
|
8
|
+
## Incident
|
|
9
|
+
|
|
10
|
+
Login broke after deployment. Fixed the config. Back to normal now.
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Vấn đề
|
|
14
|
+
|
|
15
|
+
| # | Lỗi | Giải thích |
|
|
16
|
+
|---|------|-----------|
|
|
17
|
+
| 1 | Không có severity | Không biết P1 hay P4 |
|
|
18
|
+
| 2 | Không có timeline | "Sau deployment" — khi nào? bao lâu? |
|
|
19
|
+
| 3 | Không có root cause | "Config" — config gì? |
|
|
20
|
+
| 4 | Không có impact assessment | "Broke" — ảnh hưởng bao nhiêu user? |
|
|
21
|
+
| 5 | Không có post-mortem | Không học được gì → sẽ lặp lại |
|
|
22
|
+
| 6 | Không có action items | Không ai chịu trách nhiệm prevent |
|
|
23
|
+
|
|
24
|
+
## ❌ Bad Output — Có structure nhưng thiếu depth
|
|
25
|
+
|
|
26
|
+
```markdown
|
|
27
|
+
## Incident Report INC-042
|
|
28
|
+
|
|
29
|
+
**Severity**: P1
|
|
30
|
+
**Issue**: Login not working
|
|
31
|
+
**Fix**: Updated config
|
|
32
|
+
**Status**: Resolved
|
|
33
|
+
|
|
34
|
+
### Actions
|
|
35
|
+
- Fix the bug
|
|
36
|
+
- Deploy fix
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Vấn đề
|
|
40
|
+
|
|
41
|
+
| # | Lỗi | Giải thích |
|
|
42
|
+
|---|------|-----------|
|
|
43
|
+
| 1 | "Login not working" — mơ hồ | 500? 403? Timeout? |
|
|
44
|
+
| 2 | "Updated config" — cụ thể gì? | File nào? Thay đổi gì? |
|
|
45
|
+
| 3 | Không có timeline | Mất bao lâu detect→fix? |
|
|
46
|
+
| 4 | Không có verification | Sao biết fix hoạt động? |
|
|
47
|
+
| 5 | Actions quá generic | "Fix the bug" — already done? future prevention? |
|
|
48
|
+
| 6 | Không blame-free analysis | Không có systemic improvement |
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Incident Runbook — Good Example: P1 Hotfix
|
|
2
|
+
|
|
3
|
+
> Ví dụ output chuẩn khi Operations Agent xử lý P1 incident.
|
|
4
|
+
|
|
5
|
+
## Scenario
|
|
6
|
+
|
|
7
|
+
**Alert**: Login API returning 500 after deployment at 14:30
|
|
8
|
+
**Impact**: All users unable to login — service effectively down
|
|
9
|
+
|
|
10
|
+
## Output — operations-report.md
|
|
11
|
+
|
|
12
|
+
```markdown
|
|
13
|
+
## 🚨 Incident Report — INC-042
|
|
14
|
+
|
|
15
|
+
**Status**: ✅ Resolved
|
|
16
|
+
**Severity**: P1 — Service Down
|
|
17
|
+
**Detected**: 2026-04-25 14:35 (monitoring alert)
|
|
18
|
+
**Resolved**: 2026-04-25 15:10 (35 min total)
|
|
19
|
+
**Impact**: 100% users unable to login for 35 minutes
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
### Triage (T+0 → T+5 min)
|
|
24
|
+
|
|
25
|
+
**Alert Source**: Automated monitoring (5xx spike > 50%)
|
|
26
|
+
**Impact Assessment**:
|
|
27
|
+
- Users affected: ALL (100%)
|
|
28
|
+
- Feature affected: Authentication (login, register, password reset)
|
|
29
|
+
- Data integrity: ✅ Safe (no write operations affected)
|
|
30
|
+
|
|
31
|
+
**Severity**: P1 — Service Down
|
|
32
|
+
**Response SLA**: < 15 min (started investigation at T+5m)
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
### Root Cause Analysis
|
|
37
|
+
|
|
38
|
+
**Timeline**:
|
|
39
|
+
|
|
40
|
+
| Time | Event |
|
|
41
|
+
|------|-------|
|
|
42
|
+
| 14:30 | Deploy v2.3.1 to production |
|
|
43
|
+
| 14:32 | First 500 errors appear in logs |
|
|
44
|
+
| 14:35 | Monitoring alert fires (5xx > 50%) |
|
|
45
|
+
| 14:37 | On-call engineer acknowledges alert |
|
|
46
|
+
| 14:40 | Investigation started — review deploy diff |
|
|
47
|
+
| 14:45 | Root cause identified: JWT_SECRET env var missing |
|
|
48
|
+
| 14:50 | Hotfix: restore env var in deployment config |
|
|
49
|
+
| 14:55 | Redeployed with fix |
|
|
50
|
+
| 15:00 | 5xx rate drops to 0% |
|
|
51
|
+
| 15:10 | Confirmed stable — incident resolved |
|
|
52
|
+
|
|
53
|
+
**Root Cause**: Deployment script v2.3.1 introduced new config template that didn't include `JWT_SECRET` environment variable. Auth middleware threw unhandled exception when trying to verify tokens → 500 for all authenticated routes.
|
|
54
|
+
|
|
55
|
+
**Direct cause**: Missing env var in deployment config template
|
|
56
|
+
**Contributing factor**: No pre-deploy env var validation
|
|
57
|
+
**Systemic issue**: Deployment config not versioned with code
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
### Containment
|
|
62
|
+
|
|
63
|
+
**Actions Taken**:
|
|
64
|
+
1. ✅ Restored `JWT_SECRET` in deployment config
|
|
65
|
+
2. ✅ Redeployed with correct config
|
|
66
|
+
3. ✅ Verified login flow working end-to-end
|
|
67
|
+
4. ✅ Posted status update to #incidents channel
|
|
68
|
+
|
|
69
|
+
**Verification**:
|
|
70
|
+
- Login success rate: 99.9% (back to normal)
|
|
71
|
+
- 5xx rate: 0%
|
|
72
|
+
- Response time: 120ms (normal baseline: 100-150ms)
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
### Fix Details
|
|
77
|
+
|
|
78
|
+
**Route**: `/v.hotfix` (skip spec, direct implement → review → deploy)
|
|
79
|
+
**Branch**: `hotfix/INC-042-jwt-secret`
|
|
80
|
+
**Files changed**: 1 (`deploy/config.template.yaml`)
|
|
81
|
+
**Test**: ✅ Smoke test — login flow works
|
|
82
|
+
**Rollback plan**: Revert to v2.3.0 deployment config
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
### Post-Mortem
|
|
87
|
+
|
|
88
|
+
**What went well**:
|
|
89
|
+
1. Fast detection (3 min from deploy to alert)
|
|
90
|
+
2. Clear RCA — identified in 10 minutes
|
|
91
|
+
3. Fix was minimal and non-invasive
|
|
92
|
+
|
|
93
|
+
**What went wrong**:
|
|
94
|
+
1. No pre-deploy env var validation check
|
|
95
|
+
2. Config template change not reviewed for env var completeness
|
|
96
|
+
3. No canary deployment — went straight to 100%
|
|
97
|
+
|
|
98
|
+
**Action Items**:
|
|
99
|
+
|
|
100
|
+
| # | Action | Owner | Due | Status |
|
|
101
|
+
|---|--------|-------|-----|--------|
|
|
102
|
+
| 1 | Add env var validation to deploy pipeline | DevOps | Sprint 12 | ⬜ |
|
|
103
|
+
| 2 | Add config template change to review checklist | Tech Lead | Sprint 12 | ⬜ |
|
|
104
|
+
| 3 | Implement canary deployment (10% → 50% → 100%) | DevOps | Sprint 13 | ⬜ |
|
|
105
|
+
| 4 | Add integration test for auth middleware startup | Dev | Sprint 12 | ⬜ |
|
|
106
|
+
|
|
107
|
+
### Knowledge Base Update
|
|
108
|
+
→ File: `.v-flow/knowledge/lessons-learned/INC-042-jwt-secret.md`
|
|
109
|
+
→ Added No-Go note: deployment config templates require env var review
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Why This Is Good
|
|
113
|
+
|
|
114
|
+
1. ✅ **Structured timeline** — rõ ràng từng phút xảy ra gì
|
|
115
|
+
2. ✅ **Multi-level RCA** — direct, contributing, systemic causes
|
|
116
|
+
3. ✅ **Containment verified** — metrics chứng minh fix hoạt động
|
|
117
|
+
4. ✅ **Actionable post-mortem** — 4 specific items với owner và deadline
|
|
118
|
+
5. ✅ **Knowledge captured** — lessons learned filed for future prevention
|
|
119
|
+
6. ✅ **Non-blame** — focus vào process improvement, không blame cá nhân
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Incident Runbook — Gotchas & Common Mistakes
|
|
2
|
+
|
|
3
|
+
## ⚠️ Gotcha 1: Jumping to Fix Without Understanding
|
|
4
|
+
|
|
5
|
+
**Sai**: Thấy error → sửa ngay dòng code gây lỗi.
|
|
6
|
+
**Đúng**: Triage → Investigate → Understand root cause → THEN fix. Quick patch che giấu vấn đề sâu hơn.
|
|
7
|
+
|
|
8
|
+
## ⚠️ Gotcha 2: Incorrect Severity
|
|
9
|
+
|
|
10
|
+
**Sai**: Mọi incident đều P1 vì "user is complaining".
|
|
11
|
+
**Đúng**: P1 = service down / data loss. P2 = major feature broken. Sai severity → sai response → resource waste.
|
|
12
|
+
|
|
13
|
+
## ⚠️ Gotcha 3: Skipping Post-Mortem
|
|
14
|
+
|
|
15
|
+
**Sai**: Fix xong → close ticket → move on.
|
|
16
|
+
**Đúng**: Post-mortem bắt buộc cho P1/P2. Ghi lessons learned vào `.v-flow/knowledge/lessons-learned/`.
|
|
17
|
+
|
|
18
|
+
## ⚠️ Gotcha 4: Modifying No-Go Zones
|
|
19
|
+
|
|
20
|
+
**Sai**: Emergency = được phép sửa mọi thứ.
|
|
21
|
+
**Đúng**: No-Go Zones vẫn cần Tech Lead approval, kể cả P1. Document lý do nếu phải vi phạm.
|
|
22
|
+
|
|
23
|
+
## ⚠️ Gotcha 5: No Rollback Plan
|
|
24
|
+
|
|
25
|
+
**Sai**: Deploy hotfix mà không có rollback strategy.
|
|
26
|
+
**Đúng**: Mỗi hotfix PHẢI có rollback plan. Feature flags preferred over code changes khi possible.
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: architecture-designer
|
|
3
|
+
description: "Hướng dẫn Plan Agent thiết kế kiến trúc từ spec. Agent PHẢI đọc skill này khi /v.plan được gọi. Đảm bảo design tuân thủ constitution + không vi phạm No-Go Zones."
|
|
4
|
+
trigger: "Khi /v.plan được gọi, bắt đầu thiết kế kiến trúc"
|
|
5
|
+
phase: "B.0a"
|
|
6
|
+
used_by:
|
|
7
|
+
- /v.plan
|
|
8
|
+
hooks:
|
|
9
|
+
pre_design: "Load spec.md + constitution.md + context.md → extract constraints"
|
|
10
|
+
post_design: "Cross-check plan vs No-Go Zones, verify pattern alignment"
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Architecture Designer — Thiết Kế Kiến Trúc Từ Spec
|
|
14
|
+
|
|
15
|
+
> ⚠️ Đây là **Skill bắt buộc** cho Plan Agent khi thiết kế.
|
|
16
|
+
> QUAN TRỌNG: Thiết kế PHẢI tuân thủ constitution và KHÔNG vi phạm No-Go Zones.
|
|
17
|
+
>
|
|
18
|
+
> → Xem `gotchas.md` cho lỗi thiết kế phổ biến.
|
|
19
|
+
> → Xem `examples/good/` cho mẫu plan chuẩn — và `examples/bad/` cho anti-pattern (đối chứng).
|
|
20
|
+
> → Xem `config.json` để customize (architecture style, layers).
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Khi nào KHÔNG áp dụng skill này
|
|
25
|
+
|
|
26
|
+
- Quick Fix (`/v.quickfix`) — không cần thiết kế kiến trúc, direct bugfix
|
|
27
|
+
- Hotfix (`/v.hotfix`) — minimal change, không redesign
|
|
28
|
+
- Documentation-only change — không có code change
|
|
29
|
+
|
|
30
|
+
> **Lite profile**: feature `quickfix`/`hotfix` (trong `.flow-state.yaml`) → plan tối giản; `v-flow validate` tự bỏ qua nudge Tech Decisions / NFR / file-structure. Vẫn giữ §6 File Changes + §3.4 DDL nếu đụng DB.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Quy Trình Thiết Kế — Input → Design → Validate
|
|
35
|
+
|
|
36
|
+
> 💡 Phần này cung cấp **framework tư duy**, không phải step-by-step script.
|
|
37
|
+
|
|
38
|
+
### Phase 1: Constraint Extraction
|
|
39
|
+
|
|
40
|
+
Trước khi thiết kế, extract TẤT CẢ constraints:
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
Từ constitution.md:
|
|
44
|
+
→ Architecture pattern (MVC, Clean Architecture, Hexagonal...)
|
|
45
|
+
→ Layer rules (dependency direction, coupling limits)
|
|
46
|
+
→ Naming conventions (file, class, function)
|
|
47
|
+
→ Error handling pattern (Result type, exceptions, error codes)
|
|
48
|
+
|
|
49
|
+
Từ context.md (nếu legacy):
|
|
50
|
+
→ No-Go Zones (KHÔNG ĐƯỢC ĐỤNG)
|
|
51
|
+
→ Existing patterns (đang dùng pattern gì)
|
|
52
|
+
→ Tech debt (cẩn thận khu vực này)
|
|
53
|
+
→ Entry points (extend từ đâu)
|
|
54
|
+
|
|
55
|
+
Từ spec.md:
|
|
56
|
+
→ REQ → component mapping (REQ nào cần component mới?)
|
|
57
|
+
→ Data flow (data đi từ đâu đến đâu?)
|
|
58
|
+
→ Integration points (external systems?)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Phase 2: Component Design
|
|
62
|
+
|
|
63
|
+
**Signals đúng:**
|
|
64
|
+
- Mỗi component có **single responsibility**
|
|
65
|
+
- Dependency direction tuân thủ constitution (thường: UI → Domain → Data)
|
|
66
|
+
- Interfaces tại boundaries (testable, mockable)
|
|
67
|
+
- No-Go Zone code KHÔNG bị modify — tạo adapter/wrapper nếu cần
|
|
68
|
+
|
|
69
|
+
**Signals sai:**
|
|
70
|
+
- Component làm quá nhiều việc (> 3 responsibilities)
|
|
71
|
+
- Circular dependency (A → B → C → A)
|
|
72
|
+
- Bypass layer (UI gọi thẳng DB)
|
|
73
|
+
- Modify No-Go Zone code trực tiếp
|
|
74
|
+
|
|
75
|
+
### Phase 3: File Structure
|
|
76
|
+
|
|
77
|
+
```markdown
|
|
78
|
+
Với mỗi component trong design:
|
|
79
|
+
1. Xác định file path CHÍNH XÁC (không dùng "somewhere in src/")
|
|
80
|
+
2. Xác định file là MỚI hay MODIFY
|
|
81
|
+
3. Nếu MODIFY → check No-Go Zone → nếu trùng → DỪNG, redesign
|
|
82
|
+
4. Ghi dependencies giữa files (import direction)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Đặc Thù Và Quy Ước
|
|
88
|
+
|
|
89
|
+
> 💡 Phần này chứa patterns Plan Agent thường bỏ sót.
|
|
90
|
+
|
|
91
|
+
### 1. REQ → Component Traceability
|
|
92
|
+
|
|
93
|
+
Mỗi component trong plan PHẢI trace về ≥1 REQ:
|
|
94
|
+
- ❌ Component không có REQ → over-engineering, bỏ đi
|
|
95
|
+
- ❌ REQ không có component → gap, thiếu design
|
|
96
|
+
- ✅ Ma trận REQ ↔ Component rõ ràng trong plan.md
|
|
97
|
+
|
|
98
|
+
### 2. Greenfield vs Legacy Design
|
|
99
|
+
|
|
100
|
+
| Aspect | Greenfield | Legacy |
|
|
101
|
+
|--------|-----------|--------|
|
|
102
|
+
| Component mới | Tự do tạo | Phải fit existing structure |
|
|
103
|
+
| Patterns | Theo constitution | Theo existing patterns + constitution |
|
|
104
|
+
| No-Go Zones | Không có | **BẮT BUỘC check** mỗi file |
|
|
105
|
+
| Entry points | Tự định nghĩa | Extend từ existing entry points |
|
|
106
|
+
| Test strategy | Ideal (unit + integration) | Pragmatic (integration first) |
|
|
107
|
+
|
|
108
|
+
### 3. Plan phải gồm Error Architecture
|
|
109
|
+
|
|
110
|
+
- Error types: liệt kê error types cho feature này
|
|
111
|
+
- Error flow: error propagate qua layers như thế nào
|
|
112
|
+
- Error response: format cho API/UI consumers
|
|
113
|
+
- Error logging: cái nào log, cái nào swallow
|
|
114
|
+
|
|
115
|
+
### 4. Security Architecture Section
|
|
116
|
+
|
|
117
|
+
Nếu feature involve auth/data → plan PHẢI có section Security:
|
|
118
|
+
- Authentication flow
|
|
119
|
+
- Authorization checks (WHERE trong code)
|
|
120
|
+
- Data validation layer
|
|
121
|
+
- Sensitive data handling
|
|
122
|
+
|
|
123
|
+
### 5. Brownfield — Đặc tả thay đổi mức symbol
|
|
124
|
+
|
|
125
|
+
Với mỗi file **SỬA** (không phải tạo mới), KHÔNG ghi "cập nhật logic". PHẢI có:
|
|
126
|
+
- **Vị trí**: hàm / class / widget / endpoint cụ thể
|
|
127
|
+
- **Hiện trạng**: behavior/code hiện tại
|
|
128
|
+
- **Mong muốn**: sau khi sửa
|
|
129
|
+
- **Loại**: Thêm / Sửa / Xóa / Refactor
|
|
130
|
+
|
|
131
|
+
- ❌ "Sửa AuthService để hỗ trợ role" → mơ hồ, dev phải hỏi lại.
|
|
132
|
+
- ✅ "`AuthService.login()`: hiện trả token ngay sau khi verify password → thêm bước check `user.role ∈ allowed` trước khi cấp token; ném `ForbiddenError` nếu fail."
|
|
133
|
+
|
|
134
|
+
### 6. Screen Changes — lấy từ spec, không bịa
|
|
135
|
+
|
|
136
|
+
Đọc **"Mô tả màn hình"** của từng `UC-xx` trong spec → đưa vào plan §5:
|
|
137
|
+
- Màn hình nào **New/Sửa**, thay đổi gì
|
|
138
|
+
- Component / widget liên quan
|
|
139
|
+
- Các trạng thái: empty / loading / error / success
|
|
140
|
+
- Token tham chiếu từ `DESIGN.md` (`button-primary`, `input-default`...) — KHÔNG hardcode hex/size
|
|
141
|
+
|
|
142
|
+
### 7. Migration — khi đụng schema có sẵn
|
|
143
|
+
|
|
144
|
+
Nếu data model đụng bảng đã tồn tại → tách rõ trong plan §3.4:
|
|
145
|
+
- Bảng **MỚI** vs **ALTER** bảng cũ
|
|
146
|
+
- Cột: tên / kiểu / null / default / index
|
|
147
|
+
- File migration + rollback + backfill (nếu cần)
|
|
148
|
+
- Mỗi schema change thường là 1 task `[DB]` riêng (đầu chuỗi).
|
|
149
|
+
- **DDL thật (up + down)**: ghi câu lệnh copy-paste-được trong §3.4 (`ALTER/CREATE…` hoặc lệnh ORM tương đương) — dev không phải đoán. DDL là *đặc tả schema*, không phải code logic → không vi phạm "plan không chứa code".
|
|
150
|
+
- **Breaking change → Expand-Contract** (zero-downtime): đổi/bỏ cột hoặc thêm NOT NULL → tách Expand (thêm cột nullable, ghi cả cũ+mới) → Migrate (backfill + đọc cột mới) → Contract (bỏ cột cũ release sau). KHÔNG ALTER phá tương thích trong 1 bước. → mẫu đầy đủ (DDL + chia release): `examples/good/expand-contract-migration.md`.
|
|
151
|
+
|
|
152
|
+
### 8. Contract-first — khi có cả Frontend và Backend
|
|
153
|
+
|
|
154
|
+
Nếu feature đụng **cả `[UI]` lẫn `[API]`** (FE gọi BE), phải **đóng băng contract TRƯỚC** để hai bên làm song song an toàn:
|
|
155
|
+
- Chốt **data model** + **API contract** (request/response, error codes) → ghi vào `data-model.md` (theo `.v-flow/templates/data-model-template.md`) + `contracts/` (theo `.v-flow/templates/api-contract-template.md`).
|
|
156
|
+
- Contract trở thành **một task sớm** (entrypoint hoặc dependency chung); task `[UI]` và `[API]` đều `[DEPENDS]` vào nó **trước khi** chạy `[PARALLEL]`.
|
|
157
|
+
- ❌ FE và BE `[PARALLEL]` mà contract chưa chốt → hai bên đoán field khác nhau → rework.
|
|
158
|
+
- ✅ Contract `[GATE]`/`[CRITICAL]` ở đầu → FE mock theo contract, BE implement theo contract, ghép không vỡ.
|
|
159
|
+
|
|
160
|
+
### 9. NFR — đừng để Yêu cầu phi chức năng rơi rụng
|
|
161
|
+
|
|
162
|
+
Mỗi `UC-xx` trong spec có mục **"Yêu cầu đặc biệt"** (perf / security / a11y / audit). Plan PHẢI kéo từng NFR vào §10 và gắn cách đáp ứng + nơi verify:
|
|
163
|
+
- **Perf** → ngân sách (p95/throughput) → task `[TEST]` đo budget.
|
|
164
|
+
- **A11y** → tiêu chí trong task `[UI]` (keyboard, label, contrast).
|
|
165
|
+
- **Audit/Compliance** → task `[LOGIC]` (interceptor/log) — không nhét rải rác.
|
|
166
|
+
- ❌ NFR chỉ nằm trong spec mà không có task → chắc chắn bị bỏ khi code.
|
|
167
|
+
|
|
168
|
+
### 10. Observability & Rollout — feature lên production
|
|
169
|
+
|
|
170
|
+
Nếu feature chạy thật → plan §11 phải trả lời: làm sao biết nó **chạy đúng/đổ vỡ**, và **tung ra an toàn**:
|
|
171
|
+
- Feature flag (bật dần), metrics cần emit, logs (không lộ dữ liệu nhạy cảm), alerts (ngưỡng), rollout/rollback.
|
|
172
|
+
- Gieo mầm cho `metrics-agent` / `operations` agent hạ nguồn.
|
|
173
|
+
|
|
174
|
+
### 11. Truy vấn quan trọng (Key Queries) — đừng để dev đoán access pattern
|
|
175
|
+
|
|
176
|
+
Truy vấn có pattern **không hiển nhiên** (filter/join/phân trang/soft-delete/aggregate) → ghi vào plan §3.5: **bảng · predicate chính** (vd `WHERE deleted_at IS NULL`) **· index dùng**. Ghi **hình dạng, KHÔNG full SQL** — giữ nguyên tắc "plan không chứa code logic". CRUD đơn giản theo PK → bỏ qua. (DDL migration thì NGƯỢC lại — ghi câu lệnh đầy đủ, vì DDL là đặc tả schema.)
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## Plan Output Structure
|
|
181
|
+
|
|
182
|
+
→ Xem `examples/good/plan-structure.md` cho format chuẩn.
|
|
183
|
+
|
|
184
|
+
Minimum required sections:
|
|
185
|
+
```
|
|
186
|
+
1. Overview — mô tả kiến trúc 1 đoạn
|
|
187
|
+
2. Component Diagram — mermaid hoặc ASCII
|
|
188
|
+
3. File Structure — path chính xác, new/modify (file SỬA: vị trí symbol + hiện trạng→mong muốn)
|
|
189
|
+
4. REQ ↔ Component Matrix — traceability
|
|
190
|
+
5. Data Migrations (nếu đụng schema) — bảng new/alter, cột, **DDL thật up+down**, rollback; + **Key Queries** (§3.5) nếu truy vấn không hiển nhiên
|
|
191
|
+
6. Screen Changes (nếu có UI) — màn hình, component, trạng thái, token DESIGN.md
|
|
192
|
+
7. Dependencies — external deps + internal imports
|
|
193
|
+
8. Error Architecture — error types, flow, response
|
|
194
|
+
9. Security (nếu applicable) — auth, validation, data
|
|
195
|
+
10. Tech Decisions — WHY chọn approach này + **phương án đã cân nhắc/loại** (alternatives) + đánh đổi (plan §13)
|
|
196
|
+
11. NFR (nếu spec có Yêu cầu đặc biệt) — perf/a11y/audit → cách đáp ứng + verify
|
|
197
|
+
12. Observability & Rollout (nếu lên production) — flags, metrics, alerts, rollout
|
|
198
|
+
13. Assumptions & Open Questions — gom giả định thiết kế + câu hỏi `[CLARIFY]` về một chỗ
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Self-Review — soi lại bằng "mắt mới" (bắt buộc trước khi handoff)
|
|
204
|
+
|
|
205
|
+
> 💡 Viết xong plan → ĐỌC LẠI spec một lượt như chưa từng thấy plan, bắt gap **ngữ nghĩa** mà validator (structural) không thấy. Đây là **checklist tự chạy**, KHÔNG dispatch subagent, KHÔNG đẩy validator sang kiểm semantics (giữ phân vai: validator = lint cấu trúc · Master Check = ngữ nghĩa · human = phán xét).
|
|
206
|
+
|
|
207
|
+
1. **Phủ spec 2 chiều**: lướt từng REQ/UC/NFR của spec → mỗi cái trỏ được tới ≥1 component/section trong plan? (thiếu = gap). **Và ngược lại**: mỗi component trong plan trace về ≥1 REQ? (thừa = over-engineering → bỏ).
|
|
208
|
+
2. **Quét placeholder**: không còn `TBD`/`TODO`/"xử lý sau"/"thêm validation phù hợp"/"tương tự phần trên" — thay bằng nội dung thật, hoặc gắn `[CLARIFY]` + Câu hỏi mở nếu thật sự chưa rõ.
|
|
209
|
+
3. **Nhất quán ký hiệu (symbol/naming)**: tên class/hàm/endpoint/bảng/token dùng ở section sau KHỚP đúng tên đã đặt ở section trước. `AuthService.login()` ở §3 mà thành `AuthSvc.signIn()` ở §8 = bug → sửa cho khớp.
|
|
210
|
+
4. **DDL/contract khớp design**: §3.4 DDL up+down chạy được & khớp cột mô tả ở §3; §4.2 field contract khớp data model.
|
|
211
|
+
|
|
212
|
+
Thấy lỗi → **sửa tại chỗ**, không cần review lại. Thiếu task/section cho 1 REQ → thêm. Mục tiêu: bắt drift NGAY, trước khi sang task-breakdown / Master Check.
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## V-Flow Integration Points
|
|
217
|
+
|
|
218
|
+
- **spec.md** (S.1) → Input: REQs + ACs
|
|
219
|
+
- **constitution.md** → Constraint: patterns, conventions
|
|
220
|
+
- **context.md** → Constraint: No-Go Zones, existing patterns
|
|
221
|
+
- **task-breakdown skill** → Output plan → input cho task skill
|
|
222
|
+
- **_session.md** → Ghi tech decisions + open questions
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## Gotchas
|
|
227
|
+
|
|
228
|
+
→ Xem `gotchas.md` cho lỗi thiết kế phổ biến — cập nhật liên tục.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"setup_questions": [
|
|
3
|
+
{
|
|
4
|
+
"id": "architecture_style",
|
|
5
|
+
"question": "Architecture style ưu tiên?",
|
|
6
|
+
"options": ["clean-architecture", "mvc", "hexagonal", "layered", "auto-detect"],
|
|
7
|
+
"default": "auto-detect",
|
|
8
|
+
"description": "auto-detect = đọc constitution.md để xác định. Nếu không có → dùng layered."
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"id": "diagram_format",
|
|
12
|
+
"question": "Component diagram format?",
|
|
13
|
+
"options": ["mermaid", "ascii", "none"],
|
|
14
|
+
"default": "mermaid"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"id": "include_security",
|
|
18
|
+
"question": "Luôn include security architecture section?",
|
|
19
|
+
"type": "boolean",
|
|
20
|
+
"default": true
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"hooks": {
|
|
24
|
+
"pre_design": "Extract No-Go Zones từ context.md, extract patterns từ constitution.md",
|
|
25
|
+
"post_design": "Verify: mỗi REQ có component, mỗi file path chính xác, No-Go Zone safe"
|
|
26
|
+
},
|
|
27
|
+
"memory": {
|
|
28
|
+
"file": "plan-history.log",
|
|
29
|
+
"format": "[date] | [feature] | [components_count] | [new_files] | [modified_files] | [nogo_checks_passed]",
|
|
30
|
+
"purpose": "Track design decisions — dùng cho /v.retrospective"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Ví dụ XẤU — Plan mơ hồ (KHÔNG làm theo)
|
|
2
|
+
|
|
3
|
+
> ⚠️ Đây là **anti-pattern**. Đối chiếu với `examples/good/plan-structure.md`.
|
|
4
|
+
> Mỗi khối dưới đây minh họa một lỗi trong `gotchas.md`.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## ❌ 1. File path mơ hồ + thiếu loại New/Modify
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
| Component | Vị trí | Mô tả |
|
|
12
|
+
|-----------|--------|-------|
|
|
13
|
+
| Login | đâu đó trong src/ | xử lý đăng nhập |
|
|
14
|
+
| Token | core | lưu token |
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
**Sai vì**: "đâu đó trong src/", "core" → Implement Agent tự quyết path → cấu trúc lệch chuẩn; không biết file MỚI hay SỬA.
|
|
18
|
+
**Sửa**: `lib/features/auth/data/auth_repository_impl.dart` (NEW) — path chính xác + đánh dấu New/Modify.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## ❌ 2. Thiếu REQ traceability (over-engineering)
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
Components: LoginService, AuthCache, RetryManager, CircuitBreaker, MetricsCollector, PluginRegistry
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**Sai vì**: spec chỉ có REQ về đăng nhập email/password. `PluginRegistry`, `CircuitBreaker` không trace về REQ nào → YAGNI, thừa.
|
|
29
|
+
**Sửa**: mỗi component PHẢI map ≥1 REQ-xxx. Không có REQ → bỏ.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## ❌ 3. Chỉ có happy path — thiếu Error Architecture
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
Luồng: User nhập → gọi API → nhận token → vào Home. Xong.
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Sai vì**: không nói gì khi 401 / mất mạng / account khóa → error handling ad-hoc, format lỗi mỗi nơi mỗi kiểu.
|
|
40
|
+
**Sửa**: bảng Error Architecture (type → HTTP → handler → message), xem `examples/good`.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## ❌ 4. Đụng No-Go Zone mà không kiểm tra
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
Sửa trực tiếp `legacy/sso_handler.dart` để thêm field role.
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Sai vì**: `sso_handler.dart` nằm trong No-Go Zone (context.md §4). Sửa trực tiếp → Implement Agent bị block ở B.1, phải re-plan.
|
|
51
|
+
**Sửa**: tạo adapter/wrapper, KHÔNG sửa code vùng cấm; ghi rõ ở §9 No-Go Verification.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## ❌ 5. Mô tả thay đổi chung chung (brownfield)
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
- AuthService: cập nhật logic để hỗ trợ role.
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**Sai vì**: "cập nhật logic" → dev phải hỏi lại sửa hàm nào, sửa gì.
|
|
62
|
+
**Sửa**: `AuthService.login()` — hiện trả token ngay sau verify password → thêm bước check `user.role ∈ allowed` trước khi cấp token; ném `ForbiddenError` nếu fail.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Ví dụ — Breaking migration zero-downtime (Expand-Contract) + chia release
|
|
2
|
+
|
|
3
|
+
> Minh hoạ đổi cột phá tương thích **mà không downtime**, tách 3 bước qua **2 release** (milestone). Đây là case template §3.4 mô tả nhưng ít được demo. Mỗi bước = 1 task `[DB]` riêng, có **DDL up+down thật**.
|
|
4
|
+
|
|
5
|
+
## Bối cảnh
|
|
6
|
+
Đổi `users.full_name` (1 cột) → tách `first_name` + `last_name`. Đổi/bỏ cột trực tiếp = breaking (app cũ còn đọc `full_name`). Dùng **Expand → Migrate → Contract**.
|
|
7
|
+
|
|
8
|
+
## §3.4 Database Migrations (3 bước)
|
|
9
|
+
|
|
10
|
+
| Bảng | Bước | New/ALTER | Cột | DDL |
|
|
11
|
+
|------|------|:---------:|-----|-----|
|
|
12
|
+
| `users` | 1 Expand | ALTER | `first_name`, `last_name` (nullable) | thêm cột mới, KHÔNG bỏ `full_name` |
|
|
13
|
+
| `users` | 2 Migrate | — | (backfill) | copy dữ liệu, app ghi cả cũ+mới, đọc cột mới |
|
|
14
|
+
| `users` | 3 Contract | ALTER | bỏ `full_name` | chỉ sau khi không còn consumer đọc cột cũ |
|
|
15
|
+
|
|
16
|
+
### DDL thật
|
|
17
|
+
|
|
18
|
+
```sql
|
|
19
|
+
-- Bước 1 — Expand (Release N)
|
|
20
|
+
-- up
|
|
21
|
+
ALTER TABLE users ADD COLUMN first_name text NULL;
|
|
22
|
+
ALTER TABLE users ADD COLUMN last_name text NULL;
|
|
23
|
+
-- down
|
|
24
|
+
ALTER TABLE users DROP COLUMN first_name;
|
|
25
|
+
ALTER TABLE users DROP COLUMN last_name;
|
|
26
|
+
|
|
27
|
+
-- Bước 2 — Migrate (Release N, sau khi deploy code ghi cả cũ+mới)
|
|
28
|
+
-- up
|
|
29
|
+
UPDATE users
|
|
30
|
+
SET first_name = split_part(full_name, ' ', 1),
|
|
31
|
+
last_name = NULLIF(substring(full_name FROM position(' ' IN full_name) + 1), '')
|
|
32
|
+
WHERE first_name IS NULL;
|
|
33
|
+
-- down: không cần (chỉ backfill; cột cũ vẫn còn)
|
|
34
|
+
|
|
35
|
+
-- Bước 3 — Contract (Release N+1, sau khi mọi consumer đã chuyển)
|
|
36
|
+
-- up
|
|
37
|
+
ALTER TABLE users DROP COLUMN full_name;
|
|
38
|
+
-- down
|
|
39
|
+
ALTER TABLE users ADD COLUMN full_name text;
|
|
40
|
+
UPDATE users SET full_name = concat_ws(' ', first_name, last_name);
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Phân rã task (qua 2 release)
|
|
44
|
+
|
|
45
|
+
| Task | Bước | `[DB]` | Release / Milestone | Ghi chú |
|
|
46
|
+
|------|------|--------|---------------------|---------|
|
|
47
|
+
| T-101 | Expand | thêm 2 cột nullable | M1 (Release N) | an toàn, không breaking |
|
|
48
|
+
| T-102 | App ghi cả cũ+mới | `[LOGIC]` | M1 | dual-write trước khi backfill |
|
|
49
|
+
| T-103 | Migrate/backfill | UPDATE | M1 | chạy sau khi T-102 deployed |
|
|
50
|
+
| T-104 | Chuyển đọc sang cột mới | `[LOGIC]` | M1 | |
|
|
51
|
+
| T-105 | Contract — bỏ `full_name` | `[DB]` `[GATE]` | **M2 (Release N+1)** | chỉ khi không còn consumer cột cũ |
|
|
52
|
+
|
|
53
|
+
## Vì sao chia release (Tech Decision)
|
|
54
|
+
- **KHÔNG** ALTER phá tương thích trong 1 bước → tránh downtime + rollback an toàn từng bước.
|
|
55
|
+
- Bước Contract (T-105) tách sang **release sau** + gắn `[GATE]` chờ xác nhận không còn ai đọc `full_name`.
|
|
56
|
+
- ❌ Anti-pattern: `ALTER TABLE users RENAME COLUMN full_name ...` trong 1 migration → app cũ vỡ ngay khi deploy.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Ví dụ — Plan Structure (User Login Feature)
|
|
2
|
+
|
|
3
|
+
> Đây là mẫu output chuẩn cho Plan Agent khi thiết kế kiến trúc.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. Overview
|
|
8
|
+
|
|
9
|
+
Feature User Login implement authentication flow với email/password. Sử dụng Clean Architecture theo constitution, tách rõ data → domain → presentation layers.
|
|
10
|
+
|
|
11
|
+
## 2. Component Diagram
|
|
12
|
+
|
|
13
|
+
```mermaid
|
|
14
|
+
graph TD
|
|
15
|
+
A[LoginScreen] -->|events| B[LoginBloc]
|
|
16
|
+
B -->|call| C[LoginUseCase]
|
|
17
|
+
C -->|call| D[AuthRepository]
|
|
18
|
+
D -->|HTTP| E[AuthApiService]
|
|
19
|
+
D -->|cache| F[TokenStorage]
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 3. File Structure
|
|
23
|
+
|
|
24
|
+
| File Path | Type | Description |
|
|
25
|
+
|-----------|------|-------------|
|
|
26
|
+
| `lib/features/auth/presentation/login_screen.dart` | NEW | Login UI |
|
|
27
|
+
| `lib/features/auth/presentation/login_bloc.dart` | NEW | State management |
|
|
28
|
+
| `lib/features/auth/domain/login_usecase.dart` | NEW | Business logic |
|
|
29
|
+
| `lib/features/auth/domain/auth_repository.dart` | NEW | Repository interface |
|
|
30
|
+
| `lib/features/auth/data/auth_repository_impl.dart` | NEW | Repository implementation |
|
|
31
|
+
| `lib/features/auth/data/auth_api_service.dart` | NEW | API client |
|
|
32
|
+
| `lib/core/storage/token_storage.dart` | MODIFY | Add auth token methods |
|
|
33
|
+
|
|
34
|
+
⚠️ No-Go Zone check: `token_storage.dart` OK — not in No-Go Zone (verified context.md §4).
|
|
35
|
+
|
|
36
|
+
## 4. REQ ↔ Component Matrix
|
|
37
|
+
|
|
38
|
+
| REQ | Component(s) | Responsibility |
|
|
39
|
+
|-----|-------------|----------------|
|
|
40
|
+
| REQ-E01 | LoginScreen, LoginBloc, LoginUseCase, AuthRepository | Login success flow |
|
|
41
|
+
| REQ-E02 | LoginBloc, LoginUseCase | Invalid credentials handling |
|
|
42
|
+
| REQ-U01 | AuthApiService | Password security (hash before send) |
|
|
43
|
+
| REQ-O01 | LoginBloc | Rate limiting (> 5 attempts) |
|
|
44
|
+
|
|
45
|
+
## 5. Error Architecture
|
|
46
|
+
|
|
47
|
+
| Error Type | HTTP Code | Handler | User Message |
|
|
48
|
+
|-----------|----------|---------|--------------|
|
|
49
|
+
| InvalidCredentials | 401 | LoginBloc | "Email hoặc mật khẩu không đúng" |
|
|
50
|
+
| AccountLocked | 423 | LoginBloc | "Tài khoản bị khóa, liên hệ support" |
|
|
51
|
+
| NetworkError | - | LoginBloc | "Không có kết nối mạng" |
|
|
52
|
+
| ServerError | 500 | LoginBloc | "Hệ thống lỗi, thử lại sau" |
|
|
53
|
+
|
|
54
|
+
## 6. Tech Decisions
|
|
55
|
+
|
|
56
|
+
- **BLoC pattern**: Theo constitution §3.2 — state management cho Flutter.
|
|
57
|
+
- **Repository pattern**: Interface tại domain boundary → testable với mock.
|
|
58
|
+
- **WHY không modify legacy SSO**: No-Go Zone — tạo adapter thay vì modify.
|