Files
solution-erp/.claude/workflows/runs/2026-08-01-S169-bookend-open/sleep-drafts/investigator-codebase--2026-05-q2.gist.draft.md
2026-08-03 10:53:28 +07:00

12 KiB
Raw Blame History

investigator-codebase/2026-05-q2 — gist

distill-gen: 1 source-verbatim: .claude/agent-memory/investigator-codebase/archive/2026-05-q2.md (4 entry → 4 cụm, 0 cặp trùng — dedup = nén câu chữ) pointer-style: substring

TỔNG-HỢP (3-5 ý)

  • Cùng triệu-chứng "Lịch sử thay đổi trống" nhưng 2 root-cause KHÁC trục: một bug GHI-thiếu (ApplyReturnModeAsync ZERO dòng log) ⟂ một bug nghi ĐỌC-thiếu (handler ĐÃ log, nghi FE lọc) — phải tách trục ghi/đọc trước khi đặt giả-thiết chung.
  • Nối module thứ 2 vào schema duyệt dùng-chung: chi-phí thật nằm ở Service + terminal-state khác nhau (DaPhatHanhDaDuyet), KHÔNG ở migration — Contract thừa-hưởng 7 cờ Allow* miễn phí; nhưng prod 7 HĐ 100% pin V1 (6 đang giữa quy-trình) ⇒ BẮT BUỘC cùng-tồn V1+V2, KHÔNG drop V1.
  • Ghost-wire dạng schema lộ 2 lần: EntityType.Workflow=5 khai trong enum nhưng 0 code ghi suốt 4+ migration; prod 0 row ApplicableType=3 ⇒ nối xong không seed = dropdown rỗng.
  • Thiếu component thư-viện KHÔNG chặn việc: fe-user GAP Accordion/Collapsible/Tree/Card/Badge → đường vòng <details>/<summary> native; quyết-định kiến-trúc đứng trên số ƯỚC (~50-200 dự-án) phải khai rõ (SSH prod fail auth).
  • Khuôn hạ-tầng phải quy-chiếu đúng hình-thái người dùng: 1 người 5 dự-án ≠ team 5 dev ⇒ chốt Pattern C (MCP global localhost); Voyage AI 200M token/tháng free làm đổ luôn phép so chi-phí cũ.

Entries

[cao] B2-A — "Lịch sử thay đổi" trống: 1 bug hiển-thị + 1 bug thiếu-ghi

  • VIỆC: 2 báo lỗi UAT gộp 1 lượt audit 5Q: (1) chỉnh ngân-sách 2 lần → lịch-sử không hiện 2 dòng; (2) trả-lại mode "Người chỉ định" → lịch-sử không hiện.
  • KẾT-LUẬN: Bug 1 KHÔNG phải lỗi ghi: PurchaseEvaluationFeatures.cs:379-387 ĐÃ log changelog (EntityType=Header + Action=Update + diff) ⇒ nghi FE lọc bỏ Header, hoặc DB UAT cũ. Bug 2 thiếu ghi thật: PurchaseEvaluationWorkflowService.cs:215-378 ApplyReturnModeAsync ZERO dòng log — 4 nhánh chỉ đổi con-trỏ rồi trả summary; người gọi TransitionAsync:100 LogTransitionAsync chỉ log chuyển-phase. Query handler ListPurchaseEvaluationChangelogsQueryHandler:1050-1064 không lọc gì ⇒ nếu mất thì mất ở FE. Đường vá: B2 trước (thêm Changelogs.Add() mỗi mode, 15-25 LOC 1 file), B1 sau (Option A enum Kind 30 LOC / B mở EntityType 20 LOC / C nới filter FE 10 LOC).
  • BÀI-HỌC: cùng triệu-chứng nhưng một cái ghi-thiếu, một cái đọc-thiếu — tách hai trục trước khi đặt giả-thiết chung; EntityType quá thô (Header/Update dùng chung cho "sửa ngân sách" lẫn "sửa mục 2") nên không phân-biệt được ở tầng hiển-thị.
  • BẤT-NGỜ: EntityType.Workflow=5 tồn-tại trong enum nhưng KHÔNG dòng code nào ghi vào suốt 4+ migration — schema khai một khả-năng chưa bao giờ dùng (khai-mà-không-nối, dạng ghost-wire). → substring:"1050-1064"

[cao] B2-B — Plan B Contract V2: 80% schema dùng lại, chốt cùng-tồn V1+V2

  • VIỆC: pre-flight 5Q + tái-chia chunk cho việc nối Contract vào bộ máy duyệt V2 (đang chỉ có PE).
  • KẾT-LUẬN: Contract.cs:8-58 25 field, sẵn V1 (WorkflowDefinitionId:22, CurrentWorkflowStepIndex:39, Phase:12, RejectedAtStepIndex:40) thiếu ApprovalWorkflowId + CurrentApprovalLevelOrder ⇒ Mig 32 chỉ ADD COLUMN vì Mig 22 (20260508053749_AddApprovalWorkflowsV2.cs:14-127) đã tạo 3 bảng DÙNG CHUNG cho PE lẫn Contract; ContractPhase.cs:14-28 đã có ChoDuyet=10 / TraLai=98 / TuChoi=99 soi gương PE; ContractWorkflowService.cs:23-219 220 LOC chỉ V1, sinh mã HĐ :148-155 ở bước cuối → DaPhatHanh (terminal KHÁC PE DaDuyet). Prod: 7 HĐ 100% pin V1, 6 đang giữa quy-trình (Phase 2-8) ⇒ BẮT BUỘC cùng-tồn, KHÔNG drop V1. Mẫu clone = ApproveV2Async PurchaseEvaluationWorkflowService.cs:446-634 (189 LOC: match actor → UPSERT opinion → advance → skipToFinal), điểm rẽ nhánh :167-171. Chia 6 chunk A1/A2/B/C/D/E theo tay-nghề (cookie-cutter → implementer, xuyên-tầng → em-main).
  • BÀI-HỌC: khi schema đã tách sẵn dùng-chung, chi-phí thật của "nối module thứ 2" nằm ở Service + terminal-state, không ở migration — 7 cờ Allow* trên ApprovalWorkflowLevels:86-114 Contract thừa-hưởng miễn phí.
  • BẤT-NGỜ: (a) prod 0 row ApplicableType=3 ⇒ nối xong mà không seed thì dropdown rỗng, phải gài seed vào chunk A2 (chú-thích curator S170, không thuộc verbatim: đúng thứ sau này thành sự-cố Run #231 ở lane cicd); (b) RejectedAtStepIndex Contract :40 đã chết mà chưa đánh dấu obsolete, lệch với PE :50; (c) 7 ContractType đối đầu 1 ApplicableType=3 chung — có thể phải thêm ContractTypes int[] sau. → substring:"V1Pinned"

[vừa] B2-C — Plan AG: PE List "đám rừng" → cây theo dự-án

  • VIỆC: anh gửi ảnh chụp phàn nàn danh sách phẳng; audit 5Q để chọn hướng.
  • KẾT-LUẬN: PurchaseEvaluationsListPage.tsx:133 3-panel lg:grid-cols-[340px_1fr_360px], thân phẳng <ul><li> :199-252, pageSize 50; Master/Project.cs:5-14 thiếu MaxLength + thiếu navigation sang PE ⇒ sẵn cho bảng ProjectPackage sau; fe-user THIẾU Accordion/Collapsible/Tree/Card/Badge (chỉ có Button/Dialog/Input/Label/Select/Textarea). Chốt Approach C: Phase 1 FE-only ~160 LOC × 2 app, Phase 2 schema hoãn tới sau UAT.
  • BÀI-HỌC: thiếu component thư-viện KHÔNG chặn việc — <details>/<summary> native + badge <div> là đường vòng đã kiểm-chứng ở Plan AA; chọn Phase-1-FE-only giữ quyền đổi ý về schema.
  • BẤT-NGỜ: không đo được quy-mô dữ-liệu thật (SSH prod fail auth) nên phải ƯỚC ~50-200 dự-án × 5-15 phiếu — quyết-định kiến-trúc đứng trên con số ước, có khai rõ. → substring:"340px_1fr_360px"

[vừa] B2-D — Plan AI: 4 case công-nghiệp cho hạ-tầng RAG 5 dự-án

  • VIỆC: nghiên-cứu 7Q cách chia-sẻ RAG cho 5 dự-án cùng máy.
  • KẾT-LUẬN: 4 case — Cursor (Merkle tree + Turbopuffer + tái-dùng 92% similarity, khoá dẫn-xuất từ commit hash) · Cline Memory Bank (markdown + JIT + git-native) · Continue.dev Hub (YAML slug) · Sourcegraph Cody (phản-mẫu: BỎ embedding về Search API + graph IR cho 100K+ repo). 3 khuôn multi-tenant (pool / silo / hybrid base+delta). Chốt Pattern C — MCP global cấp user, 1 server localhost phục-vụ 5 dự-án, KHÔNG theo khuôn VPS-team.
  • BÀI-HỌC: khuôn tốt nhất cho team 5 dev KHÔNG phải khuôn tốt nhất cho 1 người 5 dự-án — quy-chiếu về đúng hình-thái người dùng trước khi bê kiến-trúc về.
  • BẤT-NGỜ: Voyage AI cho 200M token/tháng miễn phí, đủ cho cả 5 dev ⇒ toàn bộ bài toán chi-phí thu về còn tiền VPS ($15/tháng), làm đổ luôn phép so "$20 vs Qdrant cloud $50". → substring:"Turbopuffer"

Phụ-lục token (coverage)

(chép TRỌN token-list section investigator-codebase/2026-05-q2 của proposal curator — lưới coverage-diff)

  • gotcha#: 0 token (file không dẫn số gotcha nào — chỉ dẫn chéo "pattern memory: S23 t3 lookup bug")
  • surprise (nhãn nguyên-văn): "Surprise: EntityType.Workflow=5 enum value design-only, unused 4+ mig history" · "Surprise: Voyage AI 200M tokens/month free tier cover 5 devs comfortably" · "Surprises: (a) ApprovalWorkflows Prod ZERO ApplicableType=3 (b) RejectedAtStepIndex Contract line 40 DEPRECATED chưa marked obsolete drift với PE line 50 (c) ContractType 7 variants vs ApprovalWorkflow generic ApplicableType=3" · "Q1-DB state Prod SSH fail (auth), fallback code inspect" (×2 entry) · "MISSING MaxLength + navigation tới PE" · "shadcn fe-user component GAP THIẾU Accordion/Collapsible/Tree/Card/Badge"
  • guard: ConflictException (Contract V2 chưa có nhánh — nêu dạng thiếu) · nhánh rẽ if (evaluation.ApprovalWorkflowId is Guid awId) ApproveV2Async else ApproveV1Legacy (:167-171) · "MUST coexist V1+V2, KHÔNG drop V1" (rào tiền-lệ Plan F) · Auth JWT RS256 + role scope + document-level ACL (thiết-kế RAG) · Risk LOW / Risk MEDIUM (ContractType discriminator)
  • root-cause: ① Bug1 — "FE filter skip Header updates OR Schema gap (Header.Update collision: budget vs section 2 edit)" ② Bug2 — "Handler intentionally skip logging (no companion audit table like PurchaseEvaluationApprovals for return history)"
  • file:line: PurchaseEvaluationFeatures.cs:379-387 · PurchaseEvaluationWorkflowService.cs:215-378 (ApplyReturnModeAsync) · TransitionAsync:100 (LogTransitionAsync) · PurchaseEvaluationChangelog.cs (EntityType=Workflow(5)) · ListPurchaseEvaluationChangelogsQueryHandler:1050-1064 · Master/Project.cs:5-14 · PurchaseEvaluationsListPage.tsx:133 + :199-252 · Contract.cs:8-58 (:12 Phase, :22 WorkflowDefinitionId, :39 CurrentWorkflowStepIndex, :40 RejectedAtStepIndex) · ContractPhase.cs:14-28 · ContractWorkflowService.cs:23-219 (:113-126 match Dept+PositionLevel, :148-155 gen mã HĐ) · 20260508053749_AddApprovalWorkflowsV2.cs:14-127 · 20260508072821_AddApprovalWorkflowIdToPurchaseEvaluation.cs:14-31 · 20260508074937_AddCurrentApprovalLevelOrderToPe.cs:14-17 · PurchaseEvaluationWorkflowService.cs:446-634 (:484-495, :522-546, :561-602, :605-633) + :167-171 · ApprovalWorkflowLevels entity :86-114 · PE RejectedAtStepIndex:50
  • định-danh khác: tag schema [audit, phase-9, contract] · source_path: solution_erp/audit/investigator-plan-b-contract-v2-preflight-2026-05-22 · token-cost 28k/30k/40k/25K · prod 35 PE·17 V2·4 V1 (entry q1) vs "7 Contracts 100% V1Pinned" (entry này) · Mig 32 tên đề-xuất AddProjectPackageTable (Plan AG) vs Mig 32 thực-dụng cho Contract (Plan B) — 2 nghĩa của "Mig 32" trong CÙNG file (xem _lienfile-notes-batchB.md #4)

Bổ-sung coverage @P3-gate S170 — ⚠️ LƯỚI GREP THUẦN, KHÔNG PHẢI DỮ KIỆN (đoạn trích sau mỗi token là phần ĐẦU DÒNG verbatim chứa token — dòng archive là mega-line nên đoạn trích thường KHÔNG liên-quan token; CHỈ dùng để coverage-diff grep trúng, đọc nội-dung thì tra verbatim theo token — reviewer P3 @S170)

  • Mig 21 — Em main spawn Investigator pre-flight Plan B priority HIGH. 5Q audit + Bonus chunk refinement. Tag schema: [audit, phase-9, contract]. Findings:
  • Mig 23 — Em main spawn Investigator pre-flight Plan B priority HIGH. 5Q audit + Bonus chunk refinement. Tag schema: [audit, phase-9, contract]. Findings:
  • Mig 24 — Em main spawn Investigator pre-flight Plan B priority HIGH. 5Q audit + Bonus chunk refinement. Tag schema: [audit, phase-9, contract]. Findings:
  • Mig 29 — Em main report 2 bug UAT: (1) Budget Adjust 2×click → "Lịch sử thay đổi" KHÔNG show 2 entry. (2) Return Assignee mode F1 click → "Lịch …
  • Mig 33 — Em main spawn Investigator pre-flight Plan B priority HIGH. 5Q audit + Bonus chunk refinement. Tag schema: [audit, phase-9, contract]. Findings:
  • Mig 34 — Em main spawn Investigator pre-flight Plan B priority HIGH. 5Q audit + Bonus chunk refinement. Tag schema: [audit, phase-9, contract]. Findings: