diff --git a/.claude/agent-memory/harvest-curator/MEMORY.md b/.claude/agent-memory/harvest-curator/MEMORY.md index 64cd6e0..28f3963 100644 --- a/.claude/agent-memory/harvest-curator/MEMORY.md +++ b/.claude/agent-memory/harvest-curator/MEMORY.md @@ -47,3 +47,4 @@ H2 harvest-MD-integrity auditor **SOLUTION_ERP-self**. Read-only + **propose-onl - **2026-07-11 (S110 @end GATE — self-write diary):** GATE **PASS 5/5 trục + close-gate**. Coverage 5/5: invest S110 H21+MTv3 deep-pass PASS 5-finding `[engine: fable-real-single · Fable-S110]` (in `debe82f`) · reviewer :93 PASS_WITH_FIXES 0C/5M CATCH-4 `[fable-real-single]` · cicd #493 :73 GO 5m24s GOVERNANCE 3-commit + :55 hash-line re-verify (`38262d8`) · tooling+harvest @start `162f0b9`; 3 worker Opus WF `wf_0c3b307f-a64` role-less 0-folder đúng chuẩn return-delta. Completeness 4-field đủ cả 3 entry mới. Fidelity khớp việc-thật: verdict khớp commit-msg debe82f "PASS_WITH_FIXES 5M-fixed" · cả 2 Fable-entry tự khai #53-garble→coordinator re-emit in-session recover, diary ghi TRƯỚC re-emit (KHÔNG on-behalf) · #493 timeline khớp `6ee60cd` 20:39:15. Corruption: FFFD 0/5 diary · tail `0a` 5/5 · 0-byte 0 · 2 gist untouched đúng kỳ-vọng. C5 close-gate: `runs/2026-07-11-h21-mtv3-adopt/` run.md 1508B + spec 9372B committed, `implement-synthesis.md` 3057B non-zero (em-main scribe 21:06) — orphan **15/15 PASS**; synthesis UNTRACKED → propose commit closeout-bundle. Method-#6 tái: grep byte-window in `�` GIẢ (cắt multibyte) — file FFFD=0, đừng false-alarm. #53 ×2/phiên (invest+reviewer, đều recovered) = garble-rate watch. Chore: SELF ~20K → self-compact S102→S105 phiên tới ĐỨNG. Tag `[s110-end-gate, pass-5truc, close-gate-15of15, garble-x2-recovered]`. - **2026-07-12 (S111 @start RE-REPORT — self-write diary):** Model `claude-fable-5`. Verdict 🟢 **ALL-CLEAN 5/5 trục** (post-S110 closeout `191532e` 21:14:52). (1) Harvest-mới **0**: porcelain 0 dòng + 12/12 L1 mtime ≤21:13:08 < closeout (method-#3) ⟹ 0 mồ-côi by-construction; S110 landing đủ 3-commit (`debe82f` invest+reviewer · `38262d8` cicd #493 · `191532e` 3-diary-@end + session-log + run-synthesis). (2) Orphan-run **0/15** (run=1·syn_nz=1·syn_z=0 cả 15; run MỚI `2026-07-11-h21-mtv3-adopt` FLAT synthesis 3057B đã committed-in-closeout, 0 sub-*.md = return-delta-only by-design, KHÔNG flag). (3) Corruption 0 THẬT: 0-byte 0/12 · tail `0a` 12/12 · FFFD 1 hit = entry S110-@end self-quote (method-#6/#9 — literal lần-đầu nằm L1, **baseline FFFD=1 từ nay**, đừng false-alarm; entry này cố-ý KHÔNG lặp literal; line-ref bỏ vì compact-shift) · mojibake-sig 1 hit = entry S108 self-quote known. (4) Gist ×2 FROZEN byte-exact == HEAD: tooling 6141B · SELF 6544B, diff-lines 0. (5) Fidelity: 5 diary S110 last-touch đúng 3 commit S110, S110-mention {cicd 3·tool 2·self 2·inv 1·rev 1} khớp spawn-set; 7 diary còn lại untouched = not-spawned đúng. Chore→ACTION cùng lượt: hook memory-gate fire (22.2K) → self-compact **EXECUTED HOOK-directed, mở-rộng S102→S106** (5 entry 6652B → archive/2026-07.md, block-md5 tại digest-line trên, anchor 5×{L1=0·AR=1}, L1 22160→~16.3K) · impl-be 23955B 93.6% idle từ 06-25 · fe-designer 21.5K · cicd 20.2K · inv-cb 19.7K · reviewer 18.9K > 17.1K watch. Tag `[s111-start, all-clean, 0-orphan-0of15, gist-frozen-x2, fffd-baseline-1-selfquote, self-compact-s102-s106-executed]`. - **2026-07-12 (S111 @end GATE — self-write diary):** GATE **PASS 5/5 trục + close-gate** (verify-idempotent, 0 re-APPEND). Coverage 7-spawn: 2 monitor @start `318a271` bundle-4-file · invest-cb +2-line & reviewer +1-line S111 tự-ghi NẰM TRONG `8aa3869` (engine-label `[engine: fable-real-single · Fable-S111]` cả 2, 0-garble) · cicd ĐANG verify Run 8aa3869 = pending-legit (S111=0 đúng trạng thái, backstop closeout) · tooling @end in-flight song-song (L1 16897B = state-318a271, pattern S107) · 3 worker `wf_5ba3daf6-fe0` role-less → memoryDelta vào synthesis đúng run-trace. Close-gate H22 run ĐẦU có sub-*.md: `runs/2026-07-12-h22-wal-adopt/` 6/6 file in-`8aa3869` (run.md 3298B `## taskList snapshot` ×1 chuẩn-MỚI · synthesis 3695B memoryDelta ×1 tail-0a · spec 16220B · sub-task-0/1/2 5737/5478/6172B) — orphan **0/16**. Fidelity: reviewer PASS_WITH_FIXES 0C/1M/~7m = 8 finding khớp commit-msg "8/8-fix" · wal-squash K=2 sạch (0 `wal:` subject trong `191532e..HEAD`; `12071c5`/`67be443` chỉ còn evidence-ref trong msg). Corruption: 0-byte 0/12 · tail `0a` 12/12 · FFFD 1 = baseline self-quote · moji 1 known · WAL.md dirty 1372B (< HEAD 1616B) = sổ-WAL live post-squash by-design → flush @closeout, KHÔNG mồ-côi. Method-trap MỚI tự-bắt: `--stat` truncate `.../` nuốt path dài → grep false-absence 5 file run-folder; lọc path PHẢI `--name-only`. Tag `[s111-end-gate, pass-5truc, close-gate-0of16, h22-first-subtask-runtrace, stat-truncate-trap]`. +- **2026-07-12 (S113 @start RE-REPORT — self-write diary):** Model `claude-opus-4-8` (Opus). Verdict 🟡 **H2 MOSTLY-CLEAN — 0 orphan/20 · corruption 0 · 2 coverage-gap propose-APPEND** (post-S112 closeout `8fa2fcc` 16:51; harvest-curator KHÔNG spawn S112 → em-main harvest direct qua `0d912ad`+`8fa2fcc`). (1) Orphan **0/20**: 4 S112 folder dùng synthesis **EMBEDDED-in-run.md** (`## synthesis` populated — pattern MỚI cho invest/review ensemble, KHÁC h21/h22 separate `implement-synthesis.md`); 14×06-18 synthesis nằm SUBFOLDER → maxdepth-1 scan FALSE-flag 5 (h10-implement/invest/review + h910-curate/finalize) → maxdepth-2 resolve sep-synth=1 (dual-accept, đừng scan nông). All 4 S112 git-tracked (6/6/4/4, 0 untracked). (2) Harvest 4/6 role CLEAN: inv-cb :20 stamp `[engine: fable-clone-ensemble · Opus-S112]` 4-field khớp run.md · reviewer ×4 :96-100 (stamp `[fable-real-single]`) · impl-fe top-🆕 date-labeled (grep-'S112' MISS = method-#4) · cicd :73 #496. (3) 🔴 2 GAP propose-APPEND: **impl-be** chỉ ghi PE (:77), THIẾU Supplier-BE (SupplierExcelImportService+preview/confirm endpoint+Mig 63 `AddSupplierImportSourceFields`) — shipped Run #496 nhưng 0 spawn-record nhà mình · **test-specialist** chỉ bump baseline 440→458 'as of D4' (nên D10/S112), 0 narrative cho ~950 test-LOC (SupplierExcelImportServiceTests +452 NEW / PeSubmitGuardAndBypass +498). Knowledge KHÔNG mất (đủ ở run.md+reviewer+cicd) → propose-only, em-main verify+APPEND B3. (4) Corruption 0: 0-byte 0 · tail 0a 6/6 · FFFD 1 = self-baseline (method-#9). Fidelity 0 fabrication → KHÔNG escalate; minor nit impl-fe '450 tests'(final 458) + test-spec label 'D4'≠'D10'. SELF ~19.2KB > 17.1 target → compact S107→S108 phiên tới. Tag `[s113-start, 0-orphan-20, embedded-synthesis-pattern, 2-coverage-gap-implbe-testspec, maxdepth1-false-flag]`. diff --git a/.claude/agent-memory/implementer-backend/MEMORY.md b/.claude/agent-memory/implementer-backend/MEMORY.md index 4fedf33..db30b7c 100644 --- a/.claude/agent-memory/implementer-backend/MEMORY.md +++ b/.claude/agent-memory/implementer-backend/MEMORY.md @@ -75,6 +75,7 @@ UI `disabled={!canX}` + BE helper `EnsureCanXAsync(id, userId)` throw 403 (NOT i ## 📅 Recent activity (FIFO — older → archive/git) - **2026-07-12 (S112 PE sign-off close-review implement — `wf_7df56b89-7bb` GO-WITH-ADJ, owner anh Kiệt PROD-UAT-live, 4-region/1 file `PurchaseEvaluationWorkflowService.cs`, NO mig/FE/test → ACCEPT Case 1):** **C1 A1 (`ApplyDrafterBypassOnSubmitAsync`):** người soạn KÝ TAY ô cấp mình — `k=Max`→`minOwn=Min(drafterSlots.Order)`, bypass `<=k`→`1){pointer=minOwn}` STOP tại minOwn (người soạn tự ApproveV2Async); minOwn=1→bypass rỗng pointer giữ (0,1); non-contiguous Cấp1+Cấp3 ký tay đúng thứ tự. **C2 EDGE-5 hard-lock:** top `TransitionAsync` sau isAdmin/isSystem TRƯỚC mọi branch → `if(fromPhase is DaDuyet or TuChoi && !isAdmin && !isSystem) throw Conflict` (chặn non-admin lật phiếu terminal; Admin+System MIỄN); KHÔNG đụng EnsureCanRejectV2Async. **C3** no self-finalize (owner oQ1 permission-driven). **C4 opinion-history (`ApproveV2Async` UPSERT else):** old.Comment→Changelog (Workflow/Update/EntityId=level.Id) TRƯỚC overwrite chỉ khi non-empty — NO mig/bảng/endpoint. Build slnx **0/0**. Infra **4 FAIL/401 pass**: fail=C1 (PeSubmitGuardAndBypassTests 9/10/12/14 assert OLD auto-sign/terminal-on-submit); C2/C4 break 0 test → test-specialist ADD. LESSON: behavior-change write-site → run consumer tests, hand VERIFIED fail-list (KHÔNG sửa test). Tag `[s112, pe-signoff, a1-sign-own-level, edge5-hardlock, opinion-history-changelog, consumer-test-verified-handoff]`. +- **2026-07-12 (S112 Supplier Excel-import Phase B BE — `wf_e2f23a84` invest-ensemble → `wf_75d6149b` close-review GO-WITH-ADJ, owner anh Kiệt, commit `e100ef0`, Mig 63 → ACCEPT Case 1/2):** **Service** `SupplierExcelImportService` (preview + confirm 2-stage) + 2 endpoint (`/suppliers/import/preview` [415 non-xlsx] · `/suppliers/import/confirm` [401 auth]) + **Mig 63 `AddSupplierImportSourceFields`** (Supplier +`SourceUpdatedAt datetime2?`+`SourceUpdatedBy nvarchar(200)?` provenance cột 29/30; 2 AddColumn nullable no-new-table 89). FE 2-app byte-identical (`SupplierImportDialog`). **LESSONS:** (1) dedup Code = **OrdinalIgnoreCase ở SERVICE** — DB unique-index CI-collation lật (SQLite fixture BINARY KHÔNG bắt, prod SQL Server CI bắt) → dedup KHÔNG dựa DB; (2) parser **absolute cell-index** (row-4 header-fingerprint), KHÔNG `CellsUsed()` (column-drift); (3) **all-or-nothing** gate TRƯỚC mutate (1 hard-error→Committed=false DB unchanged); (4) fill-nulls **SKIP Code/Name/Type** (chỉ điền field trống); (5) `.Normalize(FormC)` cho real-file NFD (close-review adjust bake 30 `RealFileHeaderTokens` byte-verify). **SURPRISE:** Approach-B (extend seed) ĐÃ ship 4 NCC prod (Mig 62) → spec "partial" SAI; import ghi entity **TRỰC TIẾP** (fill-where-non-empty) KHÔNG qua `UpdateSupplierCommand` (tránh NULL-clobber #73). Shipped Run #496 PASS, reviewer GO-WITH-ADJ (BE 6/6 axes). Tag `[s112, supplier-excel-import, mig63, ordinalignorecase-dedup-at-service, abs-cell-index-parser, all-or-nothing, fill-nulls-safe, normalize-formc-nfd, direct-entity-write]`. - **2026-06-25 (S88 PE stability cleanup — FROZEN-module mechanical relocation + 1 stale-comment fix BE — NO migration, 3 edit/2 file, em-main spec deterministic 100% file/line/boundary given → ACCEPT Case 1):** Pure mechanical move ZERO behavior-change. **T1 misplaced-command relocate:** `SetPeCcmBudgetPeriodCommand`+Validator+Handler (BUDGET setter writes `pe.CcmBudgetPeriodAmount` Section B "NS kỳ này" CCM, Mig 59) sống NHẦM trong suggested-PRICE file → move về budget file. (a) REMOVE `PeSuggestedPriceFeatures.cs` lines 144-199 (blank + `===== CCM NS kỳ này =====` header → `SetPeCcmBudgetPeriodCommandHandler` closing `}`); file end clean tại line 143 (`UpdatePeSuggestedPriceCcmCommandHandler` `}`), suggested-price PRO/CCM trên giữ nguyên. (b) APPEND `PeWorkItemBudgetFeatures.cs` END sau line 200 (`UpdatePeBudgetCcmCommandHandler` `}`) → cạnh budget setters `UpdatePeBudgetPro/Ccm`. Code BYTE-IDENTICAL (logic/authz Admin\|CostControl fail-closed/validation GTE(0).When(HasValue)/absolute-set null=clear/changelog UNCHANGED); CHỈ prepend 1 comment line `// [S88] Chuyển từ PeSuggestedPriceFeatures.cs về đây (đúng nhóm budget setter).`. Usings 8-header IDENTICAL 2 file → KHÔNG add duplicate. Namespace `SolutionErp.Application.PurchaseEvaluations` SAME → MediatR type-resolution transparent, controller `:125` KHÔNG đụng. **T2 stale-comment fix:** `Dtos/PurchaseEvaluationDtos.cs` ~250-254 comment trên `decimal WinnerQuoteTotal` ghi SUM "của SelectedSupplierId" (OLD single-winner) → verified actual compute `PurchaseEvaluationFeatures.cs:1093-1099` = `Suppliers.Where(s=>s.IsWinner)` (multi, Mig 58) → sửa CHỈ comment-text "MỌI đơn vị IsWinner (multi-winner Mig 58)". Field/code UNCHANGED. **LESSON:** frozen-relocation = read BOTH file FIRST exact boundary + verify usings-superset target + verify stale-comment claim vs real compute-site TRƯỚC sửa (KHÔNG trust comment blind, mirror S35 EF-source-of-truth). Build `SolutionErp.Application.csproj -v q` **0 warn 0 err** (4s). KHÔNG test (test-specialist)/FE/mig/commit. Tag `[s88, frozen-relocation, byte-identical-move, mediatr-type-resolve-transparent, stale-comment-verify-compute-site, no-behavior-change]`. - **2026-06-24 (PE Section B 3-cột THỰC HIỆN — CCM "NS kỳ này" cột riêng BE — Mig 59 `AddCcmBudgetPeriodToPurchaseEvaluation` 3-file, 5 edit/0 new file, em-main CHỐT spec+API-contract 100% → ACCEPT Case 1):** Section B tách 3 cột Dự án|PRO|CCM giống Section A. PRO=`BudgetPeriodAmount` sẵn có; CCM nhập cột riêng độc-lập. COOKIE-CUTTER mirror S77 suggested-price-Ccm + S65b HoSoLink one-column. (1) `PurchaseEvaluation.cs` +`decimal? CcmBudgetPeriodAmount` sau ExpectedRemainingAmount. (2) `PurchaseEvaluationConfiguration.cs` +`HasColumnType("decimal(18,2)")` sau ExpectedRemaining (spec asked literal decimal(18,2); siblings dùng HasPrecision(18,2) NHƯNG emit identical column — tôi follow spec verbatim HasColumnType). (3) Mig: Up=1 AddColumn decimal(18,2) nullable NO table/index, Down=1 DropColumn, snapshot verified — clean mirror Mig 52. (4) DTO `PurchaseEvaluationDetailBundleDto` +`decimal? CcmBudgetPeriodAmount` sau ExpectedRemainingAmount TRƯỚC BudgetSummary + projection PEFeatures.cs:1110 positional-insert đúng order (positional record → projection order BẮT BUỘC khít). (5) Setter `SetPeCcmBudgetPeriodCommand(Guid Id, decimal? CcmBudgetPeriodAmount):IRequest` append `PeSuggestedPriceFeatures.cs` (same concern PE role-gate setters) + Validator `GreaterThanOrEqualTo(0).When(HasValue)` (budget=0 hợp lệ) + Handler fail-closed Forbidden Admin|CostControl TRƯỚC side-effect (S56 #5) + absolute-set null=clear (gotcha #73) + changelog Header (sibling-consistency; spec min=SaveChanges). (6) Controller `[HttpPatch("{id:guid}/budget/ccm-period")]` + `CcmBudgetPeriodBody` (spec EXPLICIT PATCH dù siblings PUT — follow spec). **Call-site verify:** `new PurchaseEvaluationDetailBundleDto(` repo-wide → EXACTLY 1 (PEFeatures:1100, đã sửa) → positional-safe. Submit-guard `BudgetPeriodAmount` PRO KHÔNG đụng. Build SolutionErp.slnx (6 proj incl 2 test, gotcha #65) **0 warn 0 err**. KHÔNG apply DB/FE/test/commit. Route FE/test mirror: DTO field `ccmBudgetPeriodAmount` camelCase + PATCH `/api/purchase-evaluations/{id}/budget/ccm-period` body `{ ccmBudgetPeriodAmount }`. Tag `[pe-section-b-3col, ccm-budget-period, mig59, one-column-no-table, absolute-set-fail-closed, positional-dto-order, patch-per-spec]`. - **2026-06-19 (PE chuông báo approver BE — NO migration, 1 edit/1 file, em-main spec deterministic 100% → ACCEPT Case 1):** Tra Sol (Zalo) "không thấy chuông — việc có hồ sơ cần duyệt": approver Cấp hiện tại KHÔNG nhận notify khi phiếu ENTER/ADVANCE tới ChoDuyet (chỉ drafter báo terminal). FIX = +1 block trong `LogTransitionAsync` (PurchaseEvaluationWorkflowService.cs ~line 1058) NGAY SAU drafter-notify, KHÔNG endpoint mới (Pattern 4 — notify = side-effect của Submit/Approve-advance, cả 2 đã gọi LogTransitionAsync + end ChoDuyet). **Resolution mirror EXACT canonical** `EnsureActorInLevel` (line ~301): `db.ApprovalWorkflows.AsNoTracking().Include(Steps).ThenInclude(Levels)` → `stepsOrdered[CurrentWorkflowStepIndex]` (bounds-check) → `.Levels.Where(Order==CurrentApprovalLevelOrder && ApproverUserId!=Guid.Empty && !=actorUserId).Select(ApproverUserId).Distinct()` → `NotifyManyAsync(ids, Generic, "Phiếu cần bạn duyệt: {MaPhieu??TenGoiThau}", "Có phiếu Duyệt NCC đang chờ bạn duyệt.", /purchase-evaluations/{Id}, refId:Id, ct)`. **Recon:** (1) `ApprovalWorkflowLevel.ApproverUserId` = non-null `Guid` (NOT Guid?) → "exclude null" = `!=Guid.Empty` defensive (OR-of-N rows mỗi 1 NV). (2) `NotifyManyAsync` sig verified = `(IEnumerable, NotificationType, title, string? desc, string? href, Guid? refId, CT)` khớp urgent-feature ref. (3) actor-exclude qua `!= actorUserId` (Guid != Guid? lift OK). **Guard V2-only:** `ApprovalWorkflowId is Guid && CurrentWorkflowStepIndex is int && CurrentApprovalLevelOrder is int` → V1/no-workflow skip. **Best-effort try/catch** nuốt lỗi (phiếu đã SaveChanges; notify fail KHÔNG rollback). Block đọc pointer SAU set → Submit (idx0/lvl1) + Approve-advance (pointer advance rồi LogTransition) đều fire đúng. Build SolutionErp.slnx (2 test project, gotcha #65) **0 warn 0 err**. KHÔNG test/FE/mig/commit. Tag `[pe-approver-bell, notify-many, log-transition-hook, no-mig, v2-only, best-effort-trycatch, pattern4-side-effect]`.