[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:
pqhuy1987
2026-06-01 12:39:56 +07:00
parent 197c72f352
commit ae30f8f5e2
17 changed files with 160 additions and 42 deletions

View File

@ -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/

View File

@ -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 5591; 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 đã / #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). 9091 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

View File

@ -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)
>

View File

@ -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

View 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).

View File

@ -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