[CLAUDE] Docs: S44 monthly drift audit + AI_INFRA bundle 06-01 adopt
Cadence audit (2026-06-01), docs-only -> CI-skip. investigator-codebase drift scan (ground-truth from disk) -> em main patch. No code touched, 154 test unchanged. Drift fixes (42 count corrections): 40->42 mig, 84/59/55/47->91 tables, 130/111->154 test, 52/49->56 gotcha across CLAUDE.md, docs/CLAUDE.md, ef-core-migration + dependency-audit skills, schema-diagram, database-guide. schema-diagram migration table extended Mig 17-42; ef-core history Mig 27-42; detailed-section gap (Mig 27-42 modules) flagged explicit (deferred, not silent). AI_INFRA bundle 06-01 (federated, full scope): - A: RAG T1/T2 auto-ack - C: hygiene 7/7 agent-mem L1 <=16KB; "25KB"->"~30KB tiered" wording x7 - D: #4 self-sustaining adoption-report step -> /session-end Phase 6.3 - E/F: report + ledger -> docs/governance/ Carry-over .mcp.json + BROADCAST-05-29 left untouched (concurrency rule). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
# CI/CD Monitor Agent — Persistent Memory
|
||||
|
||||
> **Persistent diary cross-session.** Auto-injected first 200 lines / 25KB at spawn.
|
||||
> **Persistent diary cross-session.** Auto-injected first ~200 lines at spawn (L1 HOT).
|
||||
> Update BEFORE every stop. Tiered Memory v1: L1 HOT soft-cap ~30KB · L2 `archive/` on-demand · L3 RAG `search_memory` just-in-time. Keep entry ≤ 1.5K chars (gotcha #53).
|
||||
> Full verbatim run history pre-S40 → git `d2f52ba` + `archive/2026-05-{runs,q2,q3,q4}.md`.
|
||||
|
||||
@ -79,5 +79,5 @@ BE (test+build) ~90s · FE × 2 ~60s/app · deploy ~30s · **total ~3min code /
|
||||
---
|
||||
|
||||
## 🔄 Curate trigger
|
||||
- >25KB → archive recent runs → `archive/<period>.md`. Dup failure patterns → merge. Stale >3mo → remove.
|
||||
- >~30KB → archive recent runs → L2 `archive/<period>.md`. Dup failure patterns → merge. Stale >3mo → remove.
|
||||
- **Last curate: 2026-05-29 S40 em main proxy** (35.3→~21KB): archived Run #359/#243/#242/#241/#240 + S35/S36 startup → q4 + git d2f52ba; refreshed stale 120→130 test + Mig 34→40 + Stage 3 111→130. Foundation (gotcha patterns + Stage 0-5 + Stage 4.6 + 10-point + Discovery #4-8) preserved. Prev: S34 q3 · S32 q2 · S22 runs.
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# Implementer-Backend Agent — Persistent Memory
|
||||
|
||||
> **Persistent diary cross-session.** Auto-injected first 200 lines / 25KB at spawn.
|
||||
> **Persistent diary cross-session.** Auto-injected first ~200 lines at spawn (L1 HOT).
|
||||
> Update BEFORE every stop. Tiered Memory v1: L1 HOT soft-cap ~30KB · L2 `archive/` on-demand · L3 RAG `search_memory` just-in-time. Keep entry ≤ 1.5K chars (gotcha #53).
|
||||
> Full verbatim history pre-S40 → git `d2f52ba` + `archive/2026-05-q1..q4.md`.
|
||||
> **Renamed S39:** implementer → implementer-backend (.NET half). FE patterns → `implementer-frontend` MEMORY. Test patterns → `test-specialist` MEMORY.
|
||||
@ -86,5 +86,5 @@ UI `disabled={!canX}` + BE helper `EnsureCanXAsync(id, userId)` throw 403 (NOT i
|
||||
---
|
||||
|
||||
## 🔄 Curate trigger
|
||||
- >25KB → archive recent → `archive/<period>.md`. Stale >3mo → remove.
|
||||
- >~30KB → archive recent → L2 `archive/<period>.md`. Stale >3mo → remove.
|
||||
- **Last curate: 2026-05-29 S40 em main proxy** (30.9→~18KB): **dedup split** — removed FE patterns (5/6/13/14/15/16-bis → implementer-frontend) + test patterns (10/11/12 → test-specialist), condensed Pattern 12-bis/12-ter, refreshed stale (104/111→130 test, Opus 4.7→4.8 model). BE patterns 1-4/7-9/12-bis/12-ter foundation preserved. Prev: S34 q3 · S32 q2 · S22 q1.
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# Implementer-Frontend Agent — Persistent Memory
|
||||
|
||||
> **Persistent diary cross-session.** Auto-injected first 200 lines / 25KB at spawn.
|
||||
> **Persistent diary cross-session.** Auto-injected first ~200 lines at spawn (L1 HOT).
|
||||
> Update BEFORE every stop. Tiered Memory v1: L1 HOT soft-cap ~30KB · L2 `archive/` on-demand · L3 RAG `search_memory` just-in-time. Keep entry ≤ 1.5K chars (gotcha #53).
|
||||
> **NEW agent S39 (2026-05-29)** — split từ implementer (FE 2 app half). Backend scaffold history ở `implementer-backend`.
|
||||
|
||||
@ -51,4 +51,4 @@ Dynamic class purged. PALETTE array full literal `as const` cycle `index % lengt
|
||||
1. ❌ Touch BE files · 2. ❌ Miss 4th Layout staticMap · 3. ❌ Skip npm build × 2 · 4. ❌ `git add -A` · 5. ❌ Push remote · 6. ❌ UX decision autonomous → REFUSE
|
||||
|
||||
## 🔄 Curate trigger
|
||||
Size > 25KB → archive. Commit scope (em main commits): `FE-Admin` · `FE-User`.
|
||||
Size > ~30KB → archive to L2 (tiered v1). Commit scope (em main commits): `FE-Admin` · `FE-User`.
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# Investigator-API Agent — Persistent Memory
|
||||
|
||||
> **Persistent diary cross-session.** Auto-injected first 200 lines / 25KB at spawn.
|
||||
> **Persistent diary cross-session.** Auto-injected first ~200 lines at spawn (L1 HOT).
|
||||
> Update BEFORE every stop. Tiered Memory v1: L1 HOT soft-cap ~30KB · L2 `archive/` on-demand · L3 RAG `search_memory` just-in-time. Keep entry ≤ 1.5K chars (gotcha #53).
|
||||
> **NEW agent S39 (2026-05-29)** — split từ investigator (external research half). Internal audit history ở `investigator-codebase`.
|
||||
|
||||
@ -34,4 +34,4 @@ Read-only EXTERNAL research specialist. WebFetch/WebSearch official docs + NuGet
|
||||
---
|
||||
|
||||
## 🔄 Curate trigger
|
||||
- Size > 25KB → archive `archive/<period>.md`. Stale > 3 months → remove.
|
||||
- Size > ~30KB → archive to L2 `archive/<period>.md`. Stale > 3 months → remove.
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# Investigator-Codebase Agent — Persistent Memory
|
||||
|
||||
> **Persistent diary cross-session.** Auto-injected first 200 lines / 25KB at spawn.
|
||||
> **Persistent diary cross-session.** Auto-injected first ~200 lines at spawn (L1 HOT).
|
||||
> Update BEFORE every stop. Tiered Memory v1: L1 HOT soft-cap ~30KB · L2 `archive/` on-demand · L3 RAG `search_memory` just-in-time. Keep entry ≤ 1.5K chars (gotcha #53).
|
||||
> Full verbatim history pre-S40 → git `d2f52ba` + `archive/2026-05-q1..q4.md`.
|
||||
> **Renamed S39:** investigator → investigator-codebase (internal half; external → investigator-api).
|
||||
@ -70,14 +70,14 @@ Bearer từ `POST api.solutions.com.vn/api/auth/login` → status matrix expecte
|
||||
|
||||
## 📅 Recent activity (FIFO — older → archive/git)
|
||||
|
||||
- **2026-06-01 (MONTHLY DRIFT AUDIT):** Ground truth code: **migrations=42** (last `AddLeaveBalances`, path `.../Persistence/Migrations/*.cs`) · **gotchas highest=#56** (file header NO self-count → drift chỉ ở file *reference* gotchas.md) · tests=154 (58 Domain+96 Infra, em main verified) · tables≈91 (45 config class nhưng Catalogs=4+ContractDetails=7+7 Identity untracked → khớp STATUS 91, KHÔNG cheap-exact). **Biggest drift: ef-core-migration SKILL** (frontmatter:3 "31 migration"→42, :19 history "31"→42 + thiếu rows Mig 27-42, :50 "59 bảng"→91, :80 "111 test"→154, :258/:267 "59 bảng"). dependency-audit SKILL:153 "49 bẫy"→56. CLAUDE.md:53 "40 mig→84 bảng"→42/91, :66 "130 test"→154, :133 "52 bẫy"→56. docs/CLAUDE.md:65 "52"→56. **schema-diagram GAP:** migration TABLE dừng Mig 16 (line 487); detail § cuối =§15=Mig 26 (§16=Related KHÔNG phải mig) → thiếu § cho **Mig 27-42** (16 mig). database-guide:4 "47 bảng/13 mig"→91/42. STATUS:97 backlog "Curate 4 agent MEMORY 35.7/35.3/30.9/28.4" STALE (đã curate S40 `78c9de3`, all ≤16KB) → REMOVE. NO-CHANGE: contract-workflow (historical counts OK), form-engine, iis-deploy (no count), HANDOFF (S43 current), PROJECT-MAP (no count). Tag `[drift-audit, monthly, 2026-06]`.
|
||||
- **2026-05-30 (P11-A WorkflowApps wire pre-flight):** 4 module Leave/OT/Travel/Vehicle. Schema pin ĐÃ CÓ SẴN (Mig 39): `Office/{Module}.cs` đều có `ApprovalWorkflowId?`+`CurrentApprovalLevelOrder?`+`WorkflowAppStatus` (5-state khớp ProposalStatus). SKELETON tại `Application/Office/WorkflowAppsFeatures.cs:11-15` (chỉ Create+List, KHÔNG Approve/Reject/Return/GetById). **Proposal = mirror HOÀN HẢO** (cùng Office ns, Mig 38): `ProposalFeatures.cs:403-486` ApproveHandler = flatten `Steps.OrderBy(Order).SelectMany(Levels.OrderBy(Order))` global level index → `allLevels[CurrentApprovalLevelOrder-1]` → actor match `Level.ApproverUserId==uid||Admin` → UPSERT LevelOpinion → advance++/DaDuyet. ⚠️ `ApprovalWorkflow.cs:72` nói Level **KHÔNG OR-of-N** (1 ApproverUserId/Level) — KHÁC memory cũ "OR-of-N", verify lại. Gap: 4 bảng `{Module}LevelOpinion` mới (Mig 41+), 3 route/controller, 4 seed WF, FE Detail+Opinion (chỉ có WorkflowAppsListPage chung). ⚠️ enum `ApplicableType` THIẾU Travel (có Leave=5/OT=6/Vehicle=7/ItTicket=8); `ExtendApplicableTypeForWorkflowApps` mig empty Up/Down (enum-only). Tag `[pre-flight, p11-a, workflowapps]`.
|
||||
- **2026-05-29 (S40 STATE GROUNDING):** 7 metric verify. ✅ Migrations=**40** (path `.../Persistence/Migrations/*.cs`, last `AddAttendances`). ✅ Gotchas=**55** (`### N.`). ✅ git clean. DbSet=77 nhưng **SQL tables=84** (em main verify `.ToTable()` ModelSnapshot — 77+7 Identity, "84 docs ĐÚNG", DbSet count sai −7). Endpoints=**211** (docs ~223). FE pages fe-admin **36**+fe-user 29=**65** (docs 53 under-count). Menu keys=**53** const (docs 85 over-count). 3 số tin cậy nhất = mig/gotcha/git. Lesson: tables phải count ToTable KHÔNG DbSet. Tag `[state-grounding, docs-drift, s40]`.
|
||||
- **2026-05-29 (S39 BVAAU 7-agent extract):** Đọc 8 file BVAAU `.claude/agents/` ~22K. Split 4→7 trục research(2)/implement(2)/quality(3). Boundary: repo interface=domain, EF config=infra, test=test-specialist. Tool: cả 7 agent 5 RAG MCP (+search_code BM25 +store_memory +list_projects). BVAAU Phase 0 codebase RỖNG → aspirational template chưa battle-test; SOLUTION_ERP giữ 6 skill + backend/frontend split (thay domain/infra cho 2-FE fit). VIPIX guide claim KHÔNG verify được (file miss). Tag `[cross-project, bvaau, port]`.
|
||||
- **2026-05-28 (S37 G-O3 Proposal pre-flight):** PE pattern mirror cho Mig 38. LevelOpinion UNIQUE per-LEVEL `(EntityId, LevelId)` FK Cascade+Restrict. CodeSequence 1 row/Prefix (`DX/YYYY` 3 col Prefix PK+LastSeq, tx SERIALIZABLE). ApproveV2Async 7 step (group Levels by Order=Cấp OR-of-N → match actor.Id∈ApproverUserId + Admin bypass → UPSERT LevelOpinion sync → F2 skipToFinal → advance levelOrder++ → DaDuyet). NamGroup TblRequest generic → **SOL clean-room MẠNH HƠN**. CategoryId nullable FK + free text fallback (lesson Plan C 8 FK ZERO populated). Tag `[pre-flight, g-o3, proposal]`.
|
||||
- **Archived S29-S36 → `archive/2026-05-q4.md` + git d2f52ba (S40 curate):** S36 G-O2 Phòng họp clean-room + FullCalendar v6 MIT eval · S36 startup MEMORY-size audit · S35 G-H2 HRM clean-room verdict · S33 G-H1 NamGroup TblNhanVien 10-bảng (105 cols main) · S33 startup RAG verify · S32 Plan G 11-module backlog · S29 Plan CA+B pre-flight (3 patterns: 9-menu terrain, V1+V2 coexist, reference-template-paths cite line-range ROI). KEY absorbed: **clean-room > NamGroup port verified 4×** · Pattern 12-bis cross-module mirror · FK+freetext dual-write.
|
||||
- **Archived S29-S37 → `archive/2026-05-q4.md` + git d2f52ba (S40 curate):** S36 G-O2 Phòng họp clean-room + FullCalendar v6 MIT eval · S36 startup MEMORY-size audit · S35 G-H2 HRM clean-room verdict · S33 G-H1 NamGroup TblNhanVien 10-bảng (105 cols main) · S33 startup RAG verify · S32 Plan G 11-module backlog · S29 Plan CA+B pre-flight (3 patterns: 9-menu terrain, V1+V2 coexist, reference-template-paths cite line-range ROI). KEY absorbed: **clean-room > NamGroup port verified 4×** · Pattern 12-bis cross-module mirror · FK+freetext dual-write.
|
||||
|
||||
---
|
||||
|
||||
## 🔄 Curate trigger
|
||||
- >25KB → archive recent → `archive/<period>.md`. Stale >3mo → remove.
|
||||
- >~30KB → archive recent → L2 `archive/<period>.md`. Stale >3mo → remove.
|
||||
- **Last curate: 2026-05-29 S40 em main proxy** (35.7→~20KB): archived 7 FIFO S29-S36 → q4 + git d2f52ba, refreshed stale essentials S25→S40 numbers, trimmed memory-list. Prev: S34 q3 · S32 q2 · S22 q1.
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# Reviewer Agent — Persistent Memory
|
||||
|
||||
> **Persistent diary cross-session.** Auto-injected first 200 lines / 25KB at spawn.
|
||||
> **Persistent diary cross-session.** Auto-injected first ~200 lines at spawn (L1 HOT).
|
||||
> Update BEFORE every stop. Tiered Memory v1: L1 HOT soft-cap ~30KB · L2 `archive/` on-demand · L3 RAG `search_memory` just-in-time. Keep entry ≤ 1.5K chars (gotcha #53).
|
||||
> Full verbatim history pre-S40 → git `d2f52ba` + `archive/2026-05-q1..q2.md`.
|
||||
|
||||
@ -66,5 +66,5 @@ Adversarial pre-commit reviewer SOLUTION_ERP. Read-only verify + live curl prod
|
||||
---
|
||||
|
||||
## 🔄 Curate trigger
|
||||
- >25KB → archive recent → `archive/<period>.md`. Stale >3mo → remove.
|
||||
- >~30KB → archive recent → L2 `archive/<period>.md`. Stale >3mo → remove.
|
||||
- **Last curate: 2026-05-29 S40 em main proxy** (28.4→~18KB): archived S33 Plan C + S33 startup + S32×2 + S29 wrap detail → q2 + git d2f52ba; refreshed stale (81/111→130 test, 47→55 gotcha, 31→40 mig, ~146→211 endpoints). Foundation (bug patterns + 5-category + Smart Friend guard + cross-module security) preserved. Prev: S34 q2 · S22 q1.
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# Test-Specialist Agent — Persistent Memory
|
||||
|
||||
> **Persistent diary cross-session.** Auto-injected first 200 lines / 25KB at spawn.
|
||||
> **Persistent diary cross-session.** Auto-injected first ~200 lines at spawn (L1 HOT).
|
||||
> Update BEFORE every stop. Tiered Memory v1: L1 HOT soft-cap ~30KB · L2 `archive/` on-demand · L3 RAG `search_memory` just-in-time. Keep entry ≤ 1.5K chars (gotcha #53).
|
||||
> **NEW agent S39 (2026-05-29)** — dedicated test layer (tách khỏi implementer Case 3).
|
||||
|
||||
@ -62,4 +62,4 @@ Test theo CODE (single source truth), document mismatch header comment + report.
|
||||
1. ❌ Touch production code → REPORT bug · 2. ❌ Skip MEMORY · 3. ❌ Test không chạy (dotnet test must PASS) · 4. ❌ `git add -A` · 5. ❌ Push remote · 6. ❌ Assertion trivial
|
||||
|
||||
## 🔄 Curate trigger
|
||||
Size > 25KB → archive. Commit scope (em main commits): `Tests`.
|
||||
Size > ~30KB → archive to L2 (tiered v1). Commit scope (em main commits): `Tests`.
|
||||
|
||||
@ -107,6 +107,14 @@ Plan cha: [tên]
|
||||
- ⚠️ **Charter v2:** RAG eval + full re-index (`bootstrap.py`, golden set, recall@5) = **AI_INFRA op** (cần VOYAGE_API_KEY). SE KHÔNG tự chạy.
|
||||
- SE-side closeout: (a) verify `store_memory` chunk retrievable (1 `search_memory` rerank check); (b) flag drift/staleness lên AI_INFRA nếu `last_indexed` lag nhiều; (c) báo cáo broadcast nếu adopt infra change.
|
||||
|
||||
### 6.3 INFRA-ADOPTION report (cadence #4 — self-sustaining, AI_INFRA bundle 2026-06-01)
|
||||
- NẾU session này adopt bất kỳ infra/governance change từ AI_INFRA (RAG fix / session-cmd / hygiene / charter / Gov-v2) → **tự-sinh adoption-report §E** TRƯỚC khi đóng (KHÔNG cần anh nhắc):
|
||||
- **SERVER-VERIFIABLE** (Gitea url): chain N commit sha (origin synced, tree clean)
|
||||
- Per-§: §A RAG · §B Gov · §C Hygiene (X/7 agent-mem L1 ≤30KB · bloat>50KB=0 — đo byte thật) · §D session-cmd (KHUNG added `<sha>` / skip `<đã-có>`) · §E evidence (sha list + integrity moved-not-cut) · §F mirror ledger committed `<sha>`
|
||||
- **NẤC:** agreed / executed / VERIFIED-self. Caveat by-design: L2 gitignored · CANONICAL-pull = trust.
|
||||
- Surface report cho anh main relay AI_INFRA (1 lần báo = ACK+executed+evidence). Em main `/session-start` kế watch + double-check → cơ chế 2 chiều tự duy trì.
|
||||
- Session KHÔNG adopt infra gì → ghi "N/A (no infra adoption this session)".
|
||||
|
||||
---
|
||||
|
||||
**Trigger sau Phase 6:** Session đóng. Working memory có thể `/clear` an toàn (persistent memory đã flush + commit + push).
|
||||
|
||||
@ -150,6 +150,6 @@ Lưu vào `docs/changelog/deps-audit-{YYYY-MM-DD}.md` nếu có action.
|
||||
|
||||
## Related
|
||||
|
||||
- `docs/gotchas.md` — 49 bẫy package compat / CI / IIS / Identity / per-NV refactor / SQLite tie-break đã gặp
|
||||
- `docs/gotchas.md` — 56 bẫy package compat / CI / IIS / Identity / per-NV refactor / SQLite tie-break đã gặp
|
||||
- `docs/changelog/migration-todos.md` Phase 5.1 — checklist deps scan CI
|
||||
- `SolutionErp.slnx` + `global.json` — .NET version pin
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
---
|
||||
name: ef-core-migration
|
||||
description: Tạo/sửa/revert EF Core 10 migration cho SOLUTION_ERP. Dùng khi thêm entity mới, thay đổi schema, rollback migration, debug DesignTimeDbContextFactory fail. Đã có 31 migration sẵn (Init → RefactorSkipToFinalToApproverLevel Mig 31 S23 t1 F2 per-Approver-slot swap). Snapshot + Designer + Migration 3-file rule bắt buộc commit đủ.
|
||||
description: Tạo/sửa/revert EF Core 10 migration cho SOLUTION_ERP. Dùng khi thêm entity mới, thay đổi schema, rollback migration, debug DesignTimeDbContextFactory fail. Đã có 42 migration sẵn (Init → AddLeaveBalances Mig 42, S43 Phase 11 P11-B). Snapshot + Designer + Migration 3-file rule bắt buộc commit đủ.
|
||||
when-to-use:
|
||||
- "thêm migration"
|
||||
- "EF Core migration"
|
||||
@ -16,7 +16,7 @@ when-to-use:
|
||||
|
||||
> **Context:** .NET 10 + EF Core 10 + SQL Server. DbContext: `ApplicationDbContext` ở `Infrastructure/Persistence/`. Startup: `SolutionErp.Api`.
|
||||
|
||||
## Migration history (31 migration hiện có)
|
||||
## Migration history (42 migration hiện có)
|
||||
|
||||
| # | Name | Tables added / changed |
|
||||
|---|---|---|
|
||||
@ -46,8 +46,24 @@ when-to-use:
|
||||
| **24** | **`AddCurrentApprovalLevelOrderToPe`** | **Service V2 wire — `PE.CurrentApprovalLevelOrder int?` track Cấp đang chờ trong Step hiện tại khi pin ApprovalWorkflowId. Null khi V1 legacy hoặc terminal. Service `ApproveV2Async` group Levels by Order = Cấp (OR-of-N), match `actor.Id ∈ ApproverUserId`, advance levelOrder++ trong Step → idx++ + reset levelOrder=1 → DaDuyet. Synthetic Policy `ForV2Schema()` cho FE nextPhases. Session 17.** |
|
||||
| **25** | **`AddIsUserSelectableToApprovalWorkflows`** | **ALTER `ApprovalWorkflows` +`IsUserSelectable bit NOT NULL DEFAULT 0` — admin pin/unpin workflow cho user pick lúc create phiếu (multi-select, độc lập IsActive — multiple version cùng selectable). Backfill `WHERE IsActive=1 SET 1` giữ behavior cũ (active workflows vẫn pickable). Designer +badge "Cho user chọn" + button Ghim/Bỏ ghim + mutation toggle. Workspace dropdown filter `isUserSelectable=true` only. API `PATCH /api/approval-workflows-v2/{id}/user-selectable` admin-only. Session 18 (2026-05-08).** |
|
||||
| **26** | **`AddPeLevelOpinionsForV2`** | **🎯 Section 5 dynamic theo Workflow V2 (Session 19, 2026-05-09) — bảng mới `PurchaseEvaluationLevelOpinions` UNIQUE composite (PEId, ApprovalWorkflowLevelId), FK Cascade Pe + Restrict Level. Comment nvarchar(2000) + SignedAt + SignedByUserId + SignedByFullName denorm. Service `ApproveV2Async` UPSERT auto khi NV duyệt (Q1=1B sync gắn với Duyệt, KHÔNG endpoint CRUD rời). Match level theo ApproverUserId; Admin override fallback first level (FE banner "Admin duyệt thay" khi SignedByUserId !== ApproverUserId). Comment empty → "(duyệt — không ý kiến)" placeholder Q4 bonus. Phiếu V1 legacy fallback Mig 15 4 box readOnly. Mig 15 deprecated cho V2 phiếu (drop sau UAT confirm Mig 27+).** |
|
||||
| **27** | **`AddVisibilityAndDisplayLabelToMenuItems`** | **2 ALTER `MenuItems` (+`IsVisible bit`=1 +`DisplayLabel nvarchar(200)?`) — admin ẩn/hiện + đổi tên menu eOffice (fe-user). Không bảng mới. Session 20.** |
|
||||
| **28** | **`AddAdvancedOptionsToApprovalWorkflows`** | **ALTER `ApprovalWorkflows` — advanced options (skip/optional level config). Session 22.** |
|
||||
| **29** | **`RefactorAdvancedOptionsToPerLevelAndDrafterUser`** | **Refactor advanced options → per-`ApprovalWorkflowLevel` + DrafterUser scope. Session 22.** |
|
||||
| **30** | **`AddAllowApproverEditBudgetToLevels`** | **ALTER `ApprovalWorkflowLevels` +`AllowApproverEditBudget bit`. Session 22.** |
|
||||
| **31** | **`RefactorSkipToFinalToApproverLevel`** | **Per-Approver-slot skip-to-final (Level → Approver slot swap). Session 23.** |
|
||||
| **32** | **`AddApprovalWorkflowToContract`** | **🎯 Contract V2 wire (Plan B S29) — 2 ALTER `Contracts` (+`ApprovalWorkflowId Guid?` +`CurrentApprovalLevelOrder int?`) cookie-cutter mirror PE Mig 23+24. Không bảng mới.** |
|
||||
| **33** | **`AddContractLevelOpinions`** | **1 bảng `ContractLevelOpinions` (UNIQUE composite ContractId+LevelId, FK Cascade Contract + Restrict Level) — mirror PE Mig 26. Session 29.** |
|
||||
| **34** | **`AddEmployeeProfiles`** | **HRM core — `EmployeeProfiles` + N satellite tables cùng parent (Pattern 12-ter). Session 34.** |
|
||||
| **35** | **`AddHrmConfigs`** | **HRM config catalogs (LeaveTypes / Holidays UNIQUE composite / declarative KIND_CONFIG). Session 35.** |
|
||||
| **36** | **`AddMeetingRooms`** | **Office — `MeetingRooms` + booking. Session 36-37.** |
|
||||
| **37** | **`ExtendApplicableTypeForWorkflowApps`** | **Enum extend `ApplicableType` (+Proposal +WorkflowApps values). Không bảng mới. Session 37-38.** |
|
||||
| **38** | **`AddProposals`** | **Module Đề xuất (Proposal) — tables + workflow V2 mirror PE/Contract. Session 37.** |
|
||||
| **39** | **`AddWorkflowApps`** | **Workflow Apps skeleton — Leave/OT/Travel/Vehicle/Ticket request tables (Phase 10 Plan G-O4/O5). Session 38.** |
|
||||
| **40** | **`AddAttendances`** | **Chấm công (Attendance) tables + Dashboard NS skeleton. Session 38.** |
|
||||
| **41** | **`WireWorkflowAppsApprovalV2`** | **🎯 Phase 11 P11-A (S42) — +4 `{Leave,Ot,Travel,Vehicle}LevelOpinions` (UNIQUE composite + Cascade/Restrict) + `WorkflowAppCodeSequences` (atomic MaDonTu) + 4 ALTER `RejectedFromStatus` + enum `TravelRequest=9`.** |
|
||||
| **42** | **`AddLeaveBalances`** | **🎯 Phase 11 P11-B (S43) — 1 bảng `LeaveBalances` (User×LeaveType×Year + Entitled/Used/Adjustment, UNIQUE composite + FK LeaveTypes Restrict). Trừ phép tự động khi đơn nghỉ duyệt cuối.** |
|
||||
|
||||
Total: **59 bảng** dbo + `__EFMigrationsHistory` (Mig 22 add 3 V2 + Mig 26 add 1 PE Level Opinions). Xem `docs/database/schema-diagram.md` ERD đầy đủ + §14 ApprovalWorkflow V2 + §15 PE Level Opinions V2.
|
||||
Total: **91 bảng** dbo + `__EFMigrationsHistory` (last Mig 42 AddLeaveBalances). Xem `docs/database/schema-diagram.md` migration table + §11-15 module ERD (§16+ Mig 27-42 chi tiết pending).
|
||||
|
||||
## N-stage workflow pattern (Mig 18-20 — Session 12-13)
|
||||
|
||||
@ -77,7 +93,7 @@ Architecture decision đáng ghi cho session sau:
|
||||
|
||||
**Phase 8 update (2026-04-29 Session 5):**
|
||||
- Migration 15 `AddPurchaseEvaluationDepartmentOpinions` — 1 bảng riêng (UNIQUE PEId+Kind), max 4 row mỗi phiếu cho 4 phòng ban (Phê duyệt/Ccm/MuaHang/SmPm). UPDATE in-place khi user đổi ý, audit qua Changelog.
|
||||
- Tests Phase 1-2-3mini live + cumulative S22-S25 regression tests: `tests/SolutionErp.Domain.Tests/` (58 test policy state machine) + `tests/SolutionErp.Infrastructure.Tests/` (53 test = 17 codegen + 7 PE 2-stage + 7 PE N-stage + 6 PE WF + 5 AuthorizePolicy + 4 TraLai + 2 Plan M edge case + 1 V2 actor scope + 4 Approver F2/lookup regression). **Total 111 test pass / ~5s**. S22-S23 +20 cumulative regression: ReturnMode + DraftGuard + Reflection AuthorizePolicy + V2 actor scope reject + per-NV lookup discrimination (Plan N+O). Mig 21 drop 19 legacy (PE 2-stage S9 + PE N-stage S12 + Contract N-stage S13 + PE Reject S14) — flat workflow stabilized post-S22 V2 ground truth.
|
||||
- Tests: `tests/SolutionErp.Domain.Tests/` (58 test policy state machine) + `tests/SolutionErp.Infrastructure.Tests/` (96 test = codegen + 2-stage/N-stage + AuthorizePolicy + V2 actor scope + WorkflowApps ApproveV2 + LeaveBalance/guard). **Total 154 test pass** (current S43; S22-S25 baseline was 111). S22-S23 +20 cumulative regression: ReturnMode + DraftGuard + Reflection AuthorizePolicy + V2 actor scope reject + per-NV lookup discrimination (Plan N+O). Mig 21 drop 19 legacy (PE 2-stage S9 + PE N-stage S12 + Contract N-stage S13 + PE Reject S14) — flat workflow stabilized post-S22 V2 ground truth.
|
||||
- CI optimize 3 fix (29/04):
|
||||
- Manual checkout bypass github.com (gotcha #39) — fix TCP timeout 21s
|
||||
- Path filter docs-only skip (gotcha #41) — commit MD-only KHÔNG trigger CI
|
||||
@ -255,7 +271,7 @@ sqlcmd -S .\SQLEXPRESS -d SolutionErp -U vrapp -P <pw> -i migrate.sql
|
||||
|
||||
## Code pointers
|
||||
|
||||
- `src/Backend/SolutionErp.Infrastructure/Persistence/ApplicationDbContext.cs` — DbSet cho 59 bảng (31 migration)
|
||||
- `src/Backend/SolutionErp.Infrastructure/Persistence/ApplicationDbContext.cs` — DbSet cho 91 bảng (42 migration)
|
||||
- `src/Backend/SolutionErp.Infrastructure/Persistence/DesignTimeDbContextFactory.cs` — EF tooling factory
|
||||
- `src/Backend/SolutionErp.Infrastructure/Persistence/DbInitializer.cs` — seed + warn + migrate runtime + backfill (idempotent reconcile pattern)
|
||||
- `src/Backend/SolutionErp.Infrastructure/Persistence/Configurations/` — IEntityTypeConfiguration<T> per entity
|
||||
@ -264,5 +280,5 @@ sqlcmd -S .\SQLEXPRESS -d SolutionErp -U vrapp -P <pw> -i migrate.sql
|
||||
## Related
|
||||
|
||||
- `docs/database/database-guide.md` — conventions + migration workflow chi tiết
|
||||
- `docs/database/schema-diagram.md` — **ERD 59 bảng** + §11 PE module + §12 Budget module + §13 PEDeptOpinions (Mig 15) + §14 ApprovalWorkflow V2 (Mig 22-25) + §15 PE Level Opinions V2 (Mig 26)
|
||||
- `docs/database/schema-diagram.md` — **ERD 91 bảng** + §11 PE + §12 Budget + §13 PEDeptOpinions (Mig 15) + §14 ApprovalWorkflow V2 (Mig 22-25) + §15 PE Level Opinions V2 (Mig 26); §16+ Mig 27-42 detail pending (xem migration table)
|
||||
- `docs/gotchas.md` #7, #17, #38 — migration pitfalls + Identity 4-field rename
|
||||
|
||||
12
CLAUDE.md
12
CLAUDE.md
@ -50,7 +50,7 @@ Kiến trúc: **.NET 10 Clean Architecture + 2 React FE (admin + user) + SQL Ser
|
||||
- Audit fields: `CreatedAt`, `UpdatedAt`, `CreatedBy`, `UpdatedBy` (`BaseEntity`)
|
||||
- Soft delete: `IsDeleted`, `DeletedAt`, `DeletedBy` (`AuditableEntity`)
|
||||
- Migrations: `dotnet ef migrations add <Name> --project src/Backend/SolutionErp.Infrastructure --startup-project src/Backend/SolutionErp.Api`
|
||||
- **Hiện có 40 migration → 84 bảng** (Phase 10 COMPLETE — Mig 34-40 HRM/Office/WorkflowApps. V2 schema history S29-era bên dưới giữ nguyên — Mig 32+33 Plan B Contract V2 cookie-cutter mirror PE Mig 22-26 (S29). Mig 26 `AddPeLevelOpinionsForV2`: bảng mới `PurchaseEvaluationLevelOpinions` UNIQUE composite (PEId, LevelId), FK Cascade Pe + Restrict Level. Section 5 "Ý kiến cấp duyệt" V2 dynamic theo workflow đã pin: forEach Step (Phòng) → forEach Level (Cấp) → forEach NV → 1 OpinionBox. Service `ApproveV2Async` UPSERT auto khi NV duyệt — Q1=1B (sync gắn với Duyệt, KHÔNG form input rời). SignedByUserId track signer thật, FE banner "Admin duyệt thay" khi !== ApproverUserId. Comment empty → "(duyệt — không ý kiến)" placeholder. Phiếu V1 legacy fallback Mig 15 4 box readOnly (data history). Mig 25 `AddIsUserSelectableToApprovalWorkflows`: ALTER `ApprovalWorkflows` +`IsUserSelectable bit` (admin pin/unpin workflow nào cho user pick lúc create phiếu, multi-select độc lập IsActive). Backfill `WHERE IsActive=1 SET 1` giữ behavior cũ. Designer +badge "Cho user chọn" + button Ghim/Bỏ ghim. Workspace filter dropdown chỉ workflows `IsUserSelectable=true`. Mig 22-24 V2 schema (Session 17): `ApprovalWorkflows`/Steps/Levels — Quy trình > Bước (Phòng) > Cấp (N NV cụ thể qua ApproverUserId, OR-of-N cùng cấp). PE.ApprovalWorkflowId pin V2. PE.CurrentApprovalLevelOrder track. State machine 5 trạng thái: Nháp / Đã gửi duyệt / Trả lại (Phase riêng TraLai=98) / Từ chối / Đã duyệt. PE Service V2 wire match `actor.Id == ApproverUserId`. Contract V2 ĐÃ WIRE (Mig 32+33 Plan B S29 — cookie-cutter mirror PE V2: `ApproveV2Async` + `ContractLevelOpinions` UPSERT + Workspace V2 Select dropdown). Mig 21 V1 flat workflow vẫn live cho phiếu cũ.)
|
||||
- **Hiện có 42 migration → 91 bảng** (Phase 10 COMPLETE + Phase 11 P11-A/B — Mig 34-42 HRM/Office/WorkflowApps/Attendance + Contract V2 (32-33) + WireWorkflowApps V2 (41) + LeaveBalance (42). V2 schema history S29-era bên dưới giữ nguyên — Mig 32+33 Plan B Contract V2 cookie-cutter mirror PE Mig 22-26 (S29). Mig 26 `AddPeLevelOpinionsForV2`: bảng mới `PurchaseEvaluationLevelOpinions` UNIQUE composite (PEId, LevelId), FK Cascade Pe + Restrict Level. Section 5 "Ý kiến cấp duyệt" V2 dynamic theo workflow đã pin: forEach Step (Phòng) → forEach Level (Cấp) → forEach NV → 1 OpinionBox. Service `ApproveV2Async` UPSERT auto khi NV duyệt — Q1=1B (sync gắn với Duyệt, KHÔNG form input rời). SignedByUserId track signer thật, FE banner "Admin duyệt thay" khi !== ApproverUserId. Comment empty → "(duyệt — không ý kiến)" placeholder. Phiếu V1 legacy fallback Mig 15 4 box readOnly (data history). Mig 25 `AddIsUserSelectableToApprovalWorkflows`: ALTER `ApprovalWorkflows` +`IsUserSelectable bit` (admin pin/unpin workflow nào cho user pick lúc create phiếu, multi-select độc lập IsActive). Backfill `WHERE IsActive=1 SET 1` giữ behavior cũ. Designer +badge "Cho user chọn" + button Ghim/Bỏ ghim. Workspace filter dropdown chỉ workflows `IsUserSelectable=true`. Mig 22-24 V2 schema (Session 17): `ApprovalWorkflows`/Steps/Levels — Quy trình > Bước (Phòng) > Cấp (N NV cụ thể qua ApproverUserId, OR-of-N cùng cấp). PE.ApprovalWorkflowId pin V2. PE.CurrentApprovalLevelOrder track. State machine 5 trạng thái: Nháp / Đã gửi duyệt / Trả lại (Phase riêng TraLai=98) / Từ chối / Đã duyệt. PE Service V2 wire match `actor.Id == ApproverUserId`. Contract V2 ĐÃ WIRE (Mig 32+33 Plan B S29 — cookie-cutter mirror PE V2: `ApproveV2Async` + `ContractLevelOpinions` UPSERT + Workspace V2 Select dropdown). Mig 21 V1 flat workflow vẫn live cho phiếu cũ.)
|
||||
|
||||
### Modules
|
||||
|
||||
@ -63,7 +63,7 @@ Kiến trúc: **.NET 10 Clean Architecture + 2 React FE (admin + user) + SQL Ser
|
||||
| Identity (User/Role/Permission/MenuItem) | `Domain/Identity/` | 1, 3, 11 | Feature-complete (30 demo user — 16 sample + 14 Solutions thật) |
|
||||
| Forms (Template + Clause) | `Domain/Forms/` | 4 | Feature-complete |
|
||||
| Notifications | `Domain/Notifications/` | 6 | In-app + SignalR OK, email SMTP TODO |
|
||||
| **Tests** | `tests/SolutionErp.{Domain,Infrastructure}.Tests/` | — | **130 test pass** (58 Domain + 72 Infra) — CI gate + path filter docs-only skip |
|
||||
| **Tests** | `tests/SolutionErp.{Domain,Infrastructure}.Tests/` | — | **154 test pass** (58 Domain + 96 Infra) — CI gate + path filter docs-only skip |
|
||||
|
||||
### Commit convention
|
||||
|
||||
@ -78,13 +78,13 @@ Kiến trúc: **.NET 10 Clean Architecture + 2 React FE (admin + user) + SQL Ser
|
||||
```
|
||||
tests/
|
||||
├── SolutionErp.Domain.Tests/ (58 test — Domain policy: Workflow / PE / Budget)
|
||||
└── SolutionErp.Infrastructure.Tests/ (72 test)
|
||||
└── SolutionErp.Infrastructure.Tests/ (96 test)
|
||||
├── Common/ (SqliteDbFixture + TestApplicationDbContext + IdentityFixture S9)
|
||||
├── Services/ (17 codegen + 6 PE 2-stage approval S9)
|
||||
└── Application/ (6 test - PeWorkflowDefinition versioning)
|
||||
```
|
||||
|
||||
**130 unit test pass** / ~15s (58 Domain + 72 Infra). CI gate + path filter live. (Coverage gap S35-S38: HrmConfig Holiday UNIQUE + EmployeeSatellite cascade + gotcha #44 regression — backlog `docs/STATUS.md`.)
|
||||
**154 unit test pass** (58 Domain + 96 Infra). CI gate + path filter live. (Coverage gap S35-S38: HrmConfig Holiday UNIQUE + EmployeeSatellite cascade + gotcha #44 regression — backlog `docs/STATUS.md`.)
|
||||
|
||||
```bash
|
||||
dotnet test SolutionErp.slnx # chạy cả 2 test project
|
||||
@ -128,9 +128,9 @@ Quy tắc:
|
||||
| [`docs/workflow-contract.md`](docs/workflow-contract.md) | State machine 9 phase HĐ + role matrix |
|
||||
| [`docs/forms-spec.md`](docs/forms-spec.md) | Catalog 8 form + quy định mã HĐ RG-001 |
|
||||
| [`docs/database/database-guide.md`](docs/database/database-guide.md) | DB conventions + migration workflow + cheatsheet |
|
||||
| [`docs/database/schema-diagram.md`](docs/database/schema-diagram.md) | ⭐ ERD + luồng DB + data flow 60 table (+ §11 PE module + §12 Budget module + §13 PEDeptOpinions + §14 Contract V2 LevelOpinions) |
|
||||
| [`docs/database/schema-diagram.md`](docs/database/schema-diagram.md) | ⭐ ERD + luồng DB + data flow 91 table (+ §11 PE module + §12 Budget module + §13 PEDeptOpinions + §14 Contract V2 LevelOpinions) |
|
||||
| [`docs/flows/README.md`](docs/flows/README.md) | Index 6 flow (auth, permission, contract, form, SLA) |
|
||||
| [`docs/gotchas.md`](docs/gotchas.md) | ⭐ 52 bẫy đã gặp — đọc trước khi debug tương tự |
|
||||
| [`docs/gotchas.md`](docs/gotchas.md) | ⭐ 56 bẫy đã gặp — đọc trước khi debug tương tự |
|
||||
| [`.claude/skills/`](.claude/skills/README.md) | 6 skill: contract-workflow, form-engine, permission-matrix, dependency-audit-erp, ef-core-migration, iis-deploy-runbook |
|
||||
| [`docs/guides/vps-setup.md`](docs/guides/vps-setup.md) | ⭐ Master runbook deploy VPS shared với VIETREPORT |
|
||||
|
||||
|
||||
@ -62,12 +62,12 @@ SOLUTION_ERP/
|
||||
│ ├── PROJECT-MAP.md bản đồ tổng quan
|
||||
│ ├── rules.md coding conventions
|
||||
│ ├── architecture.md layered + PE §9 + Budget §10 + Testing §11
|
||||
│ ├── gotchas.md 52 pitfall đã gặp
|
||||
│ ├── gotchas.md 56 pitfall đã gặp
|
||||
│ ├── forms-spec.md 8 form catalog + RG-001
|
||||
│ ├── workflow-contract.md 9 phase HĐ + role matrix
|
||||
│ ├── database/
|
||||
│ │ ├── database-guide.md conventions + migration workflow
|
||||
│ │ └── schema-diagram.md ERD 55 bảng (+§11 PE +§12 Budget +§13 PEDeptOpinions +§14 DepartmentApprovals Mig 16)
|
||||
│ │ └── schema-diagram.md ERD 91 bảng (+§11 PE +§12 Budget +§13 PEDeptOpinions +§14 Contract V2 LevelOpinions; §16+ Mig 27-42 pending)
|
||||
│ ├── flows/ 6 sequence diagram (auth/permission/contract/form/sla + PE ref architecture)
|
||||
│ ├── guides/ setup, cicd, deploy, runbook, security
|
||||
│ ├── changelog/
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
> **Update rule:** trước khi bắt đầu 1 task → ghi row `🔥 In Progress`. Xong → `✅ Recently Done`.
|
||||
> **Tiering rule (S40):** chỉ giữ **state hiện tại + 3 session gần nhất** ở file này. Session cũ hơn → `docs/changelog/sessions/`. Full history pre-S40 → `docs/_archive/STATUS-preS40-fullhistory.md`. (Tránh over-context — xóa double, không cắt nội dung.)
|
||||
|
||||
**Last updated:** 2026-05-30 (Session 42 — **Phase 11 P11-A SHIPPED**: wire ApproveV2 + LevelOpinions cho 4 WorkflowApps module (Leave/OT/Travel/Vehicle). Mig 41 + 30 handler + 8 route + FE detail ×2 + 11 test. Run #250 PASS, deployed prod.)
|
||||
**Last updated:** 2026-06-01 (Session 44 — **Monthly drift audit + AI_INFRA bundle 06-01 adoption**: 42 doc/skill count-drift fixes (40→42 mig · 84→91 tables · 130→154 test · 52→56 gotcha across CLAUDE/skills/schema-diagram/database-guide) + agent-mem "25KB"→"~30KB tiered" wording ×7 + /session-end #4 adoption-report step. Docs-only, CI-skip. Prev: S42 P11-A Gitea #364/#365, S43 P11-B #367.)
|
||||
|
||||
---
|
||||
|
||||
@ -44,6 +44,12 @@
|
||||
|
||||
## ✅ Recently Done (newest on top — 3 session; cũ hơn → session logs)
|
||||
|
||||
### S44 (2026-06-01) — 🗓️ Monthly drift audit + AI_INFRA bundle 06-01 adoption (docs-only, CI-skip)
|
||||
- **Cadence audit** (cron 2026-06-01) + adopt AI_INFRA bundle 06-01 (federated, team chọn full scope). 🟦 investigator-codebase drift scan (read-only, ground-truth verified) → 👤 em main patch. No code touched → **154 test PASS unchanged**.
|
||||
- **42 count-drift fixes:** CLAUDE.md root + docs/CLAUDE.md + `ef-core-migration` SKILL + `dependency-audit-erp` SKILL + schema-diagram + database-guide — `40→42 mig · 84/59/55/47→91 tables · 130/111→154 test · 52/49→56 gotcha`.
|
||||
- **Schema-diagram:** migration table extended Mig 17-42 (was stop ở 16) + total 55→91; detailed-§ gap (Mig 27-42 modules) flagged **explicit** (không silent → deferred backlog). `ef-core` SKILL migration history extended Mig 27-42.
|
||||
- **AI_INFRA bundle:** §A RAG T1/T2 auto-ack · §B Gov-v2 align (no new layer) · §C hygiene **7/7 agent-mem L1 ≤16KB**, "25KB"→"~30KB tiered" wording ×7 · §D `#4` self-sustaining adoption-report step → `/session-end` (skip #1 đã có / #3 helper) · §E report + §F ledger `docs/governance/`.
|
||||
|
||||
### S43 (2026-05-30) — 🔄 Phase 11 P11-B: LeaveBalance business logic (trừ phép + số dư)
|
||||
- **Commit `82d7fcf` → Gitea #367 PASS ~4m08s, deployed prod.** 7-agent (recon → BE → FE ∥ test → reviewer → cicd), agents Max → **0 bug lọt**.
|
||||
- **Mig 42 `AddLeaveBalances`** (additive): `LeaveBalances` (User×LeaveType×Year + Entitled/Used/Adjustment, UNIQUE composite + FK LeaveTypes Restrict). 90→91 tables.
|
||||
@ -94,10 +100,9 @@
|
||||
- **P11-C** Vehicle+Driver catalog Mig 43 · **P11-D** ItTicket auto-assign + SLA timer · **P11-E** AttendanceReport + Excel + OtPolicy multiplier · **P11-F** CodeGen atomic MaTicket (MaDonTu xong S42)
|
||||
|
||||
### 🔧 Maintenance backlog
|
||||
- Curate 4 agent MEMORY >25KB: investigator-codebase 35.7 / cicd-monitor 35.3 / implementer-backend 30.9 / reviewer 28.4
|
||||
- RAG re-ingest `solution_erp` S37-S39 content (Proposal/WorkflowApps/7-agent)
|
||||
- RAG re-ingest `solution_erp` S42-S43 content (store_memory stopgap live; full re-index = AI_INFRA op)
|
||||
- Test coverage gaps: **Gap1** HrmConfig Holiday composite UNIQUE (🔴 CRITICAL) · **Gap2** EmployeeSatellite cascade · **Gap3** gotcha #44 regression `EmployeesController`+`HrmConfigsController`
|
||||
- Skill + doc drift audit cron **2026-06-01**
|
||||
- Skill + doc drift audit cron — ✅ **2026-06-01 DONE (S44)** — 42 count-drift fixes + AI_INFRA bundle adopt; next **2026-07-01**
|
||||
|
||||
### 🚫 Phase 9 Ops (blocked — anh main coordinate)
|
||||
- SMTP email outbound · Rotate prod creds · SQL auto-backup (backup-sql.ps1 ready, chờ Task Scheduler register) · UAT 2-3 user 1 tuần
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
# Database Guide — SOLUTION_ERP
|
||||
|
||||
> **DB engine:** SQL Server 2022 (LocalDB dev, full instance prod)
|
||||
> **ORM:** EF Core 10 Code-First migrations — **47 bảng, 13 migration** (Init → AddPurchaseEvaluationCodeSequences)
|
||||
> **ORM:** EF Core 10 Code-First migrations — **91 bảng, 42 migration** (Init → AddLeaveBalances)
|
||||
> **DbContext:** [`ApplicationDbContext`](../../src/Backend/SolutionErp.Infrastructure/Persistence/ApplicationDbContext.cs) extends `IdentityDbContext<User, Role, Guid>`
|
||||
> **Current schema + ERD:** xem [`schema-diagram.md`](schema-diagram.md) (luôn cập nhật)
|
||||
>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# Schema Diagram — Luồng DB SOLUTION_ERP
|
||||
|
||||
> ERD đầy đủ + mối quan hệ **36 table** sau Migration 11 (Tier 3 + 4-bảng overhaul + 4 master catalogs + Role/User VN). Mermaid render ở VS Code / GitHub / Gitea.
|
||||
> ERD core mermaid dưới = **36 table** (Migration 11 — Tier 3 + 4-bảng overhaul + 4 master catalogs + Role/User VN). Module mở rộng Mig 12-42 → migration table §7 + section §11-15. **Tổng schema hiện tại: 91 table (Mig 42, 2026-05-30).** Mermaid render ở VS Code / GitHub / Gitea.
|
||||
|
||||
## 1. Full ERD
|
||||
|
||||
@ -485,8 +485,36 @@ COMMIT;
|
||||
| **14** | **`AddBudgets`** | **4 bảng module Ngân sách: Budgets + BudgetDetails + BudgetApprovals + BudgetChangelogs. + nullable FK index Contract.BudgetId & PurchaseEvaluation.BudgetId** |
|
||||
| **15** | **`AddPurchaseEvaluationDepartmentOpinions`** | **1 bảng `PurchaseEvaluationDepartmentOpinions` (UNIQUE PEId+Kind, max 1 row mỗi loại phòng ban per phiếu — UPDATE in-place, audit qua Changelog)** |
|
||||
| **16** | **`AddTwoStageDeptApprovalAndSmartReject`** | **3 bảng `Contract/PurchaseEvaluation/Budget DepartmentApprovals` (UNIQUE TargetId+Phase+Dept+Stage cho 2-stage NV/TPB approval per phòng × phase) + 4 ALTER (`Users.CanBypassReview` bit + 3 `RejectedFromPhase` int cho smart reject quay về Drafter + jump-back phase đã reject)** |
|
||||
| **17** | **`AddManualBudgetFieldsToPeAndContract`** | **4 ALTER (PE + HĐ × `BudgetManualName` + `BudgetManualAmount`) — manual budget fallback. Không bảng mới.** |
|
||||
| **18** | **`AddPeWorkflowInnerStepsAndPositionLevel`** | **N-stage PE — 1 bảng `PurchaseEvaluationWorkflowStepInnerSteps` + 2 ALTER (`Users.PositionLevel` + `PEDeptApproval.InnerStepId`). (Mig 21 drop sau.)** |
|
||||
| **19** | **`AlterPeDeptApprovalsUniqueFilteredForInnerSteps`** | **Filtered unique split legacy/N-stage. Không bảng mới.** |
|
||||
| **20** | **`AddContractWorkflowInnerStepsAndAlterDeptApprovalUnique`** | **N-stage Contract mirror — 1 bảng `WorkflowStepInnerSteps` + ALTER. (Mig 21 drop sau.)** |
|
||||
| **21** | **`RefactorWorkflowToFlatModel`** | **🎯 DRASTIC: bỏ phase enum legacy → ChoDuyet=10 flat. DROP TABLE × 2 (InnerSteps PE+Contract) + ALTER tracking.** |
|
||||
| **22** | **`AddApprovalWorkflowsV2`** | **🎯 V2 schema — 3 bảng `ApprovalWorkflows` + `ApprovalWorkflowSteps` + `ApprovalWorkflowLevels` + enum ApplicableType. Quy trình > Bước (Phòng) > Cấp (NV).** |
|
||||
| **23** | **`AddApprovalWorkflowIdToPurchaseEvaluation`** | **Pin V2 vào PE — `PE.ApprovalWorkflowId`. Không bảng mới.** |
|
||||
| **24** | **`AddCurrentApprovalLevelOrderToPe`** | **Service V2 wire — `PE.CurrentApprovalLevelOrder`. Không bảng mới.** |
|
||||
| **25** | **`AddIsUserSelectableToApprovalWorkflows`** | **ALTER `ApprovalWorkflows` +`IsUserSelectable bit`. Không bảng mới.** |
|
||||
| **26** | **`AddPeLevelOpinionsForV2`** | **1 bảng `PurchaseEvaluationLevelOpinions` (UNIQUE PEId+LevelId, FK Cascade Pe + Restrict Level). Section 5 V2 dynamic.** |
|
||||
| **27** | **`AddVisibilityAndDisplayLabelToMenuItems`** | **2 ALTER `MenuItems` (+IsVisible +DisplayLabel) — admin ẩn/hiện + đổi tên menu eOffice. Không bảng mới.** |
|
||||
| **28** | **`AddAdvancedOptionsToApprovalWorkflows`** | **ALTER `ApprovalWorkflows` advanced options. Không bảng mới.** |
|
||||
| **29** | **`RefactorAdvancedOptionsToPerLevelAndDrafterUser`** | **Refactor advanced options → per-Level + DrafterUser. Không bảng mới.** |
|
||||
| **30** | **`AddAllowApproverEditBudgetToLevels`** | **ALTER `ApprovalWorkflowLevels` +`AllowApproverEditBudget`. Không bảng mới.** |
|
||||
| **31** | **`RefactorSkipToFinalToApproverLevel`** | **Per-Approver-slot skip-to-final. Không bảng mới.** |
|
||||
| **32** | **`AddApprovalWorkflowToContract`** | **🎯 Contract V2 wire (Plan B) — 2 ALTER `Contracts` (+ApprovalWorkflowId +CurrentApprovalLevelOrder) mirror PE Mig 23-24. Không bảng mới.** |
|
||||
| **33** | **`AddContractLevelOpinions`** | **1 bảng `ContractLevelOpinions` (UNIQUE ContractId+LevelId, mirror PE Mig 26). Section "Ý kiến cấp duyệt" V2.** |
|
||||
| **34** | **`AddEmployeeProfiles`** | **HRM core — `EmployeeProfiles` + satellite tables (N-satellite per parent).** |
|
||||
| **35** | **`AddHrmConfigs`** | **HRM config catalogs (LeaveTypes / Holidays UNIQUE composite / ...).** |
|
||||
| **36** | **`AddMeetingRooms`** | **Office — `MeetingRooms` + booking.** |
|
||||
| **37** | **`ExtendApplicableTypeForWorkflowApps`** | **Enum extend `ApplicableType` (+Proposal +WorkflowApps). Không bảng mới.** |
|
||||
| **38** | **`AddProposals`** | **Module Đề xuất (Proposal) — tables + workflow V2 mirror PE/Contract.** |
|
||||
| **39** | **`AddWorkflowApps`** | **Workflow Apps skeleton — Leave/OT/Travel/Vehicle/Ticket request tables.** |
|
||||
| **40** | **`AddAttendances`** | **Chấm công (Attendance) tables + Dashboard NS skeleton.** |
|
||||
| **41** | **`WireWorkflowAppsApprovalV2`** | **🎯 P11-A — 4 `{Leave,Ot,Travel,Vehicle}LevelOpinions` + `WorkflowAppCodeSequences` + 4 ALTER RejectedFromStatus + enum TravelRequest=9.** |
|
||||
| **42** | **`AddLeaveBalances`** | **🎯 P11-B — 1 bảng `LeaveBalances` (User×LeaveType×Year, UNIQUE composite + FK LeaveTypes Restrict). Trừ phép tự động khi đơn nghỉ duyệt cuối.** |
|
||||
|
||||
Tổng: **55 bảng** (+ `__EFMigrationsHistory` hệ thống).
|
||||
Tổng: **91 bảng** (Mig 42, + `__EFMigrationsHistory` hệ thống).
|
||||
|
||||
> ⚠️ **ERD chi tiết §11-15 cover Mig 12-26.** Mig 16-21 + 27-42 (DepartmentApprovals, flat-refactor, Contract V2, HRM/Office/Proposal/WorkflowApps/Attendance/LeaveBalance) — migration index ở bảng trên + skill `ef-core-migration`; schema field chi tiết xem entity `Configurations/` + session logs. Full per-table ERD sections cho module mới = **deferred backlog** (không silent — xem STATUS Maintenance backlog).
|
||||
|
||||
## 8bis. Bảng mới sau Migration 9-11
|
||||
|
||||
|
||||
50
docs/governance/BROADCAST-OUT-SOLUTION-ERP-2026-06-01.md
Normal file
50
docs/governance/BROADCAST-OUT-SOLUTION-ERP-2026-06-01.md
Normal file
@ -0,0 +1,50 @@
|
||||
# ✅ [SOLUTION_ERP → AI_INFRA] Adoption report — 2026-06-01
|
||||
|
||||
> Response to AI_INFRA bundle **"Framework + session-cmd BUNDLE — 2026-06-01 (fast-path, autonomy-first)"**.
|
||||
> Federated model: team self-decided **full scope** (coincides with monthly drift-audit cadence date). Docs-only → CI-skip (gotcha #41).
|
||||
|
||||
---
|
||||
|
||||
## NẤC: VERIFIED-self · executed · evidence committed
|
||||
|
||||
**SERVER-VERIFIABLE** (Gitea `git.baocaogiaoduc.vn/vietreport-admin/solution-erp`): commit sha relayed in session S44 chat + `git log` (origin synced, tree clean for audit files; carry-over `.mcp.json` + `BROADCAST-...-05-29.md` left untouched per concurrency rule).
|
||||
|
||||
| § | Item | Decision | Evidence |
|
||||
|---|---|---|---|
|
||||
| **A — RAG** | T1 store_memory survives re-bootstrap · T2 uuid5 idempotent | ✅ **auto-ack** | No SE action. De-risks SE's S42-S43 `(manual)` store_memory stopgap chunks (future re-index won't wipe). Verified retrievable in-session (rerank 0.855). |
|
||||
| **B — Gov-v2** | Memory-Governance v2 principles | ✅ **adopt-by-alignment (no new layer)** | `archive≠memory`+`single-source` already = SE tiering rule (S40); `surface-the-need`+`measure` = this report + re-grounded counts. `CANONICAL-pull = trust` (did not pull full doc). |
|
||||
| **C — Hygiene** | L1 ≤30KB / L2 / L3 tiered | ✅ **adopted; wording refreshed** | **7/7 agent-mem L1 ≤16KB · bloat>50KB = 0** (measured bytes). Refreshed stale "25KB" → "~30KB tiered (L1/L2/L3)" in 7 `MEMORY.md` (header line 3 + curate-rule line, ×7). Archive/ historical refs left (archive≠memory). |
|
||||
| **D — Session-cmd** | 3 KHUNG + #4 report-step | ✅ **#4 added · skip #1/#3 · #2 noted** | `#1` echo-body = already present both commands (skip). `#3` helper tier = skip (7-agent topology + investigator-codebase/api cover it; 0/6 sisters use helpers). `#4` self-sustaining adoption-report step **ADDED** to `/session-end` Phase 6.3. `#2` dep/critical-path = REPORT already detailed; deferred as marginal. |
|
||||
| **E — Report** | this doc | ✅ | §E format followed. |
|
||||
| **F — Mirror** | ledger committed | ✅ | `docs/governance/README.md` § Cross-Project Adoption Ledger (this file linked). |
|
||||
|
||||
Caveat by-design: L2 `archive/` gitignored · CANONICAL-pull = trust.
|
||||
|
||||
---
|
||||
|
||||
## Bundled this session: monthly drift audit (cadence 2026-06-01)
|
||||
|
||||
🟦 investigator-codebase drift scan (read-only, ground-truth from disk: counted migration files + gotcha #N) → 👤 em main patch. **No production code touched → 154 test PASS unchanged.**
|
||||
|
||||
**Ground truth verified:** migrations **42** (last `AddLeaveBalances`) · gotchas **#56** · tests **154** (58 Domain + 96 Infra) · tables **91**.
|
||||
|
||||
**42 count-drift fixes** (stale → correct):
|
||||
- `CLAUDE.md` (root): `40→42 mig · 84→91 tables · 130→154 test (72→96 Infra) · 52→56 gotcha · 60→91 table`
|
||||
- `docs/CLAUDE.md`: `52→56 pitfall · ERD 55→91 bảng`
|
||||
- `.claude/skills/ef-core-migration/SKILL.md`: frontmatter `31→42 mig` · history table extended **Mig 27-42** · `59→91 bảng · 111→154 test · 31→42 mig` (code pointers + Related)
|
||||
- `.claude/skills/dependency-audit-erp/SKILL.md`: `49→56 bẫy`
|
||||
- `docs/database/schema-diagram.md`: intro `36 table` clarified (core ERD Mig 11 vs total 91) · migration table extended **Mig 17-42** · total `55→91` · **detailed-§ gap (Mig 27-42 modules) flagged explicit** (không silent → deferred backlog)
|
||||
- `docs/database/database-guide.md`: `47→91 bảng · 13→42 mig`
|
||||
- `docs/STATUS.md`: removed stale "curate >25KB" backlog line (now all ≤16KB) · refreshed RAG backlog (S42-S43) · cron marked DONE (next 2026-07-01)
|
||||
|
||||
**Deferred (not silent — recorded in STATUS backlog):** full per-table ERD § sections for Mig 27-42 modules (HRM/Office/Proposal/WorkflowApps/Attendance/LeaveBalance) — migration index now complete; field-level ERD = a future doc task.
|
||||
|
||||
---
|
||||
|
||||
## FYI raised back to AI_INFRA (infra-owned, non-blocking)
|
||||
|
||||
1. **Governance README + eval baseline still reference old corpus `11,922`** (pre-S41 inflated). SE updated README prose → `~2,409` (post-S41 cleanup) + marked Anti #23/#24 resolved. **`eval/trial-state-lock.json` + `eval/runs/*baseline*` baseline numbers = AI_INFRA's to reconcile** (SE won't touch eval harness — charter v2).
|
||||
2. **RAG `last_indexed` = 2026-05-29** → S42-S43 not file-indexed (store_memory stopgap live + verified retrievable). Full re-index = AI_INFRA op (VOYAGE_API_KEY). No drift >20%, non-urgent.
|
||||
3. **No infra currently blocking product** — RAG noise = 0 after S41 cleanup, agents fire correctly per decision tree.
|
||||
|
||||
→ ✅ **SOLUTION_ERP adopted + evidence committed.** Team self-decided full scope, no push-back. Confirm: em main `/session-start` next session watches for #4 cadence (2-way loop live).
|
||||
@ -48,7 +48,7 @@ SOLUTION_ERP adopts RAG Framework v1.3 via **Path B delegation stub** — deferr
|
||||
|
||||
### Anatomy gate threshold
|
||||
|
||||
**6/6 STRICT** per v1.3 §5.2 default — corpus 11,922 chunks mature enough.
|
||||
**6/6 STRICT** per v1.3 §5.2 default — corpus **~2,409 chunks** (post-S41 cleanup 2026-05-29; was 11,922 pre-cleanup inflated) mature enough.
|
||||
|
||||
### Spec A vs B
|
||||
|
||||
@ -73,9 +73,20 @@ SOLUTION_ERP adopts RAG Framework v1.3 via **Path B delegation stub** — deferr
|
||||
|
||||
## Anti-pattern watch (SOLUTION_ERP-specific)
|
||||
|
||||
- **Anti #23 source_path absolute path leak** — chunks contain `D:\Dropbox\...` Windows absolute path. Noted — fix in next re-bootstrap run.
|
||||
- **Anti #24 registry drift +321%** — `projects.json` says 2830, Qdrant LIVE 11,922. Intentional defer — document in trial-lock `_baseline_note`. Re-bootstrap align khi Phase 9 UAT ổn định.
|
||||
- **Anti #23 source_path absolute path leak** — ✅ resolved S41 re-bootstrap (2026-05-29): node_modules/_archive excluded, slug fixed. Some `(manual)` store_memory chunks retain absolute path (cosmetic, non-blocking).
|
||||
- **Anti #24 registry drift +321%** — ✅ resolved S41: re-bootstrap host-side `--config` → Qdrant **2,406** (−674 junk), registry aligned. (Was: projects.json 2830 / Qdrant LIVE 11,922 inflated.) ⚠️ `eval/trial-state-lock.json` baseline still cites old number → AI_INFRA to reconcile.
|
||||
|
||||
---
|
||||
|
||||
**Tags:** solution-erp delegation-stub rag-v1.3 path-b spec-a anatomy-gate-6-6
|
||||
## Cross-Project Adoption Ledger (AI_INFRA bundles)
|
||||
|
||||
| Bundle date | Adopted | Evidence |
|
||||
|---|---|---|
|
||||
| **2026-05-29** (charter v2 / tiered-mem / session-cmd / RAG v1.3) | 4/4 | `6f08d1f` (Tiered Memory v1) + `c8ff5e1` (/session-start /session-end) · RAG re-bootstrap 3080→2406 |
|
||||
| **2026-06-01** (RAG T1/T2 · Gov-v2 · hygiene · session-cmd #4) | §A auto · §B align · §C wording ×7 · §D #4 step · §E/§F | S44 audit (docs-only) — [`BROADCAST-OUT-SOLUTION-ERP-2026-06-01.md`](BROADCAST-OUT-SOLUTION-ERP-2026-06-01.md) |
|
||||
|
||||
**Cadence #4 (self-sustaining):** `/session-end` Phase 6.3 auto-generates §E adoption-report when infra adopted → em main `/session-start` next watches + double-checks (2-way loop).
|
||||
|
||||
---
|
||||
|
||||
**Tags:** solution-erp delegation-stub rag-v1.3 path-b spec-a anatomy-gate-6-6 adoption-ledger
|
||||
|
||||
Reference in New Issue
Block a user