Files
solution-erp/.claude/agent-memory/investigator-codebase/MEMORY.md
pqhuy1987 d2f52ba586 [CLAUDE] Docs: S40 consolidate STATUS/HANDOFF 393KB→9KB + re-ground count drift + archive zero-loss
- STATUS.md 169.7KB→5.7KB, HANDOFF.md 223.6KB→3.4KB (giữ current+3 session, pointer logs)
- Full verbatim archived docs/_archive/{STATUS,HANDOFF}-preS40-fullhistory.md (zero info loss)
- Re-ground count: endpoints ~223→211, FE pages 53→65 (36+29), menu 85→~53; tables 84 confirmed correct (DbSet 77 + Identity 7)
- CLAUDE.md root patch: 33→40 mig, 60→84 bảng, 111→130 test
- S40 init audit: 7-agent live, RAG re-rank PASS 0.8789, 130 test PASS
- agent-memory S40 entries (investigator-codebase/api + test-specialist smoke audit)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-29 13:00:09 +07:00

36 KiB
Raw Blame History

Investigator Agent — Persistent Memory

Persistent diary cross-session. Auto-injected first 200 lines / 25KB at spawn. Update BEFORE every stop. Curate when > 25KB.


🎯 Role baseline

Read-only research + audit for SOLUTION_ERP codebase. Tools: Read, Grep, Glob, Bash, WebFetch, WebSearch. Output: concise structured findings under 500 words.


📋 Patterns proven (cross-session)

Pattern: Smoke verify catalog SOLUTION_ERP

  • Bearer auth từ https://api.solutions.com.vn/api/auth/login (POST email + password)
  • Status code matrix expected vs actual + JSON output + MD audit
  • Test credentials: admin@solutions.com.vn / Admin@123456 (full) OR nv.test@solutions.com.vn / TestUser@123456 (Drafter UAT scope)

Pattern: Schema scan via sqlcmd

# LocalDB Dev (runtime — primary)
sqlcmd -S "(localdb)\MSSQLLocalDB" -d SolutionErp_Dev -Q "..."

# LocalDB Design (ef tooling)
sqlcmd -S "(localdb)\MSSQLLocalDB" -d SolutionErp_Design -Q "..."

# Production (qua SSH vietreport-vps)
ssh vietreport-vps "sqlcmd -S .\SQLEXPRESS -d SolutionErp -U vrapp -P '...' -Q '...'"

Common queries: sys.columns, sys.triggers, __EFMigrationsHistory, COUNT(*), sys.indexes.

Gotcha: 2 LocalDB distinct (memory feedback_designtime_runtime_db):

  • _Dev — runtime API (appsettings.Development.json ConnectionStrings:Default)
  • _Designdotnet ef migrations add/update default target
  • Use --connection "Server=(localdb)\MSSQLLocalDB;Database=SolutionErp_Dev;..." override khi cần Dev specifically.

Pattern: Controller audit

  • Grep \[Route\("api/[a-z]+"\)\] enumerate ~30+ controllers
  • Grep \[Authorize(Policy = "..." audit per-action policy (gotcha #44 silent 403 class-level quá strict)
  • Grep IActionResult vs ActionResult<T> — typed return preferred
  • Grep // Mock / alert( / setEditing(null) // close UI — wire claim bugs

Pattern: Memory cross-reference

19 memory entries tại C:\Users\pqhuy\.claude\projects\D--Dropbox-CONG-VIEC-SOLUTION\memory\ (S20 +2 turn 11/12, S21 +2 turn 5):

  • MEMORY.md — index
  • project_solution_erp.md — cumulative narrative S1-S17
  • feedback_per_chunk_commit.md — 5-chunk A-E discipline
  • feedback_uat_skip_verify.md — Phase 9 skip test rule
  • feedback_drastic_refactor_scope.md — defer dedicated session
  • feedback_audit_reuse_before_clone.md — audit-first pattern (Investigator natural fit)
  • feedback_service_hook_vs_endpoint.md — derived state hook pattern
  • feedback_n_stage_workflow_pattern.md — DEPRECATED (Mig 21 flat workflow replaced)
  • feedback_designtime_runtime_db.md — 2 LocalDB distinct
  • feedback_md_compact_narrative.md — §6.5 KEEP narrative rule
  • feedback_unittest_timing.md — §7 test timing
  • feedback_cron_monthly_limitation.md — Cron SDK 7-day expire
  • feedback_user_manual_style.md — non-tech docs style
  • feedback_node_cicd.md — Node 20.x pin
  • feedback_responsive_laptop_breakpoint.md — 4-tầng responsive pattern (S20 t11)
  • feedback_multi_agent_setup.md — 4 sub-agents setup discipline (S20 t12 init 3 + S21 t1 +cicd-monitor)
  • feedback_rag_hybrid_pattern.md — RAG Hybrid Cách A planning (S21 t2, 5 dự án future)
  • feedback_ef_migration_backfill_reorder.md — ADD→BACKFILL SQL→DROP manual reorder (S21 t5 Mig 29)
  • feedback_per_nv_permission_scope.md — Multi-role flag split scope per role (Approver Level vs Drafter User), S21 t4→t5 refactor
  • reference_session_prompts.md — canonical session start template

Pattern: External research priority sources

  • anthropic.com/engineering/ (official patterns)
  • cognition.ai/blog/ (Devin lessons)
  • philschmid.de + eugeneyan.com + hamel.dev (senior engineers)
  • learn.microsoft.com/en-us/aspnet/core/ (.NET 10 official)
  • tanstack.com/query/latest (TanStack Query)

⚠️ Anti-patterns observed

  • Skip MEMORY.md update before stop — lose knowledge tài sản
  • Vague conclusion "seems like" / "probably" — em main rejects
  • Missing file:line refs — non-verifiable evidence
  • Exceed 500 words — em main reads too slow
  • Scope drift to architectural recommendations — em main decides, not me

🧠 SOLUTION_ERP context essentials (auto-load)

  • DB Dev: SolutionErp_Dev LocalDB (59 tables / 30 migrations / Mig 30 latest AddAllowApproverEditBudgetToLevels)
  • DB Design: SolutionErp_Design (ef tooling distinct)
  • DB Prod: .\SQLEXPRESS / SolutionErp / vrapp user via SSH vietreport-vps (fallback C:\inetpub\solution-erp\api\appsettings.Production.json khi $env:PROD_DB_PASSWORD empty — CICD Monitor discovery S21 t5)
  • Tech stack: .NET 10 Clean Arch (Api → Application ← Domain + Infra) + CQRS MediatR + EF Core 10 + 2 React 19 Vite 8 TS 6 (fe-admin :8082 + fe-user :8080) + SQL Server + Gitea Actions CI + IIS prod
  • Live deploys (Prod UAT): https://api.solutions.com.vn · https://admin.solutions.com.vn · https://eoffice.solutions.com.vn
  • Gitea remote: https://git.baocaogiaoduc.vn/vietreport-admin/solution-erp
  • Gitea Actions API: path /api/v1/repos/.../actions/tasks (NOT /actions/runs — 404). Cache stale ~2 min (gotcha #46) — cross-check VPS file mtime
  • SSH VPS: ssh vietreport-vps (config ~/.ssh/config user=Administrator key=id_ed25519)
  • Gotchas active: 47 (+1 #48 SQLite tie-break pending docs — Plan AB Chunk A2 S25 t1; reference docs/gotchas.md)
  • Tests baseline: 111 PASS (S22 baseline 104 + 7 PE WF cumulative; S25 Plan M tests SQLite tie-break re-stabilized Chunk A2) — Phase 9 UAT skip per chunk (memory feedback_uat_skip_verify)
  • Endpoints: ~146 (S22 +3 stable: PATCH /users/{id}/allow-skip-final + PATCH /pe/{id}/budget-adjust + GET /pe/{id}/attachments/{attId}/view)
  • Memory user-level: 23 entries (+2 S25: Plan AC2 FE merge synthetic recovery + Plan AF userMap fallback patterns)
  • Users: 30 demo + 33 active prod (13 cũ + 20 mới S22+2 role-based: act/bod/equ/fin/hra/pm/qs prefix .nv/.pp/.tp + bod.1/2). Password policy ≥12 chars (S22+2 discovery, TestUser@2026)
  • API auth response: accessToken + refreshToken + user (S22+2, NOT token)
  • Master HEAD reference: check via git log -1 --format='%H'
  • 6 skills: contract-workflow · permission-matrix · form-engine · ef-core-migration · dependency-audit-erp · iis-deploy-runbook

🔄 Active workflow schemas (V1 + V2 coexist post-Session 17)

  • V1 Mig 21 flat workflowWorkflowDefinition pin với PE/Contract cũ. Match Dept+PositionLevel.
  • V2 Mig 22-30ApprovalWorkflow pin với PE mới + match ApproverUserId 1-1 OR-of-N cùng Cấp. Steps (Phòng) > Levels (Cấp). PE đã wire V2. Contract V2 PENDING (Plan F drop V1 ABORTED S22+4 — Contract entity HOÀN TOÀN V1 chưa wire V2 + 4 PE V1-only + 19 PE V1+V2 mix).
    • Mig 25 IsUserSelectable (admin pin/unpin per workflow cho user pick)
    • Mig 26 PE Level Opinions UPSERT (service hook khi Duyệt)
    • Mig 28 (S21 t4) 6 Allow* workflow-level — REPLACED by Mig 29
    • Mig 29 (S21 t5) Allow* refactor per-NV: 5 flag on ApprovalWorkflowLevels (F1+F3 per Approver slot) + 1 flag on Users.AllowDrafterSkipToFinal (F2 per Drafter)
    • Mig 30 (S22+5) F4 AllowApproverEditBudget per-Level slot on ApprovalWorkflowLevels — admin Designer tick per slot cho Approver được edit Budget khi review. Pattern reinforced 2× với Mig 29 F1+F3: default = admin opt-in per slot, KHÔNG = mở rộng default. Cross-ref memory feedback_per_nv_permission_scope.md proven cumulative Mig 29 + Mig 30.

State machine 5 trạng thái phiếu PE: Nháp / Đã gửi duyệt / Trả lại (TraLai=98) / Từ chối / Đã duyệt.

Mode Trả lại 4 option per-Level (S21 t4-t5 Mig 28→29):

  • OneLevel = lùi 1 Cấp cùng Step (peer review)
  • OneStep = lùi sang Bước trước Cấp cuối
  • Assignee = pick NV đã ký runtime (PeLevelOpinions)
  • Drafter = Phase=TraLai clear pointer (S17 backward compat default TRUE)

3 mode đầu giữ Phase=ChoDuyet lùi pointer. Mode Drafter giữ Phase=TraLai. Admin bypass level.Allow* flag.


📅 Recent activity (last 10 FIFO)

  • 2026-05-29 (S40 STATE GROUNDING AUDIT — docs vs codebase drift): Em spawn ~9K. 7 metric verify, 4 DRIFT / 3 khớp. Migrations=40 (path THẬT src/Backend/SolutionErp.Infrastructure/Persistence/Migrations/*.cs — STATUS glob Migrations/*.cs trả 0 SAI, skill ef-core-migration ghi đúng path nhưng stale "31 mig"). Mig cao nhất = 20260528090839_AddAttendances (G-P1). Gotchas=55 (format ### N. NOT #NN, highest ### 55.). git clean main. DbSet=77 (docs 84, -7) — grep "public DbSet<" ApplicationDbContext.cs. ⚠️ Endpoints=211 (docs ~223): 65 GET+69 POST+39 PUT+33 DELETE+5 PATCH. FE pages fe-admin=36 (docs 53, -17 nặng; fe-user=29; 36+29=65≠53 nên không phải gộp). Menu keys=53 (docs 85, -32 nặng — MenuKeys.cs const string=53 single-source; 85 nghi là seed row runtime sau inheritance expand NOT const định nghĩa). Drift nặng nhất = Menu keys + FE pages (over-count, docs trộn seed runtime vs const, hoặc S38 skeleton không sync ngược). Surprises: (a) Mig 37/38 THỰC = 37 ExtendApplicableTypeForWorkflowApps + 38 AddProposals TÁCH RIÊNG — KHÁC S37 memory tôi ghi "gộp 37+38 = Proposal" (recommend gộp KHÔNG được adopt). (b) DbSet 77<84 nghi vài entity Phase 10 (WorkflowApps/Attendances/Proposals/MeetingRooms G-* skeleton) chưa add DbSet hoặc gom chung — đáng audit sâu nếu skeleton wire thiếu. (c) Mig 40 thực = AddAttendances NOT documented "Mig 34-40 G-* port" range vẫn đúng. Recommend: sync STATUS.md 4 con số (Tables 77 / Endpoints 211 / FE pages 36 / Menu keys 53). Migration + gotcha + git là 3 con số TIN CẬY nhất. Token ~9K. Tag [state-grounding, docs-drift, s40].

  • 2026-05-29 (cross-project — BVAAU 7-agent config extract): Em đọc full 8 file D:\Dropbox\CONG_VIEC\BENHVIEN_A_AU\SOURCE_CODDE\.claude\agents\ ~22K. BVAAU split 4→7 trục research(2)/implement(2)/quality(3): investigator-api(blue READ external GetFly/Pancake docs) · investigator-codebase(cyan READ internal+sqlcmd) · implementer-domain(yellow WRITE Domain/**+Application/** only) · implementer-infra(orange WRITE Infra/**+Api/**+Web/**+Web.Reports React) · test-specialist(purple WRITE tests/** only NEW) · reviewer(red) · cicd-monitor(green). Boundary key: repo interface=domain, EF config=infra, test assertion=test-specialist (2 implementer KHÔNG viết test). 8-criteria REFUSE cả 2 implementer (schema/UX/cross-stack>2layer/bug-reasoning/<30min/first-time/spec ambiguity>20%). Token: ~1.35M/heavy (~6.5× solo) optimized ~700K; Agent fresh ~150K cache-write / warm ~50K / SendMessage 5-30K/turn / parallel SendMessage ⚠️2.25-3×. Tool diff CRITICAL: cả 7 BVAAU agent có 5 RAG MCP (search_memory+search_code+cross_project_search+store_memory+list_projects) vs SOLUTION_ERP hiện chỉ 2 (search_memory+cross_project_search) → BVAAU +3 (search_code BM25 saves Read full file + store_memory instant index + list_projects). Skill: BVAAU skills: frontmatter KHÔNG có, total skill=0 (Phase 0 all TBD) — SOLUTION_ERP 6 skill+preload MẠNH HƠN, giữ nguyên khi port. Curate rule: >25KB archive <YYYY-MM>.md, >50KB hard limit. Parallel patterns: A=investigator-api→DTO→(infra+domain parallel)→test→reviewer→cicd; B=4 sync job song song file-disjoint. Surprises: (a) VIPIX guide D:\...\VIPIX_MULTISITE_PROJECT\docs\guides\multi-agent-setup-guide.md KHÔNG tồn tại (glob toàn project miss) → "16 spawn ~1.49M" claim không verify được, đừng cite. (b) 3 inconsistency BVAAU file: cicd ghi cả .gitea/ (L25) lẫn .github/ (L159) workflow path; investigator-codebase MEMORY path /investigator/ mismatch tên agent; README "Setup checklist" L331 vẫn "4 sub-agent" chưa update 7. (c) BVAAU Phase 0 codebase RỖNG → config aspirational template chưa battle-test (vs SOLUTION_ERP 38 session proven). Recommend port: trục split + 8-criteria REFUSE + 5-category reviewer adversarial, GIỮ skill-frontmatter SOLUTION_ERP, ADD 3 RAG tool nếu MCP support. Token cost ~22K. Tag [cross-project, bvaau-agent-config, port-pattern].

  • 2026-05-28 (S37 Plan G-O3 Đề xuất pre-flight 4 task): Em spawn ~14K. T1 Enum: ApprovalWorkflowApplicableTypeApprovalWorkflow.cs:45-50 Mig 22 add — 3 value 1-based (DuyetNcc=1, DuyetNccPhuongAn=2, Contract=3) NOT 0-based. Mig 37 +1 value Proposal=4 (G-O3 first), reserve 5-8 cho G-O4..O6 future. T2 PE pattern intel (mirror skeleton Mig 38): main entity 25 field critical (Id/MaPhieu/Type/Phase 5-state/TenGoiThau/ProjectId/DepartmentId/DrafterUserId + ApprovalWorkflowId pin V2/CurrentStepIndex/CurrentLevelOrder + BudgetId/BudgetManual + RejectedFromPhase legacy + 8 nav list). LevelOpinion UNIQUE per-LEVEL NOT per-User (composite (PEId, LevelId)), FK Cascade Pe + Restrict Level, denorm SignedByFullName(200). CodeSequence 1 row per Prefix (NOT N rows per year): PE/YYYY/A + PE/YYYY/B riêng, 3 col Prefix PK+LastSeq+UpdatedAt, tx SERIALIZABLE. ApproveV2Async logic 7 step (load eager → group Levels by Order = Cấp OR-of-N → match actor.Id ∈ ApproverUserId + Admin bypass → log Approval + UPSERT LevelOpinion auto sync → F2 skipToFinal check matchingLevel.AllowApproverSkipToFinal advance tới last Step+last Level Phase giữ ChoDuyet → advance normal levelOrder++ trong Step → next Step reset 1 → DaDuyet terminal). T3 NamGroup Proposal: 3 entity TblRequest.cs (25 cols generic + SoTien decimal + NguoiNhanTien + TaiKhoanNganHang advance payment) + TblRequestConfig.cs (CSV ListApproval inline + IsDirectManager) + TblRequestListApproval.cs (forward mechanism qua NguoiChuyenTiepId/NgayChuyenTiep + ChapThuanHoanToan int). Verdict: SOL CLEAN-ROOM MẠNH HƠN — NamGroup generic Request KHÔNG phân biệt Đề xuất/Yêu cầu/Phép (1 entity cover ALL). SOL dedicated Proposal entity + Workflow V2 pin FK > NamGroup inline CSV JSON. T4 Mig 38 propose 4 bảng: Proposals (Code DX/YYYY/NNNN, Title/Desc/Category nullable FK + free text fallback, AmountEstimate decimal? optional, Status ProposalStatus 5-state mirror PE, DepartmentId/DrafterUserId, ApprovalWorkflowId pin ApplicableType=4 + CurrentStep/Level pointer + SLA) + ProposalAttachments + ProposalLevelOpinions UNIQUE (PropId, LevelId) + ProposalCodeSequences 1 row Prefix DX/YYYY. 3 decision points em main chốt: (1) CategoryId nullable FK + free text fallback (lesson Plan C drift 8 FK ZERO populated 1675 NV). (2) 5-state mirror PE NOT 7-state Contract (Đề xuất đơn giản hơn HĐ). (3) Dedicated ProposalStatus enum NOT reuse PurchaseEvaluationPhase (anti-pattern cross-module coupling). Surprises: (a) NamGroup TblRequest có SoTien + NguoiNhanTien + TaiKhoanNganHang advance payment — SOL có cần? Defer Mig 39 optional. (b) F1+F3+F4+F2 per-Level pattern Mig 29-31 — Proposal có nên mirror? Option B "đơn giản KHÔNG flag" tiết kiệm 3 chunk admin Designer. (c) Recommend gộp Mig 37+38 → 1 Mig AddProposalsAndExtendApplicableType (mirror Mig 20 Contract N-stage gộp). Token cost ~14K.

  • 2026-05-28 (S36 Plan G-O2 pre-flight Phòng họp 3 task): Em spawn ~10K. T1 NamGroup TblResource + TblBookingResource (NAMGROUP.Server\Data\Entities\TblPhongHop.cs 5-47): 2 entity LEGACY V1 reuse, KHÔNG dedicated MeetingRoom. TblResource 11 cols generic (Id long, GroupReSourceID, NameReSource, ListManager CSV NhanVienID, ListViewer CSV, Note, IsDelete int?). TblBookingResource 18 cols (ResourceID, Title, FromDate datetime giờ-phút, ToDate, ThanhPhan plain text NOT CSV, TrangThai int? -1=Rej/0=Pending/1=Approved/2=Cancelled, IsDelete int? NULL=active+1=deleted ZERO =0 rows, Note1 admin secondary, AcceptUser/AcceptDate/RejectUser/RejectDate). 5 gotcha NamGroup: (1) IsDelete filter (IsDelete ?? 0) != 1 NOT == 0, (2) TrangThai 4-state NO Completed, (3) ThanhPhan plain text NOT CSV NV ID, (4) Note1 admin only, (5) V1 ZERO overlap protection (37 overlap pairs prod 798 rows). Repo PhongHopRepository.cs:61-75 overlap app-level: b.FromDate < toDate AND b.ToDate > fromDate AND TrangThai NOT IN (-1, 2). CSV ListManager → manager approve. Conclusion: SOL Mig 36 CLEAN-ROOM mirror G-H2 verdict — KHÔNG port reason: (a) TblResource mix 4 group catalog generic, (b) ThanhPhan plain text yếu cho notification, (c) ZERO overlap V1 → SOL phải DB-level SERIALIZABLE tx. T2 FullCalendar v6 React (https://fullcalendar.io/docs/react): @fullcalendar/react MIT cho core + 3 plugin daygrid/timegrid/interaction. Premium chỉ Resource Timeline + Vertical Resource (NOT cần Plan G-O2). Drag-resize event = MIT @fullcalendar/interaction. Bundle ~150-200KB gz (bundlephobia 403). Alternative: NamGroup PhongHopPage.tsx:10-12 S50 hotfix CHỐT custom day-grid HTML NO lib install reason "saves install friction + bundle minimal" — 1 file ~600 LOC month-view custom grid 5-6 rows × 7 cols Sun-Sat. react-big-calendar MIT clean alternative nhưng semi-deprecated. T3 Schema Mig 36 propose 3 entity (KHÔNG 2): MeetingRoom (Id Guid, Code unique nvarchar(20), Name nvarchar(200), Capacity int, Location nvarchar(200), Equipment nvarchar(500)?, IsActive bit, IsDeleted, audit) + MeetingBooking (Id, RoomId FK Restrict, BookedByUserId FK Restrict, StartAt datetime2, EndAt datetime2, Title nvarchar(200), Description nvarchar(1000)?, Status enum int Confirmed=1/Cancelled=2/Completed=3, Note nvarchar(500)?, audit) + MeetingBookingAttendees join (BookingId FK Cascade, UserId FK Restrict, PK composite (BookingId, UserId), Notes nvarchar(200)?). Attendees mode JOIN TABLE (NOT JSON) reason: (a) notification push query indexed efficient, (b) FE picker multi-select shadcn reuse Users API, (c) audit "ai từ chối" future ready. Overlap check SERIALIZABLE tx + EXISTS WHERE RoomId=@r AND Status=1 AND StartAt < @newEnd AND EndAt > @newStart AND Id != @currentId → 409 Conflict. Recommend index IX_MeetingBookings_RoomId_StartAt composite range query. Surprises: (a) NamGroup s47 Plan 9.2 V1 reuse dựa 798 row prod data NOT scratch — SOL có lợi thế clean-room không legacy. (b) NamGroup community ưu tiên bundle size hơn dev velocity (custom HTML grid thay FullCalendar) — em main weigh trade-off ~150KB cost vs drag-drop UX. (c) TblBookingResource NO Title index — SOL must add IX. Recommend forward: (1) Mig 36 design 3 entity clean-room per propose; (2) FullCalendar v6 MIT fe-admin (manager view drag-drop) + custom day-grid HTML fe-user (book simple) — split UX 2 app per convention; (3) Skill ef-core-migration attach Implementer. Token cost ~10K.

  • 2026-05-28 (S36 startup audit — 3 task readonly factual report): Em spawn 1 lần ~12K token. Task 1 — MEMORY size 4 sub-agent: path actual project-level D:\Dropbox\CONG_VIEC\SOLUTION\SOLUTION_ERP\.claude\agent-memory\{agent}\MEMORY.md (em main provide path user-level C:\Users\pqhuy\.claude\projects\...\agents\ KHÔNG tồn tại — em correct path). Investigator 24.7KB/157 lines borderline · Implementer 36.4KB/419 lines PRIORITY curate · Reviewer 28.4KB/181 lines borderline · CICD 40.4KB/213 lines PRIORITY curate. Drift +12-15KB ALL 4 agent từ S33 startup baseline (cicd 25.5→40.4, implementer 28.6→36.4, reviewer 25.9→28.4, investigator 20.2→24.7) — heavy S33+S34+S35 entries chưa archive. Task 2 — Audit định kỳ status: docs/changelog/skill-audit-2026-05.md 6.2KB manual 2026-05-04 + skill-audit-2026-05-late.md 9.1KB early-trigger 2026-05-22 (drift +8 gotcha 41→49). Next scheduled 2026-06-01 (CLAUDE.md:60 confirm). Today 2026-05-28 còn 4 ngày → SKIP audit lần này. Cron solution-erp-skill-audit-monthly fire 9:00 AM ngày 1. Task 3 — Plan G- progress map 10 atomic (NOT 11 — Cấu hình + Hồ sơ NS gộp Phase 10.1):* G-H1 S33 (commit 5400983..79a8343 Run #237 PASS, 67 tables Mig 34) + G-H2 S34+S35 (commit 07b3f3b schema + 909655c BE + 021674a FE Run #244 PASS Mig 35). 8 pending: G-O1 Danh bạ (1 endpoint nhẹ nhất) · G-O2 Phòng họp Mig 36 FullCalendar · G-O3-O6 Workflow Apps cần extend ApplicableType enum +5 (Mig 37 first cookie-cutter Mig 22) · G-H3 Dashboard NS · G-P1 Chấm công GPS web Mig 42. NO DRIFT giữa feedback_phase10_namgroup_port.md (4 quyết định) vs migration-todos.md:637-792 (Phase 10 backlog). Recommendation forward S36: (a) Curate session PRIORITY cicd-monitor (40.4KB) + implementer (36.4KB) trước kick off Plan G-O1; (b) Reviewer 28.4KB defer S37 nếu không kịp; (c) Plan G-O1 phù hợp S36 sau curate (1 endpoint + 1 FE page). Surprise: Em main note "G-O1 Danh bạ S34 done" trong instruction — DRIFT thực tế. Migration-todos:696-700 G-O1 vẫn pending. Anh main confuse với G-H1 S33 + G-H2 S34/35. Token cost ~12K.

  • 2026-05-28 (S35 — Plan G-H2 Task 3+4 pre-flight HRM CRUD audit): Em spawn 1 lần ~8K token. Task 1 — Plan CA Chunk B precedent: SHA 06a441c "FE move 4 master pages 948 LOC byte-identical". 4 catalog page mirror fe-admin/master/{Suppliers,Projects,Departments,Catalogs}Page.tsxfe-user/. LOC actual: Catalogs=321 / Departments=160 / Projects=214 / Suppliers=253 = 948 LOC tổng. Pattern = single file inline list + create/edit dialog (NO split route /new). DataTable + PageHeader + PermissionGuard + 6 shadcn UI. Task 2 — NamGroup HRM ref MISS: Glob *Phep* *TimeOff* *NgayLe* *Ca* *Ot* → KHÔNG có entity dedicated. NamGroup chỉ có TblTimeOffConfig.cs 14 cols generic + TblTimeOff.cs 47 cols (request, Ngay1-10 + TypeNgay1-10 hardcoded over-engineered) + TblDmChung.cs 10 cols generic bucket. SOL Mig 35 entity design MẠNH HƠN: LeaveType có IsPaid + RequiresAttachment + DaysPerYear decimal(5,2) (NamGroup miss). Holiday composite UNIQUE Year+Date + IsRecurring (NamGroup không có). ShiftPattern WorkDays comma string + TimeOnly Start/End + BreakMinutes (NamGroup không có). OtPolicy 3-tier multiplier weekday/weekend/holiday + 3 cap day/month/year Luật LĐ VN (NamGroup không có). Kết luận: KHÔNG cần port field từ NamGroup. SOL clean-room design mạnh hơn. Workflow integration: NamGroup TimeOffConfig embed ListApproval JSON inline; SOL sẽ dùng ApprovalWorkflow V2 pattern khi G-O4 LeaveRequest land. Task 3 — SOL Master pattern: ProjectFeatures.cs 150 LOC + DepartmentFeatures.cs 128 LOC + CatalogsFeatures.cs 334 LOC (4 sub-entity Units/Materials/Services/WorkItems gộp 1 file mega). Controller layout: CatalogsController.cs 1 controller cho 4 sub-entity. Pattern Suppliers split (Suppliers/Dtos/Queries/Commands subdir) = legacy heavyweight scale, KHÔNG nên mirror cho HRM. Pattern Catalogs single-file mega = đúng cho HRM (4 simple catalog tương đương Units/Materials/Services/WorkItems). LOC estimate G-H2 Task 4 FE: LeaveTypesPage 200 + HolidaysPage 250 (Year filter + bulk roll-over) + ShiftPatternsPage 250 (WorkDays multi-select + TimeOnly picker) + OtPoliciesPage 220 (1 STANDARD constraint UI) ≈ 920 LOC ~ Plan CA Chunk B 948 LOC parity. Recommendation: Option B 1 mega HrmConfigFeatures.cs ≈ 600-700 LOC mirror Pattern 12-bis Catalogs. Reason: (1) 4 simple catalog cùng module HRM lifecycle parallel. (2) Pattern 12-bis cross-module entity cookie-cutter proven 2× (Plan CA Catalogs + Plan B Contract V2). (3) 1 controller HrmConfigsController.cs route /api/hrm/configs/{kind} mirror /api/catalogs/{kind}. (4) Constraints differ (Holiday composite + OtPolicy 1 STANDARD active) handle qua per-handler validation. Surprise: EF Configuration files riêng LeaveTypeConfiguration.cs + 3 file khác EXIST — KHÔNG cần mirror Application Features file split (Config riêng OK + Features mega OK). Cross-stack KHÔNG conflict. Token cost ~8K.

  • 2026-05-26 (S33 t1 — Plan G-H1 pre-flight NamGroup TblNhanVien audit):* Em spawn task A+B+C audit NAMGROUP.Server\Data\Entities\ ~10K token. Inventory 10 TblNhanVien bảng* (NOT 8 anh main estimate): 1 main TblNhanVien (105 cols!) + 9 satellite (QtCongTac/QtDaoTao/QuanHeThanNhan/KyNangViTinh/KyNangNgoaiNgu/KyNangKhac/QtHopDong/QtCongTacIn/QtPhulucHd). PK long Id (NOT Guid) — port phải convert. Soft delete IsDelete int? OR bool? (legacy inconsistent). Audit fields KHÔNG có ở satellite (chỉ QtCongTacIn có NhanVienTaoId/SuaId/NgayTao/NgaySua) — port phải fill từ BaseEntity. Main TblNhanVien 105 cols PERSONAL HEAVY: identity (CMND/HoChieu/MaSoThue/SoBhxh) + diachi (6 FK Tinh/Quan/Phuong x HKTT/TamTru + freetext fallback) + bank (SoTK/NganHang/ChiNhanh) + physical (ChieuCao/CanNang/NhomMau) + salary (LuongTN/LuongCB/PhepTrongNam/PhepTon/NghiBu/PhepThamNien) + BHXH (NgayThamGia/NoiDkkCb) + political (IsDangVien/IsHcmDoan/IsCongDoan + 3 Ngay*) + theme cols (BgmenuColor/MenuColor — SKIP UX-only) + 4 contact ng liên hệ + 14 FK catalog (DanToc/TonGiao/TinhTrangHonNhan/QuocTich/GioiTinh/TrinhDo/...). Drift discovered s49 Plan C 8 FK DiaChi cascade ADDED Sep 2025 but ZERO populated 1675 NV — entity drift expose. Tip: SOL Mig 34 nên design FK DiaChi NULLABLE + freetext fallback nvarchar(500) cùng tồn tại từ ngày đầu. Satellite simple: QtCongTac (12 cols work history external), QtDaoTao (16 cols + 4 FK catalog), QuanHeThanNhan (8 cols + FK), KyNangViTinh (3 cols MINIMAL — chỉ TenPhanMem string!), KyNangNgoaiNgu (4 cols + FK NgoaiNgu), KyNangKhac (4 cols freetext). Satellite contract HEAVY: QtHopDong (28 cols HĐLĐ — defer Plan H2), QtCongTacIn (16 cols internal position change — defer), QtPhulucHd (10 cols phụ lục HĐ — defer). DbInitializer GLOB NO MATCH — NamGroup KHÔNG seed demo data via DbInitializer pattern. SOL User existing đã có: FullName + DepartmentId + Position + PositionLevel + Email + IsActive. Skip 5 duplicate fields. Patterns proven NEW: (a) Skip-list aggressive cookie-cutter audit — Mig 34 chỉ port 5 satellite defer 4. (b) FK + freetext fallback dual-write pattern từ Plan C drift lesson. (c) MaNhanVien NV/YYYY/NNNN mirror PE CodeGen atomic Serializable. (d) Polymorphic Skill table — gộp 3 KyNang* thành 1 với Kind enum giảm 2 bảng. (e) 30 demo seed pattern reuse mirror SOL DbInitializer existing 30 user 1-1 link User.Id. Surprise: Theme cols BgmenuColor/MenuColor ở entity hồ sơ NS! NamGroup mix UX preference với business data — SOL SKIP, dùng UserPreferences riêng. Token cost ~10K.

  • 2026-05-26 (S33 startup — em main spawn em đầu S33 audit 4 sub-agent MEMORY + RAG hit rate verify): Em spawn 1 lần đầu S33 task A+B song song readonly. Task A audit 4 MEMORY file sizes: Investigator 20.2KB OK / CICD 25.5KB borderline > 25KB triggers curate flag / Reviewer 25.9KB borderline / Implementer 28.6KB OVER triggers curate priority. Cross-agent learnings ≥ 2 agent: (a) Smart Friend pattern 4× cumulative noted BOTH Reviewer (foundation 4 catches S22 #44 + S25 #48 + S29 Plan B ApplicableType + S29 DemoSeed gate) + CICD (Discovery #6 INFRASTRUCTURE vs DEMO seed catch Run #232 Hotfix SeedSampleContractWorkflowV2 out of DemoSeed gate) — pattern strong candidate Layer B promote OR add to docs/rules.md §10 review process. (b) Per-NV admin opt-in flag wire 10-surface-point noted BOTH Implementer Pattern 7 (4 flag cumulative Mig 29-31 + Mig 30 F4) + CICD MEMORY 10-point checklist foundation (line 142-160) + Reviewer Per-NV scope split + RAG memory user-level cross-ref. (c) Pattern 12-bis cross-module entity cookie-cutter mirror PE→Contract noted BOTH Implementer (line 178-200) + Reviewer Cross-module security validation mirror (S29 Plan B). (d) gotcha #48 SQLite tie-break noted BOTH CICD (line 40-45 detail) + Reviewer (Cat 5 lesson catch from CICD pre-deploy). Drift detected: (1) CICD MEMORY line 124-125 cite "Mig 31 latest" but actual repo Mig 33 prod (Plan B Contract V2 Mig 32+33) per Investigator narrative S29 + RAG hit STATUS. CICD recent activity correctly mentions Mig 32+33 deployed Run #232 but baseline header line 124-125 stale. (2) Reviewer line 130 cite "Migrations: 31 latest" but actual 33 — same baseline header stale post-S29 Plan B. (3) Test baseline 111 unchanged ALL 4 agents consistent OK. (4) Endpoints ~146 (Reviewer line 132) vs ~148 (Investigator line 137) — minor 2 endpoint delta drift. Curate recommend next session: PRIORITY Implementer (28.6KB > 25KB hard, archive 2-3 verbose entries q2) + CICD (25.5KB borderline, drop 1 oldest entry 2026-05-12 setup since baseline preserved foundation section) + Reviewer (25.9KB borderline, drop 1 oldest S25 entry duplicated in S25 wrap below). Investigator self OK 20.2KB headroom. Task B RAG verify 3/3 PASS all rerank > 0.7: Q1 Plan G NamGroup port phase 10 top hit HANDOFF.md rerank 0.848 PASS · Q2 gotcha 52 qdrant client search removed top hit investigator MEMORY S32 startup entry rerank 0.910 PASS (also gotcha doc 0.875 + memory user-level feedback_rag_bootstrap 0.863) · Q3 per-NV admin opt-in F1 F2 F3 F4 wire 10 surface points top hit HANDOFF.md S23 t4 rerank 0.684 BELOW 0.7 threshold WARN (semantic match correct, distance score boundary — RAG indexing for narrative cumulative entries reaches diminishing returns at 5+ session reinforcement). Recommendation forward em main S33: (a) Spawn Investigator pre-flight Plan G-H1 NamGroup TblNhanVien* 8 bảng audit per Phase 10.1 kick off plan; (b) Schedule dedicated curate session 3 sub-agents (Implementer priority) before next heavy plan kick off; (c) Update Reviewer + CICD baseline header Mig 31→33 + endpoint ~146→148 in next curate. Token cost spawn này ~10K (4 Read + 3 RAG query + 1 Bash + Edit MEMORY + final report).

  • 2026-05-26 (S32 wrap — em main proxy update final state): Session 32 đóng clean. Em chủ trì spawn em 2 lần S32: (1) startup verify ~10K (afaf6d52a6a59a844 alive) + (2) NamGroup audit pre-flight ~30K (a533c3e8ed4e03bfe hit limit 157K/72 tool_uses fallback em main solo audit). Em main solo audit NamGroup directly thay vì re-spawn: discovered NAMGROUP.Server\Data\Entities có 8+ TblNhanVien* (QtCongTac/QtDaoTao/QuanHeThanNhan/KyNangViTinh) + 4 bảng org chart (SoDoToChuc/SoDoKhoi/ChucDanh/ViTri) + Announcement/InternalDocument/TblMenu. Plan G 11 module port DOCUMENTED migration-todos với 4 quyết định chốt anh main (FULL 11 module + dbo single + Workflow V2 enum +5 + chunk per-module Plan riêng). S33 priority spawn em pre-flight Plan G-H1 Hồ sơ NS audit NamGroup TblNhanVien* 8 bảng + map fields → SOL EmployeeProfile schema (Mig 34 design 1 main + 5 satellite WorkHistory/Education/FamilyRelation/Skill/Document) — scope narrower 30 phút mục tiêu. Curate Plan A3: MEMORY archived 4 verbose entries q2 (S25 t1 5Q audit Bug Changelog + S26 Plan AG 5Q + S26 Plan AI RAG research + Plan B Contract V2 Q1-Q5 audit detail) → 27.7→19KB. Pending tasks anh main S33 SendMessage gọi em: (a) Plan G-H1 pre-flight NamGroup TblNhanVien* audit (PRIORITY HIGH first thing S33); (b) Plan B-Wrap test bundle pre-flight verify ContractWorkflowService ApproveV2Async test scenarios spec D-Bis trong migration-todos; (c) Phase 9 UAT smoke verify V2 contract create flow post-S29 deploy QT-HD-V2-001 workflow. Token cost wrap ~5K. Tag: [wrap, phase-9-to-phase-10, infra].

  • 2026-05-22 (S29 wrap — Plan CA + Plan B pre-flight 2 spawns + 3 patterns NEW): S29 close 2 big plans cumulative. Plan CA (Move Cấu hình danh mục admin → eoffice) 7 commits 06a441c..6eec8d7 push deployed Run #229+#230 PASS. Plan B (Contract V2 wire mirror PE V2 pattern Mig 22-26) 11 commits 58898e8..38f1c4d push deployed Run #231+#232 PASS. Investigator role 2 spawn: (1) Plan CA pre-flight audit (agentId a7ab5576c77ee3730, ~15K token): map 9 menu danh mục terrain + GOTCHA tree-inherit Catalogs↔Master + recommend chunk structure A/B/C/D. fe-user component parity verified (DataTable + PageHeader + PermissionGuard + 6 shadcn ui). DbInitializer SeedAdminPermissionsAsync admin role grant CRUD 27 menu key. Permission Matrix dynamic load /api/menus → tự reflect post-move. (2) Plan B pre-flight audit Contract V1 state (agentId abf91b30391fb0cdb, ~25K token): map Contract.cs 25 fields (V1 only) + ContractPhase enum 12 values (TraLai=98 + TuChoi=99 ready) + ContractWorkflowService.cs 220 LOC V1 only + sqlcmd prod 7 V1 contract (Phase 2-8 active workflow) + PE Mig 22-26 reference templates + impact assessment (COEXIST V1+V2, KHÔNG drop V1) + re-chunk 6 chunks (split A → A1 entity + A2 mig). 3 surprise: ApprovalWorkflows Prod ZERO ApplicableType=3 (Chunk A2 must seed sample) + RejectedAtStepIndex drift deprecated + ContractType 7 variants generic ApplicableType=3. Patterns proven NEW Investigator perspective S29: (a) 9-menu permission terrain map pattern (Plan CA) — Investigator inventory file paths + line ranges + component parity check + recommend chunk before delegate Implementer. ROI cao. (b) V1+V2 coexist boundary (Plan B) — KHÔNG drop V1 vì 7 prod contract pinned. Mirror PE Mig 22-24 spec. (c) Reference template paths cross-module mirror (PE → Contract V2): Investigator cite EXACT line ranges (PE Mig 23:14-31, Mig 24:14-17, Mig 26 UNIQUE composite, Service ApproveV2Async 446-634, 519-546 UPSERT, 774-783 ResolveActor) → em main + Implementer chỉ cần mirror rename entity. ROI rất cao saving 30%+ time. Anti-patterns observed: (a) Investigator KHÔNG verify endpoint exists end-to-end qua live curl — defer to CICD Monitor stage 4. (b) Investigator output sometimes verbose >700 words → em main hỏi cô đọng <500 next time.

  • Archived 4 verbose entries S25-S26-S29 → archive/2026-05-q2.md 2026-05-26 S32 curate: S25 t1 5Q audit Bug Changelog detail + S26 Plan AG 5Q PE List tree view + S26 Plan AI RAG 4 study cases (Cursor/Cline/Continue/Sourcegraph) + Plan B Contract V2 Q1-Q5 audit detail. KEY recommendations preserved in S29 wrap entry above (Plan B re-chunk 6 chunks pattern + ApplicableType=3 ZERO Prod seed flag + PE Mig 22-26 reference template paths).

  • Archived to archive/2026-05-q3.md 2026-05-27 S34 curate (em main proxy): S28 wrap Layer A governance internalized (3 rules + tag schema mandatory + 4-category default + NO self-authorize cross-project — absorbed forward into agent output discipline) + S27 wrap-up retrospective (pre-flight infrastructure audit must spawn Investigator lesson + S20-S26 spawn audit uncertainty flag) + 2026-05-22 curate session note + S25 wrap Bug 1+2 audit + 2026-05-11 setup baseline. KEY pattern absorbed forward: pre-flight infrastructure audit MUST spawn Investigator + scope-down SOLUTION_ERP self-discipline + tag schema [type, phase, bc-or-module] mandatory output.


🔄 Curate trigger

  • Memory size > 25KB → archive recent entries to archive/<period>.md
  • Duplicate entries detected → merge
  • Stale > 3 months → remove

Last curate: 2026-05-27 S34 em main proxy curate (post-S33 wrap, sequence 1/4) — archived 4 verbose entries (S27 wrap retrospective + 2026-05-22 curate session + S25 wrap + S11 setup) → archive/2026-05-q3.md. KEEP: S33 t1 Plan G-H1 pre-flight NamGroup audit (latest 10 bảng inventory + 4 decision schema), S33 startup audit (4 MEMORY size + RAG hit verify), S32 wrap (Plan G 11 module backlog), S32 startup (S31 RAG awareness), S29 wrap (2 spawn Plan CA + Plan B pre-flight + 3 patterns NEW), S28 wrap (Layer A governance). Patterns + Active workflow schemas foundation preserved untouched. MEMORY size before: 26 KB → after: target ~20-22 KB. Previous curate: 2026-05-26 S32 — 4 verbose entries → archive/2026-05-q2.md. Previous curate: 2026-05-22 — 10 verbose S21→S24 → archive/2026-05-q1.md. Next trigger: > 25KB OR Plan G-O1 Danh bạ kick off.