Files
solution-erp/.claude/agent-memory/investigator-codebase/MEMORY.md
2026-08-08 01:01:12 +07:00

61 lines
14 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Investigator-Codebase Agent — Persistent Memory
> **Persistent diary cross-session.** Auto-injected first ~200 lines at spawn (L1 HOT). Update BEFORE every stop; keep entries to 1 line (gotcha #53 truncation — hook hard-cap 24.4KB, curate S180: 24.9→~13KB). Verbatim entry dài → `archive/2026-08-curate-s180.md` + `archive/2026-0{5,6,7}.md` + `archive/_INDEX.md` (substring, Ctrl-F) + `runs/*/sub-*.md`. Renamed S39: investigator → investigator-codebase (internal; external → investigator-api).
## 🎯 Role baseline
Read-only INTERNAL audit SOLUTION_ERP. Tools: Read/Grep/Glob/Bash + 5 RAG MCP. Output: concise <500w + file:line. Skills: contract-workflow + permission-matrix + ef-core-migration.
- MINE: sqlcmd schema scan, EF/grep, controller/authz audit, migration diff, count grounding
- NOT: external docs/CVE/lib investigator-api · write implementer · test test-specialist · architecture decision em main
## 📌 Recent invest (1-line digest; verbatim → archive + runs)
- **S182 (08-08) ×Fable KHKK 8-nhóm AWF mirror DuyetNcc [`runs/2026-08-08-S182-khkk-awf-mirror-ncc/sub-invest-be-fable.md`]:** BE generic ~85% 8 workflow seed `KHKK-N{n}` CÙNG ApplicableType=10, phân biệt bằng CODE (`DbInitializer.cs:549-687`, idempotent per-Code CỐ Ý khuôn per-type) bất biến only-1-active-per-type VỠ TỪ SEED + POST version mới deactivate CẢ 8 (`ApprovalWorkflowV2AdminFeatures.cs:339-343`); 9-checkbox = 9 cột per-Level dùng chung mọi type nhưng KHKK runtime CHỈ đọc F5 (`ContractSigningPlanWorkflowService.cs:276`) 6/9 tick cho type-10 = #78-class cờ-nằm-im; bypass rào-(v) 2-bước (UpdateDraft re-pin `ContractSigningPlanFeatures.cs:603-607` chỉ check type, không re-check group-match); DELETE version 0 usage-check + `DbUpdateException` KHÔNG được middleware map FK Restrict nổ 500 không phải 409 (`GlobalExceptionMiddleware.cs:39`); 32 policy `AwV2_KhkkN*` 0 consumer BE (0-hit Api + control-dương `KeHoachKyKet` 29-hit cùng path) mirror y 2 key `AwV2_DuyetNcc*` ; FE 8 route KhkkN đổ landing chung (`TYPE_CODE_TO_INT` thiếu key). #53 cắt return giữa phiên artifact đổ-ruột-liên-tục cứu trọn, 0 mất. Tag `[s182, seed-code-family-cung-type, khkk-runtime-chi-F5, policy-menu-only, dbupdate-500]`
- **S180-W1a (08-07) kiểm-kê MÁY-ĐỌC-TÊN [`runs/2026-08-07-S180-adap-upgrade-pack-phased/sub-w1a-mayd-octen.md` 44.9KB]:** 14 đoạn máy (11 vỡ-CÂM · 3 ồn · **0 tự-thích-nghi**) · BÁC 2 (`detectors:1716`+`:1679` = CHÚ THÍCH không phải ; `applied-eval-nokey.ps1` = 0 file-IO, control-dương mfe-eval=14). **Luật rút ra: nhóm tên sạch CHÍNH XÁC tới độ sâu máy KIỂM, không sâu hơn 1 nấc** STOP-HARD KHÔNG cần (`detectors:1639` chỉ INFORM `session-<N>` sạch 12/12); cần **máy TỪ CHỐI**, *đọc-rồi-liệt* (`$unmapped:1109`) + *chấp-2-tên* (`-or :1660`) + *[skip] not found* đều để tên trôi. 🔴 `memory-selfimprove-audit.ps1:298` còn dùng `-Filter 'sub-*.md'` = ĐÚNG bug C11(b) đã @S159 `detectors:1102` **vá tệp A quên tệp B**. Bất biến ngầm 0-máy-kiểm: `agents/<role>.md`.BaseName `agent-memory/<role>/`. Miễn-trừ 5 vùng đóng băng nuốt **73,2% kho .md (1131/1545) + 90,7% lệch đã biết (225/248)** máy soi quét .md trả 0-hit nghĩa; đường thoát = quét **231 tên vật-bộ-máy, 0 miễn trừ**. `CLAUDE.md:151` khớp 64/159=40,3% đĩa, 0 máy chặn, sống nhiều tháng. Tag `[s180, sach-toi-do-sau-may-kiem, va-tep-A-quen-tep-B, mau-so-sau-mien-tru]`
- **S180 (08-07) ×Fable fit-map 4-thư upgrade-pack 7GĐ [`runs/2026-08-07-S180-adap-upgrade-pack-phased/sub-invest-fitmap-S180.md`]:** PHỦ-ĐỦ 7GĐ/12TC/9LỖI. Nghề: hash mesh CHỈ tin máy canonical `scripts/stamp_verify.py` (tự chế MISMATCH cả 4 = suýt phán tamper sai) · TÔI = vai 7/7 dính #53 + bị bắt LỚP-7 tự-giẫm (202K đọc/7KB đĩa) "đổ ruột TRƯỚC đo SAU" cứu; tỉ-lệ byte-đĩa/token-đọc = tín hiệu giám sát · xung đột duy nhất gói: SE exit-0-advisory (`governance-detectors.ps1:1963`) hub cổng-chặn-mã-lỗi VƯỢT-KHUNG · GĐ-5 gần xong nhất / GĐ-4 hổng nhất (0 sổ-yêu-cầu-anh, 0 chấm-điểm) · bác-một-phần lead: `pull_warn_days` trống = CỐ Ý owner khai (`check-email.md:48`) ghost-wire. Tag `[s180, stamp-verify-canonical-only, lop7-tu-giam, exit0-vs-gate]`
- **S175 (08-05) ×Fable cột DỰ ÁN ma-trận NS [seed on-behalf; `runs/2026-08-05-S175-duan-budget-column/`]:** BÁC 2 tiền-đề lead cột = CHỖ-CHỪA-SẴN (`e33481e` cùng-commit comment `PeWorkItemBudget.cs:19`, KHÔNG phải di-chứng Mig50) · `—` = 11 ô/app không phải 3; phả-hệ đo bằng commit-sinh-ra + comment cùng commit, đừng suy từ khoảng-thời-gian-gần. `Project.BudgetTotal` sống từ Mig-2 nhưng Dev 61/69 NULL = "cơ-chế đúng dữ-liệu không có" lần 7. Spawn TASK-RỖNG cứu bằng run.md trên đĩa. Tag `[s175, pha-he-commit, artifact-dia-cuu]`
- **S171 (08-04) ×Fable KHKK-UI-mirror-PE [`runs/2026-08-04-S171-khkk-ui-mirror-pe/` 44.8KB]:** VERDICT 27-giống/6-buộc-khác/8-gap; §0 đính-chính ground-truth lead TRƯỚC §1 (nghề đúng); bị 3 lane reviewer lật: miễn-trừ 63, 6 acceptance gãy khi chạy thật **đầy-đủ ≠ đúng, invest 44KB không thay được reviewer đối-kháng**. Tag `[s171, day-du-khong-bang-dung]`
- **S160 (07-29) dry-run toàn-trình HĐ-cứng 2-lane [`runs/2026-07-29-S160-khkk-dryrun-plan/`]:** `Hdc_*` = 7-leaf-per-ContractType (`DbInitializer.cs:1862-1867`, lead sai 2 grounding) · KHÔNG phase KyCung (GĐ4 = DERIVE sau terminal 9, 0 mig) · 🔴 `DeleteContract` guard so SỐ `Phase >= DangInKy` chặn xóa cả 9/10/98/99 · mặt tấn công = Reject-trước-guard `ContractWorkflowService.cs:49-66` · "MB" codegen không gốc RG-001 · prod Contracts = 0 active/0 deleted (sổ "7 V1" stale). Tag `[s160, delete-guard-numeric, reject-truoc-guard]`
- **S158 (07-28) ×Fable day-wake-probe-first [seed on-behalf; `runs/2026-07-28-S158-day-wake-probe-first/`]:** return CLEAN giữa closeout 7/8 lane #53 khác biệt = ghi-đĩa-từng-phần + verify-RUỘT trước return. BÁC 2 tiền-đề lead bằng **cửa-cho-verdict-ngược** (mạnh hơn lập luận nguyên tắc); anchor = **carrier-commit** `git log --diff-filter=A -1 -- <marker>` sống-sau-squash; **đo BYTE cấm quy token** (`tiep_reload` = 122.115 B / 5 nguồn). Tag `[s158, carrier-commit-anchor, byte-khong-token]`
- **S157 (07-28) KH-ký-kết b.712 [`runs/2026-07-28-S157-ke-hoach-ky-ket-hd/`]:** O-1 tái dùng khung V2 + 7 bảng `ContractSigningPlan*` + `ApplicableType=10`; 🔴 twin-bẫy: **Proposal-lite ApproveV2 PHÁ OR-of-N** (`ProposalFeatures.cs:427-439` flatten + `ElementAtOrDefault`) KH service PHẢI copy `ContractWorkflowService.ApproveV2Async:217-394`; ISO 9-bước ContractPhase 1:1; #53 skeleton-chặn @202K Edit-liền-tay từng mục. Tag `[s157, proposal-lite-breaks-or-of-n]`
- **S156 (07-27) BCH post-CEO b.721 [`runs/2026-07-27-S156-bch-post-ceo-flow/`]:** verdict LAI 1321 tái dùng Contract (7 dòng LEGACY `ContractPhase.cs:11-13` = trạm gỡ cố ý) · 7-12 dựng mới; chuỗi "cơ-chế đúng thứ-đi-qua-không-có": cầu PE pin V1 (`CreateContractFromEvaluationFeatures.cs:68-71`) · `GetEligiblePhases`+inbox 100% LEGACY approver V2 ChoDuyet · SLA V2 hardcode AddDays(7)×3 · notify chỉ Drafter. Bắt lead sai 12-enum/7-LEGACY. Tag `[s156, eligible-phases-legacy-only]`
- **S155 (07-27) PE xóa-phiếu 4 lượt [`runs/2026-07-27-S155-pe-delete-approver/` + archive/2026-07.md]:** menu = SEED-DB 6-chỗ-mirror, đổi KEY = mồ côi 13-row/key giữ key đổi label · `?type=1&phase=7` chạy được hôm nay 0-route-mới · 🔴 WF-V2 **0 lệnh Update** sửa cờ = POST version mới = **Id mới mà phiếu pin Id cũ (F17)** ChoDuyet kẹt vĩnh viễn, 0 backfill re-pin; con trỏ LAI Bước=INDEX Cấp=ORDER ranh an-toàn = không đổi tập Order; OR-of-N xác nhận `:689` (comment `ApprovalWorkflow.cs:81-82` SAI) · `Department.ManagerUserId` 0/10 Dev + 2 FE hardcode null tự-xoá. Tag `[s155, wf-v2-no-update-cmd, f17-new-id-unreachable, menu-seed-db]`
- **S153 (07-26) ctx soft-memory spec [fable-real, `runs/2026-07-26-S153-ctx-adopt/`]:** SE 0 content-ts-reader sống rào-2 canonical `_TS_KEY_RE` đặt session_ctx.py, máy-7-phép = EXTEND python (tái dụng `_SECRET_RES` 1-nguồn); `secrets_sweep` rglob trọn session-dir; `_mind` mới-nhất-ở-TRÊN `_context` FLOW-ở-CUỐI; C11(b) filter khiến tên `sub-ctx-audit-*` lọt lưới. Tag `[s153, ts-reader-absent, one-source-regex]`
- **S149S152 (07-2425) 10-invocation + R1 [lead on-behalf; `runs/2026-07-24-S149-*/` + `runs/2026-07-25-S149-adap-backlog/`]:** chẩn-đoán "SE = rules-đủ MÁY-THIẾU" (0 script GHI counter "đo rồi như chưa đo" ×3) đứng qua gate spec bookend M1-M9; #53 3 sub-class (ngược-#53 · kinh-điển · mất-cả-hai); ghi-đĩa-trong-lúc-làm = CẦN KHÔNG ĐỦ. R1: **KHÔNG fabricate — uncertain + reason; mọi số kèm lệnh**. Tag `[s149, rules-du-may-thieu, s152-no-fabricate]`
- **S148 (07-23) PE tree DUP project by-space:** `FLOCK 01`/`FLOCK01` = path-A TWO real Project rows diff-by-space; tree groups `p.projectId` GUID (`PurchaseEvaluationsListPage.tsx:192-197`); CRUD zero-trim (`ProjectFeatures.cs:80/:95/:138` exact `Code==`); seeds emit ONLY no-space (`SeedRealMasterDataAsync:2776` UNGATED); blast 3 bảng ProjectId, chỉ `PeWorkItemBudgets` UNIQUE filtered; direction KEEP no-space RETIRE space; soft-del survivor seed RE-CREATES (#75/#76); prod UNVERIFIED (SSH chết khi SQL-client load S134/S148). Tag `[s148, dup-by-space, no-normalize-crud]`
- **S147 (07-23) PE attach TraLai edit-block:** FE-ONLY (BE zero phase-guard, `PurchaseEvaluationsController.cs:15` class-trần; gate = raw `readOnly` prop `:3555/:3577`; List detail HARDCODE `readOnly=true` `:574/:669`); BE no-guard CỐ Ý (S78); fix = `attachEditable=isDrafter&&isEditablePhase`. Tag `[s147, fe-only-screen-gate]`
- **S133-S141 (07-1620) gộp [archive/2026-07.md + runs]:** S141 adap 5-lane pin regex sha-extraction + roster-count 3-tầng · S138 delta-hẹp PHẢI grep landing-site luật SỐNG · S134 lũy-kế row1 PrevSubmitted ĐÃ gồm ChoDuyet (`PeBudgetAccumulator.cs:42-48`) · S133 freeze-at-DaDuyet 4-assignment Mig67 · S128 RAG config in-repo · S126 worker-pin 14/14 no-tieropus lead=Fable · S125 verifier-suspect-first · S122 orphan đo TÊN không NỘI-DUNG.
- **S116/S117 (07-13) PE neg-quote + giá-chốt RANGE [fable]:** neg-quote FE-ONLY (quote sống `details[].quotes` KHÔNG `suppliers[].quotes`); ApprovedPrice WRITE 1-site `ApplyApprovedPriceOnFinalize`; HĐ-gen KHÔNG đọc ApprovedPrice (GiaTri=SUM IsSelected); endsBeforeCeo=config-lie #78.
- **[archived archive/2026-07.md + git]** S87-S114: PE recon (multi-winner Mig65 · WinnerQuoteTotal DERIVED · V2 routing LINEAR) · Supplier-import-v2 · S105 BVAAU auth RCA · S104 30-field · S98-S101 harness · Office/HRM recon. Ctrl-F `_INDEX.md`.
## 📋 Patterns proven
### Schema scan sqlcmd
```
sqlcmd -S "(localdb)\MSSQLLocalDB" -d SolutionErp_Dev -Q "..." # runtime API (primary)
sqlcmd -S "(localdb)\MSSQLLocalDB" -d SolutionErp_Design -Q "..." # ef tooling
```
Prod: `ssh vietreport-vps` powershell-wrapper **SSH session DIES khi SQL-client load** (S134/S148); prod-DB unverifiable đường này flag + đưa query cho implementer. **2 LocalDB distinct.** Queries: `sys.columns/indexes/tables`, `__EFMigrationsHistory`, dup-detector `REPLACE(Code,' ','')`.
### Controller / wire-claim audit
- Grep `\[Route\("api/[a-z]+"\)\]` · `\[Authorize(Policy="…"` per-action (gotcha #44 silent-403; class-trần = no phase-guard S147) · `// Mock` / `alert(` / `setEditing(null)` wire bugs.
### Mesh / governance đo
- Hash thư mesh: `python scripts/stamp_verify.py <file.md>` CẤM tự chế phép băm (S180).
- 0-hit PHẢI kèm control-dương cùng thước; đếm phải xem format file trước khi viết regex (S180 gotcha-count 2 thước hỏng).
- Máy đo sẵn: governance-detectors (exit-0 advisory, TOTAL INFORM 2 dòng) · nhip-no-probe (đèn nợ 4 cửa) · session-counter-tick + h24-signal-write (fail-loud thật) · closeout-sentinel (verdict-line) · spawn-model-audit · memory-archive-gate A7.
### Memory cross-reference
30+ user-memory `C:\Users\pqhuy\.claude\projects\D--…\memory\MEMORY.md`. Key: designtime_runtime_db · workflow_fanout_reliability · canonical_spec_over_broadcast · root_cause_over_symptom · cardinality_change_grep_consumers.
## ⚠️ Anti-patterns
Skip MEMORY update · Vague "seems/probably" · Missing file:line · >500 words report · ❌ Scope drift sang architecture rec · ❌ Multi-line MEMORY entries (hook hard-cap 24.4KB) · ❌ Đọc nhiều đổ đĩa ít (LỚP-7 S180 — đổ ruột TRƯỚC đo SAU).
## 🧠 SOLUTION_ERP context (numbers canonical → docs/STATUS.md; re-ground don't trust)
- **DB:** Dev `SolutionErp_Dev` · Design `SolutionErp_Design` (2 LocalDB distinct — memory `feedback_designtime_runtime_db`) · Prod `.\SQLEXPRESS`/`SolutionErp` via SSH `vietreport-vps`.
- **Mig path:** `src/Backend/SolutionErp.Infrastructure/Persistence/Migrations/*.cs` (NOT root). MỌI count (mig/bảng/endpoint/test/gotcha/menu/policy) → `docs/STATUS.md`, KHÔNG neo ở đây (bản cũ neo stale = LỚP-5; "Mig 67 last" từng ghi ở đây đã sai — nay ≥71).
- **Tech:** .NET 10 Clean Arch + CQRS MediatR + EF Core 10 + 2 React Vite TS (fe-admin :8082 / fe-user :8080) + SQL Server + Gitea CI (`/actions/tasks` NOT `/runs`, cache ~2min #46) + IIS. Prod: api/admin/eoffice.solutions.com.vn.
- **Auth test:** `admin@solutions.com.vn/Admin@123456` (full) · `nv.test@solutions.com.vn/TestUser@123456` (Drafter).
- **Workflow V1/V2 chi tiết + state PE 5 + TraLai 4-mode + seeds gating:** → skill `contract-workflow` + verbatim block trong `archive/2026-08-curate-s180.md`.
## 🔄 Curate log
- **S180 (08-07):** hook hard-cap 24.9→~13KB — S171/S160/S157/S156/S155×2/S149/S152/S158/S175 entry-dài + context-blocks verbatim → `archive/2026-08-curate-s180.md`; mọi entry → 1-line.
- **S155 (07-27):** 20.7→~17.1KB gộp S122-S141. · **S148 (07-23):** 28.2→~14KB. · **Prev:** S125/S71/S70/S40. Verbatim byte-exact ở `archive/`.