Commit Graph

376 Commits

Author SHA1 Message Date
61e9ce5b3b [CLAUDE] Domain+App+Api+Tests+FE-Admin+FE-User: S34 Plan 3 Phase 1.5 batch 4 item
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 3m48s
Phase 1.5 backlog G-H1 EmployeeProfile hardening batch (Items 6+2+1+4 of 6).

Item 6 — menuKeys FE drift sync × 2 app:
- fe-admin add: Catalogs + 4 Catalog leaves + Workflows + Budgets + Bg_List/Create/Pending (10 key)
- fe-user add: Budgets + Bg_List/Create/Pending + ApprovalWorkflowsV2 + 2 AwV2 leaf + MenuVisibility + Workflows (8 key)
- Cả 2 file giờ identical mirror BE MenuKeys.cs (28 key cumulative)

Item 2 — UpdateEmployeeProfileCommand bool→bool? safe partial update:
- 3 field IsCommunistParty/IsYouthUnion/IsTradeUnion → bool?
- Handler: HasValue check, null = giữ giá trị cũ (Reviewer minor #(b) S33 fixed)
- FE không bắt buộc gửi 3 field every PUT — tránh accidental reset

Item 1 — EmployeesController per-action policy (gotcha #44 mitigation):
- Class-level [Authorize(Policy = "Hrm_HoSo.Read")] — non-admin thiếu Read → 403
- POST [Authorize(Policy = "Hrm_HoSo.Create")]
- PUT  [Authorize(Policy = "Hrm_HoSo.Update")]
- DELETE [Authorize(Policy = "Hrm_HoSo.Delete")]

Item 4 — Test bundle Phase 1.5 (+10 [Fact], baseline 120 → 130/130 PASS):
- EmployeeCodeGeneratorTests (3 [Fact]) — atomic SERIALIZABLE NV/YYYY/NNNN
  + first call + sequential increment + year boundary preserve old year
- CreateEmployeeProfileCommandTests (4 [Fact]) — Create handler edge case
  + first profile + duplicate UserId Conflict + soft-deleted Conflict-restore
  + UserNotFound NotFoundException
- ListEmployeesQueryTests (3 [Fact]) — filter + paging logic
  + status filter + departmentId filter + search by EmployeeCode partial

Implementer Case 3 test gen caught spec mismatch (allow new after soft-delete
vs throws Conflict-restore) — chose CODE source of truth + renamed test
documenting discriminator message branch. Em main verify behavior correct
(admin UX khôi phục thay vì tạo mới — explicit flow defer Phase 1.5+).

Verify:
- dotnet build PASS (2 warn DocxRenderer baseline, 0 error)
- dotnet test 130/130 PASS (58 Domain + 72 Infra = +10)
- 4 endpoint /api/employees policy wired (gotcha #44 active mitigation)
- 4 MEMORY agent updated post-spawn (CICD Run #238 + Implementer test bundle)

Deferred Phase 1.5 next batch:
- Item 3 Satellite CRUD endpoints (WorkHistory/Education/FamilyRelation/Skill/
  Document) + FE inline edit forms — heavy ~2-3h
- Item 5 UAT smoke non-admin role verify silent 403 catch — defer post-deploy

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-27 13:57:08 +07:00
ea440da990 [CLAUDE] Domain+App+Api+Infra+FE-Admin+FE-User: S34 Plan 2 G-O1 Danh bạ nội bộ
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 3m46s
Phase 10.2 Văn phòng số — Internal Directory (1 endpoint reuse Users +
EmployeeProfiles + Departments, FE card grid avatar/dept/email/phone/Ext).

BE Task 1+2 (em main solo):
- Application/Office/DirectoryFeatures.cs — GetDirectoryQuery + DirectoryItemDto
  12 field LEFT JOIN Users.IsActive + Departments + EmployeeProfiles
- Api/Controllers/DirectoryController.cs — GET /api/directory?search=&departmentId=
  class-level [Authorize] (mọi authenticated NV tra cứu danh bạ nội bộ)
- MenuKeys.cs +Off+OffDanhBa const + All[] update
- DbInitializer.SeedMenuTreeAsync Off Order=29 + OffDanhBa Order=1 dưới Off

FE Task 3 (Implementer Case 2 Pattern 16-bis 4-place mirror cross-app — 5×):
- types/directory.ts SHA256 7349d9f64e78 × 2 app IDENTICAL
- pages/office/InternalDirectoryPage.tsx SHA256 2aa7e0eed2c8 × 2 app IDENTICAL
  Card grid responsive 1/2/3/4 col + filter dept dropdown + search input
  Avatar 14×14 initials gradient PALETTE 6 màu (Pattern 14 Tailwind JIT)
  EmployeeCode badge + Department emerald badge + email mailto + phone tel
  Internal phone Ext: amber badge + empty/loading state Vietnamese 100%
- App.tsx route /directory × 2 app
- lib/menuKeys.ts Off+OffDanhBa const × 2 app
- components/Layout.tsx resolvePath staticMap Off_DanhBa:/directory × 2 app
  (gotcha #50 — 5 places mirror crossapp DON'T MISS)

Verify:
- dotnet build PASS (2 warn DocxRenderer existing, 0 error)
- dotnet test 120/120 PASS (58 Domain + 62 Infra baseline preserve)
- npm build × 2 app PASS 0 TS err (fe-admin 1436KB / fe-user 1350KB)

Implementer MEMORY Pattern 16-bis reinforced 5× cumulative (S29 Plan CA HF1 +
S29 Plan B Chunk D + S33 Plan B G-H1 Task 5 + S34 Plan G-O1 Task 3).

Endpoint smoke pending CICD post-deploy Stage 4 (Run #XXX expected ~3m30s).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-27 13:39:10 +07:00
7b0781b94e [CLAUDE] Docs: S34 Plan 1 — Curate 4 sub-agent MEMORY 118KB→101KB (-15%)
Em main proxy curate sequence 1/4 post-S33 wrap. Archive verbose Recent
activity/runs entries cumulative S25-S28-S29 sang archive/2026-05-q2.md
(Reviewer) + archive/2026-05-q3.md (3 agent khác) — KHÔNG động vào
Patterns/Foundation sections.

Sizes delta:
- CICD: 32.9KB → 27.3KB (Run #215+#216 + S22 verify + S27/S28 governance archived)
- Implementer: 30.5KB → 24.6KB (S29/S28/S27 wrap + 2026-05-22 curate + setup archived)
- Reviewer: 28.5KB → 25.1KB (S26/S25/S28 + S29 Plan B pre-push archived)
- Investigator: 26KB → 21.8KB (S28/S27 retrospective + S25 + setup archived)

Foundation PRESERVED 100%:
- Smart Friend 6× cumulative guard (Reviewer)
- 10-surface-point per-NV checklist + gotcha #39-#48 detail (CICD)
- Patterns 1-15 + 12-bis + 16-bis (Implementer)
- Active workflow schemas V1+V2 + smoke verify patterns (Investigator)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-27 13:24:12 +07:00
edba4ae147 [CLAUDE] Docs+Memory: S33 wrap — Plan B G-H1 + Plan C B-Wrap deploy prod end-to-end
S33 cumulative wrap update STATUS + HANDOFF + migration-todos tick G-H1
7 task done + session log + CICD MEMORY post-Run #237 entry.

## Updates

- docs/STATUS.md: prepend S33 entry (Plan B + C + D drift patch + multi-agent
  ROI ~250K total + 8 patterns reinforced + new capability UAT-ready)
- docs/HANDOFF.md: prepend S33 wrap + S34 handover recommend sequence (curate
  4 MEMORY → G-O1 Danh bạ → G-H2 HrmConfig)
- docs/changelog/migration-todos.md: tick [x] G-H1 7 task + stats final S33
  + Phase 1.5 backlog
- docs/changelog/sessions/2026-05-26-2030-s33-plan-bc-deploy.md: NEW session
  log full (~250 line: outcomes + plan execution table + multi-agent ROI +
  8 patterns + defer Phase 1.5/S34+ + commits range + UAT capability)
- .claude/agent-memory/cicd-monitor/MEMORY.md: post-Run #237 entry append
  (truncated from S33 startup curate 24.2KB → 32.9KB, curate priority next
  session)

## Stats final S33

| Metric | Pre-S33 | Post-S33 | Δ |
|--------|---:|---:|---:|
| Migrations | 33 | 34 | +1 (Mig 34 AddEmployeeProfiles) |
| Tables | 60 | 67 | +7 (EmployeeProfile + 5 satellite + Sequence) |
| Endpoints | ~148 | ~153 | +5 (/api/employees REST) |
| FE pages | 38 | 40 | +2 (EmployeesListPage + EmployeeCreatePage × 2 app) |
| Menu keys | ~60 | ~62 | +2 (Hrm + HrmHoSo) |
| Tests | 111 | 120 | +9 (BW1-BW7 Plan C, BW6 split 3) |
| Gotchas | 52 | 52 | 0 new (2 existing lesson applied: #50 + #51) |
| Memory user-level | 26 | 26 | 0 new (decision: no rule warrant new entry, all patterns reinforce existing) |
| AppRoles | 14 | 14 | 0 new |
| EmployeeProfile prod | 0 | 33 | +33 (seeded via DbInitializer idempotent) |
| EmployeeCodeSequences | 0 | 1 | NV/2026 LastSeq=33 |

## Multi-agent ROI cumulative S33

🟦 Investigator 2 spawn ~20K + 🟨 Implementer 4 spawn ~110K (2/4 truncated
mid-MEMORY, functional complete) + 🟥 Reviewer 3 spawn ~60K (Smart Friend
6× clean) + 🟩 CICD 3 spawn ~60K (Run #350 + #237 PASS) + em main solo
~150K (Task 2 + Task 3b + Task 6 + 7 commit batch + push).

## CI Runs

- #350 Phase 1 (commit 48a99e1) — 3m38s PASS — Mig 34 prod + 33 seeded + 9 BW
- #237 Phase 2 (commit 79a8343) — 3m50s PASS — 5 NEW employee endpoint + Hrm
  menu seeded + bundle rotate × 2 app

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 22:25:19 +07:00
79a8343de3 [CLAUDE] Memory: S33 Plan B Phase 2 + Reviewer activity 3 sub-agent append
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 3m50s
3 sub-agent MEMORY auto-updated qua spawn S33 Plan B Phase 2:

🟨 Implementer (a8f4567 + a9bb9f3 + afdc812) — 3 spawn Task 3+4+5:
- Task 3 Mig 34 BE entity scaffold 17 file (truncated mid-Pattern 12-bis
  lookup, MEMORY.md NOT updated — pending em main proxy entry)
- Task 4 BE CQRS 3 file scaffold (truncated mid-MEMORY update — pending
  em main proxy entry)
- Task 5 FE 2 app 12 file scaffold (COMPLETE w/ MEMORY updated cleanly,
  Pattern 16-bis + 12-bis reinforcement noted Recent activity FIFO)

🟥 Reviewer (a5acadc + aaa1df3 + ae752c0) — 3 spawn cumulative S33:
- S33 startup drift severity assessment SEVERE patch CLAUDE.md now
- Plan C B-Wrap pre-commit Smart Friend 5× clean 9/9 PASS in 4.7s
- Plan B Phase 2 pre-commit Smart Friend 6× clean 17 file 0 critical/major
  3 minor defer Phase 1.5 (per-action policy + bool partial + IDateTimeProvider)

🟩 CICD Monitor (aa504e8 + a67df4e) — 2 spawn:
- S33 startup health-check HEALTHY 3/3 prod 200 + cert 58 days
- Plan B Phase 1 + Plan C verify Run #350 PASS 3m38s + Mig 34 prod applied
  + 33 EmployeeProfiles seeded + gotcha #51 INFRASTRUCTURE seed verify

Pattern: per repo convention (5400983 S32 wrap + b3444a3 S33 startup),
sub-agent MEMORY auto-append commit scope `[CLAUDE] Memory:` separate từ
substantive scope.

Implementer truncation pattern observation (Task 3 + Task 4):
- Heavy scaffold ~50+ tool uses → MEMORY update at end runs out of token
  budget → mid-sentence cutoff "Let me check..." / "Let me append..."
- Functional work complete despite truncation (verified via file existence
  + build + test)
- Mitigation: Implementer split heavy task into 2 phases (scaffold first
  100K tokens, MEMORY update separate 20K tokens budget reserve)
- Em main proxy MEMORY append later session — defer non-critical knowledge
  loss (Pattern 12-bis foundation already in MEMORY from S29 Plan B Chunk C)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 20:28:02 +07:00
9616ae219c [CLAUDE] FE-Admin+FE-User: Plan B G-H1 Task 5 — EmployeesPage 2-panel + EmployeeCreatePage cookie-cutter mirror
Phase 10.1 G-H1 Phase 2 Task 5 — FE 2 app cookie-cutter mirror PE pattern.
Phase 1 ULTRA-MINIMAL scope (Implementer afdc812 scaffold):
- 2-panel ListPage (filter left + list+detail right, KHÔNG 3-panel vì Hrm
  no workflow)
- 6-section inline collapsible detail (Cơ bản/Công tác/Đào tạo/Thân nhân/
  Kỹ năng/Hồ sơ) — NO separate DetailTabs component file
- CreatePage Header form minimal (UserId picker + Status + DateOfBirth +
  Gender + Phone + HireDate + Nationality)
- Display read-only Phase 1 satellite (no inline edit — defer Phase 1.5)

## Files (6 new + 6 modified × 2 app = 12)

### NEW (3 × 2 app, SHA256 IDENTICAL cross-app mirror)

| File | LOC | SHA256 prefix |
|------|----:|---|
| `fe-{admin,user}/src/types/employee.ts` | 283 | CCFC70666568 |
| `fe-{admin,user}/src/pages/hrm/EmployeesListPage.tsx` | 417 | DC859C897C5C |
| `fe-{admin,user}/src/pages/hrm/EmployeeCreatePage.tsx` | 178 | C796F25D01AC |

10 const-object enum mirror BE Domain.Hrm.Enums + DTOs:
- EmployeeStatus/Gender/MaritalStatus/EmployeeType/DegreeLevel/
  EducationMode/GradeLevel/FamilyRelationKind/SkillKind/EmployeeDocumentType
- EmployeeListItem + EmployeeDetail + 5 satellite DTO type

### MODIFIED (3 × 2 app)

- `fe-{admin,user}/src/lib/menuKeys.ts` — +Hrm + HrmHoSo const
- `fe-{admin,user}/src/components/Layout.tsx` — +Hrm_HoSo:'/employees' staticMap
  (LESSON Plan CA Hotfix 1 gotcha #50: page route mới phải thêm staticMap
  entry cùng commit, else silent sidebar drop)
- `fe-{admin,user}/src/App.tsx` — +2 route /employees + /employees/new

## Pattern reinforcement

- **Pattern 16-bis 4-place mirror cross-app** reinforced 4× cumulative (S29
  Plan CA HF1 + S29 Plan B Chunk D + S33 Task 5 admin + S33 Task 5 user).
  Comment header trong Layout.tsx ghi explicit Plan CA Hotfix 1 #50 lesson.
- **Pattern 12-bis cross-module entity FE port PE → Hrm** reinforced 4× (Plan
  B Chunk C Mig 33 + G-H1 Task 4 BE + Task 5 FE types mirror PE types/page
  structure mirror PE 2-panel scope-down 3→2 panel).

## Reviewer ae752c0 verdict: PASS (commit 0e191de earlier)

- Smart Friend 6× cumulative clean (em main + Implementer quality genuine)
- gotcha #50 Layout staticMap mirror ✓ (cả fe-admin + fe-user)
- menuKeys.ts FE drift pre-existing intentional (fe-admin minimal vs fe-user
  expanded Catalogs/Suppliers/Projects/Departments) — NOT blocking, follow-up
  task add Budgets/Catalogs to fe-admin OR document intentional minimal scope.

## Verify

- fe-admin npm build: PASS 21.4s · 0 TS6 err · 1,431 KB bundle
- fe-user npm build: PASS 9.2s · 0 TS6 err · 1,345 KB bundle
- dotnet build: PASS 1.59s · 0 warn 0 err (no BE change)
- dotnet test: 120/120 PASS baseline preserved

## Defer Phase 1.5 (per Reviewer recommend)

1. PermissionGuard wrapper menuKey HrmHoSo + per-action Hrm_HoSo_View/Create
2. Convert 3 bool field UpdateCommand thành bool? safe partial update
3. Satellite CRUD endpoint + form (WorkHistory/Education/FamilyRelation/
   Skill/Document)
4. Test bundle (Create UNIQUE conflict + List filter + codeGen race)
5. Add Bg_*/Catalog* to fe-admin menuKeys.ts sync với fe-user

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 20:27:25 +07:00
0e191deea5 [CLAUDE] Domain+App+Api+Infra: Plan B G-H1 Task 4+6 — Hrm CQRS 5 endpoint + Permission menu
Phase 10.1 G-H1 Phase 2 — Task 4 (BE CQRS + REST endpoint) + Task 6
(Permission menu seed) cumulative. Foundation BE side complete cho Hồ sơ
Nhân sự module — FE Task 5 + Reviewer Task 7 + CICD verify next.

## Task 4 — BE CQRS + Controller (3 file new, Implementer Case 2)

src/Backend/SolutionErp.Application/Hrm/EmployeeFeatures.cs (~450 LOC):
- CreateEmployeeProfileCommand + Validator + Handler
  - Verify User.Id exists qua UserManager.FindByIdAsync
  - UNIQUE 1-1 check: throw ConflictException nếu User đã có EmployeeProfile
  - EmployeeCode auto-gen qua IEmployeeCodeGenerator (NV/{YYYY}/{Seq:D4})
  - 50+ field assignment từ Command record
- UpdateEmployeeProfileCommand + Validator + Handler (mutable fields, UserId+EmployeeCode immutable)
- DeleteEmployeeProfileCommand + Handler (soft delete IsDeleted=true)
- GetEmployeeProfileQuery + Handler (Include 5 satellite collection)
- ListEmployeesQuery + Handler (paged + JOIN Users+Departments, filter Status/DepartmentId/Search)

src/Backend/SolutionErp.Application/Hrm/Dtos/EmployeeDtos.cs (~110 LOC):
- EmployeeProfileListItemDto (Id, EmployeeCode, UserId, FullName/Email/Department JOIN, Status, Phone, HireDate)
- EmployeeProfileDetailDto (full 50+ field + 5 satellite collection)
- 5 satellite DTO: EmployeeWorkHistoryDto + EmployeeEducationDto +
  EmployeeFamilyRelationDto + EmployeeSkillDto + EmployeeDocumentDto

src/Backend/SolutionErp.Api/Controllers/EmployeesController.cs (~70 LOC):
- 5 REST endpoint: GET list / GET detail / POST / PUT / DELETE
- Class-level [Authorize] only Phase 1 (per-action policy Hrm_HoSo_View/Create/
  Edit/Delete defer Phase 1.5 per Reviewer recommend)
- Route prefix /api/employees

## Task 6 — Permission menu Hrm_HoSo* (em main solo, 2 file mod)

src/Backend/SolutionErp.Domain/Identity/MenuKeys.cs (+10 LOC):
- +2 const: Hrm root group + HrmHoSo leaf
- Update All[] array → SeedAdminPermissionsAsync auto-grant Admin role CRUD

src/Backend/SolutionErp.Infrastructure/Persistence/DbInitializer.cs (+4 LOC):
- SeedMenuTreeAsync +2 entry:
  - (Hrm, "Nhân sự", null, 28, "UserCircle") — root group
  - (HrmHoSo, "Hồ sơ Nhân sự", Hrm, 1, "ContactRound") — leaf
- Order=28 between Budgets=27 và Contracts=30+ (no collision)
- INFRASTRUCTURE menu seed (NOT gated DemoSeed:Disabled — em main verified
  outside gate block per gotcha #51 lesson, mirror Plan B Task 3b
  SeedDemoEmployeeProfilesAsync placement)

## Reviewer ae752c0 verdict: PASS Smart Friend 6× clean

- 0 critical, 0 major, 3 minor defer Phase 1.5 (per-action policy + bool
  partial update + IDateTimeProvider injection)
- Cumulative Smart Friend track: S22 #44 + S25 #48 + S29 Plan CA ≥12 + S29
  Plan B ApplicableType + S33 Plan C BW clean + S33 Plan B Phase 2 clean
- gotcha #51 INFRASTRUCTURE seed gate compliance: ✓
- gotcha #50 Layout staticMap mirror: ✓ (Task 5 commit next)

## Verify
- dotnet build: 0 err 0 warn (1.72s)
- dotnet test: 120/120 PASS baseline preserved
- Endpoint claim verified grep 0 mock marker, 5 mediator.Send real

Pattern 12-bis cross-module entity cookie-cutter mirror PE→Hrm reinforced 4×
cumulative (S29 Plan B Contract Chunk C + S33 Task 3 entity scaffold + Task
3b seed + Task 4 CQRS).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 20:26:44 +07:00
48a99e14e7 [CLAUDE] Domain+App+Infra: Plan B G-H1 Mig 34 EmployeeProfile + seed 30 demo
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 3m38s
Phase 10.1 G-H1 Hồ sơ Nhân sự Foundation — port từ NamGroup CT_NHANSU
(1675 NV, 10 bảng TblNhanVien*) sau anh main chốt S32 4 quyết định
(scope FULL 11 module + DB single schema dbo + reuse Workflow V2 +
chunk per-module Plan riêng). G-H1 CRITICAL FIRST vì depend by 8/11
module Phase 10 sau (Đề xuất/Đơn từ/OT/Đặt xe/Ticket/Dashboard NS/
Chấm công đều cần EmployeeProfile data).

Investigator pre-flight (a103d20) audit NamGroup confirm:
- Main TblNhanVien 105 cols (drop 35 cols duplicate User/UX legacy)
- 5 satellite Phase 10.1 (defer 3 HĐLĐ Plan H2): WorkHistory + Education
  + FamilyRelation + Skill polymorphic Kind + Document
- 6 enum thay catalog FK (Gender/MaritalStatus/EmployeeStatus/...)
- DiaChi dual-write FK + freetext lesson Plan C NamGroup 1675 NV drift

Em main 4 decision chốt:
1. 5 satellite Phase 10.1 (defer 3 HĐLĐ Plan H2)
2. Skill polymorphic Kind enum (gộp 3 NamGroup table)
3. DiaChi 6 FK Province/District/Ward declare nullable + freetext dual-write
   ngày đầu (FK constraint defer G-H2 khi catalog scaffold — Implementer
   smart decision documented EmployeeProfile.cs comment line 14-17)
4. MaNhanVien format NV/{YYYY}/{Seq:D4} atomic Serializable reset/year

Implementer Case 2 (a8f4567) Pattern 12-bis cross-module mirror PE → Hrm
cookie-cutter scaffold 17 file mới + 4 modified + 3-file mig rule:

Domain (8 file SolutionErp.Domain.Hrm):
- EmployeeProfile.cs (main ~70 cols inherit AuditableEntity, 1-1 UNIQUE User)
- EmployeeWorkHistory.cs + EmployeeEducation.cs + EmployeeFamilyRelation.cs
- EmployeeSkill.cs (polymorphic Kind=Computer/Language/Other)
- EmployeeDocument.cs (IdCard/Passport/Degree/Certificate/LaborContract/Other)
- EmployeeCodeSequence.cs (PK string Prefix, NOT BaseEntity Id Guid)
- Enums.cs (10 enum gọn 1 file)

Application (1 file):
- IEmployeeCodeGenerator.cs interface (mirror IContractCodeGenerator)

Infrastructure (8 file):
- EmployeeCodeGenerator.cs impl IsolationLevel.Serializable transaction
- 7 EF Configuration file (HasIndex UNIQUE UserId/EmployeeCode/Phone +
  HasMaxLength + HasColumnType decimal(18,2) + FK Cascade satellite)
- DependencyInjection.cs (M): register IEmployeeCodeGenerator → impl

Persistence (3 file modified + 2 new mig + 1 snapshot):
- IApplicationDbContext.cs (M): +7 DbSet<EmployeeProfile/...>
- ApplicationDbContext.cs (M): +7 DbSet impl
- ApplicationDbContextModelSnapshot.cs (M): EF auto-update
- 20260526110207_AddEmployeeProfiles.cs (NEW, EF auto-gen)
- 20260526110207_AddEmployeeProfiles.Designer.cs (NEW, EF auto-gen)

DbInitializer.cs (M, em main solo Task 3b ~90 LOC):
- using SolutionErp.Domain.Hrm import added
- SeedDemoEmployeeProfilesAsync method appended (end of class)
- Register call after SeedDemoUsersAsync line 88 (depend user exist first)
- NOT gated DemoSeed:Disabled flag (infrastructure data per gotcha #51 lesson)
- 30 demo profile mirror 30 user @solutions.com.vn + sequential code
  NV/{YYYY}/0001..0030 + placeholder masked CMND/BHXH/Bank (bro UAT update
  qua FE Page Task 5) + EmployeeCodeSequence row LastSeq=30 → production
  gen tiếp 0031+

Verify:
- dotnet build: 0 err 2 unrelated warn DocxRenderer (2.49s + 7.86s rebuild)
- dotnet ef database update _Dev: Mig 34 applied (top of __EFMigrationsHistory)
- dotnet test: **120/120 PASS** baseline preserved (no test add Phase 10
  test-after per §7 UAT mode — test bundle defer Task 4+5+6 done)

Stats target Phase 10 end: 33→42 mig (+9 Mig 34-42), 60→85 tables (+25),
~148→250 endpoint (+100), 38→60 FE pages (+22). Current after this commit:
33→34 mig + 60→66 tables + endpoint/FE unchanged (G-H1 Task 4+5 next).

Pattern reusable cross-project:
- Pattern 12-bis cross-module entity cookie-cutter mirror reinforced 3×
  (S29 Plan B Contract V2 + S33 Plan B G-H1 EmployeeProfile)
- Infrastructure seed OUT of DemoSeed gate (gotcha #51 lesson, mirror Mig 32
  SeedSampleContractWorkflowV2)
- DiaChi dual-write FK + freetext từ ngày đầu (NamGroup 1675 NV drift lesson)

Pending Plan B G-H1 Phase 2 (chờ anh main signal kick off):
- Task 4 — Implementer BE CQRS handler + 6 endpoint controller
- Task 5 — Implementer FE 2 app EmployeesPage 3-panel + 6 section tabs
- Task 6 — Em main Permission menu Hrm_HoSo* seed
- Task 7 — Reviewer pre-commit + CICD post-deploy verify

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 18:18:57 +07:00
0605f19f57 [CLAUDE] Tests: Plan C B-Wrap BW1-BW7 Contract V2 test bundle +9 tests (111→120)
Plan C B-Wrap (spec D-Bis migration-todos.md lines 563-619) — Contract V2
ApproveV2Async ~227 LOC NO test cover after S29 Plan B deploy prod. Risk
gotcha #48 high. Anh main S32 chốt defer dedicated session ~2h post-Phase 9
stabilize. S33 kick off cùng Plan B G-H1.

7 BW spec deterministic → 9 [Fact] method (BW6 split 3 for clean isolation):

BW1 — ApproveV2 happy path Cấp 1→Cấp 2 cùng Bước advance pointer + Approval
      row + LevelOpinion UPSERT + LogTransition "Hoàn tất Cấp 1, sang Cấp 2"
BW2 — Terminal Cấp cuối Bước cuối → DaPhatHanh + gen mã HĐ format
      "FLOCK01/HĐTP/SOL&BTBM/01" + clear pointers
BW3 — skipToFinal F2 admin opt-in AllowApproverSkipToFinal=true Cấp 1 Bước 1
      → advance lastStepIdx/lastLevelMaxOrder + prefix [Duyệt vượt cấp]
BW4 — Outsider (không trong pendingLevelGroup.ApproverUserId) → ForbiddenException
BW5 — CreateContractCommand pin workflow ApplicableType=DuyetNcc → exception
      "Workflow phải ApplicableType=Contract" (Reviewer S29 MAJOR catch)
BW6a — ContractLevelOpinion duplicate composite (ContractId, LevelId)
       → DbUpdateException (UNIQUE Mig 33)
BW6b — UPSERT pattern fetch+update → 1 row only Comment updated
BW6c — Delete Contract → FK Cascade auto-delete ContractLevelOpinions
BW7 — V1 fallback skipToFinal non-admin → ConflictException
      "skipToFinal chỉ hỗ trợ HĐ V2"

Test infra dependencies:
-  TestApplicationDbContext SQLite reuse (Common/SqliteDbFixture.cs)
-  IdentityFixture reuse (UserManager + CreateUserAsync helper)
-  FixedDateTime reuse (deterministic clock)
-  NoOpNotificationService reuse
- 🆕 TestCurrentUser stub ICurrentUser (configurable per-test scope) — 31 LOC
-  REAL ChangelogService inject TestCurrentUser
-  REAL ContractCodeGenerator inline (no mock needed, SqliteDbFixture
     enough for atomic sequence test)

Verify:
- dotnet build: 0 err 0 warn (2.49s)
- dotnet test: **120/120 PASS** (was 111 baseline + 9 new)
  - Domain: 58/58 PASS
  - Infrastructure: 62/62 PASS (was 53 → +9 BW)

Reviewer S33 verdict: **PASS** — 0 critical/major issues, 3 minor cosmetic
defer-OK (CreateService helper dead code unused, TestCurrentUser null
defensive C# warning shadow, BW1-4+7 vs BW6 using pattern style). 9/9 indep
verify PASS in 4.7s. Spec strings exact match service source (BW1 ContextNote
+ BW2 Mã HĐ + BW3 ContextNote + BW4-7 exception messages).

Smart Friend independence lần thứ 5 cumulative:
1. S22 #44 silent 403 — Reviewer catch
2. S25 #48 SQLite tie-break — Reviewer catch
3. S29 Plan CA password ≥12 — Reviewer catch
4. S29 Plan B ApplicableType — Reviewer catch
5. S33 Plan C BW — clean, em main+Implementer quality genuine NOT lowered

Patterns applied:
- Implementer Pattern 12-bis cross-module entity cookie-cutter mirror PE
  → Contract (proven 3× S29 + S33)
- Test deterministic seeded helper SeedApproverF2WorkflowAsync mirror
  PurchaseEvaluationWorkflowServiceReturnModeTests.cs structure

Files (4 new tests + 1 stub):
- A tests/SolutionErp.Infrastructure.Tests/Common/TestCurrentUser.cs (31 LOC)
- A tests/SolutionErp.Infrastructure.Tests/Services/ContractWorkflowServiceApproveV2Tests.cs
- A tests/SolutionErp.Infrastructure.Tests/Application/CreateContractCommandApplicableTypeTests.cs
- A tests/SolutionErp.Infrastructure.Tests/Common/ContractV2SchemaPersistenceTests.cs

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 18:17:59 +07:00
b3444a3448 [CLAUDE] Memory: S33 startup + Plan B+C activity 3 sub-agent append
3 sub-agent MEMORY auto-updated qua spawn S33:

🟦 Investigator (a327050, afaf6d5, a103d20) — 3 spawn entries:
- S33 startup audit 4 MEMORY size + cross-agent learnings 4 pattern +
  RAG hit verify 2/3 PASS + 1 WARN boundary 0.684
- Plan B G-H1 Task 1 pre-flight NamGroup TblNhanVien* 10 bảng audit
  (NOT 8 anh main estimate) + field map 70 cols main + 5 satellite
  proposal (defer 3 HĐLĐ Plan H2)

🟥 Reviewer (a5acadc, aaa1df3) — 2 spawn entries:
- S33 startup drift severity assessment CLAUDE.md SEVERE patch now
- Plan C B-Wrap pre-commit verify 9/9 PASS in 4.7s, Smart Friend 5×
  cumulative clean (em main+Implementer quality genuine NOT lowered)

🟩 CICD Monitor (aa504e8) — 1 spawn entry:
- S33 startup health-check HEALTHY 3/3 prod endpoint 200 + Mig 33 prod
  synced + cert api.solutions.com.vn 58 days lead 2026-07-23 + discovery
  paths-ignore thiếu eval/** wastefully deploy S31 RAG telemetry JSON

Pattern: per repo convention (5400983 S32 wrap), 3 sub-agent MEMORY auto-
append commit scope `[CLAUDE] Memory:` separate từ substantive scope.

Implementer MEMORY truncated giữa update Pattern 12-bis lookup (Plan B
Task 3 scaffold) — em main append proxy entry sau (defer).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 18:17:15 +07:00
1bc6b708fc [CLAUDE] Docs: patch CLAUDE.md+docs/CLAUDE.md+implementer.md drift S19→S32
Reviewer S33 startup audit verdict SEVERE drift CLAUDE.md baseline header
(emain context first-load file misleads sub-agent spawns post-S19).

Patches (10 line cross 3 file):
- CLAUDE.md mig count 26→33 + bảng 59→60 (Mig 32+33 Plan B Contract V2 S29)
- CLAUDE.md test count 81→111 × 2 sites
- CLAUDE.md gotcha count 26→52 (cumulative S22-S32 +26 entries)
- CLAUDE.md schema-diagram table 52→60 + +§14 Contract V2 LevelOpinions
- CLAUDE.md audit next cycle 2026-05-01→2026-06-01 (cron next due 6 ngày)
- CLAUDE.md Contract V2 wire status "chưa wire" → "ĐÃ WIRE (Mig 32+33 Plan B)"
- docs/CLAUDE.md gotchas table 38→52 pitfall
- implementer.md test baseline 81→111 × 2 (verify command + report format)

Drift defer 2026-06-01 batch (Reviewer recommend):
- investigator.md + reviewer.md gotcha 44→52 cosmetic
- docs/gotchas.md #50/#51 renumber order (non-functional)

Smart Friend independence note: Reviewer NOT softened verdict — em main
patched S29 sub-agent cicd-monitor.md baseline but MISSED CLAUDE.md root
cùng pass. Pattern reinforced: khi update mig count phải bundle CLAUDE.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 18:16:41 +07:00
540098347d [CLAUDE] Memory: S32 wrap — 4 sub-agent MEMORY append S32 wrap entry (em main proxy)
4 sub-agent MEMORY append S32 wrap entry FIFO top:
- Investigator (20.6KB): S32 startup verify spawn + NamGroup audit pre-flight hit
  limit + em main solo audit fallback findings + Plan G 11 module DOCUMENTED.
  Pending S33 spawn: Plan G-H1 NamGroup TblNhanVien* audit (priority high).
- Implementer (29.2KB): S32 startup verify spawn + em main proxy curate 5
  entries S25-S29 -> q2. Patterns 1-19+12-bis+16-bis foundation preserved.
  Pending S33 spawn: Plan G-H1 6-entity scaffold + Plan B-Wrap BW1-BW7 codegen
  + Plan G-O2 BookingCalendar + Plan G-O3-O6 workflow apps mirror PE V2.
- Reviewer (26.5KB): S32 startup verify spawn (self-curated S27 retro dropped).
  Smart Friend 4x cumulative preserved. Pending S33 spawn: Plan B-Wrap test
  bundle adversarial review + Plan G-H1 Mig 34 schema pre-commit + Phase 9 UAT
  hard blocker security audit.
- CICD Monitor (26KB): S32 startup verify spawn + Run #231 PARTIAL detail
  archived q2. No new Run S32 (5 commits docs-only CI skip). 3 prod endpoint
  smoke 200 OK preserved. cert notAfter 2026-07-23 verified. Pending S33
  spawn: Phase 10.1 G-H1 first code commit Run verify + Plan B-Wrap test
  count delta + V2 contract create flow UAT smoke.

Re-ingest stats: 166 files -> 2991 chunks (+3 delta S32 wrap content). Cache
hit 11.4s vs initial 75.7s = 6.6x speedup post Plan A2.
RAG eval v1.1 verify: recall@5=1.000 (11/11) PASS, avg_rerank ~0.84 preserves
S31 baseline. Negatives q12-q14 correctly excluded (rerank 0.40-0.43 < 0.7).

Refs: docs/STATUS.md S32 wrap. docs/HANDOFF.md S32. migration-todos.md
§Phase 10 + §D-Bis + §A + §E.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 16:49:28 +07:00
abcc1ed747 [CLAUDE] Docs: S32 wrap STATUS+HANDOFF — Phase 9 stabilize done + Phase 10 backlog Plan G + S33 handover G-H1
S32 wrap final headers:
- STATUS.md: S32 entry insert TRUOC S31 (preserve history). 4 quyet dinh chot anh
  main (FULL 11 module + single dbo + Workflow V2 enum +5 + chunk per-module).
  Phase 9 stabilize 4 task done. 4 commits S32 push remote.
- HANDOFF.md: S32 brief 5 phut next session S33. 7-step kick off plan G-H1 Ho so
  NS. Anh main coordinate ops trong meantime (SMTP/rotate creds/Task Scheduler).
  S31 caveat resolved (CLI restart confirm live RAG fix rerank 0.906 post-S32
  re-ingest 2988 chunks).

Refs: docs/changelog/migration-todos.md §Phase 10 + §A/§D-Bis/§E. memory user-level
feedback_phase10_namgroup_port.md (4 quyet dinh chot cross-session).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 16:40:24 +07:00
cce096309f [CLAUDE] Docs+Memory: S32 Phase 9 stabilize batch — Plan A3 MEMORY curate 3 agents + Plan B-Wrap spec BW1-BW7 defer + Plan C1 ops status update
Phase 9 stabilize sequential batch S32:
- Plan A2 DONE: RAG re-ingest 166 files / 2988 chunks / 75.7s. Verify gotcha #52
  query rerank 0.906 (was 0.516 < 0.7 threshold). Phase 10 backlog query rerank 0.758
  semantic match good.
- Plan A3 DONE: MEMORY curate 3 agents OVER 25KB threshold. Implementer 38.4 -> 27.5KB
  (5 verbose S25-S29 entries archived q2 - Patterns 1-19 + 12-bis + 16-bis foundation
  preserved). Investigator 27.7 -> 19KB (4 verbose S25-S26-S29 entries archived q2).
  CICD Monitor 27 -> 24.2KB (Run #231 PARTIAL detail archived q2 - S29 wrap summary
  preserves key findings). Reviewer 24.39KB unchanged (self-curated S32 startup).
  Total 117.9 -> 95.7KB (-22KB ~18%).
- Plan B-Wrap spec BW1-BW7 documented detailed (migration-todos D-Bis section):
  BW1 happy path step advance + BW2 terminal gen ma HD + BW3 skipToFinal F2 admin
  opt-in + BW4 ForbiddenException + BW5 ApplicableType=Contract validation (Reviewer
  S29 MAJOR catch) + BW6 Mig 32+33 schema persistence UNIQUE composite + BW7 V1
  fallback ConflictException. Defer dedicated session ~2h chot anh main S32 (test
  infra IChangelogService + IContractCodeGenerator mocks first-time).
- Plan C1 ops status update: backup-sql.ps1 ready (register Task Scheduler manual cmd
  documented). win-acme cert api.solutions.com.vn notAfter=2026-07-23 (auto-renew
  ~2026-06-23 NOT 2026-06-18 stale STATUS.md note). SMTP + Rotate creds BLOCKED chờ
  anh main coordinate.

Refs: docs/STATUS.md S31 wrap. docs/HANDOFF.md S31. gotcha #52 qdrant-client search
removed (RAG layer stable post-S31 fix + S32 re-ingest gotchas hit). gotcha #51
INFRASTRUCTURE vs DEMO seed (Phase 10.3 enum extend caution).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 16:36:14 +07:00
b832f43d8e [CLAUDE] Docs+Memory: S32 Phase 10 backlog Plan G NamGroup port + 4 sub-agent startup entries
migration-todos.md: insert Phase 10 detail section (10 Plan G-* atomic per-module sprint
~3 thang T6-T8/2026 target, aggressive multi-agent parallel ROI ~70%). 4 quyet dinh anh
chot S32: FULL 11 module scope + single schema dbo mo rong Mig 34-42 + reuse Workflow
V2 extend ApplicableType +5 values + chunk per-module Plan rieng. Sequence Phase 9
stabilize first per anh main "tuan tu theo ke hoach tot nhat". G-P1 pure web GPS
check-in (no device). G-H2 seed reference NamGroup demo data.

4 MEMORY sub-agent: append S32 startup entry (Investigator + Implementer + Reviewer +
CICD Monitor) ghi nhan S31 RAG retrieval.py fix + S29 Plan CA+B deploy + Pending tasks
anh main co the SendMessage reuse. Implementer 36.2KB OVER 25KB threshold FLAG curate.

Refs: docs/CLAUDE.md Phase 6-9 done. docs/STATUS.md S31 wrap. gotcha #51 INFRASTRUCTURE
vs DEMO seed gate (Phase 10.3 enum extend caution). gotcha #52 qdrant.search removed
(RAG layer stable post-S31 fix).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 16:17:36 +07:00
f938bf57f5 [CLAUDE] Docs: patch cicd-monitor.md stale test+mig numbers (S31)
- Tests baseline: 81/81 → 111/111 PASS (58 Domain + 53 Infra)
- Migrations: 27 → 33 (latest Mig 33 AddPeLevelOpinionsForV2 S29)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-26 13:43:24 +07:00
1e1c9a2433 [CLAUDE] Docs: S31 RAG v1.3 baseline PASS (11/11 recall@5=1.000) + gotcha #52
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 3m38s
- eval/runs/: baseline v1.1 final PASS after retrieval.py fix (vector search restored)
- eval/trial-state-lock.json: quality_gate.pass=true, baseline=1.000, avg_rerank=0.847
- docs/gotchas.md: +gotcha #52 qdrant-client 1.18 removed search() silent AttributeError
- docs/STATUS.md: S31 entry — RAG PASS, retrieval.py fix, CLI restart required
- docs/HANDOFF.md: S31 brief + CRITICAL CLI restart note
- docs/changelog/sessions/: S31 session log

Root cause: qdrant-client 1.18 removed search() → vec_results always [] → BM25-only
Fix: retrieval.py query_points().points (applied to AI_INFRA repo)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-26 13:42:04 +07:00
b223466ded [CLAUDE] Docs: setup RAG Framework v1.3 governance + eval framework
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 3m52s
- docs/governance/README.md: Path B delegation stub → AI_INFRA canonical
  Phase/BC vocabulary documented (9 phase + 10 BC SOLUTION_ERP-specific)
- .claude/rag.json: add _decision_log block (10 rationale entries) +
  add .claude/agents/**/*.md to corpus_paths (fix Case D harvest gap)
- eval/evaluator.md: inline executor spec v1.0 (Spec A strict)
- eval/golden-set-solution_erp.jsonl: 14-entry golden set v1.1
  (5 gotcha + 3 pattern + 3 decision + 3 negative)
- eval/runs/2026-05-26-baseline-v1.0-failed.json: v1.0 attempt
  recall@5=0.455 FAIL — root cause diagnosis Case A/C/D
- eval/runs/2026-05-26-baseline-v1.1-pending.json: v1.1 attempt
  pending CLI restart for accurate numbers
- eval/trial-state-lock.json: 2-section split (quality_gate +
  drift_monitor) per v1.3 §6.2, 4-week milestones 2026-05-26 → 2026-06-23

CRITICAL lesson: bootstrap.py --project flag overrides collection name only.
Use --config D:\...\SOLUTION_ERP\.claude\rag.json for correct project root.
Old projects.json had root_path=AI_INFRA for solution_erp (Anti #24) — FIXED.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-26 13:14:23 +07:00
c506919d7d [CLAUDE] Skill: S27 audit late drift fix include batch (mig 26→31, gotcha 44→49)
3 file skill modified bởi S27 audit late (drift trigger +8 gotcha vượt §9.4
threshold) — committed log `docs/changelog/skill-audit-2026-05-late.md` đã ghi
chi tiết 5 patches, NHƯNG 3 file SKILL.md tự thân chưa được include trong
commit batch S29 wrap `e199603` (em main quên git add `.claude/skills/`).

Changes confirm S27 audit late patches:
- .claude/skills/README.md: ef-core-migration cell `26 mig → 31 mig` + Session
  marker `S19 → S23 t1 (Mig 31 F2 per-Approver-slot)` + docs/gotchas count
  `44 → 49 bẫy`
- .claude/skills/dependency-audit-erp/SKILL.md: gotcha count `41 → 49 bẫy`
- .claude/skills/ef-core-migration/SKILL.md: description `26 mig → 31 mig` +
  heading `26 → 31 migration hiện có` + Tests note `77 → 111 test pass` +
  DbSet cho 59 bảng note `26 → 31 mig`

Verify:
- git diff 3 file content already match docs/changelog/skill-audit-2026-05-late.md
  spec → S27 patches confirmed apply
- KHÔNG drift NEW post S29 — chỉ catch-up include batch missing

CI skip per paths-ignore (.claude/skills/** match docs-only pattern).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 13:43:51 +07:00
e199603420 [CLAUDE] Docs+Memory: Session 29 FINAL wrap — Plan CA + Plan B Contract V2 cumulative
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 3m31s
20 commits S29 push 4 CI Runs PASS (#229+#230 Plan CA, #231+#232 Plan B).
2 big plans END-TO-END deployed prod.

Changes (docs + memory + scripts — CI skip per paths-ignore):

docs/:
- STATUS.md: S29 FINAL wrap header với cumulative summary 20 commits +
  multi-agent ROI ~565K + 8 patterns NEW + state stats (33 mig, 60 tables,
  51 gotcha, 14 AppRoles, 34 active users, 4× bundle rotate)
- HANDOFF.md: S29 FINAL wrap header với end-to-end V2 capability + pending S30+
  follow-up (anh restart CLI MCP RAG hot-reload, UAT verify V2, test bundle
  Plan B, curate dedicated session)
- gotchas.md: +gotcha #51 INFRASTRUCTURE vs DEMO seed phân biệt (Plan B
  Hotfix CICD lesson) với decision tree + seed classification table
- changelog/sessions/2026-05-22-s29-plan-ca-plan-b-contract-v2-wire.md:
  Session log đầy đủ 20 commits + 4× Smart Friend pattern proven + 8
  patterns NEW + file-touched list + NEW capability end-to-end test plan

.claude/agent-memory/:
- 4 MEMORY.md flush S29 wrap entry FIFO each agent perspective:
  - Investigator (25.2 KB just over threshold) — Plan CA + Plan B pre-flight
    2 spawn + 3 patterns NEW (terrain map, V1+V2 coexist, reference templates)
  - Implementer (35.4 KB over hard threshold, defer curate S30) — 5 spawn
    cookie-cutter + E3 stopped + Pattern 12-bis NEW (cross-module entity mirror)
  - Reviewer (23.0 KB compacted) — 4 spawn 2 MAJOR catches + Cat 3 security
    cross-module validation foundation reinforced
  - CICD Monitor (24.9 KB) — 4 Runs verify + CRITICAL DemoSeed gate catch +
    Stage 4.6 sqlcmd seed verify foundation + Discovery #6 gotcha #51 cross-ref
- implementer/pattern_master_page_mirror.md (NEW Plan CA Chunk B Pattern 16-bis)

scripts/:
- plan-ca-{verify-menu,verify-perms,run-perms}.{sql,ps1} (5 verify scripts)
- plan-b-{verify-prod,run-verify}.{sql,ps1} (2 verify scripts)

Smart Friend pattern proven 4× cumulative S22 #44 + S25 #48 + S29 Reviewer
#ApplicableType + S29 CICD #DemoSeed.

Pending S30+:
- Anh restart CLI hot-reload MCP RAG cho 4 sub-agents (commit b51fc94)
- Anh UAT verify V2 contract end-to-end (Drafter → CCM approve → DaPhatHanh)
- Test bundle Plan B (regression ApproveV2Async + ApplicableType validation)
- Curate dedicated session 4 MEMORY (Implementer 35.4 KB priority)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 13:29:49 +07:00
38f1c4d2d9 [CLAUDE] Infra: Plan B Hotfix CICD — SeedSampleContractWorkflowV2 OUT of DemoSeed gate
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 3m32s
CICD Monitor post-deploy verify (Run #231 SUCCESS) caught CRITICAL:
SeedSampleContractWorkflowV2Async nested inside `if (!demoSeedDisabled)`
branch → prod has 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.

Fix: PROMOTE SeedSampleContractWorkflowV2 ra ngoài DemoSeed gate. Lý do
architectural:
- Sample workflow là INFRASTRUCTURE config (như Roles + Departments + Catalogs)
- KHÔNG phải demo data wipeable
- Production cần để Drafter create V2 contract
- Admin có thể edit/delete/disable qua Designer sau seed (idempotent skip)

Pattern lesson reusable cross-project: phân biệt INFRASTRUCTURE seed (always
run) vs DEMO seed (gated by flag). Bảng phân loại:
- INFRASTRUCTURE always: Roles, Departments, Catalogs, MenuTree, AdminPerms, Templates
- DEMO gated: DemoUsers (30 sample, Plan T disabled prod), DemoContracts, DemoPE, SampleWorkflows
- INFRASTRUCTURE NEW post-S29: SampleContractWorkflowV2 (cần cho V2 path work)

Verify:
- dotnet build PASS 0 err
- Mig 32 + Mig 33 prod đã apply (Run #231 success)
- Sample seed sẽ chạy on next IIS recycle post-push
- Idempotent: skip nếu QT-HD-V2-001 already exists (rare race admin tự seed Designer trước)

Post-deploy expect:
- ApprovalWorkflows table +1 row Code=QT-HD-V2-001 ApplicableType=3 IsActive=1 IsUserSelectable=1
- Drafter login fe-user → /contracts/new → Workspace dropdown "Quy trình duyệt V2" có 1 option

CICD Monitor ROI: caught BEFORE bro UAT 401/empty dropdown experience. Smart
Friend guard pattern proven 4× cumulative S22 #44 + S25 #48 + S29 Plan B
Reviewer ApplicableType + S29 Plan B CICD DemoSeed gate.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 13:11:05 +07:00
3e92584238 [CLAUDE] App: Plan B Hotfix Reviewer — CreateContractCommand validate ApplicableType=Contract
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 3m30s
Reviewer pre-push verify (agentId ace4799) catch MAJOR security gap:
CreateContractCommand thiếu validation guard rằng ApprovalWorkflowId pin
phải có ApplicableType=Contract(3). Attacker forge POST body với V2 PE
workflow ID (ApplicableType=1/2 DuyetNcc) → contract pin sai workflow type
→ Service ApproveV2Async sẽ run pattern PE workflow trên Contract entity
→ behavior nondeterministic + audit log nhầm.

Fix: Mirror PE pattern PurchaseEvaluationFeatures.cs:62-77.

Validation block thêm vào CreateContractCommandHandler.Handle sau activeWfId
query:
1. Load aw entity by Id (throw NotFound nếu invalid Guid)
2. Verify aw.ApplicableType == Contract(3) (throw Conflict nếu mismatch)

Defense-in-depth: FE Workspace dropdown (Chunk D 62b50d1) đã filter
ApplicableType=3 client-side; BE guard chặn request forge.

Verify:
- dotnet build PASS 0 err 2 pre-existing warn
- dotnet test 111/111 PASS — 0 regression
- Mirror PE pattern exact (only switch enum DuyetNcc/PhuongAn → Contract literal)

Smart Friend ROI: Reviewer caught MAJOR before push prod. Cumulative S22 #44
+ S25 #48 + S29 (this Hotfix) — pattern proven 3× Reviewer save UAT 401/403
prod incidents.

Plan B chain COMPLETE 10/10 (9 + 1 hotfix):
- A1 58898e8 / A2 a85e437 / B 138469d / C 26c98d3 / B2 1f199b0
- E1 ef23308 / D 62b50d1 / E2 48f6d22 / E3 14feb69
- Hotfix Rev (this) ApplicableType=Contract guard

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 12:52:40 +07:00
14feb6955d [CLAUDE] FE-Admin+FE-User: Plan B Chunk E3 — ContractDetailPage Section 5 LevelOpinionsV2 dynamic
Em main solo sau Implementer E3 stuck mid-task. Minimum viable mirror PE
Section 5 LevelOpinionsSectionV2 pattern. V2 contract pin ApprovalWorkflowId
→ render dynamic Section 5 với opinion data UPSERT từ Service ApproveV2Async
(Plan B Chunk B2 1f199b0).

Changes × 2 app:

types/contracts.ts (×2):
- ContractDetail +3 fields V2 (default null backward compat):
  - approvalWorkflowId: string | null
  - currentApprovalLevelOrder: number | null
  - levelOpinions: ContractLevelOpinion[] | null
- NEW type ContractLevelOpinion (12 fields mirror BE DTO)

components/contracts/ContractDetailContent.tsx (×2):
- Add Section 5 sau "Chi tiết HĐ" section
- Conditional render: chỉ khi c.approvalWorkflowId (V2 mode)
- Empty placeholder "Chưa có ý kiến" khi workflow vừa start
- forEach opinion render card:
  - Title: Bước X (StepName) — Cấp Y (LevelName)
  - Comment + signedAt vi-VN format
  - NV duyệt: approverFullName
  - Banner " Admin duyệt thay" khi signedByUserId !== approverUserId
- Style: emerald palette mirror PE Section 5

V1 contract: 3 fields null → Section 5 KHÔNG render (backward compat).

Verify:
- npm run build × 2 app PASS 0 TS err
- Mirror 2 app §3.9 byte-similar (4 file edit cùng pattern)
- BE wire OK: E2 commit 48f6d22 expose approvalWorkflowId + levelOpinions

Plan B COMPLETE 9/9 chunks LOCAL:
- A1 58898e8  Entity +2 fields
- A2 a85e437  Mig 32 + Config + Seed
- B 138469d  Service ApproveV2Async branch
- C 26c98d3  Mig 33 LevelOpinions
- B2 1f199b0  UPSERT block
- E1 ef23308  CreateContractCommand +V2
- D 62b50d1  FE Workspace V2
- E2 48f6d22  ContractDetailDto + populate
- E3 (this)  FE Section 5 LevelOpinionsV2

Implementer E3 spawn stopped mid-task ("check ContractDetail type" judgment
call) → em main solo finish. Pattern lesson: complex FE feature mirror với
type extend + new component → em main solo more reliable than Implementer.

Pending: Reviewer pre-commit Plan B cumulative + push remote + CICD verify
+ docs/STATUS update.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 12:45:33 +07:00
48f6d22b3d [CLAUDE] App: Plan B Chunk E2 — ContractDetailDto +ApprovalWorkflowId + LevelOpinions[] populate
Mirror PE PeDetailBundle pattern. Expose V2 workflow state cho FE Section 5
Chunk E3 (Implementer pending) render dynamic LevelOpinionsSectionV2.

Changes:
- ContractDtos.cs:
  - ContractDetailDto +3 fields (default null backward compat):
    - Guid? ApprovalWorkflowId (V2 pin)
    - int? CurrentApprovalLevelOrder
    - List<ContractLevelOpinionDto>? LevelOpinions
  - NEW record ContractLevelOpinionDto (mirror PE 12 fields)
- ContractFeatures.cs GetContractQueryHandler:
  - Load LevelOpinions via 3-step JOIN (ContractLevelOpinions + ApprovalWorkflowLevels.Include(Step) + Users)
  - Map to ContractLevelOpinionDto với StepOrder/Name + LevelOrder/Name + Approver/SignedBy resolve
  - OrderBy StepOrder + LevelOrder
  - Null fallback Comment "" (CS8604 silence)
  - Empty list khi V2 pin nhưng KHÔNG có opinion (workflow start lúc Drafter trình)
  - Skip load nếu V1 (ApprovalWorkflowId null) → null marker FE detect

FE Chunk E3 sẽ:
- Detect V2 mode qua `bundle.approvalWorkflowId != null`
- Fetch ApprovalFlow shape via existing /api/approval-workflows-v2/{ApprovalWorkflowId}
- Render Section 5 dynamic forEach Step → forEach Level → 1 OpinionBox với opinion data from LevelOpinions[]

Verify:
- dotnet build PASS 0 err, 0 warn (clean)
- dotnet test 111/111 PASS — 0 regression
- V1 legacy contract Detail unchanged (ApprovalWorkflowId=null + LevelOpinions=null)

Plan B chain status (8/9 chunks done):
- A1 58898e8  Entity
- A2 a85e437  Mig 32 + Seed
- B 138469d  Service ApproveV2 branch
- C 26c98d3  Mig 33 LevelOpinions
- B2 1f199b0  UPSERT block
- E1 ef23308  CreateContractCommand +V2
- D 62b50d1  FE Workspace V2
- E2 (this)  ContractDetailDto +V2 + LevelOpinions populate
- E3 FE Section 5 LevelOpinionsV2 (Implementer next)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 12:38:38 +07:00
62b50d112b [CLAUDE] FE-Admin+FE-User: Plan B Chunk D — ContractCreatePage Workspace V2 Select dropdown
Mirror PE PeWorkspaceCreateView Workspace pattern. Drafter pick V2
workflow IsUserSelectable=true filter ApplicableType=Contract(3).

Changes × 2 app:
- Add useQuery fetch /api/approval-workflows-v2?applicableType=3 + filter
  client-side isUserSelectable=true (mirror PE Mig 25 pattern)
- Add Select dropdown "Quy trình duyệt V2 (tùy chọn)" trong
  ContractHeaderForm (create mode panel 2)
- Wire approvalWorkflowId vào CreateContractCommand POST body
- Conditional UI: blank = V1 fallback auto pick (7 prod contract behavior
  giữ nguyên); user pick V2 → pin ApprovalWorkflowId Mig 32 schema
- Hint khi 0 workflows V2 admin ghim → message rõ V1 fallback

Verify:
- npm run build × 2 app PASS 0 TS err (1.32MB fe-user, 1.40MB fe-admin)
- Mirror 2 app §3.9: +44 LOC mỗi file = +88 LOC total byte-similar
- API endpoint /api/approval-workflows-v2 existing (Mig 25 Plan AA S24)
- BE CreateContractCommand.ApprovalWorkflowId field đã add Chunk E1
  (em main commit prior) — FE wire safe
- Backward compat: V1 contract path unchanged khi user bỏ trống dropdown

Plan B chain (6 chunks):
- A1 58898e8  Entity ApprovalWorkflowId + CurrentApprovalLevelOrder
- A2 a85e437  Mig 32 + Seed sample V2 Contract workflow
- B 138469d  Service ApproveV2 branch (PE pattern mirror)
- C 26c98d3  Mig 33 ContractLevelOpinions
- B2 1f199b0  UPSERT LevelOpinion block (PE Mig 26 mirror)
- D (this)  FE Workspace V2 dropdown
- E FE Section 5 V2 (em main + Implementer split E1+E2 sau)

Pattern 16-bis 4-place mirror check:
- Page file × 2 app: edited (insertion mirror byte-similar)
- App.tsx Routes: N/A (enhance existing /contracts/new route)
- menuKeys.ts: N/A (không thêm menu key mới)
- Layout staticMap: N/A (route unchanged)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 12:34:00 +07:00
b51fc94ca6 [CLAUDE] Skill: Add MCP RAG tools cho 4 sub-agent definitions
Add mcp__rag-unified__search_memory + mcp__rag-unified__cross_project_search
vào tools list 4 agents (Investigator + Implementer + Reviewer + CICD Monitor).

Tại sao:
- Sub-agent spawn KHÔNG inherit MCP server access từ parent session
- 4 agents previously CHỈ có Read/Grep/Glob/Bash → re-read MD files manually
- Plan B pre-flight Investigator phải Read PE Mig 22-26 thủ công thay vì 1 RAG query
- Plan CA Reviewer Cat 1 wire claim verify KHÔNG retrieve historical gotcha cross-session
- Plan CA Hotfix 1 silent sidebar drop nếu Implementer có RAG → catch Pattern 16-bis trước commit

Trade-off accepted (anh chốt full 4 agents):
- Token cost spawn cao hơn (~5-10K extra per RAG query)
- Risk noise dilute focus → mitigate by skill-specific prompt focus

Pitfall #1 reinforced (S27 multi-agent setup):
- Session đang chạy KHÔNG hot-reload registry
- Anh restart Claude Code CLI để spawn S30+ pick up MCP RAG tools
- Plan B Chunk D Implementer đang chạy dùng config CŨ (no MCP) — KHÔNG affect

Verify post-restart (Anh):
- Spawn test Investigator → call mcp__rag-unified__search_memory thử
- Pass = MCP tools loaded; Fail = YAML syntax issue (fallback wildcard mcp__rag-unified__*)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 12:32:58 +07:00
ef2330871d [CLAUDE] App: Plan B Chunk E1 — CreateContractCommand +ApprovalWorkflowId V2 pin field
Mirror PE CreatePurchaseEvaluationCommand pattern. Drafter pick V2 workflow
qua Workspace Select dropdown (Chunk D FE Implementer running parallel) →
ApprovalWorkflowId pin lúc create. Fallback V1 auto activeWfId nếu null
(7 prod contract giữ behavior).

Changes:
- CreateContractCommand record +Guid? ApprovalWorkflowId = null (optional)
- Handler line 96 wire entity.ApprovalWorkflowId = request.ApprovalWorkflowId
- Both V1 + V2 fields persist (Service ApproveV2Async branch dispatch theo V2 first)

Verify:
- dotnet build PASS 0 err
- Backward compat: existing caller (KHÔNG pass ApprovalWorkflowId) → fallback null
- V1 contract path UNCHANGED

Plan B chain status:
- A1 58898e8  Entity
- A2 a85e437  Mig 32 + Seed
- B 138469d  Service ApproveV2 branch
- C 26c98d3  Mig 33 LevelOpinions
- B2 1f199b0  UPSERT block
- E1 (this)  CreateContractCommand +ApprovalWorkflowId
- D FE Workspace V2 (Implementer running parallel)
- E2 ContractDetailDto + GetContractByIdQuery extend (em main pending)
- E3 FE Section 5 LevelOpinionsV2 (Implementer pending sau E2)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 12:30:06 +07:00
1f199b01a5 [CLAUDE] Infra: Plan B Chunk B2 — UPSERT ContractLevelOpinion + ResolveActorFullName helper
Replace TODO marker trong Chunk B 138469d (line 257-262) bằng UPSERT block
mirror PE Mig 26 line 512-546.

Changes:
- ApproveV2Async: move matchingLevel computation UP (trước UPSERT block)
- +UPSERT ContractLevelOpinion ~25 LOC:
  - Match level theo ApproverUserId (OR-of-N) + fallback first (admin override)
  - Empty comment → "(duyệt — không ý kiến)" placeholder
  - Insert mới hoặc update existing (UPSERT semantic)
  - SignedByUserId + SignedByFullName denormalized cho Section 5 FE
- skipToFinal block reuse matchingLevel (KHÔNG re-compute)
- +ResolveActorFullNameAsync helper (mirror PE line 774-783)

Section 5 FE (Chunk E) sẽ render dynamic theo flow.steps[].levels[] với
opinion data từ table này. Admin override → FE detect SignedByUserId !==
Level.ApproverUserId → banner "Admin duyệt thay".

Verify:
- dotnet build SolutionErp.slnx PASS 0 err, 2 pre-existing DocxRenderer warn
- dotnet test 111/111 PASS — 0 regression
- V1 legacy path UNCHANGED (7 prod contract giữ behavior)

Plan B chain status:
- A1 58898e8  Entity +2 fields
- A2 a85e437  Mig 32 + Config + Seed
- B 138469d  Service ApproveV2Async branch (UPSERT TODO)
- C 26c98d3  Mig 33 ContractLevelOpinions
- B2 (this)  UPSERT block (resolve TODO Chunk B)
- D FE Workspace V2 (Implementer, next)
- E FE Section 5 V2 (Implementer, pending)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 12:27:46 +07:00
26c98d3c11 [CLAUDE] Domain+App+Infra: Plan B Chunk C — Mig 33 ContractLevelOpinions cookie-cutter mirror PE Mig 26
- Domain/Contracts/ContractLevelOpinion.cs (NEW entity mirror PE — AuditableEntity, 4 field core + 2 nav)
- Domain/Contracts/Contract.cs (+LevelOpinions nav collection)
- Migrations/20260522052240_AddContractLevelOpinions.cs (3-file rule: .cs + .Designer.cs + Snapshot)
- Configurations/ContractLevelOpinionConfiguration.cs (NEW separate file, mirror PE pattern)
- IApplicationDbContext.cs + ApplicationDbContext.cs (+DbSet<ContractLevelOpinion>)

UNIQUE composite (ContractId, ApprovalWorkflowLevelId) — 1 row per HĐ × Level.
FK Cascade Contract + Restrict ApprovalWorkflowLevel.
SignedByUserId KHÔNG nav (denorm SignedByFullName tránh cascade khi xoá user).

Mirror PE Mig 26 pattern (S19 2026-05-09) EXACT — UPSERT row khi Approver duyệt qua
Service ApproveV2Async (Plan B Chunk B em main 138469d đã có TODO marker).
Em main sẽ add UPSERT block sau Chunk C done (Chunk D).

Verify:
- dotnet build PASS 0 err (2 pre-existing warn DocxRenderer unrelated)
- dotnet ef database update PASS (Mig 33 applied SolutionErp_Dev + _Design)
- dotnet test 111/111 PASS (58 Domain + 53 Infra — no regression)

Plan B chain (6 chunks):
- A1 58898e8  ContractApprovalWorkflowV2 entity scaffold
- A2 a85e437  Contract.ApprovalWorkflowId + ContractConfiguration FK
- B 138469d  ContractWorkflowService ApproveV2Async skeleton + TODO LevelOpinion UPSERT
- C (this)  ContractLevelOpinions entity + Mig 33 + config + DbSet
- D FE Workspace V2 (Implementer, pending)
- E FE Section 5 V2 (Implementer, pending)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 12:24:38 +07:00
138469db4e [CLAUDE] Infra+App: Plan B Chunk B — Service ApproveV2Async branch + gen mã HĐ adapt
Mirror PE PurchaseEvaluationWorkflowService.cs:ApproveV2Async (line 446-634).
V1 legacy giữ behavior cũ — 7 prod contract chạy nhánh này. V2 mới pin
ApprovalWorkflowId chạy ApproveV2Async helper.

Changes:
- ContractWorkflowService.cs:
  - TransitionAsync +skipToFinal=false param F2 (Mig 31 Plan K mirror PE)
  - Drafter trình init CurrentApprovalLevelOrder=1 nếu V2 schema pin
  - APPROVE STEP branch V2/V1 dispatch theo ApprovalWorkflowId
  - +ApproveV2Async helper ~150 LOC (mirror PE pattern):
    - Load AW.Steps.Levels OR-of-N
    - Match approver actor.Id ∈ pendingLevelGroup.ApproverUserId
    - Add ContractApproval row + enrich comment skipPrefix
    - skipToFinal F2: AllowApproverSkipToFinal guard + advance pointer last
    - Advance level/step normal
    - Terminal: gen mã HĐ RG-001 + Phase=DaPhatHanh (khác PE just DaDuyet)
- IContractWorkflowService.cs: TransitionAsync +skipToFinal=false param
- ContractFeatures.cs: caller TransitionAsync use named arg ct: ct (skip optional)

TODO Chunk C: UPSERT ContractLevelOpinion (table chưa tồn tại — Mig 33
sẽ scaffold + entity + EF config). Block UPSERT add ở đây sau Chunk C done.

Verify:
- dotnet build SolutionErp.slnx PASS 0 err, 2 pre-existing DocxRenderer warn
- dotnet test 111/111 PASS (58 Domain + 53 Infra) — 0 regression
- V1 legacy path UNCHANGED (7 prod contract giữ behavior)

Plan B chain (6 chunks):
- A1 58898e8 Contract +2 fields (em main, done)
- A2 a85e437 Mig 32 schema + Config + Seed (Implementer Case 2, done)
- B (this) Service ApproveV2Async branch (em main, done)
- C Mig 33 ContractLevelOpinions (Implementer, next)
- D FE Workspace V2 (Implementer, pending)
- E FE Section 5 V2 (Implementer, pending)

Race condition lesson: em main + Implementer parallel touch BE same plan
→ Implementer stash em main WIP for clean build verify. Solution: SEQUENTIAL
chunks A→B→C, NOT parallel B với A2. Pattern add to Implementer MEMORY.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 12:18:46 +07:00
a85e437478 [CLAUDE] Infra: Plan B Chunk A2 — Mig 32 Contract V2 schema + Configuration + Seed sample workflow
Cookie-cutter mirror PE Mig 23+24 GỘP thành 1 Mig 32 (ADD 2 column +
FK + IX). Mirror Mig 26 pattern cho FK Restrict.

Files added/modified:
- Migrations/20260522051059_AddApprovalWorkflowToContract.cs (3-file rule )
- Migrations/20260522051059_AddApprovalWorkflowToContract.Designer.cs
- Migrations/ApplicationDbContextModelSnapshot.cs (updated)
- Configurations/ContractConfiguration.cs (+HasIndex + FK Restrict ApprovalWorkflows)
- Persistence/DbInitializer.cs (SeedSampleContractWorkflowV2 idempotent QT-HD-V2-001)

Mig 32 Up():
- ADD COLUMN Contracts.ApprovalWorkflowId Guid? NULL
- ADD COLUMN Contracts.CurrentApprovalLevelOrder int? NULL
- ADD INDEX IX_Contracts_ApprovalWorkflowId (filtered NOT NULL)
- ADD FK FK_Contracts_ApprovalWorkflows_ApprovalWorkflowId Restrict

Seed sample workflow (UAT smoke + admin Designer default):
- Code: QT-HD-V2-001 Name: "Quy trình duyệt HĐ mẫu UAT V2"
- ApplicableType: 3 (Contract) IsActive: true IsUserSelectable: true
- 1 Step "Bước 1 - Phòng CCM" + 1 Level + Approver Lê Văn Bình CCM
- Idempotent: skip nếu Code+Version existing

V1 coexist: 7 prod contract giữ WorkflowDefinitionId; V2 mới pin
ApprovalWorkflowId. Service ApproveV2Async (Chunk B em main) sẽ branch.

Verify (Implementer):
- dotnet build SolutionErp.slnx PASS 0 err (em main WIP stashed for verify)
- dotnet ef database update Dev PASS (Mig 32 applied)
- 3-file rule Mig: mig.cs + Designer.cs + Snapshot.cs

Plan B chain (6 chunks):
- A1 58898e8 Contract +2 fields (em main, done)
- A2 (this) Mig 32 schema + Config + Seed (Implementer Case 2, done)
- B Service ApproveV2Async branch (em main, in progress)
- C Mig 33 ContractLevelOpinions (Implementer, pending)
- D FE Workspace V2 (Implementer, pending)
- E FE Section 5 V2 (Implementer, pending)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 12:15:11 +07:00
58898e8fbe [CLAUDE] Domain: Plan B Chunk A1 — Contract +2 fields V2 (ApprovalWorkflowId + CurrentApprovalLevelOrder)
Mirror PE Mig 22-24 pattern. V1+V2 coexist (7 V1 contract giữ
WorkflowDefinitionId, V2 mới pin ApprovalWorkflowId).

Fields added:
- ApprovalWorkflowId Guid? — pin schema mới ApprovalWorkflowsV2
- CurrentApprovalLevelOrder int? — Cấp đang chờ duyệt (1/2/3) trong Step

Service ApproveV2Async branch (Chunk B) sẽ dispatch:
- if (contract.ApprovalWorkflowId is Guid awId) ApproveV2Async
- else ApproveV1Legacy (giữ behavior 7 V1 contract)

Verify:
- dotnet build SolutionErp.slnx PASS 0 err, 2 pre-existing DocxRenderer warn
- No migration (Chunk A2 sẽ scaffold Mig 32)

Plan B chain (6 chunks):
- A1 (this) Entity +2 fields (em main)
- A2 Mig 32 schema (Implementer Case 2 cookie-cutter)
- B Service ApproveV2Async branch (em main critical ~200 LOC)
- C Mig 33 ContractLevelOpinions (Implementer)
- D FE Workspace V2 (Implementer)
- E FE Section 5 LevelOpinionsV2 (Implementer)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 12:07:01 +07:00
6eec8d78fb [CLAUDE] Docs+Memory: Plan CA wrap — gotcha #50 + Implementer Pattern 16-bis + STATUS
docs/gotchas.md:
- Add gotcha #50 "Page move cross-app Layout.tsx resolvePath staticMap missed mirror → silent sidebar drop"
- Reference Hotfix 1 commit e55d96b + Implementer Chunk B 06a441c missed point 4
- Add checklist item 25 vào "Checklist debug bug mới" section

.claude/agent-memory/implementer/MEMORY.md:
- Add Pattern 16-bis "4-place mirror checklist khi cookie-cutter copy page CROSS-APP"
- 4 places: page + Routes + menuKeys.ts + Layout.tsx staticMap
- Bug latency observed lesson + REFUSE criteria note + Reviewer Cat 1 wire claim verify suggestion

docs/STATUS.md:
- New Last updated S29 header với Plan CA cumulative summary
- 7 commits chain + 2 CI runs PASS + bundle hash rotate + multi-agent ROI breakdown
- Stats updated: 50 gotcha (+1), 13 AppRoles (+1 CatalogManager), 34 active users (+catalog.manager), 36 FE pages (+4)

Docs-only commit → CI skip per paths-ignore (gotcha #41 + #47 confirmed).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 11:45:41 +07:00
e55d96b856 [CLAUDE] FE-User: Plan CA Hotfix 1 — Add 7 master/catalog leaf routes vào resolvePath staticMap
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 3m24s
Bug UAT bro screenshot 2026-05-22: eoffice sidebar group "DANH MỤC" expand
chỉ thấy "Danh mục chi tiết" (Catalogs sub-group), 3 leaf Suppliers/Projects/
Departments + 4 sub-catalog leaves KHÔNG render.

Root cause: fe-user/src/components/Layout.tsx:238 `MenuLeaf` component
`if (!path) return null` → silent drop khi resolvePath(key) trả null.
Implementer Chunk B (06a441c) thêm Routes vào App.tsx + 4 page + menuKeys.ts
NHƯNG QUÊN mirror staticMap resolvePath (line 55-94) — fe-admin có sẵn
7 entries nhưng fe-user chỉ có 7 entries Dashboard/Contracts/PE/Budget.

Fix: thêm 7 entries vào fe-user staticMap mirror fe-admin EXACT route:
- Suppliers: '/master/suppliers'
- Projects: '/master/projects'
- Departments: '/master/departments'
- CatalogUnits: '/master/catalogs/units'
- CatalogMaterials: '/master/catalogs/materials'
- CatalogServices: '/master/catalogs/services'
- CatalogWorkItems: '/master/catalogs/work-items'

Verify:
- npm run build PASS 9.68s 0 TS err
- BE /api/menus/me admin token return CORRECT tree (Master + 4 children +
  Catalogs sub-tree 4 children) — verified curl pre-fix
- Permissions OK: Admin 9/9 CRUD + CatalogManager 9/9 CRUD (verified sqlcmd)
- fe-admin parity already correct (Layout.tsx:33-47 staticMap có 7 entries
  từ trước Plan CA)

Pattern reusable: Khi Implementer Case 2 cookie-cutter mirror page move
cross-app, MUST also mirror Layout.tsx resolvePath staticMap entries —
KHÔNG chỉ Routes + menuKeys.ts. Gotcha discovery thêm vào MEMORY post-deploy.

Plan CA chain (6 commits cumulative):
- A 80d39a0 BE Role + Seed
- B 06a441c FE move 4 master pages (missed resolvePath mirror)
- C c995f42 Sidebar filter 2 app
- D 4a592cf Seed demo user
- D2 68bcedd Password ≥12 chars hotfix
- HF1 (this) Mirror resolvePath staticMap 7 entries

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 11:38:10 +07:00
68bceddabb [CLAUDE] Infra: Plan CA Chunk D2 hotfix — Password ≥12 chars cho catalog.manager (S22+2 policy)
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 3m31s
Reviewer spawn pre-push verify catch CRITICAL bug Chunk D 4a592cf:
- DemoUserPassword = "User@123456" (11 chars)
- Identity password policy S22+2 ≥12 chars enforced
- → New user catalog.manager CreateAsync FAIL prod → user KHÔNG seed
- → Bro UAT login fe-user 401 → Plan CA broken on prod

Fix: per-user password override conditional check trên roles.Contains(CatalogManager).
- CatalogManager role → password = "CatalogMgr@2026" (15 chars, complexity OK)
- Existing 30 demo user → giữ DemoUserPassword "User@123456" (created pre-S22+2, alive)

Pattern reusable: Khi add demo user MỚI sau S22+2 password policy bump, MUST verify
password ≥12 chars OR override per-user. Existing 30 user idempotent skip CreateAsync
nên KHÔNG bị ảnh hưởng (password hashed in DB từ pre-bump).

Verify:
- dotnet build SolutionErp.slnx PASS 0 err
- Idempotent: existing catalog.manager (nếu manual create) skip + KHÔNG đụng password
- Smart Friend Reviewer guard active — caught issue trước push

Plan CA chain (5 commits cumulative):
- A 80d39a0 BE Role + Seed (em main solo)
- B 06a441c FE move 4 master pages (Implementer Case 2)
- C c995f42 Sidebar filter 2 app (em main solo)
- D 4a592cf Seed demo user (em main solo) — INTRODUCED BUG
- D2 (this) Hotfix password policy (em main solo, Reviewer catch)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 11:09:11 +07:00
4a592cfadb [CLAUDE] Infra: Plan CA Chunk D — Seed demo user catalog.manager + role CatalogManager
DbInitializer.cs SeedDemoUsersAsync array thêm 1 entry:
- Email: catalog.manager@solutions.com.vn (password default User@123456 per SeedDemoUsersAsync logic)
- FullName: "NV Quản lý Danh mục"
- Dept: PRO (Cung ứng)
- Position: "Nhân viên Quản lý Danh mục Dùng chung"
- Roles: [AppRoles.CatalogManager]

Cấp 1 demo user mặc định để bro UAT login fe-user verify 9 menu danh mục
(Master + Suppliers + Projects + Departments + Catalogs + 4 sub-catalogs).
Admin có thể tạo thêm user gán role CatalogManager qua /system/users +
/system/permissions Matrix tự reflect 9 menu key.

Verify:
- dotnet build SolutionErp.slnx PASS 0 err, 2 pre-existing DocxRenderer warn
- Idempotent: SeedDemoUsersAsync skip nếu user existing email
- DbInitializer chạy mỗi lần API startup → demo user auto-seed lên prod sau deploy

Plan CA wrap (4 chunk):
- A 80d39a0 BE Role + Seed permissions (em main solo)
- B 06a441c FE move 4 master pages 948 LOC (Implementer Case 2)
- C c995f42 Sidebar filter 2 app (em main solo)
- D (this) Seed demo user (em main solo)

Total LOC: +1,034 / -2 (BE 67 + FE 962 + sidebar 14 - 2 unused)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 11:02:21 +07:00
c995f42e0d [CLAUDE] FE-Admin+FE-User: Plan CA Chunk C — Sidebar filter 2 app (admin HIDE + user SHOW)
fe-admin/src/components/Layout.tsx:
- Add ADMIN_HIDDEN_MASTER_KEYS Set với 9 menu key danh mục
- Extend isAdminHidden predicate: hide Ct_* + ADMIN_HIDDEN_MASTER_KEYS
- Master/Suppliers/Projects/Departments/Catalogs/4 sub-catalogs giờ ẩn khỏi admin sidebar

fe-user/src/components/Layout.tsx:
- Remove `Master, Suppliers, Projects, Departments` khỏi USER_HIDDEN_KEYS
- Catalogs (root + 4 leaf) auto-visible qua tree-inherit từ Master
- Giữ ẩn `System, Users, Roles, Permissions, Forms, Reports` (admin tools)

Verify:
- npm run build × 2 app PASS 0 TS err
- fe-admin bundle `index-BQidGwKU.js` 1,404 KB gz 357 KB (rotate)
- fe-user bundle `index-Co8LTtad.js` 1,317 KB gz 342 KB (rotate)
- Pattern 5 (mirror 2 app §3.9) applied — cùng 1 plan touch 2 file Layout

Plan CA chain:
- Chunk A 80d39a0 BE Role + Seed (em main solo)
- Chunk B 06a441c FE move 4 pages (Implementer Case 2)
- Chunk C (this) sidebar filter (em main solo)
- Pending Chunk D: smoke verify + tạo demo user catalog.manager@solutions.com.vn

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 11:00:29 +07:00
80d39a06fb [CLAUDE] Domain+Infra: Plan CA Chunk A — Add role CatalogManager + seed 9 menu CRUD
- AppRoles.cs +CatalogManager const + update All array (6 LOC)
- DbInitializer.cs RoleLabels +CatalogManager ("DM", "Nhân viên Quản lý danh mục")
- DbInitializer.cs +SeedCatalogManagerPermissionsAsync() method ~50 LOC
- Wire seed call vào SeedAdminPermissionsAsync chain (idempotent, mirror SeedPePermissionDefaults pattern)

Permission scope: 9 menu key CRUD all true
- Master (root) + Suppliers + Projects + Departments
- Catalogs (root) + CatalogUnits + CatalogMaterials + CatalogServices + CatalogWorkItems

Verify:
- dotnet build SolutionErp.slnx PASS 0 err, 2 pre-existing DocxRenderer warn
- Idempotent: skip per-(role,menuKey) existing row
- 0 FE touch (Chunk B Implementer parallel commit 06a441c)

Plan CA: anh chốt move "Cấu hình danh mục dùng chung" từ fe-admin → fe-user.
Admin tạo role CatalogManager gán user nào cần CRUD; phần phân quyền User
giữ trong fe-admin Permission Matrix (existing /system/permissions).

Pending Chunk C: sidebar filter 2 app (fe-admin HIDE 9 menu, fe-user SHOW)
Pending Chunk D: smoke verify + tạo demo user catalog.manager@solutions.com.vn

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 10:58:18 +07:00
06a441cf4e [CLAUDE] FE-User: Plan CA Chunk B — Move 4 master pages từ fe-admin → fe-user
- Copy SuppliersPage/ProjectsPage/DepartmentsPage/CatalogsPage (948 LOC mirror)
- Extend menuKeys.ts với 5 key Catalogs* (CatalogUnits/Materials/Services/WorkItems)
- Add 7 route App.tsx (/master/suppliers + /master/projects + /master/departments + 4 catalogs tab)
- fe-user component parity verified (DataTable, PageHeader, PermissionGuard, 6 shadcn ui)

Verify:
- fe-user npm run build PASS 0 TS err (1916 modules, 14.14s)
- 4 file SHA256 byte-identical mirror fe-admin (all 4 hash match)
- 0 BE touch (Chunk A em main solo parallel)

Pending Chunk C: sidebar filter 2 app (fe-admin HIDE 9 menu, fe-user SHOW)
Pending Chunk D: smoke verify + role demo user

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 10:56:11 +07:00
3cb54e032e [CLAUDE] Docs: Session 26 FINAL wrap — 2 architectural decisions + RAG indexing verify
Anh chốt 2 decisions cuối session sau commit bf93abd:

1. Approach B distributed RAG bootstrap — em main SOLUTION_ERP chỉ build
   INFRASTRUCTURE + DOCS, KHÔNG bootstrap data hộ 4 dự án khác. Em main
   NamGroup/DH Y Dược/Ashico/Vipix tự bootstrap khi anh mở session project đó.
   Lý do: Cognition "writes single-threaded" boundary + sensitivity per project
   + self-ownership re-bootstrap + knowledge propagation natural qua shared_global.

2. Option 4a manual PowerShell scripts thay Phase 6b Task Scheduler auto-start.
   Anh OWN control qua aliases rag-start/rag-stop/rag-status/rag-dashboard
   + Qdrant dashboard built-in FREE http://localhost:6333/dashboard.

Bug fix bootstrap.py glob extra_corpus — import glob.glob(recursive=True)
thay Path manual parsing (out-of-tree D:\.claude-rag, không commit project).
Re-bootstrap: 2,421 → 2,628 chunks (+207 user-level memory 23 file).
Cache SHA256 hit perfect — 2nd run 6.5s vs initial 60.9s (10× speedup).

+1 memory user-level NEW feedback_rag_distributed_ownership.md ~200 lines
documenting 2 decisions + setup-once scale-distributed pattern reusable.

RAG indexing + rerank verify S26 content: 5/6 query hit rerank 0.498-0.926.
Best hit "em main project X build infrastructure docs không bootstrap project Y"
→ rerank 0.926 — semantic search Anthropic Contextual Retrieval working PERFECT.

Pending S27+ updated:
- Phase 5 SKIP em (distributed approach chốt)
- Phase 6 Option 4a — 4 PowerShell scripts (start/stop/status/dashboard) + $PROFILE aliases (~30 phút)
- Phase 7 rag-onboarding-guide.md 13 section (11 outline cũ + §12 monitoring + §13 distributed) (~40 phút)
- 4 em main project khác tự setup ~10 phút khi anh mở session

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 03:03:47 +07:00
bf93abd467 [CLAUDE] Docs: Session 26 chốt cuối — 6 Plan AG series PE tree view + Plan AI RAG global MCP setup
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 3m39s
Update:
- docs/STATUS.md: Last updated S26 cumulative wrap
- docs/HANDOFF.md: TL;DR S26 chốt cuối với 3 pattern reusable NEW
- docs/changelog/sessions/2026-05-21-s26-pe-tree-view-rag-setup.md: NEW session log đầy đủ
- docs/guides/multi-agent-setup-guide.md: NEW ~750 lines onboarding 4 dự án future
- .claude/agent-memory/*/MEMORY.md: 4 agent flush S26 entries
- .claude/rag.json: NEW project config cho RAG bootstrap

Plans done S26:
- Plan AG/AG2/AG3/AG4/AG5/AG6 — 6 commits 0bf6c7e..d99069a PE List tree view UI iteration
- Plan AI Phase 0-4 — RAG global MCP setup (Voyage-4-large + Qdrant Windows native binary v1.18.0 NO Docker + FastMCP 3.3.1 stdio + SQLite FTS5 BM25 + RRF k=60 + Anthropic Contextual Retrieval prepend)
- SOLUTION_ERP bootstrap: 126 files → 2,392 chunks indexed 60.9s (~484K Voyage tokens = 0.24% free tier 200M/month)

Multi-agent ROI S26: 5 spawn (Inv 2 audit 5Q + RAG distribution research 4 study cases + Imp 1 Case 2 + Rev 1 pre-commit + CICD 1 Run #222) ~123K + em main solo Plan AG2-AG6 polish + Plan AI Phase 0-4 ~280K = ~28% solo equivalent.

3 patterns reusable cross-project NEW S26:
1. Pattern 19 Implementer — HTML native <details>/<summary> + Tailwind named groups (group/proj+year+sup) + localStorage Set<string> cho hierarchical 3-level tree UI when no Accordion lib
2. RAG User-level Global MCP — 1 server localhost serve N project + per-project .claude/rag.json (Approach A — 1 dev solo scenario, không phải team VPS)
3. Qdrant Windows native binary deployment — no Docker overhead, qdrant-x86_64-pc-windows-msvc.zip 28.3MB chính thức GitHub release

Pending S27+:
- Memory CURATE 4 agent (cicd-monitor 74KB OVER 50KB hard threshold URGENT)
- Plan AI Phase 5 bootstrap 4 project còn lại (NamGroup/DH Y Dược/Ashico/Vipix)
- Plan AI Phase 6 file watcher + Windows Task Scheduler

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 02:27:36 +07:00
d99069a305 [CLAUDE] FE-User+FE-Admin: Plan AG6 — Compact PE card 3 row gọn đẹp
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 3m21s
Anh feedback 2026-05-21: "Cho thông tin bên trong này nó gọn đẹp lại nhé".
PE card hiện 4-5 row hơi dài. Compact xuống 3 row tightly packed:

Row 1: [Tên gói thầu]                        [Status badge]
Row 2: PE/2026/A/035 · 10:40 19/05/2026
Row 3: 👤 Drafter · Phòng ban                [✓ HĐ if any]

Changes:
- py-2.5 → py-2 (compact vertical padding)
- Drop Type label "Duyệt NCC" badge redundant (page header đã hiện)
- Combine maPhieu + createdAt vào 1 row với separator ·
- Combine drafter + department + contract badge vào 1 row (conditional render)
- "✓ Đã tạo HĐ" → "✓ HĐ" short label inline cuối row 3
- Separator color slate-300 nhẹ hơn slate-500

Verify:
- npm build fe-user PASS 0 TS err 1292.66 KB (gzip 337.19 KB)
- npm build fe-admin PASS 0 TS err 1404.01 KB (gzip 357.70 KB)
- 2 file SHA256 IDENTICAL 3645307C... (mirror §3.9)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 22:50:14 +07:00
083b601ea4 [CLAUDE] FE-User+FE-Admin: Plan AG5 — PE List tree 3-level Project > Năm > NCC > PE
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 3m32s
Anh feedback 2026-05-21: "Folder cấp dưới dự án là theo năm và dưới năm là theo NCC nhé".
Plan AG3 chỉ 1-level Project > PE. Plan AG5 extend xuống 3 cấp: Năm + NCC.

Group structure:
- Level 1: 📁 Project (bg-slate-50, font-medium 13px)
- Level 2: 📅 Năm {year} (border-l ml-3, 12px)
- Level 3: 🏢 NCC (border-l ml-3, 12px, italic slate-400 nếu "Chưa chọn NCC")
- Leaf: PE card (border-l ml-3, giữ nguyên content)

Sort:
- Project A-Z (vi locale)
- Năm DESC (2026 trước 2025)
- NCC A-Z (vi locale)
- PE within NCC: createdAt DESC

Fallback:
- empty projectName → "(Dự án đã xoá)"
- selectedSupplierName null (PE chưa DaDuyet) → "(Chưa chọn NCC)" group + italic style

Drop redundant selectedSupplierName line trong PE card (đã hiện ở NCC group header).

localStorage keys:
- Project: projectId
- Năm: `${projectId}::y${year}`
- NCC: `${projectId}::y${year}::s${supplierId|'_none_'}`

Verify:
- npm build fe-user PASS 0 TS err 1292.68 KB (gzip 337.18 KB) 1907 modules
- npm build fe-admin PASS 0 TS err 1404.02 KB (gzip 357.70 KB) 1926 modules
- 2 file SHA256 IDENTICAL E5FE4979... (mirror §3.9)
- KHÔNG BE change, KHÔNG Mig, KHÔNG test (UAT mode)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 22:41:58 +07:00
2bf01184ca [CLAUDE] App+FE-User+FE-Admin: Plan AG4 — bổ sung Drafter + Department vào PE List card
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 3m27s
Anh UAT 2026-05-21: PE card danh sách thiếu người tạo + phòng ban tạo. Bổ sung 4 field
qua BE JOIN Users + Departments LEFT (cả 2 nullable theo PE entity).

BE — 4 file:
- PurchaseEvaluationDtos.cs: +4 fields DrafterUserId/DrafterName/DepartmentId/DepartmentName
- PurchaseEvaluationFeatures.cs ListHandler: JOIN Users + Departments LEFT, projection +4
- PurchaseEvaluationFeatures.cs InboxHandler: mirror JOIN + projection +4
- CreateContractFromEvaluationFeatures.cs ListApproved: mirror JOIN + projection +4

FE — 4 file × 2 app mirror:
- types/purchaseEvaluation.ts: PeListItem +4 fields
- pages/pe/PurchaseEvaluationsListPage.tsx: PE card render thêm dòng "👤 {drafterName} · {departmentName}"
  giữa Mã phiếu và Supplier. Conditional: chỉ render khi có ít nhất 1 field.

Verify:
- dotnet build clean 0 err
- dotnet test SolutionErp.slnx 111/111 PASS (58 Domain + 53 Infra) — no regression
- npm build fe-user PASS 0 TS err 1290.31 KB (gzip 336.79 KB) 1907 modules
- npm build fe-admin PASS 0 TS err 1401.66 KB (gzip 357.30 KB) 1926 modules
- 2 FE PE List file SHA256 IDENTICAL C6996194... (mirror §3.9)
- KHÔNG Mig (chỉ DTO + projection extend)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 18:52:04 +07:00
fbad4a9251 [CLAUDE] FE-User+FE-Admin: Plan AG3 — PE List tree consistent (drop single-PE flat branch)
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 3m19s
Anh feedback 2026-05-21: "nếu có 1 thì cũng để tương tự luôn nhé, đừng để khác các thằng kia".
Plan AG2 render single-PE project flat card + UPPERCASE label phía trên — khác phong cách
với multi-PE project (folder <details>). UX inconsistent.

Plan AG3 drop nhánh single-PE flat. Mọi dự án dù 1 hay nhiều PE đều render <details>
folder collapsed với badge count "(N)" — consistent visual.

Diff: -60 LOC (drop entire single-PE flat block).

Verify:
- npm build fe-user PASS 0 TS err
- npm build fe-admin PASS 0 TS err
- 2 file SHA256 IDENTICAL 749FF703... (mirror §3.9)
- KHÔNG BE change, KHÔNG Mig, KHÔNG test (UAT mode)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 18:35:25 +07:00
c5429c0d10 [CLAUDE] FE-User+FE-Admin: Plan AG2 — Simplify PE List tree 1-level + Panel 1 widen 400px
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 3m29s
Anh feedback Plan AG (2-level Project > Gói thầu > PE) cầu kỳ quá. Simplify
xuống 1-level + widen panel cho dễ đọc.

3 changes:
1. Panel 1 widen 340px → 400px (lg:grid-cols-[400px_1fr_360px])
2. Drop GoiThauGroup nested type + inner <details> tree, useMemo group 1-level
   Project > PE[]; PE sort by createdAt DESC trong group (mirror BE sort)
3. Smart render: single-PE project → flat card (no <details> wrapper, project
   name UPPERCASE label inline) / multi-PE project → <details> tree expand
4. localStorage key rename 'pe_list_expanded_projects' (drop ::gtKey composite suffix)

UAT visual: dự án solo PE hiện flat (không cần click expand), dự án có nhiều
phiếu render tree compact.

Drop redundant projectName ở PE card (đã có ở group header / UPPERCASE label).

Verify:
- npm build fe-user PASS 0 TS err 1291.76 KB (gzip 336.90 KB) 1907 modules
- npm build fe-admin PASS 0 TS err 1403.10 KB (gzip 357.41 KB) 1926 modules
- 2 file SHA256 IDENTICAL 37520D01... (mirror §3.9)
- KHÔNG BE change, KHÔNG Mig, KHÔNG test (UAT mode per feedback_uat_skip_verify)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 18:24:59 +07:00
0bf6c7ec63 [CLAUDE] FE-User+FE-Admin: Plan AG Chunk A+B+C — PE List tree view 2-level Project > Gói thầu
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 3m39s
UAT feedback bro Tra Sol 2026-05-21: UI Duyệt NCC flat list "đám rừng" → tree view giống Outlook folder.

Phase 1 FE-only mirror 2 app §3.9 — KHÔNG schema mới (Phase 2 ProjectPackage defer sau UAT confirm).

Chunk A — Data transform useMemo group:
- Map<projectId, Map<normalizedGoiThau, PeListItem[]>>
- Normalize TenGoiThau: trim + toLowerCase, display raw đầu tiên trong group
- Sort: Project A-Z + gói thầu A-Z (vi locale)
- Fallback: "(Dự án đã xoá)" empty projectName + "(Chưa phân loại)" empty TenGoiThau
- Filter (pendingMe → DaGuiDuyet) áp dụng TRƯỚC group

Chunk B — UI render <details>/<summary> 2-level:
- Replace flat <ul><li> bằng nested <details> HTML native (no shadcn Accordion — gap component lib)
- 📁 Project + 📄 Gói thầu icon + count badge inline
- Chevron rotation via Tailwind group-open/proj + group-open/gt named groups
- PE card content preserve nguyên (line 209-248 unchanged)

Chunk C — Expand state localStorage persist:
- Key 'pe_list_expanded_groups' Set<string>
- Project level key: projectId; Gói thầu level key: ${projectId}::${normalizedGoiThau}
- Default empty Set (all collapse) — bro Tra Sol expect Outlook-style closed default

Verify:
- npm build fe-user PASS 0 TS err 1291.33 KB (gzip 337.00 KB) 1907 modules 16.05s
- npm build fe-admin PASS 0 TS err 1402.68 KB (gzip 357.51 KB) 1926 modules 6.86s
- KHÔNG BE change, KHÔNG Mig, KHÔNG test (UAT mode per feedback_uat_skip_verify)

Pending: Reviewer pre-commit + CICD Run #222 verify

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 17:46:17 +07:00
0c6efdaf4f [CLAUDE] Docs: Session 25 chốt cuối — Plan AB→AF cumulative 7 commits + 4 agent MEMORY flush
S25 wrap final:
- STATUS.md + HANDOFF.md prepend Plan AB→AF cumulative narrative (7 commits cdfd542..506cada + 7 CICD Runs #215-#221)
- gotchas.md +2 NEW entries:
  - #48 Multi-Changelog.Add() SQLite frozen-clock tie-break (Run #215 catch, fix Plan AB Chunk A2)
  - #49 UI dual-phase badge confusion khi state machine self-loop (Plan AD drop + extractNextTargetHint helper)
- Checklist debug bug mới +2 entries (24-25)
- Session log NEW docs/changelog/sessions/2026-05-19-s25-pe-history-visibility.md (~360 LOC)
- 4 agent MEMORY drift sync:
  - investigator/MEMORY.md (30→32KB) FIFO entry S25 wrap + count metadata
  - implementer/MEMORY.md (34→36KB) FIFO entry + patterns 16-18 saved
  - reviewer/MEMORY.md (31→32KB) FIFO entry + lesson SQLite tie-break + UAT skip risk reinforced
  - cicd-monitor/MEMORY.md (~72KB CRITICAL OVER) — 7 Run entries #215-#221 + curate flag MAX

Memory user-level +2 NEW entries (separate commit memory dir, KHÔNG trong this commit):
- feedback_fe_merge_synthetic_audit.md (Plan AC2 pattern)
- feedback_fe_usermap_fallback.md (Plan AF pattern)

Stats final S25:
- 31 mig (no schema) · 59 tables · ~146 endpoints · 35 FE pages
- 111 test unchanged (UAT defer test-after per §7)
- 49 gotcha (+2: #48 + #49)
- 23 memory user-level (+2 NEW S25 patterns)
- 6 skills · 4 sub-agents active
- 7 commits cumulative S25 · 7 CICD Runs (1 FAIL caught + 6 PASS)
- 6× bundle rotate × 2 app (Run #220 BE-only unchanged)

Critical pending S26+:
- Memory curate cicd-monitor PRIORITY MAX (~72KB strongly over hard threshold)
- Plan B Contract V2 wire HIGH priority (5-6 chunk pre-allocated S23 HANDOFF)

Per §6.5 KEEP narrative — KHÔNG cut rationale/gotcha context, chỉ phân tầng prepend latest.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 16:33:41 +07:00
506cada86b [CLAUDE] FE-User FE-Admin: Plan AF — userMap fallback resolve historical entries pre-Plan AE
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 3m23s
Bro UAT 2026-05-19 post-Plan AE: phiếu cũ entries vẫn show "Hệ thống" thay
vì user name. Plan AE chỉ forward fix — entries CŨ pre-deploy có
userName="" empty, FE fallback "Hệ thống".

Fix Plan AF — Option A bro chốt (FE fallback lookup, no DB write):

ApprovalsTab + HistoryTab build userMap useMemo từ PeDetailBundle data
có sẵn (KHÔNG cần extra fetch /api/users admin permission):
- ev.drafterUserId + ev.drafterName
- ev.approvals[].approverUserId + approverName
- ev.approvalFlow.steps[].levels[].approvers[].userId + fullName
- ev.levelOpinions[].signedByUserId + signedByFullName
- ev.departmentOpinions[].userId + userName

resolveUserName / resolveActorName helper:
1. Trust entry.userName nếu non-empty
2. Lookup userMap qua entry.userId
3. Fallback 'Hệ thống' nếu không match

Cover gần hết users tham gia phiếu (drafter + approver + signer). Edge
case: user edit phiếu nhưng KHÔNG xuất hiện trong workflow → vẫn fallback.

Pattern reusable: synthetic data recovery cho audit trail từ embedded
domain data sources, no extra API contract change.

Mirror 2 app §3.9 identical logic.

Verify:
- npm build × fe-user PASS 0 TS err (9.12s)
- npm build × fe-admin PASS 0 TS err (8.91s)
- BE unchanged from 9ea62be

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-19 13:04:59 +07:00
9ea62be6a7 [CLAUDE] PurchaseEvaluation: Plan AE — fix Changelog UserName 9 sites (Budget Adjust + 8 preventive)
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 3m25s
Bro UAT 2026-05-19 post-S25 Plan AD: "Điều chỉnh ngân sách" entry trong
Lịch sử thay đổi show "Hệ thống" thay vì tên user thật (Phan Văn Chương /
NV CCM). Audit phát hiện systemic bug — 9 Changelog.Add sites trong PE
features MISSING UserName field, FE fallback "Hệ thống" toàn bộ.

Fix Plan AE — preventive batch (8 sites khác chắc chắn bro sẽ phát hiện sau):

PurchaseEvaluationFeatures.cs (4 sites):
- line 120 Tạo phiếu
- line 149 Hạng mục mặc định
- line 228 Cập nhật thông tin phiếu (UpdateDraft)
- line 379 Điều chỉnh ngân sách (Budget Adjust) — bro feedback chính

PurchaseEvaluationDetailFeatures.cs (5 sites):
- line 167 Thêm hạng mục (Detail Insert)
- line 225 Cập nhật hạng mục (Detail Update)
- line 257 Xóa hạng mục (Detail Delete)
- line 317 Cập nhật báo giá (Quote Update — inside if block, 16-space indent)
- line 342 Thêm báo giá (Quote Insert)
- line 377 Xóa báo giá (Quote Delete)
- line 416 Chọn NCC trúng thầu (Select Winner)

Pattern: `UserName = currentUser.FullName ?? currentUser.Email` — ICurrentUser
đã có FullName + Email từ JWT claims, KHÔNG cần inject userManager mới.

Verify:
- dotnet build clean 0 err 2 warn (pre-existing DocxRenderer)
- dotnet test 111/111 PASS

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-19 12:32:53 +07:00