18 KiB
Investigator-Codebase Agent — Persistent Memory
Persistent diary cross-session. Auto-injected first ~200 lines at spawn (L1 HOT). Update BEFORE every stop. Tiered Memory v1: L1 HOT soft-cap ~30KB · L2
archive/on-demand · L3 RAGsearch_memoryjust-in-time. Keep entry ≤ 1.5K chars (gotcha #53). Full verbatim history pre-S40 → gitd2f52ba+archive/2026-05-q1..q4.md+archive/2026-06.md. 🗺️ Lookup map:archive/_INDEX.md— 1 dòng/bản-ghi + con-trỏ substring (sha-keyed, Ctrl-F fallback); đọc verbatim +2026-0{5,6}.gist.mdtheo nhu cầu. S80 curate: moved 15 recon entries S65→S76 + 2× 06-20 → archive. Renamed S39: investigator → investigator-codebase (internal half; external → investigator-api).
🎯 Role baseline
Read-only INTERNAL audit SOLUTION_ERP codebase. Tools: Read, Grep, Glob, Bash + 5 RAG MCP. Output: concise findings <500 words + file:line refs. Skills: contract-workflow + permission-matrix + ef-core-migration.
🚫 Split boundary (S39)
- ✅ MINE: internal SQL/EF/grep/reference mirror, sqlcmd schema scan, controller audit, migration diff, count grounding
- ❌ NOT: external docs/CVE/lib →
investigator-api· write → implementer · test → test-specialist · architecture decision → em main
🆕 Recent invest (S112-S114 stubs — verbatim → git history + archive/2026-07.md)
- S114 (07-12) PE multi-winner PER-HANG-MUC (fable-clone): Mig58/59 multi-winner = WHOLE-SUPPLIER (
PurchaseEvaluationSupplier.IsWinner);Quote.IsSelectedper hang-muc×NCC = latent-hook Mig12 nay LIVE (Mig65 backfill re-key winner-truth IsWinner→IsSelected = CARDINALITY-CHANGE #2). winnerQuoteTotal=SUM(Quote WHERE IsSelected)PeFeatures.cs:1188. #1 open: N-win 1 hang-muc split KHOI-LUONG hay full-price (schema thieu per-winner volume). Tag[s114, pe-multiwinner-per-hangmuc, quote-isselected-live]. - S113 (07-12) Supplier import v2 (5-lane ensemble): selection consumers qua ListSuppliersQuery (
PeDetailTabs:2222+ContractCreatePage:321+dashboard); chot IsPublic-bool + dedup-MST+Code + fail-closed default. Prod 37 NCC. 1 lane #53-garble→em-main recover. Tag[s113, supplier-import-v2, ma-ncc=code]. - S112 (07-12) Supplier Excel-import + PE sign-off (fable-clone): Supplier 27/27 bijective (Mig62 SHIPPED prod); dedup Code CI-collation → normalize-case TRUOC store; PE bypass = go/gate
ApplyDrafterBypassOnSubmitAsync; EDGE-5 drafter-forge-Reject REACHABLE. Tag[s112, supplier-mapping, pe-bypass-a1, edge5-reachable].
📋 Patterns proven (apply confidently)
Schema scan via sqlcmd
sqlcmd -S "(localdb)\MSSQLLocalDB" -d SolutionErp_Dev -Q "..." # runtime API (primary)
sqlcmd -S "(localdb)\MSSQLLocalDB" -d SolutionErp_Design -Q "..." # ef tooling
ssh vietreport-vps "sqlcmd -S .\SQLEXPRESS -d SolutionErp -U vrapp -P '...' -Q '...'" # prod
Queries: sys.columns, sys.triggers, __EFMigrationsHistory, COUNT(*), sys.indexes.
Gotcha 2 LocalDB distinct (feedback_designtime_runtime_db): _Dev=runtime (appsettings.Development), _Design=dotnet ef default. Prod password fallback C:\inetpub\solution-erp\api\appsettings.Production.json khi $env:PROD_DB_PASSWORD empty.
Controller / wire-claim audit
- Grep
\[Route\("api/[a-z]+"\)\]enumerate controllers ·\[Authorize(Policy = "..."per-action policy (gotcha #44 silent 403 class-level quá strict) - Grep
// Mock/alert(/setEditing(null) // close UI— wire claim bugs ·IActionResultvsActionResult<T>
Smoke verify catalog
Bearer từ POST api.solutions.com.vn/api/auth/login → status matrix expected vs actual + file:line evidence.
Memory cross-reference
30 user-memory tại C:\Users\pqhuy\.claude\projects\D--...\memory\MEMORY.md (index). Key: per_chunk_commit · uat_skip_verify · designtime_runtime_db · per_nv_permission_scope · ef_migration_backfill_reorder · workflow_fanout_reliability · canonical_spec_over_broadcast (S79).
External research → DEFER investigator-api (split S39)
⚠️ Anti-patterns
❌ Skip MEMORY update · ❌ Vague "seems like/probably" · ❌ Missing file:line · ❌ >500 words · ❌ Scope drift to architecture recommendation (em main decides)
🧠 SOLUTION_ERP context essentials (S80 verified — re-ground từ docs/STATUS.md canonical)
- DB: Dev
SolutionErp_Dev· DesignSolutionErp_Design(distinct) · Prod.\SQLEXPRESS/SolutionErp/vrappvia SSHvietreport-vps - Migration path:
src/Backend/SolutionErp.Infrastructure/Persistence/Migrations/*.cs(⚠️ NOT root/Migrations/). 57 mig, lastAddPeSuggestedPriceNotes. - Counts S80 (canonical docs/STATUS.md): 57 mig · 88 SQL tables (count
.ToTable()ModelSnapshot NOT DbSet) · ~253 endpoints · 68 FE pages · 54 menu keys (BEMenuKeysconst) · 354 test (45 Domain + 309 Infra) · 71 gotchas (format### N.) · 30 user-memory · 6 skills · 11 sub-agents (all-inherit H8) - Tech: .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 CI + IIS
- Prod: api/admin/eoffice.solutions.com.vn · Gitea
git.baocaogiaoduc.vn/vietreport-admin/solution-erp(Actions API/api/v1/repos/.../actions/tasksNOT/runs404, cache stale ~2min gotcha #46 — cross-check VPS mtime). Bundle live adminCsJetgZH/userBVS0ApIm(Run #330). - Auth:
admin@solutions.com.vn/Admin@123456(full) /nv.test@solutions.com.vn/TestUser@123456(Drafter). ResponseaccessToken+refreshToken+user. Password ≥12 chars.
🔄 Active workflow schemas (V1 + V2 coexist post-S17)
- V1 Mig 21 flat —
WorkflowDefinitionpin PE/Contract cũ. Match Dept+PositionLevel. - V2 Mig 22-31 —
ApprovalWorkflowpin PE/Contract mới, matchApproverUserId1-1 OR-of-N cùng Cấp. Steps (Phòng) > Levels (Cấp). PE + Contract đã wire V2 (Mig 32+33 S29). Proposal V2 (Mig 38). WorkflowApps skeleton (Mig 39).- Mig 25 IsUserSelectable · Mig 26 PE LevelOpinions UPSERT · Mig 29 Allow* per-NV · Mig 30 F4 AllowApproverEditBudget · Mig 31 SkipToFinal→ApproverLevel · Mig 53 cờ-gấp+CeoApprovalThreshold · Mig 54 giá-đề-xuất PRO/CCM+giá-chốt · Mig 56 ProInitial/ProAdjust · Mig 57 ghi-chú-giá.
- State machine PE 5 trạng thái: Nháp / Đã gửi duyệt / Trả lại (TraLai=98) / Từ chối (REMOVED-S60 hard-guard) / Đã duyệt
- Mode Trả lại 4 option per-Level: OneLevel (lùi 1 Cấp) / OneStep (lùi Bước trước) / Assignee (pick NV đã ký) / Drafter (Phase=TraLai). 3 mode đầu giữ ChoDuyet lùi pointer. Admin bypass
level.Allow*.
📅 Recent activity (compressed — full verbatim → archive/2026-06.md via archive/_INDEX.md)
-
[→ archive/2026-07.md] 2026-07-13 PE negative-quote 2× LENS (Budget-consumers + edge/precedent/test) — key giữ: budget-not-mutated-by-quote (architectural) · submit-guard
Sum()<=0:206duy-nhất reject · no-quote-validator · parseVnd strip-minus · giaTri-âm bypass validator · gotcha #81 orthogonal-dấu. Executed S116; anchors sống trong S116/S117 entries. -
[→ git 07-12 · superseded by S115 entry above] PE per-HANGMUC multi-winner LENS BE-consumer-audit: 3 cardinality axes —
SelectedSupplierIdsingle (legacy) · Mig58IsWinner=WHOLE-SUPPLIER liên-danh ·Quote.IsSelectedper hangmuc×supplier (S114 made LIVE). 5 money consumers keyed off IsSelected now (winnerQuoteTotal/submit-guard/ccm-threshold/giaTri/budget-block-B). ~6 test files. Tag[pe-multiwinner, per-hangmuc, quote-isselected, cardinality]. -
[→ git 07-12] Supplier-import-v2 LENS-3 FE-dialog-UX: SupplierImportDialog+SuppliersPage SHA-identical 2-app; dialog 2-step preview→confirm round-trips
preview.rows→ per-row edit feasible;ExpectedHeaderTokens30-token bakedSupplierExcelImportService.cs:35-68= template single-source; Mã NCC=Code; import authz-mismatch BE[Roles=Admin,CatalogManager]vs FESuppliers/Createopen. Tag[s112, supplier-import-v2, fe-lens3, import-authz-mismatch]. -
[→ git+session-log 07-07] S105 BVAAU cross-repo auth RCA: Q1 root-cause = FE Home MÙ session (bundle cũ relative
/apitrên site TĨNHweb.configloại^/api/→/api/auth/me404 → anonymous); fix API_BASE-absolute51c69fbLIVE. Q2 CRM1 hở 2 tầng (FE soft + APIenforceCrmGate:false) → flipAUTH_ENFORCE_CRM_GATE=true. Q3 Zalo "User_ID" KHÔNG có UI. Class "hub+site-tĩnh relative-/apichết im prod"; #53-garble-7 → SendMessage-resume recover. (verbatim → archive/2026-07.md) -
[→ 07-12 LENS-3 entry above + git 07-06] S104 Supplier 30-field 🅰️ schema-invest WF
wf_5ac2cdb0: SUPERSEDED anchors giữ: ClosedXML 0.105.0 = Excel-standard (KHÔNG OpenXml-raw,csproj:8); reuse-existing-cols>parallel;UpdateSupplierCommand.cs:49-57blind-set=latent#73; seed fill-nulls-if-exists (DbInitializer.cs:2781);SupplierDtohand-projected 2-site (GetSupplierQuery.cs:21+ListSuppliersQuery.cs:48-50);Dialog.tsx:48max-h-70vh; extractui/PathLink.tsx. Chốt Mig 62 +18 nullable. (verbatim → archive/2026-07.md) -
[→ git+session-log 07-03 + adap-reports] S101 H19-adopt Lane-2: map reviewer=review-gate / investigator=ground-truth-lane; 12-pt tier-checklist ALL✅ (11/11 inherit, C3 no-
[1m]-in-frontmatter); toggle-marker MUST copy.gitignore:87last-match placement; VACUOUS-MET all-inherit+Fable. (verbatim → archive/2026-07.md) -
[→ git+session-log 07-02 + adap-reports] S100 H18-adopt WF1: ⭐ ghost-wire-class config-key-defined-but-unread (
budget.json:54-55script re-hardcode same-value→no-flag; catch=grep-key-across-scripts); cron=ghost-wire (CronList=0);_ledgerorphan-catch 0/15-lifetime. (verbatim → archive/2026-07.md) -
[→ git 07-12 · Mig64 IsPublic shipped since] Supplier import-v2 LENS-4 public/visibility recon: 3 SELECTION consumers ALL hit
GET /suppliersListSuppliersQuery (SuppliersPage:83 · PeDetailTabs:2222 · ContractCreatePage:321); DISPLAY-of-existing joins by stored SupplierId MUST NOT filter (ContractFeatures/PeFeatures/Dashboard); write-guard backstopsContractFeatures.cs:64+PurchaseEvaluationSupplierFeatures.cs:49. Rec fail-closed default + storedIsPublic bit. Tag[s112b, supplier-visibility, fail-closed-default]. -
[all verbatim → archive/2026-07.md] S98 verify-lane (detector 28→25, 8 derived-stale=FP vs canonical 61/89/440/79; grep exact misses README variant) · S97 feedback-audit (#77/#78/#79
gotchas.md:1301/1317/1325; #53-garble×6=cicd MEMORY-self-target ~17.5KB; Mig60 wrong-table Approvals→Mig61 Changelogs) · 07-01 Supplier-predecessor SUPERSEDED by 07-06 · S93 MFE denom=marks/AS/guards dedup-AS-xref=29, coverage exact-id OR ≥2-content-word. -
PE FROZEN-Mig59 patchwork + go-live recon cluster (S87→S89, 8 entries verbatim →
archive/2026-06.md): key catches — AREA-4 LATENT #73-class BUG HoSoLink absolute-setPurchaseEvaluationFeatures.cs:280but PeHeaderForm PUT OMITS→clears (2 PUT mutually destructive, no preserve-test) · AREA-3 AllowApproverFinalize AUTO(Mig58)+finalizeByCcmDelegation OPT-IN(Mig54) coexist AUTO-first, ApplyApprovedPrice allow-list {Ncc,ProMin,ProMax,Ccm} · AREA-2 budget-matrix band-aidPeSuggestedPriceFeatures.cs:153-199PRO=drafter vs CCM=role authz-asymm · AREA-6 FE all 6-comp+3-pages SHA-mirror 2-app, #70 stale-echo · S89 AllowApproverFinalize-NOTE GAP BE-field-MỚI (flag onlycurrentLevelOptions, DTO no-carry→expose EndsBeforeCeo) · 06-24 winner=SINGLESelectedSupplierIdderived-3-site, terminal=per-Level bool · 06-23 urgent authz asymmetric, PE-create dropdownPeWorkspaceCreateView.tsx:94. -
2026-06-20 governance recon (both → archive/_INDEX): (a) landing-map —
harness-11-engine.md=CANONICAL engine (D5/6/7 safety-tier+D8 one-dir-lock+D9 single-writer+D10 Bash-residual+CAVEAT no-OS-hook);error-ledger.md=§L.a AS-1..13+§L.b 7-step; rules.md §6.6=objective-criteria; report-before-stamp ⊂ D7 (extend not duplicate→C3 vocab-fork). (b) Harness-14 = age/recency-decay KHÔNG căn-cứ cắt feature;memory-budget.json0 decaykeep_floor=5=newest-protect drains-OLDEST; detectors canonical-anchor-vs-STATUS+disk 0 age-window; EVALgolden-set-solution_erp.jsonl14q recall@5≥0.7 weekly-manual; anti-downgrade=H8 all-inherit PARTIAL (no generic rule grep 0). -
PE recon cluster (S69→S76, verbatim → _INDEX): "Giá chào thầu" mục-c=
WinnerQuoteTotal=SUM(Quote.ThanhTien WHERE supplier==Selected) DERIVED 3-site; Budget gate=PURE ROLE no-phase (canEditPro/CcmPurchaseEvaluationFeatures.cs:800-801); submission-count-lock NEXISTS (grep 0); Value-threshold HOOK B=ApproveV2Async :816-845; PRO/CCM/CEO=Procurement/CostControl/Directorshorthand; V2 routing IGNORES roles (=ApproverUserId) 100% LINEAR. -
Office/HRM recon cluster (S65→S69, verbatim → _INDEX): 21
Off_*keys, 10 office pages{fe-admin,fe-user}/src/pages/office/SHA-mirror (exc MyAttendance+AttendanceReport admin-only); golive-flip=removeRevokeTemporarilyHiddenModulesAsyncDbInitializer.cs:2040; Employee master-detail EXISTS, Dept FLAT pre-Mig51; NamGroup PURO=UI-skin hardcoded-navTree; gotcha #66index.css h1-4{color}OUTSIDE @layer→TW-v4 unlayered wins→heading MUSTtext-white!. -
Governance/Harness recon cluster (S71, → _INDEX): H8 all-inherit FULLY adopted both layers (12/12 frontmatter + hmw.js resolveModel); run-trace "TRACKED" = 2-level (
git check-ignoreeligible vsgit ls-filescommitted — model works only postgit add); G-015 containment shift (Harness-2 "mọi tracked=vi-phạm" → H10 "tracked NGOÀI run-folder+code-disjoint=vi-phạm"). path-trap: bareruns/from repo-root = 0 → actual.claude/workflows/runs/(22 tracked). detector refine(b) =.claude/hooks/.claude/scriptsnot-exist (now S75 hasscripts/governance-detectors.ps1). -
[→ git pre-S60] S60 recon#2 V2-engine-map (ApproveV2Async:446-634 guard+UPSERT+advance; skipToFinal F2:561-602 precedent) · S60 PE Section-3 submit-guard ROLE-only. Full text git.
-
[→ archive/2026-06.md + git] S52 P11-D/E/F 6-gap recon · S50 HrmConfigs add-kind 11-spot · S51 gotcha #57 EXT reachability (curated S59).
-
[→ archive/2026-05-q4.md + git
d2f52ba] S29-S37: clean-room > NamGroup-port verified 4× · Pattern 12-bis cross-module mirror · FK+freetext dual-write. -
[→ git 07-10] S108 first-real-run H19 cite-audit: 103/111 exact; class = worker-draft cite lệch ±1-2 quanh code-fence (audit MỞ ĐÚNG DÒNG đừng tin range) + drift-note-stale + email-fact honesty-trap. 0 garble.
-
[→ archive/2026-07.md] S111 (07-12) H22 WAL deep-pass
[fable-real-single]— READY_WITH_NUANCES; hook=STAGED-until-verified (S100 ghost-wire class); engine:402 = MÔ-TẢ không phải luật cấm; Stop-hook fire TURN-boundary only. (H22 nay VERIFIED-RUNTIME per project memory.) -
[→ archive/2026-07.md] S110 (07-11) H21+MTv3 deep-pass
[fable-real-single]— PASS; 12 persona 0-hit; regex-heuristic-miss class (sister diễn-đạt khác cụm); hmw.js:38 comment-conflict; standing-imperative-trong-history-blurb class; #53 garble→SendMessage re-emit recover OK.
S117 — PE lũy-kế "không bắt sau duyệt" RCA (fable-real single deep-pass)
- 2026-07-14 VERDICT: phiếu nguồn A/018 KHÔNG hề DaDuyet — Chương (Bước2 Cấp2
AllowApproverFinalize, badge "Duyệt thay CEO" = CONFIG-displayPeWorkflowPanel.tsx:364) duyệt KHÔNG tick ô OPT-IN "Cấp này KẾT THÚC" (S97 Part1 đảo default UNCHECKEDPeWorkflowPanel.tsx:57useState(false); FE gửi tường minh :203) → advance thường lên Bước3 CEO, Phase=10 ChoDuyet. Prod ground-truth: StepIdx=2 LvlOrd=1 EndedFin=0; changelog 13/07 12:23Z "Hoàn tất Bước 2/3, sang Bước 3 (Cấp 1)" no-finalize-marker; IsWinner=1 SelQ=1 (749.564M) → RC-2 refuted. Lũy-kế Row2 filterPhase==DaDuyet(PeFeatures.cs:906) ĐÚNG nguyên tắc Kenny "duyệt rồi mới bắc"; tính LIVE :886-918 no-store → xóa+tạo-lại phiếu-XEM vô ích. ⭐ Residual = DISPLAY-LIE nửa-còn-lại gotcha #78: non-DaDuyetendsBeforeCeo=config TRUE bất chấp pointer (detail:1152-1154literal: true; list:647-651subquery.Any()) → Bước3 mờ "Kết thúc tại Cấp 2" + chip list "⚑ Kết thúc·CCM" NGAY KHI phiếu nằm inbox CEO → user tưởng xong. 3 cơ chế chồng phân biệt: AllowApproverFinalize (Mig58 + opt-in S97) ≠ finalizeByCcmDelegation (Mig53/54 threshold — v04 CeoThresh=NULL không dùng) ≠ skipToFinal (Mig31 pointer-jump giữ ChoDuyet). Fix rec: vận-hành CEO-duyệt hoặc trả-lại→Chương tick; code = pointer-aware endsBeforeCeo (detail in-memory trivial, list EF-subquery kềnh), KHÔNG nới filter lũy kế.[engine: fable-real-single · Fable-S117]
S116 — PE negative-quote invest (fable-clone ensemble, 07-13)
- Hội-tụ FE-ONLY: BE/DB nhận âm sẵn (no validator/CHECK); NS giữ-nguyên architectural; 3 chốt FE parseVnd/format/gate; sign-aware
VndInlineEdit:1003tái dùng; chỉ submit-guard:206hard-reject. ⚠️ Lesson: quote sốngdetails[].quotesKHÔNGsuppliers[].quotes. Detail:.claude/workflows/runs/2026-07-13-pe-negative-quote/+ session-log S116 + archive/2026-07.md 2×LENS.[Opus-S116]
🔄 Curate trigger
-
~30KB → archive recent → L2
archive/<period>.md(byte-exact append) +_INDEX.mdsubstring pointer. Stale >3mo → remove. - Last curate: 2026-07-06 (em-main single-writer, hook-triggered @21.4KB) — 6 stale governance/superseded entries (S93/S97/S98/S100/S101 + 07-01 Supplier-predecessor) verbatim →
archive/2026-07.md, replaced with pointer-stubs. L1 back under target. - Prev curate: 2026-06-18 S71 (29.8→23.2KB FIFO-trim 3 + gist gen:2). Prev S70 (47.0→24.1KB dark-matter recovery + built _INDEX/gist). Prev S40 (35.7→~20KB).