Session 21 5-turn timeline chốt cuối (2026-05-12 0030 → 2026-05-13 1530): | Turn | Topic | Commits | |---|---|---| | t1 | Add cicd-monitor sub-agent (4th, Path A) | 2 | | t2 | RAG Hybrid setup planning Cách A | 2 | | t3 | Fix gotcha #45 PE button "Trả lại" mismatch | 3 | | t4 | F1+F2+F3 PE Workflow Mig 28 workflow-level | 5 | | t5 | Refactor Allow* sang per-NV Mig 29 | 4 | Cumulative 12 commits pushed remote `3a34831..c0af9e0`. No pending push. **Gotcha mới #46** (`docs/gotchas.md`): - Gitea Actions API path `/actions/tasks` not `/actions/runs` (Gitea v1 vs GitHub naming khác) - Cache `updated_at` stale ~2 min → cross-check VPS file LastWriteTime - Discovery từ CICD Monitor Run #186 (S21 t4) + #187 (S21 t5) - Saved Bash command preset cho future CICD spawn **2 Memory user-level mới** (`C:\Users\pqhuy\.claude\projects\D--Dropbox-CONG-VIEC-SOLUTION\memory\`): 1. `feedback_ef_migration_backfill_reorder.md` — Cross-project pattern: - EF auto-generated drop-then-add WRONG cho data preservation - Manual reorder ADD → BACKFILL SQL via migrationBuilder.Sql() → DROP - Anti-patterns: trust EF order, backfill separate migration, C# foreach - Down() rollback chấp nhận data loss - Bài học S21 t5 SOLUTION_ERP Mig 29 (48/48 Levels + 0/13 Users backfill OK) 2. `feedback_per_nv_permission_scope.md` — Cross-project pattern: - Multi-role workflow flag KHÔNG gắn parent table cho "tiện" - Split scope theo role context: Approver → Level table, Drafter → User table - Decision tree: role context → entity natural carry - UX implication: per-Level inline checkbox + User Mgmt per-user toggle - Bài học S21 t4 (Mig 28 SAI scope) → S21 t5 (Mig 29 ĐÚNG per-NV) - Trigger: user feedback "cấu hình cho từng người chứ ko phải toàn bộ" **4 agent MEMORY.md flush:** - 🟦 Investigator: seeds-only S21 t3-t5 (em main solo cross-stack reasoning chain) - 🟨 Implementer: REFUSE 3× per criteria #3+#4 (correct — Anthropic warning match) - 🟥 Reviewer: seeds-only (em main self-review build+test + CICD post-deploy) - 🟩 CICD Monitor: 2 runs PASS (#186 + #187, ~110-120K cost each, all 5-stage green) **Plan G Trial Week 1 evidence:** - CICD Monitor: 2/2 PASS green = 0 fail catch (deploy clean) - Cost: ~110-120K per spawn, under 150K budget - CI baseline: 3-3.5 min stable - Bonus discoveries saved: Gitea API path + prod credential fallback - Other 3 agents: seeds-only ROI track pending future spawn opportunity **STATUS + HANDOFF updates:** - STATUS: Last updated S21 chốt + count 45→46 gotcha + 17→19 memory - HANDOFF: Insert section "Session 21 chốt cuối — 5 turn timeline" trên cùng: - Turn-by-turn table với commits + CICD verify - Major schema evolution Mig 28 → Mig 29 (workflow-level → per-NV) - 2 pattern reusable saved memory - Plan G Trial Week 1 evidence table - Pending S22+ tree (Plan C test bundle / F2 UI / Plan B Contract V2 / etc) - Audit cron 2026-06-01 unchanged (threshold KHÔNG đạt sớm) **MEMORY index user-level +2 entry** (memory MEMORY.md). State final S21: - 29 mig · 59 tables · ~143 endpoints · 34 FE pages - 84 test pass (58 Domain + 26 Infra) - 46 gotcha (+2 từ baseline 44 sau S20: #45 + #46) - 19 memory entries (+3 từ baseline 16 sau S20: RAG + EF backfill + per-NV scope) - 6 skills unchanged - 4 sub-agents (3 seeds-only + 1 cicd-monitor 2-run PASS) Pending: bro UAT continue. Plan C test-after bundle defer sau UAT 2-3 lần ổn. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
7.4 KiB
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:
- Schema design decisions needed (FK strategy / nullable / discriminator)
- UX flow decisions needed (drawer vs tab vs modal)
- Cross-stack > 2 layers tight coupling
- Bug fix involving reasoning chain
- Integration testing involving multiple components
- < 30 min trivial task
- First time pattern (no prior precedent)
- 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)
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":
- Grep discriminator field (
ApplicableType,Type,Kindenum) - Check Service / Handler / Controller có hardcode type cụ thể không
- Check FE pages có route dynamic typeCode hay hardcode
- Check menu key (BE const + FE menuKeys.ts) — thường thiếu chính ở đây
- 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 (memoryfeedback_uat_skip_verifyexception)
Pattern 6: VND format helpers + Phone/Email validate (S20 turn 4)
Inline mỗi file FE PE:
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)
- ❌ Skip MEMORY.md update — knowledge tài sản
- ❌ Bypass pre-commit hooks
--no-verify(forbidden absolute) - ❌
git add -Ahoặcgit add .— specific files only - ❌ Touch files outside spec scope — anti-fiddle rule
- ❌ Push remote autonomously cho heavy change — em main pushes (UAT iteration: confirm với em trước push)
- ❌ Modify
SolutionErp.slnxautonomously — em main updates khi thêm.cs/.csproj - ❌ Lower bar to match em main quality — Smart Friend Cognition anti-pattern
- ❌ 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.GlobalExceptionMiddlewaremap 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
erasableSyntaxOnlycấmenum→ 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 10TestApplicationDbContextoverridenvarchar(max) → TEXT. - Build:
dotnet build SolutionErp.slnxclean 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 pin20.x(bài học NamGroup, memoryfeedback_node_cicd) - LibreOffice
25.8.6 - @microsoft/signalr
8.0.7
📅 Recent activity (last 10 FIFO)
- 2026-05-13 (S21 t3-t5, REFUSED 3×): Em main classified all 3 turns as cross-stack reasoning chain (BE+FE+test tightly coupled) → REFUSE per criteria #3+#4 (cross-stack > 2 layers, bug fix reasoning chain). Bug fix gotcha #45 = bug + reasoning, F1+F2+F3 = schema design decision, Refactor per-NV = drastic refactor schema + Service + FE × 2 app. All correct REFUSE — em main solo executed. Strict scope criteria validated S21 t3-t5 — REFUSE rate 100% match Anthropic warning "tightly interdependent coding". Cumulative: 84 test, 29 mig, 45 gotcha. Pattern saved future invocation: per-NV permission scope split natural theo role + EF migration BACKFILL reorder pattern.
- 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)