[CLAUDE] Skill: Setup multi-agent infrastructure (Investigator + Implementer + Reviewer)
Session 20 turn 12: User paste self-contained template setup multi-agent từ NAMGROUP s41-s43 trial (empirical-grounded Anthropic Building Effective Agents + Cognition "writes single-threaded"). Pre-flight decision gate 6/6 pass → proceed setup. ### Phase 0 — Pre-flight ✅ 6/6 - Codebase > 10K LOC ✅ (59 tables · 27 mig · ~142 endpoints · 34 FE pages) - Project > 6 months ✅ (roadmap T1-T13) - Heavy multi-file features regular ✅ (per-chunk 5-6 commit/session) - User extend ngáo threshold ✅ (S20 đã 12+ turn, deep context) - 25+ gotchas/patterns ✅ (44 gotchas · 14 memory · 6 skills) - Critical changes adversarial review ✅ (UAT live 3 prod domain) ### Phase 1-4 setup .claude/ ├── agents/ │ ├── README.md (master coordination guide ~9.7KB) │ ├── investigator.md (READ — research + audit + WebFetch ~7.3KB) │ ├── implementer.md (WRITE conditional Case 1+2+3+5 ~8.4KB) │ └── reviewer.md (READ adversarial pre-commit + live curl ~9.6KB) └── agent-memory/ ├── investigator/MEMORY.md (seed ~5.9KB) ├── implementer/MEMORY.md (seed ~6.9KB) └── reviewer/MEMORY.md (seed ~6.5KB) ### Customizations per SOLUTION_ERP - Stack: .NET 10 Clean Arch + 2 React 19 FE + SQL Server + Gitea + IIS - Skills preload mỗi agent (reuse 6 skills hiện có): - Investigator: contract-workflow + permission-matrix + ef-core-migration - Implementer: ef-core-migration + permission-matrix + form-engine - Reviewer: dependency-audit-erp + iis-deploy-runbook + contract-workflow - DB: SolutionErp_Dev (LocalDB runtime) + _Design (ef tooling distinct) - Test bearer: admin@solutions.com.vn / Admin@123456 (full) + nv.test@solutions.com.vn / TestUser@123456 (Drafter UAT scope) - Prod UAT: api/admin/eoffice.solutions.com.vn ### Windows MAX_PATH pitfall handled Project path D:\Dropbox\CONG_VIEC\SOLUTION\SOLUTION_ERP\ = 51 chars + nested Dropbox-managed → `isolation: worktree` DROPPED khỏi implementer.md frontmatter per template Pitfall 1. Em main reviews diff before commit (compensate). ### Memory baseline seeded 3 MEMORY.md có: - Patterns proven cross-session (5-chunk discipline, 3-file Mig rule, audit-reuse, service hook derived, FE mirror 2 app, VND format helpers) - 44 gotcha cross-ref - Phase 9 UAT iteration mode (skip test per chunk theo memory feedback_uat_skip_verify) - 5-category Reviewer checklist tinh chỉnh theo SOLUTION_ERP gotcha cluster (#44 silent 403 + #43 Step.Order + #42 V1/V2 dual schema + Wire BE claim) - Tests baseline 81/81 PASS preserve ### Trial workflow Week 1 candidate: Contract V2 wire (Mig 28+29) mirror PE pattern S17-S19 — audit-reuse pattern proven 1×. ~600+ LOC, 2 mig + Service + Controller + FE × 2 app. Investigator pre-flight + Implementer A→E chunks + Reviewer pre-commit verify gotcha #42 dual schema. Em main spawn first time qua /agents command. Pattern tracking ROI 4 tuần trial (week 4 evaluate keep / tune / archive). ### Acceptance criteria 7/7 ✅ - 4 agent .md với valid YAML frontmatter (name/description/model/effort/tools/ skills/memory/color/maxTurns) - 3 MEMORY.md seeds populated SOLUTION_ERP context - All template placeholders {XXX} replaced - Skills 3 đầu agent point tồn tại .claude/skills/ (6 skills sẵn) - File structure đúng template - Implementer isolation worktree dropped (Windows MAX_PATH) - Trial 1 ready (em main /agents spawn dispatch) References: Anthropic Building Effective Agents + Cognition "writes single-threaded" + NAMGROUP s41-s43 empirical curve (+83% → +27% → ~0% overhead). Setup time ~3-5h estimate (đã làm trong S20 turn 12 ~30min do template self-contained + project context đã accumulate). Path filter CI sẽ skip (.claude/skills/** trong paths-ignore, mirror cho .claude/agents/** + .claude/agent-memory/** thực tế cũng docs-class). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
157
.claude/agent-memory/implementer/MEMORY.md
Normal file
157
.claude/agent-memory/implementer/MEMORY.md
Normal file
@ -0,0 +1,157 @@
|
||||
# Implementer Agent — Persistent Memory
|
||||
|
||||
> **Persistent diary cross-session.** Auto-injected first 200 lines / 25KB at spawn.
|
||||
> Update BEFORE every stop. Curate when > 25KB.
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Role baseline
|
||||
|
||||
Code execution specialist for SOLUTION_ERP. Conditional WRITE (Case 1+2+3+5 ONLY). Tools: Read, Edit, Write, Bash, Skill, Grep, Glob. Output: commits + verification report.
|
||||
|
||||
## 🚨 STRICT scope auto-refuse criteria
|
||||
|
||||
REFUSE if ANY:
|
||||
1. Schema design decisions needed (FK strategy / nullable / discriminator)
|
||||
2. UX flow decisions needed (drawer vs tab vs modal)
|
||||
3. Cross-stack > 2 layers tight coupling
|
||||
4. Bug fix involving reasoning chain
|
||||
5. Integration testing involving multiple components
|
||||
6. < 30 min trivial task
|
||||
7. First time pattern (no prior precedent)
|
||||
8. Spec ambiguity > 20%
|
||||
|
||||
---
|
||||
|
||||
## 📋 Patterns proven (cross-session) — apply confidently
|
||||
|
||||
### Pattern 1: Per-chunk discipline 5-chunk A-E (Anthropic Case 2 orchestrator-workers)
|
||||
|
||||
Memory `feedback_per_chunk_commit` chốt:
|
||||
- **Chunk A:** Domain entities + Migration (3-file rule)
|
||||
- **Chunk B:** Application handlers (CQRS Commands + Queries + Validators)
|
||||
- **Chunk C:** Service layer (workflow logic, business rules)
|
||||
- **Chunk D:** API controllers + endpoints
|
||||
- **Chunk E:** FE update (cả 2 app mirror) + Tests + Docs + commit final
|
||||
|
||||
Build + test pass mỗi chunk. Commit message format:
|
||||
```
|
||||
[CLAUDE] <scope>: Chunk <X> — <one-line summary>
|
||||
<body>
|
||||
Verify:
|
||||
- Build pass (X warning, 0 error)
|
||||
- N test pass (...)
|
||||
Pending Chunk <Y+1>: <next>
|
||||
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||||
```
|
||||
|
||||
### Pattern 2: 3-file rule EF migration (BẮT BUỘC commit đủ)
|
||||
|
||||
Memory + gotcha #17:
|
||||
- `Migrations/{TS}_{Name}.cs` (Up + Down)
|
||||
- `Migrations/{TS}_{Name}.Designer.cs` (snapshot at migration time)
|
||||
- `Migrations/ApplicationDbContextModelSnapshot.cs` (current snapshot)
|
||||
|
||||
```bash
|
||||
dotnet ef migrations add <Name> \
|
||||
--project src/Backend/SolutionErp.Infrastructure \
|
||||
--startup-project src/Backend/SolutionErp.Api
|
||||
|
||||
# Apply lên DB Dev:
|
||||
dotnet ef database update --project src/Backend/SolutionErp.Infrastructure \
|
||||
--startup-project src/Backend/SolutionErp.Api \
|
||||
--connection "Server=(localdb)\MSSQLLocalDB;Database=SolutionErp_Dev;Trusted_Connection=True;TrustServerCertificate=true"
|
||||
|
||||
# Apply lên DB Design (catchup nếu thiếu):
|
||||
dotnet ef database update --project src/Backend/SolutionErp.Infrastructure \
|
||||
--startup-project src/Backend/SolutionErp.Api
|
||||
```
|
||||
|
||||
### Pattern 3: Audit reuse trước khi clone (memory `feedback_audit_reuse_before_clone`)
|
||||
|
||||
Khi user nói "clone X sang Y":
|
||||
1. **Grep discriminator field** (`ApplicableType`, `Type`, `Kind` enum)
|
||||
2. **Check Service / Handler / Controller** có hardcode type cụ thể không
|
||||
3. **Check FE pages** có route dynamic typeCode hay hardcode
|
||||
4. **Check menu key** (BE const + FE menuKeys.ts) — thường thiếu chính ở đây
|
||||
5. Default reuse 80%, chỉ thêm menu key + sample seed (3 file ~60 LOC)
|
||||
|
||||
Bài học S17+ Clone B: 1 commit `937eb24`, deploy 1 phát chạy.
|
||||
|
||||
### Pattern 4: Service hook vs CRUD endpoint cho derived state (memory `feedback_service_hook_vs_endpoint`)
|
||||
|
||||
State X = derived của action Y → UPSERT trong handler Y, KHÔNG endpoint /X riêng.
|
||||
|
||||
Bài học S19 Mig 26 PE LevelOpinions: Service `ApproveV2Async` UPSERT row qua match `ApproverUserId == actorUserId` (fallback first khi Admin override). 0 endpoint mới.
|
||||
|
||||
### Pattern 5: FE mirror 2 app rule §3.9
|
||||
|
||||
Duplicate `fe-admin/` + `fe-user/` CÓ CHỦ ĐÍCH:
|
||||
- Sửa fe-admin xong → mirror fe-user (tay)
|
||||
- Khi breaking change rename prop → BẮT BUỘC `npm run build` × 2 app (memory `feedback_uat_skip_verify` exception)
|
||||
|
||||
### Pattern 6: VND format helpers + Phone/Email validate (S20 turn 4)
|
||||
|
||||
Inline mỗi file FE PE:
|
||||
```ts
|
||||
const parseVnd = (s: string): number => Number(s.replace(/[^\d]/g, '')) || 0
|
||||
const formatVndInput = (n: number): string => (n > 0 ? n.toLocaleString('vi-VN') : '')
|
||||
const PHONE_RE = /^0\d{9,10}$/
|
||||
const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
|
||||
const isValidPhone = (s: string) => !s || PHONE_RE.test(s.replace(/[\s\-.]/g, ''))
|
||||
const isValidEmail = (s: string) => !s || EMAIL_RE.test(s)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ⚠️ Anti-patterns observed (DO NOT)
|
||||
|
||||
1. ❌ Skip MEMORY.md update — knowledge tài sản
|
||||
2. ❌ Bypass pre-commit hooks `--no-verify` (forbidden absolute)
|
||||
3. ❌ `git add -A` hoặc `git add .` — specific files only
|
||||
4. ❌ Touch files outside spec scope — anti-fiddle rule
|
||||
5. ❌ Push remote autonomously cho heavy change — em main pushes (UAT iteration: confirm với em trước push)
|
||||
6. ❌ Modify `SolutionErp.slnx` autonomously — em main updates khi thêm `.cs/.csproj`
|
||||
7. ❌ Lower bar to match em main quality — Smart Friend Cognition anti-pattern
|
||||
8. ❌ Proceed when spec ambiguous > 20% — return REFUSE với reason
|
||||
|
||||
---
|
||||
|
||||
## 🧠 SOLUTION_ERP conventions (auto-load via skills)
|
||||
|
||||
- **BE .NET 10:** PascalCase tiếng Anh entities + DTO records + command names. CQRS + MediatR + FluentValidation + AutoMapper. Repository qua `IApplicationDbContext`. `GlobalExceptionMiddleware` map exception → ProblemDetails (NO try-catch trong controllers).
|
||||
- **FE React 19 + Vite 8 + TS 6:** Named export only (trừ App). TanStack Query. shadcn/ui copy-paste. TS6 `erasableSyntaxOnly` cấm `enum` → const-object pattern. UI 100% tiếng Việt. Mirror 2 app rule §3.9.
|
||||
- **Test:** baseline 81/81 PASS (58 Domain + 23 Infra). Phase 9 UAT skip per chunk theo memory `feedback_uat_skip_verify`. Stack xUnit + FluentAssertions 7.2 + EF SQLite 10 `TestApplicationDbContext` override `nvarchar(max) → TEXT`.
|
||||
- **Build:** `dotnet build SolutionErp.slnx` clean 0 err + `npm run build` × 2 app pass.
|
||||
- **Commit:** `[CLAUDE] <scope>: <message>` + Co-Authored-By Claude Opus 4.7 (1M context).
|
||||
|
||||
## Scopes (pick 1)
|
||||
|
||||
`Contract` · `PurchaseEvaluation` · `Budget` · `Form` · `Workflow` · `Supplier` · `Auth` · `Admin` · `Api` · `App` · `Domain` · `Infra` · `FE-Admin` · `FE-User` · `Tests` · `Docs` · `CICD` · `Scripts` · `Skill`
|
||||
|
||||
---
|
||||
|
||||
## 🔑 Pin versions (package pinning §2.8)
|
||||
|
||||
KHÔNG `*` / `latest`. Critical pins:
|
||||
- MediatR `12.4.1` (14 fail DI)
|
||||
- Swashbuckle `6.9.0` (10 conflict OpenApi 2)
|
||||
- Node engines `>= 20` + CI pin `20.x` (bài học NamGroup, memory `feedback_node_cicd`)
|
||||
- LibreOffice `25.8.6`
|
||||
- @microsoft/signalr `8.0.7`
|
||||
|
||||
---
|
||||
|
||||
## 📅 Recent activity (last 10 FIFO)
|
||||
|
||||
- **2026-05-11 (setup):** Implementer agent initialized. Baseline knowledge load complete (5 patterns proven cumulative S1-S20: per-chunk 5 chunk, 3-file rule Mig, audit-reuse clone, service hook derived state, FE mirror 2 app, VND format helpers). No implementations performed yet. Awaiting first SendMessage from em main. Strict scope auto-refuse criteria active.
|
||||
|
||||
---
|
||||
|
||||
## 🔄 Curate trigger
|
||||
|
||||
- Memory size > 25KB → archive recent entries to `archive/<period>.md`
|
||||
- Duplicate entries detected → merge
|
||||
- Stale > 3 months → remove
|
||||
|
||||
Last curate: 2026-05-11 (initial seed)
|
||||
119
.claude/agent-memory/investigator/MEMORY.md
Normal file
119
.claude/agent-memory/investigator/MEMORY.md
Normal file
@ -0,0 +1,119 @@
|
||||
# Investigator Agent — Persistent Memory
|
||||
|
||||
> **Persistent diary cross-session.** Auto-injected first 200 lines / 25KB at spawn.
|
||||
> Update BEFORE every stop. Curate when > 25KB.
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Role baseline
|
||||
|
||||
Read-only research + audit for SOLUTION_ERP codebase. Tools: Read, Grep, Glob, Bash, WebFetch, WebSearch. Output: concise structured findings under 500 words.
|
||||
|
||||
---
|
||||
|
||||
## 📋 Patterns proven (cross-session)
|
||||
|
||||
### Pattern: Smoke verify catalog SOLUTION_ERP
|
||||
- Bearer auth từ `https://api.solutions.com.vn/api/auth/login` (POST email + password)
|
||||
- Status code matrix expected vs actual + JSON output + MD audit
|
||||
- Test credentials: `admin@solutions.com.vn / Admin@123456` (full) OR `nv.test@solutions.com.vn / TestUser@123456` (Drafter UAT scope)
|
||||
|
||||
### Pattern: Schema scan via sqlcmd
|
||||
```bash
|
||||
# LocalDB Dev (runtime — primary)
|
||||
sqlcmd -S "(localdb)\MSSQLLocalDB" -d SolutionErp_Dev -Q "..."
|
||||
|
||||
# LocalDB Design (ef tooling)
|
||||
sqlcmd -S "(localdb)\MSSQLLocalDB" -d SolutionErp_Design -Q "..."
|
||||
|
||||
# Production (qua SSH vietreport-vps)
|
||||
ssh vietreport-vps "sqlcmd -S .\SQLEXPRESS -d SolutionErp -U vrapp -P '...' -Q '...'"
|
||||
```
|
||||
Common queries: `sys.columns`, `sys.triggers`, `__EFMigrationsHistory`, `COUNT(*)`, `sys.indexes`.
|
||||
|
||||
**Gotcha:** 2 LocalDB distinct (memory `feedback_designtime_runtime_db`):
|
||||
- `_Dev` — runtime API (appsettings.Development.json ConnectionStrings:Default)
|
||||
- `_Design` — `dotnet ef migrations add/update` default target
|
||||
- Use `--connection "Server=(localdb)\MSSQLLocalDB;Database=SolutionErp_Dev;..."` override khi cần Dev specifically.
|
||||
|
||||
### Pattern: Controller audit
|
||||
- Grep `\[Route\("api/[a-z]+"\)\]` enumerate ~30+ controllers
|
||||
- Grep `\[Authorize(Policy = "..."` audit per-action policy (gotcha #44 silent 403 class-level quá strict)
|
||||
- Grep `IActionResult` vs `ActionResult<T>` — typed return preferred
|
||||
- Grep `// Mock` / `alert(` / `setEditing(null) // close UI` — wire claim bugs
|
||||
|
||||
### Pattern: Memory cross-reference
|
||||
14 memory entries tại `C:\Users\pqhuy\.claude\projects\D--Dropbox-CONG-VIEC-SOLUTION\memory\`:
|
||||
- `MEMORY.md` — index
|
||||
- `project_solution_erp.md` — cumulative narrative S1-S17
|
||||
- `feedback_per_chunk_commit.md` — 5-chunk A-E discipline
|
||||
- `feedback_uat_skip_verify.md` — Phase 9 skip test rule
|
||||
- `feedback_drastic_refactor_scope.md` — defer dedicated session
|
||||
- `feedback_audit_reuse_before_clone.md` — audit-first pattern (Investigator natural fit)
|
||||
- `feedback_service_hook_vs_endpoint.md` — derived state hook pattern
|
||||
- `feedback_n_stage_workflow_pattern.md` — DEPRECATED (Mig 21 flat workflow replaced)
|
||||
- `feedback_designtime_runtime_db.md` — 2 LocalDB distinct
|
||||
- `feedback_md_compact_narrative.md` — §6.5 KEEP narrative rule
|
||||
- `feedback_unittest_timing.md` — §7 test timing
|
||||
- `feedback_cron_monthly_limitation.md` — Cron SDK 7-day expire
|
||||
- `feedback_user_manual_style.md` — non-tech docs style
|
||||
- `feedback_node_cicd.md` — Node 20.x pin
|
||||
- `reference_session_prompts.md` — canonical session start template
|
||||
|
||||
### Pattern: External research priority sources
|
||||
- `anthropic.com/engineering/` (official patterns)
|
||||
- `cognition.ai/blog/` (Devin lessons)
|
||||
- `philschmid.de` + `eugeneyan.com` + `hamel.dev` (senior engineers)
|
||||
- `learn.microsoft.com/en-us/aspnet/core/` (.NET 10 official)
|
||||
- `tanstack.com/query/latest` (TanStack Query)
|
||||
|
||||
---
|
||||
|
||||
## ⚠️ Anti-patterns observed
|
||||
|
||||
- ❌ Skip MEMORY.md update before stop — lose knowledge tài sản
|
||||
- ❌ Vague conclusion "seems like" / "probably" — em main rejects
|
||||
- ❌ Missing file:line refs — non-verifiable evidence
|
||||
- ❌ Exceed 500 words — em main reads too slow
|
||||
- ❌ Scope drift to architectural recommendations — em main decides, not me
|
||||
|
||||
---
|
||||
|
||||
## 🧠 SOLUTION_ERP context essentials (auto-load)
|
||||
|
||||
- **DB Dev:** `SolutionErp_Dev` LocalDB (59 tables / 27 migrations / Mig 27 latest `AddVisibilityAndDisplayLabelToMenuItems`)
|
||||
- **DB Design:** `SolutionErp_Design` (ef tooling distinct)
|
||||
- **DB Prod:** `.\SQLEXPRESS` / `SolutionErp` / `vrapp` user via SSH `vietreport-vps`
|
||||
- **Tech stack:** .NET 10 Clean Arch (Api → Application ← Domain + Infra) + CQRS MediatR + EF Core 10 + 2 React 19 Vite 8 TS 6 (fe-admin :8082 + fe-user :8080) + SQL Server + Gitea Actions CI + IIS prod
|
||||
- **Live deploys (Prod UAT):** https://api.solutions.com.vn · https://admin.solutions.com.vn · https://eoffice.solutions.com.vn
|
||||
- **Gitea remote:** https://git.baocaogiaoduc.vn/vietreport-admin/solution-erp
|
||||
- **SSH VPS:** `ssh vietreport-vps` (config `~/.ssh/config` user=Administrator key=id_ed25519)
|
||||
- **Gotchas active:** 44 (reference `docs/gotchas.md`)
|
||||
- **Tests baseline:** 81 PASS (58 Domain + 23 Infra) — Phase 9 UAT skip per chunk (memory `feedback_uat_skip_verify`)
|
||||
- **Master HEAD reference:** check via `git log -1 --format='%H'`
|
||||
- **6 skills:** `contract-workflow` · `permission-matrix` · `form-engine` · `ef-core-migration` · `dependency-audit-erp` · `iis-deploy-runbook`
|
||||
|
||||
---
|
||||
|
||||
## 🔄 Active workflow schemas (V1 + V2 coexist post-Session 17)
|
||||
|
||||
- **V1 Mig 21 flat workflow** — `WorkflowDefinition` pin với PE/Contract cũ. Match Dept+PositionLevel.
|
||||
- **V2 Mig 22-27** — `ApprovalWorkflow` pin với PE mới + match `ApproverUserId` 1-1 OR-of-N cùng Cấp. Steps (Phòng) > Levels (Cấp). PE đã wire V2. Contract V2 PENDING Session 21+.
|
||||
|
||||
State machine 5 trạng thái phiếu PE: Nháp / Đã gửi duyệt / **Trả lại (TraLai=98)** / Từ chối / Đã duyệt.
|
||||
|
||||
---
|
||||
|
||||
## 📅 Recent activity (last 10 FIFO)
|
||||
|
||||
- **2026-05-11 (setup):** Investigator agent initialized. Baseline knowledge load complete (44 gotchas + 14 memory entries + 6 skills + 27 mig + 81 test pass cumulative). No investigations performed yet. Awaiting first SendMessage from em main.
|
||||
|
||||
---
|
||||
|
||||
## 🔄 Curate trigger
|
||||
|
||||
- Memory size > 25KB → archive recent entries to `archive/<period>.md`
|
||||
- Duplicate entries detected → merge
|
||||
- Stale > 3 months → remove
|
||||
|
||||
Last curate: 2026-05-11 (initial seed)
|
||||
144
.claude/agent-memory/reviewer/MEMORY.md
Normal file
144
.claude/agent-memory/reviewer/MEMORY.md
Normal file
@ -0,0 +1,144 @@
|
||||
# Reviewer Agent — Persistent Memory
|
||||
|
||||
> **Persistent diary cross-session.** Auto-injected first 200 lines / 25KB at spawn.
|
||||
> Update BEFORE every stop. Curate when > 25KB.
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Role baseline
|
||||
|
||||
Adversarial pre-commit reviewer for SOLUTION_ERP. Read-only verification + live curl on prod UAT environment (`*.solutions.com.vn`). Tools: Read, Grep, Glob, Bash (curl + git diff + sqlcmd read). Output: PASS/FAIL verdict + concrete issues file:line.
|
||||
|
||||
---
|
||||
|
||||
## 🚨 Recurring SOLUTION_ERP bug patterns (catch with priority)
|
||||
|
||||
### Gotcha #44 — Silent 403 class-level Authorize quá strict (S18 lesson)
|
||||
|
||||
- Symptom: Drafter dropdown V2 workflow empty silent (no error toast)
|
||||
- Root: `[Authorize(Policy = "Workflows.Read")]` class-level → non-admin 403, TanStack Query catch silent → UI empty
|
||||
- Verify: grep `\[Authorize\(Policy = .*\)\]` class-level vs action-level + curl với non-admin token expect 200
|
||||
- Fix pattern: class-level `[Authorize]` only (any authenticated). POST/PUT/DELETE giữ `[Authorize(Policy = "X.Create")]` admin-only
|
||||
|
||||
### Gotcha #43 — Step.Order ≠ index 0-based
|
||||
|
||||
- Symptom: EF query `Where(s => s.Order == i)` returns wrong row
|
||||
- Verify: grep `step.Order` arithmetic — array index 0-based vs Order field 1-based
|
||||
- Fix pattern: precompute candidates EF query → in-memory `OrderBy(s => s.Order).ToList()` → array index access
|
||||
|
||||
### Gotcha #42 — Dual schema workflow V1 vs V2 — Service phải branch
|
||||
|
||||
- Symptom: PE submit failed do Service không biết V1 hay V2 schema
|
||||
- Verify: grep `evaluation.ApprovalWorkflowId is Guid awId` — phải branch theo pin field
|
||||
- Fix pattern: `if (evaluation.ApprovalWorkflowId is Guid awId) ApproveV2Async(...) else ApproveV1LegacyAsync(...)`
|
||||
|
||||
### Wire BE claim recurring bug pattern
|
||||
|
||||
- Symptom: claim wire CRUD nhưng grep diff finds `// Mock` / `alert(...)` / no POST/PUT/DELETE call
|
||||
- Verify: grep diff mock markers + live curl POST/PUT/DELETE expect 2XX
|
||||
- Severity: CRITICAL — block commit
|
||||
|
||||
### Gotcha #17 — EF migration 3-file rule
|
||||
|
||||
- Symptom: commit migration nhưng thiếu `.Designer.cs` hoặc `ApplicationDbContextModelSnapshot.cs` → next migration fail
|
||||
- Verify: `git diff --name-only | grep Migrations/` expect 3 files (target.cs + target.Designer.cs + Snapshot.cs)
|
||||
|
||||
---
|
||||
|
||||
## 📋 5-category checklist (apply EVERY review)
|
||||
|
||||
### Category 1: Wire BE / feature claim verify
|
||||
- Grep mock markers in diff (`// Mock`, `alert(`, `setEditing(null) // close UI`, `TODO.*wire`)
|
||||
- Grep actual API call: `await api\.(post|put|delete|patch)\(` trong FE diff
|
||||
- Live curl POST/PUT/DELETE/PATCH if deploy claim (`https://api.solutions.com.vn/...`)
|
||||
- Status code matrix expected vs actual
|
||||
|
||||
### Category 2: Schema integrity (44 active gotchas)
|
||||
- Reference `docs/gotchas.md` + skill `dependency-audit-erp`
|
||||
- Check 3-file rule Mig
|
||||
- Check column types vs entity definition (Mig 27 lesson: `IsVisible bit NOT NULL DEFAULT 1` + `DisplayLabel nvarchar(200) NULL`)
|
||||
|
||||
### Category 3: Security
|
||||
- `[Authorize]` class-level on ALL new controllers
|
||||
- Per-action `[Authorize(Policy = "...")]` cho admin-scoped (gotcha #44 lesson)
|
||||
- Permission guard wrap new admin pages (FE)
|
||||
- Route permission map populate (`menuKeys.ts` mirror BE `MenuKeys.cs` + `All[]`)
|
||||
- Input validation FluentValidation Validator class
|
||||
- SQL parameterized (EF Core default OK) + XSS escape
|
||||
|
||||
### Category 4: Code quality
|
||||
- `dotnet build SolutionErp.slnx` clean 0 err
|
||||
- `npm run build` × fe-admin + fe-user clean (TS6 strict)
|
||||
- Tests baseline 81 PASS (Phase 9 UAT exception OK)
|
||||
- No `--no-verify` bypass (forbidden absolute)
|
||||
- Anti-fiddle audit (scope drift > 20% LOC outside spec = FAIL)
|
||||
- Mirror 2 FE app khi feature FE (rule §3.9)
|
||||
|
||||
### Category 5: Test coverage
|
||||
- New helper static → unit test (xUnit)
|
||||
- New Repository method → repo test
|
||||
- New endpoint API → integration test (WebApplicationFactory)
|
||||
- Bug recurring → regression test TDD-style (test BEFORE fix)
|
||||
- **Phase 9 UAT exception:** test-after default OK theo memory `feedback_uat_skip_verify`
|
||||
- Test count baseline 81 → tăng khi feature added theo §7
|
||||
|
||||
---
|
||||
|
||||
## ⚠️ Anti-patterns observed (DO NOT)
|
||||
|
||||
1. ❌ Recommend code edits — only describe issue + acceptance criteria
|
||||
2. ❌ Skip live curl verify if deploy claim — recurring risk
|
||||
3. ❌ Accept "wire" claim without grep proof
|
||||
4. ❌ Defer to em main authority — escalate disagreement explicitly
|
||||
5. ❌ Skip MEMORY.md update với anti-patterns observed
|
||||
6. ❌ Lower bar to match em main quality — Smart Friend anti-pattern Cognition
|
||||
|
||||
---
|
||||
|
||||
## 🛡️ Smart Friend anti-pattern guard
|
||||
|
||||
Per Cognition documented research:
|
||||
- NEVER lower bar to match em main's apparent quality
|
||||
- If em main code fine → say PASS
|
||||
- If em main code has issues → FAIL with specifics regardless social pressure
|
||||
- "Quality ceiling was set by the primary, not the escalation." — Your value = raise quality through catch
|
||||
|
||||
---
|
||||
|
||||
## 🧠 SOLUTION_ERP review essentials
|
||||
|
||||
- **Tests baseline:** 81/81 PASS (must increase nếu feature added per §7; UAT iteration exception per memory)
|
||||
- **Gotchas:** 44 active (`docs/gotchas.md` reference)
|
||||
- **Live deploys (Prod UAT):** https://api.solutions.com.vn · https://admin.solutions.com.vn · https://eoffice.solutions.com.vn
|
||||
- **Bearer token test:**
|
||||
- Admin: `admin@solutions.com.vn / Admin@123456` (full quyền)
|
||||
- UAT user: `nv.test@solutions.com.vn / TestUser@123456` (Drafter Phòng CCM — verify non-admin access patterns)
|
||||
- **Conventions:** `docs/rules.md` (§3.9 mirror 2 FE, §5.2 commit format, §6.5 docs KEEP narrative, §7 test timing, §2.8 package pinning)
|
||||
- **6 skills:** `contract-workflow` · `permission-matrix` · `form-engine` · `ef-core-migration` · `dependency-audit-erp` · `iis-deploy-runbook`
|
||||
|
||||
---
|
||||
|
||||
## 🔑 Critical pin verify (gotcha #1-4)
|
||||
|
||||
- MediatR `12.4.1` (14 fail DI)
|
||||
- Swashbuckle `6.9.0` (10 conflict OpenApi 2)
|
||||
- Microsoft.OpenApi `1.x` (2 breaking)
|
||||
- Node engines `>= 20` + CI `20.x` (Node latest fail Windows IIS)
|
||||
|
||||
Flag commit nếu thấy `<PackageReference Include="MediatR" Version="14...` hoặc tương tự.
|
||||
|
||||
---
|
||||
|
||||
## 📅 Recent activity (last 10 FIFO)
|
||||
|
||||
- **2026-05-11 (setup):** Reviewer agent initialized. Baseline knowledge load complete (44 gotchas + 5-category checklist + 6 skills cumulative). No reviews performed yet. Awaiting first SendMessage from em main. Smart Friend guard active.
|
||||
|
||||
---
|
||||
|
||||
## 🔄 Curate trigger
|
||||
|
||||
- Memory size > 25KB → archive recent entries to `archive/<period>.md`
|
||||
- Duplicate entries detected → merge
|
||||
- Stale > 3 months → remove
|
||||
|
||||
Last curate: 2026-05-11 (initial seed)
|
||||
Reference in New Issue
Block a user