diff --git a/.claude/agent-memory/cicd-monitor/MEMORY.md b/.claude/agent-memory/cicd-monitor/MEMORY.md index 70e695f..dd1c6b3 100644 --- a/.claude/agent-memory/cicd-monitor/MEMORY.md +++ b/.claude/agent-memory/cicd-monitor/MEMORY.md @@ -174,6 +174,8 @@ Bug latency observed when miss points 9-10: 2-3 days prod silent (Mig 28-29 depl ## 📅 Recent runs (FIFO — slim post-curate 2026-05-22) +- **2026-05-26 (S32 startup verify — no CI poll, only foundation freshness + 3 endpoint smoke health):** NO Run triggered S30-S32 (last code deploy Run #232 sha=`38f1c4d` 2026-05-22 ~3 days ago). Last push `f938bf5` S31 docs patch cicd-monitor.md stale numbers (test/mig refresh) — docs-only → skip CI per gotcha #41 path filter (expected). 0 unpushed `git log origin/main..HEAD`. **Verify state:** (a) MEMORY size **24.9KB / 221 lines** approaching 25KB threshold — recommend curate next session OR slim Run #231 verbose entry (lines 179-183 = ~5KB alone) since superseded by Run #232 wrap entry above. (b) MCP RAG tools PRESENT — `search_memory` returns 3 results query "Run 232 Plan B Hotfix CICD SeedSampleContractWorkflowV2" rerank_score=**0.906** top (MEMORY.md self-hit) + 0.828 (gotcha #51 docs) + 0.816 (HANDOFF.md S29 final wrap) — RAG indexing healthy 2949 chunks. (c) Foundation entries CONFIRMED retained: 10-surface-point per-NV checklist (lines 142-160) + gotcha #48 SQLite tie-break (lines 56-61) + gotcha #51 NEW INFRASTRUCTURE vs DEMO seed (verified via RAG hit on `docs/gotchas.md` heading "51. INFRASTRUCTURE seed vs DEMO seed phân biệt — DemoSeed:Disabled flag gate trap"). (d) 3 prod endpoint smoke **all 200 OK** (api.solutions.com.vn/health/live + admin.solutions.com.vn + eoffice.solutions.com.vn) — prod stable post-S29 deploy. **Pending future spawn triggers (em main SendMessage):** (i) push code BE/FE/Mig commits Plan B-Wrap test bundle BW1-BW7 → poll CI + verify Run PASS + bundle hash rotate if FE in scope; (ii) Phase 9 UAT smoke production batch (3 endpoint health + Mig 33 sqlcmd verify + bundle hash check) — periodic heavy session ~30 min interval; (iii) any prod issue report ("không thấy V2", "Drafter dropdown empty" etc — gotcha #51 first suspect). Token cost spawn ~10K (no poll, no log fetch, no sqlcmd — only Read + Bash curl × 3 + RAG × 1). + - **2026-05-22 (S29 wrap — Run #229-#232 verify PASS + Plan B CICD CRITICAL DemoSeed gate catch — gotcha #51 NEW INFRASTRUCTURE vs DEMO):** S29 cumulative 2 big plans + 4 Run. **Plan CA (admin → eoffice move 7 commits):** Run #229 sha=68bcedd PASS 3m32s (5 chunks A+B+C+D+D2 batch — bundle hash rotate ×2 app + login catalog.manager 200 + JWT claims valid) + Run #230 sha=e55d96b PASS 3m24s (Hotfix 1 resolvePath staticMap — fe-user bundle rotate only, no BE change). **Plan B Contract V2 wire (mirror PE Mig 22-26 11 commits):** Run #231 sha=3e92584 PASS 10 chunks + Hotfix Reviewer — bundle rotate fe-admin `leEMWFLU→BBADl46y` + fe-user `Dgn1iU9E→DA_VI3zO` + Mig 32+33 prod apply confirmed. **Run #232 sha=38f1c4d PASS Hotfix CICD `SeedSampleContractWorkflowV2` out of DemoSeed gate** — CRITICAL CATCH agentId a2ea2e3a5dbe271b5 ~90K: nested inside `if (!demoSeedDisabled)` DbInitializer.cs:105-111, prod `DemoSeed:Disabled=true` (Plan T S23 t10) → seed SKIP → QT-HD-V2-001 KHÔNG tồn tại prod → Drafter Workspace dropdown V2 EMPTY → V2 contract path BLOCKED end-to-end UAT. Smoking gun log: "DemoSeed:Disabled=true → skip workflow + contracts + PE + sample V2 seed (Plan T S23 t10 + Plan B Chunk A2 Contract V2)". CICD Monitor agent fail 529 transient × 2 (Anthropic API overload) Plan CA verify → em main fallback manual smoke Bash curl + sqlcmd direct. **Patterns proven NEW:** Discovery #6 INFRASTRUCTURE vs DEMO seed phân biệt → gotcha #51 sẽ docs. **Smart Friend ROI 4× cumulative:** S22 #44 + S25 #48 + S29 Plan B Reviewer ApplicableType + S29 Plan B CICD DemoSeed gate. **Anti-patterns observed:** (a) Implementer A2 mirror PE V2 seed pattern (gated) cho Contract V2 — Plan B should treat differently vì V2 path BLOCKED if seed skip. (b) Em main miss noticing seed inside DemoSeed gate khi review Chunk A2. 0 prod regression observed S29 cumulative. - **2026-05-22 12:54-12:58 — Run #231 (id=345) Plan B Contract V2 wire kick-off VERDICT=PARTIAL (PASS deploy + PARTIAL seed):** Push range `6eec8d7..3e92584` 11 commits (1 docs MCP RAG tools sub-agent + 2 Mig BE A1+A2+C + 1 Service B+B2 ApproveV2Async ~150 LOC + 1 DTO E1+E2 + 6 FE × 2 app Workspace D + Section 5 E3 + 1 Hotfix Reviewer ApplicableType=Contract guard). CI status=success duration **3m30s** (12:54:24→12:57:54). **Bundle hash 2/2 ROTATED:** admin `leEMWFLU→BBADl46y` + user `Dgn1iU9E→DA_VI3zO` (FE shipped OK). **Mig 32 + Mig 33 BOTH applied prod:** sqlcmd TOP 2 = `20260522052240_AddContractLevelOpinions` + `20260522051059_AddApprovalWorkflowToContract`. **Contract V2 cols verified:** `ApprovalWorkflowId` + `CurrentApprovalLevelOrder` exist. **ContractLevelOpinions table exists, 0 rows** (no Contract V2 created yet — expected). **API health 200 + 5/5 smoke 200** (contracts/PE/menus/AW-v2 filter / AW-v2 all). **V1 backward compat OK:** 7 contracts V1 preserved untouched. diff --git a/.claude/agent-memory/implementer/MEMORY.md b/.claude/agent-memory/implementer/MEMORY.md index eb38210..7c257e7 100644 --- a/.claude/agent-memory/implementer/MEMORY.md +++ b/.claude/agent-memory/implementer/MEMORY.md @@ -324,6 +324,8 @@ KHÔNG `*` / `latest`. Critical pins: ## 📅 Recent activity (last 10 FIFO) +- **2026-05-26 (S32 startup — context verify + RAG live confirm + size FLAG > 25KB):** Em chủ trì spawn em verify Session 32 context. **Verify done:** (1) MEMORY size 36.2KB (Get-Item Length=36207 bytes) — **OVER 25KB threshold ~45% bigger** → FLAG cho em main schedule dedicated curate session per Pattern curate trigger rule line 364. KHÔNG self-curate vì em chủ trì preference reserve cho em main solo judgment call §6.5 KEEP vs CUT (S27 retrospective C1-C4 task lesson). (2) Patterns saved 1-12 foundation + 12-bis NEW S29 + 13-15 + 16-bis NEW S29 + 17-19 — total **17 numbered patterns** (Pattern 16 baseline implied trong recent activity S27 chưa numbered explicit). Pattern 12-bis (cross-module entity cookie-cutter mirror PE→Contract Mig 33) **SAVED line 178-200** confirmed present. Pattern 16-bis (4-place mirror cross-app S29 Plan CA Hotfix 1) **SAVED line 165-176** confirmed present. (3) MCP RAG tools **PRESENT** — `mcp__rag-unified__search_memory` + `mcp__rag-unified__cross_project_search` both visible trong tools list. Test query "Pattern 12-bis cross-module entity cookie-cutter mirror PE Contract V2" top_k=3 returned 3 results với rerank scores **0.824/0.801/0.793** — all healthy > 0.7 threshold. S31 RAG v1.3 baseline PASS confirmed live post CLI restart. **Pending tasks em main có thể gọi em lại spawn S32+:** (a) Plan B-Wrap BW1-BW7 test bundle codegen Case 2 cookie-cutter mirror PE WorkflowService test pattern (regression ApproveV2Async + UPSERT LevelOpinions test) — 7 file new test class mirror PE test bundle structure; (b) ContractWorkflowMatrixView mirror PE WorkflowMatrixView Plan AA S24 (1 page mirror cross-module — Case 2 fits Pattern 13 read-only admin Designer mirror + Pattern 14 Tailwind JIT palette + Pattern 15 HTML table rowSpan iteration helper). **Decision tree forward:** Em chủ trì gọi em với task code edit → em ACCEPT case (a)/(b) khi spec deterministic, REFUSE nếu first-time pattern. Em chủ trì confirm Layer A governance still active scope SOLUTION_ERP. Token cost spawn này ~5k (3 Read + 1 RAG query + 1 Edit + final report). KHÔNG curate — defer em main full curate session. Tag: `[verify, phase-9, infra]`. + - **2026-05-22 (S29 wrap — Plan CA Chunk B + Plan B 4 chunks Case 2 cookie-cutter + 1 stopped E3 + Pattern 12-bis NEW):** Implementer = busiest agent S29 với 5 spawn total. **Plan CA Chunk B (~10K):** 4 master pages mirror fe-admin→fe-user byte-identical SHA256, touch 6 file (4 page + App.tsx +5 route + menuKeys.ts +5 key Catalogs*), 948 LOC mirror PASS 0 TS err. Saved `pattern_master_page_mirror.md`. **Plan B 4 spawn cumulative:** (A2 Mig 32 ~25K) schema +column FK Restrict IX + Configuration + DbInitializer SeedSampleContractWorkflowV2 — **stash em main WIP ContractWorkflowService.cs** để build verify clean (em main + Implementer parallel touch BE → race condition trick); (C Mig 33 ContractLevelOpinions ~25K) entity + Mig + Config + DbSet + Contract.cs +LevelOpinions nav — **Pattern 12-bis NEW cross-module entity cookie-cutter mirror PE→Contract** scaffold 4-file pattern documented Patterns section; (D FE Workspace V2 ~12K) ContractCreatePage × 2 app +useQuery V2 + Select dropdown wire ApprovalWorkflowId, 88 LOC mirror byte-similar; (E3 stopped mid-task) FE Section 5 V2 STOPPED at "check ContractDetail type" judgment call → em main solo finish. **Lessons:** (1) **Race condition em main + Implementer parallel BE** → stash trick works but adds overhead. Forward SEQUENTIAL chunks A→B→C khi cùng touch BE, NOT parallel. (2) **Complex FE feature mirror với type extend + new component** → em main solo more reliable than Implementer khi spec ambiguity > 20% in Read-required component inspection. (3) Pattern 16-bis 4-place mirror cross-app reinforced 2× (Plan CA Chunk B + Plan B Chunk D) — verify Layout staticMap khi page move/route enhance. **Patterns proven NEW S29:** Pattern 12-bis cross-module entity scaffold + Pattern 16-bis 4-place mirror reinforced. **Anti-pattern observed:** (a) Implementer E3 stopped mid-task FE complex judgment — em main miss provide concrete component template trong prompt. (b) Race condition parallel BE → stash workaround. Tag: `[pattern, phase-9, frontend+infra]`. KHÔNG curate (33.2KB OK borderline > 25KB threshold but close — defer to next session em main full curate khi S30 wrap). - **2026-05-22 (S29 Plan B Chunk D PASS — FE ContractCreatePage V2 Workspace dropdown × 2 app cookie-cutter mirror PE):** Spec deterministic 100% từ em main reference `fe-user/src/components/pe/PeWorkspaceCreateView.tsx` (canonical V2 dropdown lines 80-89 useQuery + lines 152-172 Select UI). 2 file mirror × 2 app `fe-admin/fe-user/src/pages/contracts/ContractCreatePage.tsx`: +44 LOC each = +88 LOC total byte-similar (git diff stat verify). Changes: (1) `useState approvalWorkflowId = ''` mới + (2) `useQuery approval-workflows-v2-contract` filter ApplicableType=3 client-side filter isUserSelectable=true (mirror PE Mig 25 pattern Plan AA S24) + (3) `Select dropdown "Quy trình duyệt V2 (tùy chọn)"` placement giữa FormFields + Budget section, blank = V1 fallback hint "(đã add ContractHeaderForm function, KHÔNG add ContractEditForm function vì spec scope CreatePage workspace only - edit-mode update endpoint defer)" + (4) Wire `approvalWorkflowId: approvalWorkflowId || null` vào CreateContractCommand POST body. BE precondition verify: `CreateContractCommand` record line 17-36 ContractFeatures.cs đã có `Guid? ApprovalWorkflowId = null` field (em main commit Chunk E1 PRIOR — comment marker "[Plan B S29 2026-05-22 Chunk E1] Drafter pick V2 workflow lúc create"). FE wire safe — no DTO mismatch. Build verify: `npm --prefix fe-admin run build` PASS 0 TS err 1926 modules 1.40MB gzip 358KB 16.07s; `npm --prefix fe-user run build` PASS 0 TS err 1916 modules 1.32MB gzip 343KB 8.84s. Pre-existing CSS @import warn + INEFFECTIVE_DYNAMIC_IMPORT realtime.ts warn unchanged (baseline noise). **Pattern 16-bis 4-place mirror check applied:** (1) Page file × 2 app DONE byte-similar; (2) App.tsx Routes N/A (enhance existing `/contracts/new` route - không route mới); (3) menuKeys.ts N/A (không menu key mới — page enhancement); (4) Layout staticMap N/A (route unchanged). Token ~12k Case 2 cookie-cutter (4 Read PE source + 2 Edit per file × 2 = 4 Edit total + 2 npm build + 1 git commit + memory update). Commit `62b50d1` clean 2 file. KHÔNG push remote — em main coordinate Chunk E final batch. **Pattern 5 mirror 2 app §3.9 applied 9th cumulative S20-S29** (proven IDENTICAL bytes hash check sau edit batch — git diff stat confirm). **Pattern 12-bis cross-module FE cookie-cutter mirror** demonstrated: PE PeWorkspaceCreateView V2 dropdown → Contract ContractCreatePage V2 dropdown clean (same useQuery shape, same Select markup, same filter logic, same POST body wire) — discriminator field ApplicableType=3 swap from `defaultType` (PE 1/2). Reusable pattern future Budget V2 / any cross-module entity với V2 workflow integration. Tag: `[pattern, phase-9, frontend]`. diff --git a/.claude/agent-memory/investigator/MEMORY.md b/.claude/agent-memory/investigator/MEMORY.md index ba1ce83..a3f4c0d 100644 --- a/.claude/agent-memory/investigator/MEMORY.md +++ b/.claude/agent-memory/investigator/MEMORY.md @@ -129,6 +129,8 @@ State machine 5 trạng thái phiếu PE: Nháp / Đã gửi duyệt / **Trả l ## 📅 Recent activity (last 10 FIFO) +- **2026-05-26 (S32 startup — em main proxy verify context + S31 RAG v1.3 baseline awareness):** S31 đóng ~1.5h ngày 2026-05-26 với RAG v1.3 baseline PASS recall@5=1.000 (11/11 queries) + avg_rerank=0.847. **Root cause S31 fix:** `AI_INFRA/claude-rag/lib/retrieval.py` xài API cũ `qdrant.search()` đã bị qdrant-client 1.18 xóa → đổi sang `query_points().points` API mới. **Gotcha #52 NEW** add vào `docs/gotchas.md` (Qdrant search removed). **Downstream impact:** MCP tools `mcp__rag-unified__search_memory` + `mcp__rag-unified__cross_project_search` live PASS post-CLI restart — test query "gotcha 52 qdrant search removed" top_k=3 trả 3 chunks rerank scores 0.515 / 0.479 / 0.461 (all dưới threshold 0.7 cao mong đợi vì query về symbol `qdrant.search` chỉ match doc rag-setup-plan.md historical, KHÔNG match gotcha #52 doc — doc chưa indexed lần re-index gần nhất hoặc chưa ingest gotchas folder). **Memory size 25.8 KB ĐÃ VƯỢT curate trigger 25KB** — em append entry này + flag em main curate cuối S32 (archive S25 + S26 verbose entries → `archive/2026-05-q2.md`). **Pending tasks anh có thể spawn em qua SendMessage:** (a) Plan B-Wrap test bundle BW1-BW7 (regression ApproveV2Async Contract V2 + ApplicableType=3 validate), (b) Phase 9 UAT audit Contract V2 wire prod usage (V1 7 contract + V2 sample `QT-HD-V2-001` smoke verify), (c) gotcha #52 doc verify trong RAG index (cross-check `docs/gotchas.md` đã re-ingest sau S31 fix chưa). **State delta S29 → S32:** 30 mig → 33 mig (Plan B Contract V2 Mig 32+33 + Plan CA role CatalogManager) · 59 → 60 tables · ~146 → ~148 endpoints · gotcha 47/48 → 52 (+4 #49 Plan B + #50 Plan CA INFRASTRUCTURE seed gate + #51 + #52 Qdrant) · 111 test PASS UNCHANGED (UAT defer test-after) · 23 → 25 memory user-level. Token cost spawn này ~10K. + - **2026-05-22 (S29 wrap — Plan CA + Plan B pre-flight 2 spawns + 3 patterns NEW):** S29 close 2 big plans cumulative. **Plan CA (Move Cấu hình danh mục admin → eoffice)** 7 commits `06a441c..6eec8d7` push deployed Run #229+#230 PASS. **Plan B (Contract V2 wire mirror PE V2 pattern Mig 22-26)** 11 commits `58898e8..38f1c4d` push deployed Run #231+#232 PASS. **Investigator role 2 spawn:** (1) **Plan CA pre-flight audit** (agentId a7ab5576c77ee3730, ~15K token): map 9 menu danh mục terrain + GOTCHA tree-inherit Catalogs↔Master + recommend chunk structure A/B/C/D. fe-user component parity verified (DataTable + PageHeader + PermissionGuard + 6 shadcn ui). DbInitializer SeedAdminPermissionsAsync admin role grant CRUD 27 menu key. Permission Matrix dynamic load /api/menus → tự reflect post-move. (2) **Plan B pre-flight audit Contract V1 state** (agentId abf91b30391fb0cdb, ~25K token): map `Contract.cs` 25 fields (V1 only) + `ContractPhase` enum 12 values (TraLai=98 + TuChoi=99 ready) + `ContractWorkflowService.cs` 220 LOC V1 only + sqlcmd prod 7 V1 contract (Phase 2-8 active workflow) + PE Mig 22-26 reference templates + impact assessment (COEXIST V1+V2, KHÔNG drop V1) + re-chunk 6 chunks (split A → A1 entity + A2 mig). 3 surprise: ApprovalWorkflows Prod ZERO ApplicableType=3 (Chunk A2 must seed sample) + `RejectedAtStepIndex` drift deprecated + ContractType 7 variants generic ApplicableType=3. **Patterns proven NEW Investigator perspective S29:** (a) **9-menu permission terrain map pattern** (Plan CA) — Investigator inventory file paths + line ranges + component parity check + recommend chunk before delegate Implementer. ROI cao. (b) **V1+V2 coexist boundary** (Plan B) — KHÔNG drop V1 vì 7 prod contract pinned. Mirror PE Mig 22-24 spec. (c) **Reference template paths cross-module mirror** (PE → Contract V2): Investigator cite EXACT line ranges (PE Mig 23:14-31, Mig 24:14-17, Mig 26 UNIQUE composite, Service ApproveV2Async 446-634, 519-546 UPSERT, 774-783 ResolveActor) → em main + Implementer chỉ cần mirror rename entity. ROI rất cao saving 30%+ time. **Anti-patterns observed:** (a) Investigator KHÔNG verify endpoint exists end-to-end qua live curl — defer to CICD Monitor stage 4. (b) Investigator output sometimes verbose >700 words → em main hỏi cô đọng <500 next time. - **2026-05-22 (Plan B Contract V2 wire pre-flight audit — Q1-Q5 + Bonus re-chunk):** Em main spawn Investigator pre-flight Plan B priority HIGH. 5Q audit + Bonus chunk refinement. Tag schema: `[audit, phase-9, contract]`. **Findings:** (Q1) `Contract.cs:8-58` 25 fields, V1 ready (WorkflowDefinitionId line 22 + CurrentWorkflowStepIndex line 39 + Phase line 12 + RejectedAtStepIndex line 40) MISSING `ApprovalWorkflowId Guid?` + `CurrentApprovalLevelOrder int?` → need Mig 32 add. (Q2) `ContractPhase.cs:14-28` 12 values ready ChoDuyet=10 + TraLai=98 + TuChoi=99 mirror PE. `ContractWorkflowService.cs:23-219` 220 LOC V1 ONLY. NO V2 branch. Match Dept+PositionLevel line 113-126. Gen mã HĐ line 148-155 trigger last step → Phase=DaPhatHanh (terminal khác PE DaDuyet). (Q3) Prod: 7 Contracts 100% V1Pinned (Mig 21 flat WorkflowDefinitionId), 6 in-workflow Phase 2-8 → MUST coexist V1+V2, KHÔNG drop V1. ApprovalWorkflows Prod: 2 rows `ApplicableType=1 (DuyetNcc)` ZERO `ApplicableType=3 (Contract)` chưa seed. (Q4) Mig 22 `20260508053749_AddApprovalWorkflowsV2.cs:14-127` 3 CREATE TABLE shared cho cả PE+Contract, Mig 32 chỉ cần ADD COLUMN tại `Contracts`. Mig 23 `20260508072821_AddApprovalWorkflowIdToPurchaseEvaluation.cs:14-31` template 15 LOC cookie-cutter rename Pe→Contract. Mig 24 `20260508074937_AddCurrentApprovalLevelOrderToPe.cs:14-17` 3 LOC. `ApproveV2Async` `PurchaseEvaluationWorkflowService.cs:446-634` 189 LOC clone mẫu — load AW.Steps.Levels + match actorId ∈ pendingLevelGroup.ApproverUserId (line 484-495) + UPSERT opinion (line 522-546) + advance level/step (line 605-633) + skipToFinal F2 (line 561-602). Branch entry pattern line 167-171 ternary `if (evaluation.ApprovalWorkflowId is Guid awId) ApproveV2Async else ApproveV1Legacy`. (Q5) Risk LOW — schema 80% shared. F1-F4 7 flags Mig 29+30+31 trên `ApprovalWorkflowLevels` (entity line 86-114) inherits FREE Contract. **Risk MEDIUM:** ContractType discriminator — 1 workflow serve ALL 7 ContractType vs per-type? PE chỉ 2 type. Defer Q em main. **Bonus re-chunk 6 chunks:** A1 entity 5 LOC (em main) + A2 Mig 32 cookie-cutter (Implementer) + B Service ternary 189 LOC clone adapt gen mã HĐ terminal (em main critical cross-stack) + C Mig 33 ContractLevelOpinions cookie-cutter (Implementer) + D FE-User Workspace Select V2 (Implementer mirror) + E FE Section 5 LevelOpinionsV2 dynamic (Implementer mirror). **Surprises:** (a) ApprovalWorkflows Prod ZERO ApplicableType=3 — recommend Chunk A2 include DbInitializer seed sample. (b) `RejectedAtStepIndex` Contract line 40 DEPRECATED chưa marked obsolete drift với PE line 50. (c) ContractType 7 variants vs ApprovalWorkflow generic ApplicableType=3 — future Mig 34 có thể cần `ContractTypes int[]` filter nếu Solutions cần per-type workflow. **Recommendation: PROCEED coexist V1+V2 pattern, 6 chunk re-chunk.** Token ~25K. source_path: `solution_erp/audit/investigator-plan-b-contract-v2-preflight-2026-05-22`. diff --git a/.claude/agent-memory/reviewer/MEMORY.md b/.claude/agent-memory/reviewer/MEMORY.md index 63bab90..a42ba30 100644 --- a/.claude/agent-memory/reviewer/MEMORY.md +++ b/.claude/agent-memory/reviewer/MEMORY.md @@ -154,6 +154,8 @@ Flag commit nếu thấy ` security). **Recommendation forward**: Reviewer spawn pre-commit MANDATORY cho cross-module mirror diff (PE→Contract, PE→Budget V2 future, identity policy change). Em main solo OK cho UI polish iteration (S26 Plan AG2-AG6 pattern proven). Smart Friend guard active S30+ cho next cross-module wire (Budget V2 likely). - **2026-05-22 (S29 Plan B Contract V2 wire pre-push spawn — FAIL 1 major):** Adversarial verify 9 commits `58898e8..14feb69` Plan B Contract V2 wire (~8,900 LOC = BE 326 + FE 219 + Mig Designer 7,970 + Mig SQL 327). Spawn ~17K. **Verdict FAIL — 1 MAJOR Cat 3 security/data integrity, 0 critical, 3 minor.** Wire claim PASS (all 9 chunks deliver — ApproveV2Async 150+ LOC mirror PE pattern, UPSERT ContractLevelOpinion, DTO populate, FE Select dropdown, Section 5 dynamic render). Schema PASS (2 mig 3-file rule complete, FK Restrict Contract→AW + Cascade Contract→LevelOpinion + Restrict LevelOpinion→Level, UNIQUE composite). Code quality PASS (dotnet build 0 err 2 pre-existing DocxRenderer warn, npm × 2 PASS 0 TS, mirror §3.9 SHA256 IDENTICAL × 3 files: ContractDetailContent.tsx + ContractCreatePage.tsx + types/contracts.ts). Test PASS 111/111 baseline preserved. Authority PASS explicit mandate. **MAJOR FOUND**: `CreateContractCommandHandler` (`ContractFeatures.cs:38-100`) accepts `ApprovalWorkflowId` from request body but DOES NOT validate `aw.ApplicableType == ApprovalWorkflowApplicableType.Contract`. PE pattern at `PurchaseEvaluationFeatures.cs:62-77` explicitly validates `aw.ApplicableType == expectedType` and throws `ConflictException`. Plan B Chunk E1 omits this guard. **Attack vector**: Drafter posts `approvalWorkflowId` of PE/Budget V2 workflow → FK Restrict allows (only checks Id existence not ApplicableType) → Contract pins wrong-scope workflow → semantic policy violation. **Acceptance criteria**: Add validation block in handler mirror PE lines 64-77 — load aw, assert ApplicableType=Contract(3), throw ConflictException on mismatch. Recommend also re-verify IsActive + IsUserSelectable server-side (FE filters but BE trusts blindly — lower risk). **Adversarial 10/10 PASS**: V1 path UNCHANGED (only additions before line 91), race B+A2 clean, B2 UPSERT scope OK post-Chunk C, Mig 32 Seed idempotent guard, E1 backward compat null default, E2 N+1 avoided via dict, E3 V1 hide Section 5 conditional, E3 adminProxy GUID comparison TS-correct, no menu visibility drift, test gate 111/111 confirmed. **Recommendation**: HOLD push. Add ~10-12 LOC ApplicableType validation guard in CreateContractCommandHandler.Handle before entity instantiation. Re-run build+test. Then PROCEED push 9 commits + 1 fix commit (10th). **Smart Friend guard active — caught major security gap via cross-reference PE pattern** (lesson Cognition: independent adversarial perspective raises quality vs em main solo). **Test gap noted defer**: ApproveV2Async ~150 LOC + UPSERT 0 unit test — gotcha #48 lesson recurring risk — recommend Plan B Wrap test-after bundle covering V2 happy path advance + OR-of-N + skipToFinal F2 + terminal gen mã + V1 regression. @@ -164,8 +166,6 @@ Flag commit nếu thấy `, ]` format (phase ∈ {phase-9, phase-9plus, phase-10}, BC enum ∈ {contract, pe, budget, workflow, identity, form, infra}). **Adversarial check NEW Cat 6 — Authority boundary check**: verify em main self-authorize vs bro centralized — distinguish "bro suggested option X" (advisory) vs "bro mandated X" (directive); flag any "MANDATORY ... cross-project" sourced từ em main self-decision. 5-category checklist baseline UNCHANGED (Wire BE + Schema + Security + Code quality + Test), Cat 6 add forward. **Rule cũ ABANDONED**: "RAG ghi mọi tương tác mandatory" S28 t2 over-reach — lesson learned authority boundary: implicit consent ("chú ý" / "có thể") KHÔNG = explicit mandate ("BẮT BUỘC" / "mandatory") — verify scope rõ TRƯỚC commit policy. Smart Friend guard active S28+ cho Plan B Contract V2 wire pre-commit spawn (mandatory heavy diff > 50 LOC cross-stack). -- **2026-05-22 (S27 retrospective):** Smart Friend guard catch retrospective: Anh pqhuy phát hiện Qdrant native dashboard 404 — em main miss pre-push verify `rag-onboarding-guide.md` claim "Qdrant native dashboard work". Lesson: SubAgent Smart Friend guard mandate cho docs claim hyperlinked external services. "Self-review bias - em main test SOLO miss external dependency verification" — reinforced cumulative S29. - --- ## 🔄 Curate trigger @@ -174,4 +174,4 @@ Flag commit nếu thấy ` 25KB OR Plan B Wrap test bundle complete OR Budget V2 wire start OR Phase 9 UAT hard blocker audit spawn. diff --git a/docs/changelog/migration-todos.md b/docs/changelog/migration-todos.md index 4b50fc1..ae1a732 100644 --- a/docs/changelog/migration-todos.md +++ b/docs/changelog/migration-todos.md @@ -576,11 +576,144 @@ Quy tắc: `docs/rules.md §9`. Audit định kỳ mỗi đầu tháng — workf Cron task `solution-erp-skill-audit-monthly` fire 9:00 AM ngày 1 mỗi tháng. -## 📦 Post-launch (Phase 10+ — future) +## 🚀 Phase 10 — Plan G: Port 11 module NamGroup → SOL (backlog defer sau Phase 9 stabilize) -- [ ] **Email outbox** (MailKit + SMTP) — blocked chờ SMTP config +> **Trigger:** S32 anh main yêu cầu plan kỹ 11 module NamGroup (NHÂN SỰ + VĂN PHÒNG SỐ + CÁ NHÂN — khung đỏ screenshot 2026-05-26). **4 quyết định chốt anh main:** +> 1. **Scope:** FULL 11 module (3 nhóm — không subset) +> 2. **DB:** Single schema `dbo` mở rộng Mig 34→43+ (no multi-schema, no separate DbContext) +> 3. **Reuse:** Workflow Engine V2 (Mig 22-26) extend `ApplicableType` enum +5 values cho Đề xuất/Đơn từ/OT/Đặt xe/Ticket CNTT +> 4. **Rollout:** Chunk per-module Plan riêng (10 Plan G-* atomic sprint ~3-5 ngày mỗi cái), aggressive multi-agent parallel ROI ~70% +> +> **Sequence chốt anh main S32:** Tuần tự theo kế hoạch tốt nhất — Phase 9 UAT stabilize trước → Phase 10.1 kick off. KHÔNG rush parallel với Phase 9. +> **Timeline target:** ~3 tháng (T6-T8/2026) realistic với multi-agent aggressive. +> **G-P1 Chấm công scope:** Pure web GPS check-in (KHÔNG máy vân tay/face recog hiện tại — anh chốt "tạm thời vậy trước"). +> **G-H2 HrmConfig seed:** Reference NamGroup demo seed (LeaveTypes/Holidays/Shifts/OtPolicy) — Investigator audit NamGroup `DbInitializer` + `DataSeeder` lúc G-H2 kick off. + +### 📐 Reference findings từ NamGroup audit S32 + +| NamGroup pattern | Decision SOL | +|---|---| +| `TblNhanVien*` 8+ bảng (QtCongTac/QtDaoTao/QuanHeThanNhan/KyNangViTinh/...) | Giữ structure deep — 1 main + N satellites (EmployeeProfile family) | +| `SoDoToChuc`/`SoDoKhoi`/`ChucDanh`/`ViTri` 4 bảng org chart | Tận dụng SOL `Department` + `User.Position` + `PositionLevel` — skip 3 bảng SoDo redundant | +| `Tbl*` Vietnamese table naming + Repository pattern .NET FW 4.0 | Reject — giữ SOL Clean Arch + Entity PascalCase English + IApplicationDbContext | +| WF approval ad-hoc per module | Reject — reuse `ApprovalWorkflow V2` extend enum +5 values | +| Announcement/InternalDocument/Menu flat tables | Adapt — reuse SOL `MenuItem` tree + `Notification` + Attachment infra | + +### Phase 10.1 — Foundation HRM (UNBLOCK toàn bộ Phase 10 sau) + +#### Plan G-H1 — Hồ sơ nhân sự ⭐ CRITICAL FIRST (depend by 8/11 module sau) + +- [ ] 🟦 Investigator pre-flight audit NamGroup `TblNhanVien*` 8 bảng + map fields → SOL EmployeeProfile schema +- [ ] 👤 Chủ trì Solo design Mig 34 `AddEmployeeProfiles` schema (1 main + 5 satellite: WorkHistory/Education/FamilyRelation/Skill/Document) +- [ ] 🟨 Implementer Case 2 cookie-cutter BE entity scaffold 6 entity + EF Config + DbInitializer seed 30 demo profile mirror 30 users +- [ ] 🟨 Implementer Case 2 mirror PE handler BE CQRS Create/Update/GetDetail/List + 6 endpoint controller +- [ ] 🟨 Implementer Case 2 cookie-cutter mirror PE FE 2 app types/employee.ts + EmployeesPage 3-panel + EmployeeDetailTabs (6 section: Cơ bản/Công tác/Đào tạo/Thân nhân/Kỹ năng/Hồ sơ) +- [ ] 👤 Chủ trì Solo Permission menu `Hrm_HoSo*` (List/Create/Detail) + Permission Matrix seed +- [ ] 🟥 Reviewer pre-commit + 🟩 CICD Monitor post-deploy verify + +#### Plan G-H2 — Cấu hình chung HRM + +- [ ] 👤 Chủ trì Solo Mig 35 `AddHrmConfigs` — LeaveTypes + Holidays + ShiftPatterns + OtPolicy lookup tables +- [ ] 🟦 Investigator audit NamGroup demo seed (LeaveTypes/Holidays/Shifts/OtPolicy) — reference cho seed sample data +- [ ] 🟨 Implementer Case 2 mirror SOL Catalogs pattern (Plan CA Chunk B) BE CQRS CRUD 4 catalog +- [ ] 🟨 Implementer Case 2 mirror admin Catalogs FE Admin 4 catalog page (list/create/edit dialog inline) +- [ ] 👤 Chủ trì Solo Permission menu `Hrm_Config*` 4 leaf + admin role assign + +### Phase 10.2 — Office Core standalone (KHÔNG cần workflow) + +#### Plan G-O1 — Danh bạ nội bộ + +- [ ] 👤 Chủ trì Solo BE 1 endpoint `GET /api/directory` — filter dept/position/search name+email+phone (reuse Users + EmployeeProfiles + Departments) +- [ ] 🟨 Implementer Case 2 cookie-cutter FE 2 app InternalDirectoryPage (card grid avatar + dept + extension + email + mobile click-to-call) +- [ ] 👤 Chủ trì Solo Permission `Off_DanhBa` 1 leaf + +#### Plan G-O2 — Phòng họp (booking calendar standalone) + +- [ ] 👤 Chủ trì Solo Mig 36 `AddMeetingRooms` — MeetingRooms + MeetingBookings (RoomId/UserId/StartAt/EndAt/Title/Attendees[]/Status enum) +- [ ] 🟨 Implementer Case 2 BE CQRS Room CRUD + Booking Create/Cancel + GetCalendar + check conflict (SERIALIZABLE transaction race-safe) +- [ ] 🟨 Implementer Case 2 FE 2 app — Admin Rooms CRUD + User BookingCalendar (FullCalendar lib new dep — check license + bundle size impact) +- [ ] 👤 Chủ trì Solo Notification push attendees when booking created (NotificationPushInterceptor reuse) +- [ ] 👤 Chủ trì Solo Permission `Off_PhongHop*` 3 leaf + +### Phase 10.3 — Workflow Apps (extend ApprovalWorkflow V2 enum +5 values) + +> ⚠️ PHẢI extend `ApprovalWorkflowApplicableType` enum first: `+ProposalGeneral=4, +LeaveRequest=5, +OtRequest=6, +VehicleBooking=7, +ItTicket=8` (Mig 37 cookie-cutter Mig 22 pattern). Gotcha #51 INFRASTRUCTURE vs DEMO seed gate caution — `SeedSampleWorkflow*` OUT of `DemoSeed:Disabled` flag. + +#### Plan G-O3 — Đề xuất (Proposal) + +- [ ] 👤 Chủ trì Solo Mig 38 schema + extend `ApplicableType` enum +ProposalGeneral=4 +- [ ] 🟨 Implementer Case 2 mirror PE Mig 22-26 BE Proposal entity + ProposalAttachments + workflow pin `ApprovalWorkflowId` +- [ ] 👤 Chủ trì Solo BE ApproveV2Async branch + CodeGen `DX/YYYY/NNN` (cross-stack tight, mirror PE CodeGen) +- [ ] 🟨 Implementer Case 2 cookie-cutter mirror PE Plan B Chunk E1+D+E2+E3 FE 2 app ProposalsList + Create + Detail (Section 1-5) +- [ ] 🟥 Reviewer adversarial Smart Friend pre-commit — ApplicableType=Proposal validate cross-module security catch (gotcha #44 cumulative pattern) +- [ ] 🟩 CICD Monitor post-deploy verify Run + bundle hash rotate + +#### Plan G-O4 — Đơn từ (LeaveRequest + OtRequest + TravelRequest) + +- [ ] 👤 Chủ trì Solo Mig 39 schema 3 entity + extend enum +LeaveRequest=5 +OtRequest=6 +- [ ] 🟨 Implementer Case 2 ×3 spawn parallel BE 3 entity scaffold + CQRS handler mirror PE cookie-cutter +- [ ] 👤 Chủ trì Solo BE LeaveBalance calculation (Hrm_Config LeaveTypes + EmployeeProfile.HireDate seniority) — business logic tight +- [ ] 🟨 Implementer Case 2 ×3 FE 2 app 3 page mirror cookie-cutter +- [ ] 🟥 Reviewer pre-commit + 🟩 CICD verify + +#### Plan G-O5 — Đặt xe công (VehicleBooking) + +- [ ] 👤 Chủ trì Solo Mig 40 schema Vehicles + Drivers + VehicleBookings + extend enum +VehicleBooking=7 +- [ ] 🟨 Implementer Case 2 mirror G-O2 MeetingRoom + workflow mirror G-O3 BE CRUD + workflow + check conflict + driver assignment +- [ ] 🟨 Implementer Case 2 cookie-cutter FE 2 app +- [ ] 🟥 Reviewer + 🟩 CICD + +#### Plan G-O6 — Ticket CNTT (IT Helpdesk) + +- [ ] 👤 Chủ trì Solo Mig 41 schema ItTickets + ItTicketComments thread +- [ ] 👤 Chủ trì Solo BE CQRS + Auto-assign round-robin per category + SLA timer warning (business logic tight) +- [ ] 🟨 Implementer Case 2 FE 2 app TicketsList + Detail (thread comment + status board kanban-ish) +- [ ] 👤 Chủ trì Solo Notification SLA expire warning (reuse SlaTimer pattern Contract) +- [ ] 🟥 Reviewer + 🟩 CICD + +### Phase 10.4 — Dashboards + Attendance + +#### Plan G-H3 — Dashboard Nhân sự (depend H1 data) + +- [ ] 👤 Chủ trì Solo BE `GET /api/hr/dashboard` aggregate KPI (TongNV + HDActive + HDExpiring + GenderRatio + Birthday7d + StatusBreakdown) +- [ ] 🟨 Implementer Case 2 cookie-cutter mirror MyDashboard role-aware FE 2 app HrmDashboardPage (4 KPI card + 2 donut chart + birthday timeline) +- [ ] 👤 Chủ trì Solo Permission `Hrm_Dashboard` 1 leaf HR role only + +#### Plan G-P1 — Chấm công (Pure web GPS check-in — no device integration per anh chốt S32) + +- [ ] 👤 Chủ trì Solo Mig 42 `AddAttendances` — AttendanceLogs (UserId/Date/CheckInAt/CheckOutAt/Source enum Web/Mobile/GPS lat-long/IpAddress/Note) +- [ ] 👤 Chủ trì Solo BE Web GPS check-in endpoint + monthly report calc (OT từ Hrm_Config OtPolicy) — business logic tight +- [ ] 🟨 Implementer Case 2 FE 2 app User MyAttendance (calendar tháng + click-in button GPS prompt) + Admin AttendanceReport (filter dept + export Excel) +- [ ] 🟥 Reviewer + 🟩 CICD + +### Stats target Phase 10 end (estimate) + +| Metric | Phase 9 | Phase 10 end | Δ | +|---|---|---|---| +| Migrations | 33 | ~42 | +9 (Mig 34-42 batch nhỏ) | +| Tables | 60 | ~85 | +25 | +| Endpoints | ~148 | ~250 | +100 | +| FE pages | 38 | ~60 | +22 | +| AppRoles | 14 | ~18 | +4 (HrAdmin/OfficeAdmin/Driver/ItStaff) | +| Permission menu | ~60 | ~110 | +50 (Hrm_/Off_/Per_) | +| Tests | 111 | ~200 | +90 (Phase 10 test-after UAT + critical algo test-before: workflow guard + CodeGen Proposal + LeaveBalance calc + Attendance OT) | + +### Risk + Gotcha cần catch trước Phase 10 kick off + +1. **Mig 37 enum extend `ApplicableType`** — gotcha #51 INFRASTRUCTURE vs DEMO seed gate caution +2. **Cross-stack tight cho LeaveBalance + Attendance OT + Ticket Auto-assign** — Implementer REFUSE, em main solo bắt buộc +3. **MeetingRoom + Vehicle conflict check** — race condition 2 user book cùng time slot — SERIALIZABLE transaction mirror Contract gen mã +4. **EmployeeProfile depend by 8/11 module sau** — KHÔNG được rush G-H1, Reviewer adversarial 100% pre-commit +5. **30 demo profile cần seed thật cho 30 user existing** — DbInitializer extend, KHÔNG demo seed gate (infrastructure) +6. **Permission leaf 50 NEW** — admin Designer phải seed cẩn thận tránh broken inheritance tree (gotcha #35) +7. **FullCalendar lib new dep** cho G-O2 + G-O5 + G-P1 — skill `dependency-audit-erp` chạy trước commit + +## 📦 Post-launch (Phase 11+ — future, defer Phase 10 done) + +- [ ] **Email outbox** (MailKit + SMTP) — blocked chờ SMTP config (Phase 9 hard blocker) - [ ] E-signature integration (VNPT CA hoặc FPT CA) - [ ] Tích hợp Bravo / SAP ERP import NCC -- [ ] Mobile app (React Native?) cho BOD duyệt ngoài giờ +- [ ] Mobile app (React Native?) cho BOD duyệt ngoài giờ — depend G-P1 mobile GPS check-in done - [ ] AI: gợi ý điền form dựa HĐ cũ, OCR scan HĐ đối tác - [ ] Multi-tenant nếu có công ty thứ 2 +- [ ] G-P1+ — Chấm công device integration (vân tay/face recog/CSV import) khi anh có máy