[CLAUDE] Docs: Session 24 chốt cuối - Plan AA cumulative 7 commits + 4 agent MEMORY drift wrap

S24 wrap deliverables:

Docs:
- docs/STATUS.md prepend Recently Done newest S24 chốt cuối row (cumulative 7 commits 3 core + 4 polish UAT iteration, multi-agent ROI ~175K ~28% solo equiv)
- docs/HANDOFF.md Last updated S24 chốt cuối (replace previous S24 t1 entry với cumulative final state)
- docs/changelog/sessions/2026-05-15-s24-turn1-plan-aa-workflow-matrix.md EXTEND
  - Phase 2 Polish iteration UAT feedback section (4 commit detail):
    - Polish 1 da218f1 hotfix container px-2
    - Polish 2 4d60598 redesign v1 panel-per-NV color mirror Designer
    - Polish 3 fbbd361 redesign v2 HTML table rowSpan tận dụng full width
    - Polish 4 ee0902a wrap fix sidebar label về đầu hàng (hanging-indent reverse)
  - Stats S24 chốt cuối table
  - Multi-agent ROI cumulative S24 table (6 owner)
  - 7 Patterns reusable cross-project saved
  - Pending S25+ checklist

4 agent MEMORY drift (3 agent flushed cumulative S24 wrap + 1 CICD prior Run #210):
- .claude/agent-memory/investigator/MEMORY.md S24 Pre-A entry + memory drift note
- .claude/agent-memory/implementer/MEMORY.md +3 patterns 13/14/15 (Designer mirror + Tailwind JIT palette + rowSpan flat row builder) + S24 polish REFUSE log
- .claude/agent-memory/reviewer/MEMORY.md +4 anti-patterns (polish iteration cost vs spawn ROI + Discovery #3 negative retest + Low note IsUserSelectable leak)
- .claude/agent-memory/cicd-monitor/MEMORY.md Run #210 PASS entry (Plan AA verify 4/4 wire end-to-end)

⚠️ Implementer + CICD Monitor agent MEMORY both over 25KB curate threshold (~31.5KB + ~43KB).
Recommend archive S20-S22 old entries next session via `archive/2026-05-S20-S22.md`.

User-level memory: NO update needed per §6.2 (responsive memory đã đúng 2-panel,
hanging-indent + JIT palette patterns captured trong agent Implementer MEMORY).

Test verify post-Plan AA: 111/111 PASS unchanged (58 Domain + 53 Infra). No regression.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
pqhuy1987
2026-05-16 00:18:48 +07:00
parent ee0902ac13
commit e23f51c42e
7 changed files with 258 additions and 1 deletions

View File

@ -139,6 +139,17 @@ Flag commit nếu thấy `<PackageReference Include="MediatR" Version="14...` ho
## 📅 Recent runs (FIFO last 20) ## 📅 Recent runs (FIFO last 20)
- **2026-05-15 ~15:25 — Run #210 id=324 sha=`ac2c859` VERDICT=PASS (S24 t1 Plan AA — IsUserSelectable filter + WfView menu + sidebar widen)**. Push range `a1a910f..ac2c859` 3 commits: `ee776d5` Chunk A BE+Layout (6 files +73/-24: Controller +`isUserSelectable` param, AdminFeatures GetWorkflowsForUserAsync optional filter, MenuKeys +`Pe_DuyetNcc_WfView`, DbInitializer seed Order shift idempotent, FE × 2 app Layout.tsx widen `w-72 xl:w-80` + revert Plan U truncate) + `c667802` Chunk B FE matrix page (3 files +305 LOC, 2 NEW: WorkflowMatrixViewPage.tsx + types extend approvalWorkflowV2.ts + App.tsx route registration) + `ac2c859` Chunk C Docs (6 files +244, docs/sessions + 3 agent MEMORY drift). Run duration 3-4 min baseline. Iter 4/10 poll completion. **CRITICAL Stage 4c — Plan AA wire VERIFY 4/4 ✓:**
- **Test 1 `isUserSelectable` filter live ✓:** Admin no filter `total_versions=1` (bf31f120 ver=1 active=true ghim=true) — only 1 ghim version exists prod (DemoSeed:Disabled active per Plan T post Run #207). Admin filter `?isUserSelectable=true` returns same 1 ghim version (count <= no-filter). Non-admin token filter ghim returns same payload (types[0].active id=bf31f120 ghim=true name="Quy trình Duyệt NCC") — **HTTP 200, NOT 403**. Gotcha #44 silent 403 fix confirmed: any-auth read OK (S22 t6 fix `[Authorize]` class-level + GetWorkflowsForUserAsync auth filter).
- **Test 2 Menu Pe_DuyetNcc_WfView present + Order shift idempotent ✓:** Sorted listing matches exact expected sequence: Pe_DuyetNcc Order=1 / Pe_DuyetNcc_WfView Order=2 "Luồng duyệt" / Pe_DuyetNcc_List Order=3 / Pe_DuyetNcc_Create Order=4 / Pe_DuyetNcc_Pending Order=5 + parallel Pe_DuyetNccPhuongAn family Order=6-10 mirror. DbInitializer seed Order shift idempotent verified (Order numbers contiguous 1-10 no gap no overlap).
- **Test 3 Non-admin Read access ✓:** `/api/menus` returns `Pe_DuyetNcc_WfView` node for nv.test (Drafter CCM) actor. Schema `keys=['key', 'label', 'parentKey', 'order', 'icon', 'isVisible', 'displayLabel']` — no explicit `canRead` field but presence in returned tree = endpoint passed permission filter (otherwise filtered out). 7-role permission seed worked for new menu key.
- **Test 4 Sidebar widen ✓ (verified via bundle hash rotate proxy):** Layout.tsx widen `w-60 → w-72 xl:w-80` change in fe-admin + fe-user shipped both bundles. Manual visual skip per brief.
- Stage 4a Auth: admin token len 468 ✓, nv.test token len 477 ✓
- Stage 4b Smoke 5/5 endpoints 200 ✓: /api/menus, /api/purchase-evaluations, /api/approval-workflows-v2?applicableType=1, /api/contracts, /api/users
- **Stage 4d Bundle hash 2/2 rotated ✓:** admin `QZIPWD-g → Dmk--X6w`, user `DaLTMGcx → Bd4gh3Tp`. BOTH apps rebuilt as expected (Layout.tsx widen + Plan U truncate revert in BOTH apps + fe-user adds WorkflowMatrixViewPage).
- Stage 4e Mig prod TOP 1 = `20260514160124_RefactorSkipToFinalToApproverLevel` (Mig 31) unchanged ✓ — Plan AA no schema change.
- **Discovery #3 anomaly RE-CONFIRMED 4th time (push range eval):** Push range `a1a910f..ac2c859` mixed BE .cs + FE .ts(x) + docs/** — CI trigger expected per gotcha #41 (intermediate commits have non-ignored files). Plan AA is normal trigger case (not docs-only tip anomaly like Run #200/201/202), so this run does NOT reinforce the anomaly hypothesis. Investigator follow-up still pending for docs-only tip cases.
- **Pattern saved (4-test Plan AA wire surface):** New endpoint filter param + new menu key + Order shift idempotency + non-admin auth read = 4 distinct verify points. Bundle hash rotate proxy for FE-only changes (Layout.tsx widen in BOTH apps confirms cross-app sync). Plan AA + Plan U revert pattern: prior chunk reverted within same session = bundle hash should rotate but reflect cumulative state, not single-chunk diff. Token cost ~12k.
- **2026-05-15 ~14:50 — Run #209 sha=`86d8806` VERDICT=PASS (S23 t11 Plan U FE sidebar truncate)**. Commit 2 file FE × 2 app mirror `Layout.tsx` — MenuNodeRenderer button (accordion toggle) + MenuLeaf NavLink + StaticLeaf (fe-user only) 3 render sites. Recipe: `min-w-0 flex-1` parent + `shrink-0` icon/chevron + `truncate` span text + `title={effectiveLabel(node)}` tooltip hover. Mig 27 DisplayLabel custom dài "1. Duyệt Nhà Cung Cấp - Thầu phụ (NCC -TP)" wrap 2 dòng → text 1 dòng + ellipsis + hover full label. Build × 2 app PASS, +25/-17 LOC. Pattern reusable cross-project: long-label sidebar handling. - **2026-05-15 ~14:50 — Run #209 sha=`86d8806` VERDICT=PASS (S23 t11 Plan U FE sidebar truncate)**. Commit 2 file FE × 2 app mirror `Layout.tsx` — MenuNodeRenderer button (accordion toggle) + MenuLeaf NavLink + StaticLeaf (fe-user only) 3 render sites. Recipe: `min-w-0 flex-1` parent + `shrink-0` icon/chevron + `truncate` span text + `title={effectiveLabel(node)}` tooltip hover. Mig 27 DisplayLabel custom dài "1. Duyệt Nhà Cung Cấp - Thầu phụ (NCC -TP)" wrap 2 dòng → text 1 dòng + ellipsis + hover full label. Build × 2 app PASS, +25/-17 LOC. Pattern reusable cross-project: long-label sidebar handling.
- **2026-05-15 ~14:30 — Run #208 sha=`7b7b28f` VERDICT=PASS (S23 t10 Plan T5+T6 docs final)**. T5 sqlcmd cleanup: DELETE 4 PE + 1 V2 + 2 V1 + cascade child sau Plan T flag deploy. T6 force `Restart-WebAppPool SolutionErp-Api` test → BE startup → sqlcmd verify NO re-seed: PE=0 + V2=0 + V1=0 preserved + masters preserved (Users=33 + Suppliers=19 + Projects=9 + Contracts=7). DemoSeed flag PROVEN active end-to-end. Plan F precedent avoid (V1 active đã xóa Plan T5 nhưng KHÔNG có Contract pin V1 → safe). Total cumulative Plan R+S+T cleanup: ~720 rows wiped + flag persist permanent. - **2026-05-15 ~14:30 — Run #208 sha=`7b7b28f` VERDICT=PASS (S23 t10 Plan T5+T6 docs final)**. T5 sqlcmd cleanup: DELETE 4 PE + 1 V2 + 2 V1 + cascade child sau Plan T flag deploy. T6 force `Restart-WebAppPool SolutionErp-Api` test → BE startup → sqlcmd verify NO re-seed: PE=0 + V2=0 + V1=0 preserved + masters preserved (Users=33 + Suppliers=19 + Projects=9 + Contracts=7). DemoSeed flag PROVEN active end-to-end. Plan F precedent avoid (V1 active đã xóa Plan T5 nhưng KHÔNG có Contract pin V1 → safe). Total cumulative Plan R+S+T cleanup: ~720 rows wiped + flag persist permanent.
- **2026-05-15 ~14:15 — Run #207 sha=`0b97840` VERDICT=PASS (S23 t10 Plan T DemoSeed disable)**. Code change: `DbInitializer.cs` + `appsettings.json` (production inherit `DemoSeed:Disabled=true`) + `appsettings.Development.json` (override `false` cho dev test seed local). Wrap conditional 5 demo seed methods `if (!demoSeedDisabled)`: SeedWorkflowDefinitions V1 + SeedPurchaseEvaluationWorkflows V1 + SeedDemoContracts + SeedDemoPurchaseEvaluations + SeedSampleApprovalWorkflowsV2. KEEP: SeedRoles + SeedAdmin + SeedDemoUsers (30 UAT) + SeedDemoMasterData + SeedContractTemplates + SeedCatalogs + Backfill helpers. Note: `appsettings.Production.json` bị `.gitignore` → flag mặc định trong `appsettings.json` commit qua git. CI deploy IIS recycle apply flag → DbInitializer skip auto re-seed permanent. - **2026-05-15 ~14:15 — Run #207 sha=`0b97840` VERDICT=PASS (S23 t10 Plan T DemoSeed disable)**. Code change: `DbInitializer.cs` + `appsettings.json` (production inherit `DemoSeed:Disabled=true`) + `appsettings.Development.json` (override `false` cho dev test seed local). Wrap conditional 5 demo seed methods `if (!demoSeedDisabled)`: SeedWorkflowDefinitions V1 + SeedPurchaseEvaluationWorkflows V1 + SeedDemoContracts + SeedDemoPurchaseEvaluations + SeedSampleApprovalWorkflowsV2. KEEP: SeedRoles + SeedAdmin + SeedDemoUsers (30 UAT) + SeedDemoMasterData + SeedContractTemplates + SeedCatalogs + Backfill helpers. Note: `appsettings.Production.json` bị `.gitignore` → flag mặc định trong `appsettings.json` commit qua git. CI deploy IIS recycle apply flag → DbInitializer skip auto re-seed permanent.
@ -220,3 +231,4 @@ Flag commit nếu thấy `<PackageReference Include="MediatR" Version="14...` ho
Last curate: 2026-05-15 13:18 (added S23 t5 Plan O HOTFIX Run #202 entry: PASS verdict + CRITICAL wire verify 4 sites confirmed in code via Grep + live NV Test POST transition test on PE/2026/A/025 returned 409 mode-mismatch NOT 403 actor-mismatch = Plan O actor discrimination active on all 4 sites. Bundle hash unchanged expected. Mig 31 TOP 1 unchanged. 111/111 test baseline +3. Discovery #3 anomaly reinforced 3rd time tip docs-only `a1c8386` (0 agent MEMORY this push, only docs/**) CI triggered = strongly suggests Gitea evaluates push range commits not just tip when intermediate commit has non-ignored files. **NEW pre-existing bug surfaced:** Controller `TransitionPeBody` schema missing 3 fields (ReturnMode/ReturnTargetUserId/SkipToFinal) — separate task recommendation. **Side effect logged:** Admin transition on PE/2026/A/025 mutated phase 10→98 during test. Memory size ~35KB approaching curate trigger; FIFO runs at ~8 entries.) Last curate: 2026-05-15 13:18 (added S23 t5 Plan O HOTFIX Run #202 entry: PASS verdict + CRITICAL wire verify 4 sites confirmed in code via Grep + live NV Test POST transition test on PE/2026/A/025 returned 409 mode-mismatch NOT 403 actor-mismatch = Plan O actor discrimination active on all 4 sites. Bundle hash unchanged expected. Mig 31 TOP 1 unchanged. 111/111 test baseline +3. Discovery #3 anomaly reinforced 3rd time tip docs-only `a1c8386` (0 agent MEMORY this push, only docs/**) CI triggered = strongly suggests Gitea evaluates push range commits not just tip when intermediate commit has non-ignored files. **NEW pre-existing bug surfaced:** Controller `TransitionPeBody` schema missing 3 fields (ReturnMode/ReturnTargetUserId/SkipToFinal) — separate task recommendation. **Side effect logged:** Admin transition on PE/2026/A/025 mutated phase 10→98 during test. Memory size ~35KB approaching curate trigger; FIFO runs at ~8 entries.)
Last curate: 2026-05-15 13:45 (added S23 t6 Plan P HOTFIX Run #203 entry: PASS verdict + CRITICAL wire verify Test 1 admin returnMode=4 numeric → HTTP 204 phase mutated 10→98 ✓ + Test 2 admin returnMode=3 Assignee → HTTP 409 BUSINESS rejection "Không tìm thấy người chỉ định" NOT pre-fix bug "Cấp Approver mode Drafter" = `returnMode` preserved end-to-end through Controller `TransitionPeBody` 7-field record + `mediator.Send` 7-arg call + Handler Assignee branch logic. NV Test actor variant not feasible (scanned 20 PEs — NV Test = Drafter not approver). Plan P fixes the "Caveat #1 pre-existing bug" surfaced from Plan O Run #202 14 min earlier — fast turnaround S23 t5 → t6. **Discovery #4:** ASP.NET Core 10 record-with-enum needs numeric input; no global `JsonStringEnumConverter` registered (Grep confirms 0 hits). Brief example payload `"Drafter"` string format fails 400. FE × 2 correctly uses numeric. Bundle hash measurement caught Run #204 Chunk Q FE banner fix in flight (admin `QZIPWD-g`, user `DaLTMGcx`); Plan P bundle UNCHANGED criterion satisfied (Plan P diff zero FE files). Memory size ~40KB approaching curate trigger; FIFO runs at ~9 entries — schedule archive next curation.) Last curate: 2026-05-15 13:45 (added S23 t6 Plan P HOTFIX Run #203 entry: PASS verdict + CRITICAL wire verify Test 1 admin returnMode=4 numeric → HTTP 204 phase mutated 10→98 ✓ + Test 2 admin returnMode=3 Assignee → HTTP 409 BUSINESS rejection "Không tìm thấy người chỉ định" NOT pre-fix bug "Cấp Approver mode Drafter" = `returnMode` preserved end-to-end through Controller `TransitionPeBody` 7-field record + `mediator.Send` 7-arg call + Handler Assignee branch logic. NV Test actor variant not feasible (scanned 20 PEs — NV Test = Drafter not approver). Plan P fixes the "Caveat #1 pre-existing bug" surfaced from Plan O Run #202 14 min earlier — fast turnaround S23 t5 → t6. **Discovery #4:** ASP.NET Core 10 record-with-enum needs numeric input; no global `JsonStringEnumConverter` registered (Grep confirms 0 hits). Brief example payload `"Drafter"` string format fails 400. FE × 2 correctly uses numeric. Bundle hash measurement caught Run #204 Chunk Q FE banner fix in flight (admin `QZIPWD-g`, user `DaLTMGcx`); Plan P bundle UNCHANGED criterion satisfied (Plan P diff zero FE files). Memory size ~40KB approaching curate trigger; FIFO runs at ~9 entries — schedule archive next curation.)
Last curate: 2026-05-15 15:25 (added S24 t1 Plan AA Run #210 entry: PASS verdict + 4/4 wire verify ✓ — Test 1 IsUserSelectable filter live admin/non-admin token both return same ghim payload HTTP 200 NOT 403 / Test 2 menu Pe_DuyetNcc_WfView Order=2 + parallel Pe_DuyetNccPhuongAn_WfView Order=7 + 10 menu keys contiguous Order 1-10 idempotent / Test 3 non-admin Read access /api/menus returns WfView node = permission filter pass / Test 4 sidebar widen proxy via bundle hash rotate. Bundle hash 2/2 rotated admin `QZIPWD-g → Dmk--X6w` + user `DaLTMGcx → Bd4gh3Tp`. Mig 31 unchanged. Smoke 5/5 200. Discovery #3 anomaly NOT applicable Plan AA (mixed BE+FE+docs trigger expected). Memory size ~43KB now over 25KB curate trigger but under 50KB hard limit; FIFO runs at ~10 entries — recommend ARCHIVE archive/2026-05.md next curation if next entry pushes >50KB. Token cost ~12k.)

View File

@ -162,6 +162,89 @@ Pattern reusable: test PE workflow → 1 Step + 2 Levels + N approvers per Level
Tránh API surface bloat. Reusable cho future guard / helper internal cần test. Tránh API surface bloat. Reusable cho future guard / helper internal cần test.
### Pattern 13: Read-only admin Designer mirror page (S24 Plan AA Chunk B)
Khi spec yêu cầu "user xem read-only data admin đã config" (vd workflow matrix ghim, permission summary, dept tree readonly):
- **Drop edit mutations** — useMutation / PATCH / POST / DELETE KHÔNG cần
- **Reuse DTO types subset** — copy `AwAdminOverviewDto` từ admin sang user types/ (KHÔNG re-export, KHÔNG share package — duplicate có chủ đích §3.9)
- **Filter via query param BE-side** — `?isUserSelectable=true` thay vì FE filter client (network payload nhẹ hơn + security tự nhiên)
- **Implementer Case 2 single file ~180-215 LOC** ACCEPT đúng scope (page mới + types mới + route 3-line App.tsx)
- **Verify shadcn library availability trước** — fe-user thường thiếu Card/Badge (chỉ có Button/Dialog/Input/Label/Select/Textarea). Fallback inline `<div className="rounded-lg border bg-card p-4">` mirror admin Designer DefinitionCard
Bài học S24 Plan AA Chunk B: 3 file ~305 LOC, useQuery readonly, no mutation, ACCEPTED ~14k tokens. Pattern reusable cho future user-side read-only page (vd permission summary, dept hierarchy view).
### Pattern 14: Tailwind JIT palette array (S24 Plan AA)
Tailwind v3 JIT KHÔNG resolve dynamic class interpolation (`bg-${color}-50` → purge xoá khi production build). Solution: PALETTE array với full class strings literal.
```ts
const PALETTE = [
{ bg: 'bg-blue-50/40', border: 'border-blue-200', text: 'text-blue-900', accent: 'bg-blue-100' },
{ bg: 'bg-emerald-50/40', border: 'border-emerald-200', text: 'text-emerald-900', accent: 'bg-emerald-100' },
{ bg: 'bg-amber-50/40', border: 'border-amber-200', text: 'text-amber-900', accent: 'bg-amber-100' },
// ... 6-8 colors total
] as const
// Apply cycle qua index:
const colorClasses = PALETTE[index % PALETTE.length]
<div className={`${colorClasses.bg} ${colorClasses.border}`}>...</div>
```
Lý do array (vs object): cycle natural qua `index % length` cho dynamic NV/Step/Cap count. Lý do `as const`: TypeScript narrow literal type tránh `string`.
Bài học S24 Plan AA redesign v1 (commit 4d60598): panel-per-NV color theo NV index — 6 NV cycle 6 màu blue/emerald/amber/violet/rose/cyan.
### Pattern 15: HTML table rowSpan iteration helper (S24 Plan AA redesign v2)
Khi render table với nested rowSpan (vd Bước rowSpan N cấp × Cấp rowSpan M NV), nested loop + conditional cells gây nhầm key + hard maintain. Solution: flat row builder helper với metadata flags.
```ts
type FlatRow = {
stepIndex: number
capIndex: number
nvIndex: number
isFirstInStep: boolean // render Bước cell
rowSpanStep: number // cap count × nv count
isFirstInCap: boolean // render Cấp cell
rowSpanCap: number // nv count
// ... level data
}
function buildFlatRows(definition: AwDefinitionDto): FlatRow[] {
const rows: FlatRow[] = []
definition.steps.forEach((step, si) => {
const stepNvCount = step.levels.reduce((sum, lv) => sum + lv.users.length, 0)
step.levels.forEach((cap, ci) => {
cap.users.forEach((nv, ni) => {
rows.push({
stepIndex: si, capIndex: ci, nvIndex: ni,
isFirstInStep: ci === 0 && ni === 0,
rowSpanStep: stepNvCount,
isFirstInCap: ni === 0,
rowSpanCap: cap.users.length,
// ...
})
})
})
})
return rows
}
// Render flat:
{rows.map(row => (
<tr key={`${row.stepIndex}-${row.capIndex}-${row.nvIndex}`}>
{row.isFirstInStep && <td rowSpan={row.rowSpanStep}>{step.name}</td>}
{row.isFirstInCap && <td rowSpan={row.rowSpanCap}>{cap.name}</td>}
<td>{nv.fullName}</td>
{/* 7 flag cells */}
</tr>
))}
```
Cleaner than nested `forEach` + render-time `if (ni === 0) <td rowSpan={...}>`. Easier debug (console.log rows array thấy structure rõ).
Bài học S24 Plan AA redesign v2 (commit fbbd361): table 3 cột meta (Bước/Cấp/NV) + 7 cột flag với rowSpan natural.
--- ---
## ⚠️ Anti-patterns observed (DO NOT) ## ⚠️ Anti-patterns observed (DO NOT)
@ -204,6 +287,7 @@ KHÔNG `*` / `latest`. Critical pins:
## 📅 Recent activity (last 10 FIFO) ## 📅 Recent activity (last 10 FIFO)
- **2026-05-15 (S24, Plan AA wrap):** Cumulative learning post-Chunk B. **3 patterns NEW added** (13 read-only admin Designer mirror, 14 Tailwind JIT palette array full class strings, 15 HTML table rowSpan flat row builder helper). **REFUSE log 4/4 correct** S24 polish chunks (commit da218f1 hotfix px-2 trivial < 30min criteria #6, 4d60598 redesign v1 panel-per-NV color UX flow criteria #2, fbbd361 redesign v2 table rowSpan UX flow criteria #2, ee0902a wrap fix sidebar label CSS polish criteria #6) em main solo executed all 4, Implementer no-spawn. **Ambiguity Chunk B**: shadcn fe-user thiếu Card/Badge (lib subset minimal chỉ Button/Dialog/Input/Label/Select/Textarea) fallback inline `<div className="rounded-lg border bg-card p-4">` + inline `<span className="rounded-full bg-...">` mirror admin Designer DefinitionCard. Pattern reusable cho fe-user pages requiring elevated UI surface (audit shadcn fe-user/src/components/ui/ TRƯỚC khi import). Total S24 commits: 7 (a1a910f..ee0902a 1 spawn Chunk B accepted + 6 em main solo: Chunk A cross-stack + Chunk C docs + 4 polish). Token cost cumulative S24 Implementer: ~14k (Chunk B only).
- **2026-05-15 (S24, Plan AA Chunk B PASS):** FE user read-only matrix view workflow V2 ghim (Mig 25 IsUserSelectable). 3 file: (1) CREATE `fe-user/src/types/approvalWorkflowV2.ts` (~55 LOC) subset DTO mirror BE `AwAdminOverviewDto` (7 Allow* flag per Level, 5 record type AwLevelDto/AwStepDto/AwDefinitionDto/AwTypeSummaryDto/AwAdminOverviewDto); (2) CREATE `fe-user/src/pages/pe/WorkflowMatrixViewPage.tsx` (~215 LOC) useQuery GET `/approval-workflows-v2?applicableType=N&isUserSelectable=true` (em main BE Chunk A đã thêm `IsUserSelectable bool?` param + Controller forward), render table 10 cột Bước (rowSpan) | Cấp | NV duyệt | 7 ✓/— flag cell, header với `title` tooltip tả từng cột, 3 state Loading/Error/Empty ràng, badge `Đang dùng` (emerald isActive) + `Được ghim` (amber isUserSelectable Pin icon); (3) UPDATE `fe-user/src/App.tsx` import WorkflowMatrixViewPage + route `/purchase-evaluations/workflow-matrix` đặt TRƯỚC `/workspace` (URL ordering logical matrix workspace new detail). Verify: `npm run build` fe-user PASS clean 0 TS err, 1907 modules, 2.61s, 1282 KB. Surprise: shadcn fe-user KHÔNG `Card`/`Badge` (chỉ Button/Dialog/Input/Label/Select/Textarea) fallback inline `<div className="rounded-lg border...">` + inline `<span className="rounded-full bg-...">` cho badge (mirror pattern admin Designer). Pattern reusable: **read-only mirror admin Designer page** = drop edit mutations + reuse DTO types (subset) + filter param BE-side (`IsUserSelectable=true` thay FE filter). Cookie-cutter 0 (lần đầu pattern). Pattern 5 mirror 2 app KHÔNG apply (fe-admin Designer riêng Plan AA scope fe-user only). Pattern 7 admin opt-in 7 Allow* flag wire full render trong table (10 cột total = 3 meta + 7 flag). KHÔNG ops git. Token cost ~14k. - **2026-05-15 (S24, Plan AA Chunk B PASS):** FE user read-only matrix view workflow V2 ghim (Mig 25 IsUserSelectable). 3 file: (1) CREATE `fe-user/src/types/approvalWorkflowV2.ts` (~55 LOC) subset DTO mirror BE `AwAdminOverviewDto` (7 Allow* flag per Level, 5 record type AwLevelDto/AwStepDto/AwDefinitionDto/AwTypeSummaryDto/AwAdminOverviewDto); (2) CREATE `fe-user/src/pages/pe/WorkflowMatrixViewPage.tsx` (~215 LOC) useQuery GET `/approval-workflows-v2?applicableType=N&isUserSelectable=true` (em main BE Chunk A đã thêm `IsUserSelectable bool?` param + Controller forward), render table 10 cột Bước (rowSpan) | Cấp | NV duyệt | 7 ✓/— flag cell, header với `title` tooltip tả từng cột, 3 state Loading/Error/Empty ràng, badge `Đang dùng` (emerald isActive) + `Được ghim` (amber isUserSelectable Pin icon); (3) UPDATE `fe-user/src/App.tsx` import WorkflowMatrixViewPage + route `/purchase-evaluations/workflow-matrix` đặt TRƯỚC `/workspace` (URL ordering logical matrix workspace new detail). Verify: `npm run build` fe-user PASS clean 0 TS err, 1907 modules, 2.61s, 1282 KB. Surprise: shadcn fe-user KHÔNG `Card`/`Badge` (chỉ Button/Dialog/Input/Label/Select/Textarea) fallback inline `<div className="rounded-lg border...">` + inline `<span className="rounded-full bg-...">` cho badge (mirror pattern admin Designer). Pattern reusable: **read-only mirror admin Designer page** = drop edit mutations + reuse DTO types (subset) + filter param BE-side (`IsUserSelectable=true` thay FE filter). Cookie-cutter 0 (lần đầu pattern). Pattern 5 mirror 2 app KHÔNG apply (fe-admin Designer riêng Plan AA scope fe-user only). Pattern 7 admin opt-in 7 Allow* flag wire full render trong table (10 cột total = 3 meta + 7 flag). KHÔNG ops git. Token cost ~14k.
- **2026-05-15 (S23 t4-t11 cumulative REFUSE em main solo Plan N+O+P+Q+R+S+T+U):** 8 plan consecutive em main solo, 0 Implementer spawn (REFUSE 100% per criteria #4 bug fix reasoning chain + criteria #3 cross-stack tight coupling). **Plan N+O** 5 lookup site discrimination fix cross-stack BE Service + Application + 3 regression test. **Plan P** Controller TransitionPeBody record drop fix tightly coupled FE wire audit (Investigator confirm BE-only scope ~6 LOC). **Plan Q** FE banner mx-5 layout CSS polish 2 app mirror trivial 8 LOC. **Plan R+S+T5** destructive sqlcmd cleanup prod (scripts/plan-r-*.sql + plan-s-*.sql + plan-t5-*.sql + plan-t-backup.sql, 4 files scp + sqlcmd -i, ~720 rows wiped cumulative). **Plan T** DbInitializer DemoSeed:Disabled flag config (Infrastructure + Api appsettings, ~25 LOC). **Plan U** FE sidebar truncate + tooltip 2 app mirror 25 LOC (em main solo CSS Tailwind). 7 strict-scope criteria validated cumulative S23: pattern reusable saved memory user-level Plan O wire 9 surface points (point 9 lookup discrimination 5 sites enum), Plan P wire 10 surface points (point 10 Controller body record mirror count check), Plan T DemoSeed flag pattern. - **2026-05-15 (S23 t4-t11 cumulative REFUSE em main solo Plan N+O+P+Q+R+S+T+U):** 8 plan consecutive em main solo, 0 Implementer spawn (REFUSE 100% per criteria #4 bug fix reasoning chain + criteria #3 cross-stack tight coupling). **Plan N+O** 5 lookup site discrimination fix cross-stack BE Service + Application + 3 regression test. **Plan P** Controller TransitionPeBody record drop fix tightly coupled FE wire audit (Investigator confirm BE-only scope ~6 LOC). **Plan Q** FE banner mx-5 layout CSS polish 2 app mirror trivial 8 LOC. **Plan R+S+T5** destructive sqlcmd cleanup prod (scripts/plan-r-*.sql + plan-s-*.sql + plan-t5-*.sql + plan-t-backup.sql, 4 files scp + sqlcmd -i, ~720 rows wiped cumulative). **Plan T** DbInitializer DemoSeed:Disabled flag config (Infrastructure + Api appsettings, ~25 LOC). **Plan U** FE sidebar truncate + tooltip 2 app mirror 25 LOC (em main solo CSS Tailwind). 7 strict-scope criteria validated cumulative S23: pattern reusable saved memory user-level Plan O wire 9 surface points (point 9 lookup discrimination 5 sites enum), Plan P wire 10 surface points (point 10 Controller body record mirror count check), Plan T DemoSeed flag pattern.
- **2026-05-15 (S24, Plan M Chunk M2 PASS):** F1 edge case Bước 1 reset ChoDuyet tests (em main M1 service edit `PurchaseEvaluationWorkflowService.cs` line 287-333 đã DONE fallback Drafter TraLai reset (0, 1) giữ ChoDuyet + audit log "không lùi được"). Cookie-cutter 1 file test `PurchaseEvaluationWorkflowServiceReturnModeTests.cs` 2 sub-tasks: (1) extend `SeedWorkflowAsync` helper +2 params optional `allowReturnOneLevelL1` + `allowReturnOneStepL2` (default false, không phá compat 4 test ReturnMode existing), set vào `l1.AllowReturnOneLevel` + `l2.AllowReturnOneStep` tương ứng Pattern 3 audit-reuse EXTEND không clone helper; (2) add 2 `[Fact]` test ngay sau test admin bypass OneLevel (line 241) `ApplyReturnMode_OneLevel_AtStep1Level1_ResetsToBuoc1Cap1_KeepsChoDuyet` (PE init Step 0 Cấp 1 + actor=a1 + slot Cấp 1 tick AllowReturnOneLevel, build PE inline helper `BuildPeAtLevel2` không phù hợp cho Cấp 1) + `ApplyReturnMode_OneStep_AtStep1_ResetsToBuoc1Cap1_KeepsChoDuyet` (PE Step 0 Cấp 2 + actor=a2 + slot Cấp 2 tick AllowReturnOneStep, reuse `BuildPeAtLevel2`, OneStep service check `curStepIdx > 0` fallback ngay không quan tâm Cấp). Assert: Phase=ChoDuyet (KHÔNG TraLai như Drafter mode) + pointer (0, 1) + SLA NotNull + Changelog **ContextNote** chứa "không lùi được" (Summary field cố định `"Chuyển phase {from} → {to}"`, summary từ ApplyReturnModeAsync chèn vào comment qua line 96-99 service LogTransition `ContextNote = comment`). K7 cascade verify NO regression: 3 ApproveV2_SkipToFinal_* tests still green (M1 edit chỉ F1 OneLevel/OneStep edge case, KHÔNG đụng F2 path `ApproveV2Async`). Verify: `dotnet test SolutionErp.slnx` clean 0 err 2 warn pre-existing DocxRenderer, **106/106 PASS** (58 Domain + 48 Infra: +2 từ 46 baseline post Plan L). 10 ReturnMode-class tests verified individually PASS (4 ReturnMode + 3 ApproveV2_SkipToFinal + 1 Reject_NonApprover + 2 edge case mới). Diff +94 LOC trên 1 test file (test add + helper signature 2 params). Token ~10k. Spec deterministic + 1 file independent + < 1h verified. - **2026-05-15 (S24, Plan M Chunk M2 PASS):** F1 edge case Bước 1 reset ChoDuyet tests (em main M1 service edit `PurchaseEvaluationWorkflowService.cs` line 287-333 đã DONE fallback Drafter TraLai reset (0, 1) giữ ChoDuyet + audit log "không lùi được"). Cookie-cutter 1 file test `PurchaseEvaluationWorkflowServiceReturnModeTests.cs` 2 sub-tasks: (1) extend `SeedWorkflowAsync` helper +2 params optional `allowReturnOneLevelL1` + `allowReturnOneStepL2` (default false, không phá compat 4 test ReturnMode existing), set vào `l1.AllowReturnOneLevel` + `l2.AllowReturnOneStep` tương ứng Pattern 3 audit-reuse EXTEND không clone helper; (2) add 2 `[Fact]` test ngay sau test admin bypass OneLevel (line 241) `ApplyReturnMode_OneLevel_AtStep1Level1_ResetsToBuoc1Cap1_KeepsChoDuyet` (PE init Step 0 Cấp 1 + actor=a1 + slot Cấp 1 tick AllowReturnOneLevel, build PE inline helper `BuildPeAtLevel2` không phù hợp cho Cấp 1) + `ApplyReturnMode_OneStep_AtStep1_ResetsToBuoc1Cap1_KeepsChoDuyet` (PE Step 0 Cấp 2 + actor=a2 + slot Cấp 2 tick AllowReturnOneStep, reuse `BuildPeAtLevel2`, OneStep service check `curStepIdx > 0` fallback ngay không quan tâm Cấp). Assert: Phase=ChoDuyet (KHÔNG TraLai như Drafter mode) + pointer (0, 1) + SLA NotNull + Changelog **ContextNote** chứa "không lùi được" (Summary field cố định `"Chuyển phase {from} → {to}"`, summary từ ApplyReturnModeAsync chèn vào comment qua line 96-99 service LogTransition `ContextNote = comment`). K7 cascade verify NO regression: 3 ApproveV2_SkipToFinal_* tests still green (M1 edit chỉ F1 OneLevel/OneStep edge case, KHÔNG đụng F2 path `ApproveV2Async`). Verify: `dotnet test SolutionErp.slnx` clean 0 err 2 warn pre-existing DocxRenderer, **106/106 PASS** (58 Domain + 48 Infra: +2 từ 46 baseline post Plan L). 10 ReturnMode-class tests verified individually PASS (4 ReturnMode + 3 ApproveV2_SkipToFinal + 1 Reject_NonApprover + 2 edge case mới). Diff +94 LOC trên 1 test file (test add + helper signature 2 params). Token ~10k. Spec deterministic + 1 file independent + < 1h verified.

View File

@ -129,6 +129,7 @@ State machine 5 trạng thái phiếu PE: Nháp / Đã gửi duyệt / **Trả l
## 📅 Recent activity (last 10 FIFO) ## 📅 Recent activity (last 10 FIFO)
- **2026-05-15 (S24 t1 spawn Pre-A — Plan AA User Workflow Matrix view + sidebar widen):** 5Q audit. Q1 endpoint: `ApprovalWorkflowsV2Controller.cs:16-19` đã class-level `[Authorize]` bare từ S18 2026-05-08 (gotcha #44 fixed permanent), per-method admin Workflows.Create. Handler `GetAwAdminOverviewQuery` KHÔNG có IsUserSelectable filter — cần ADD param + Where conditional. Q2 menu seed: `DbInitializer.cs:1429-1437` peOrder global increment (Group=1, leaves 2/3/4 cycle per type). Permission seed `line 1541-1547` cho 7 role (Drafter/DeptManager/Procurement/CostControl/ProjectManager/Director/AuthorizedSigner). Accounting NOT trong list — admin manual grant nếu cần. Q3 Admin Designer: `ApprovalWorkflowsV2Page.tsx` 975 lines, AwLevelDto 13 fields (7 Allow*), VI labels line 892-948 ("Trả về 1 Cấp trước"/"Trả về 1 Bước trước"/"Trả về Người chỉ định"/"Trả về Drafter (mặc định)"/"Cho phép chỉnh sửa Section 2 (Hạng mục/NCC/Báo giá) lúc đang duyệt"/"Cho phép chỉnh sửa Section ngân sách lúc đang duyệt"/"Cho phép duyệt thẳng Cấp cuối khi đang duyệt"). KHÔNG có usePermission/PermissionGuard wrap (class-level [Authorize] route guard sufficient). Q4 sidebar widen: fe-user `Layout.tsx:325` + fe-admin `Layout.tsx:218` `w-60 xl:w-72` (240/288px). PE Workspace 2-panel `[260px_1fr] xl:[320px_1fr]` (NOT 3-panel như memory `feedback_responsive_laptop_breakpoint` stale claim). After widen `w-72 xl:w-80` (288/320px) SAFE (sidebar 288 + main 992 → workspace 260+732 fit @ 1280px). `w-80 xl:w-96` THRESHOLD RISKY (sát 700px remaining). Q5 ApplicableType enum `ApprovalWorkflow.cs:45-50` {DuyetNcc=1, DuyetNccPhuongAn=2, Contract=3}. Surprises: (1) memory responsive breakpoint stale "3-panel" → cần update sau Plan AA. (2) Order strategy "Luồng duyệt" Order=2 first → shift existing leaves +1 → cần DbInitializer UPDATE Order existing (KHÔNG chỉ INSERT-if-not-exists). (3) Contract=3 chưa wire FE (chỉ DuyetNcc + DuyetNccPhuongAn). Recommendation: Proceed Plan AA — chỉ ADD param filter + 1 menu key + page mới + sidebar widen. Token cost ~32k. - **2026-05-15 (S24 t1 spawn Pre-A — Plan AA User Workflow Matrix view + sidebar widen):** 5Q audit. Q1 endpoint: `ApprovalWorkflowsV2Controller.cs:16-19` đã class-level `[Authorize]` bare từ S18 2026-05-08 (gotcha #44 fixed permanent), per-method admin Workflows.Create. Handler `GetAwAdminOverviewQuery` KHÔNG có IsUserSelectable filter — cần ADD param + Where conditional. Q2 menu seed: `DbInitializer.cs:1429-1437` peOrder global increment (Group=1, leaves 2/3/4 cycle per type). Permission seed `line 1541-1547` cho 7 role (Drafter/DeptManager/Procurement/CostControl/ProjectManager/Director/AuthorizedSigner). Accounting NOT trong list — admin manual grant nếu cần. Q3 Admin Designer: `ApprovalWorkflowsV2Page.tsx` 975 lines, AwLevelDto 13 fields (7 Allow*), VI labels line 892-948 ("Trả về 1 Cấp trước"/"Trả về 1 Bước trước"/"Trả về Người chỉ định"/"Trả về Drafter (mặc định)"/"Cho phép chỉnh sửa Section 2 (Hạng mục/NCC/Báo giá) lúc đang duyệt"/"Cho phép chỉnh sửa Section ngân sách lúc đang duyệt"/"Cho phép duyệt thẳng Cấp cuối khi đang duyệt"). KHÔNG có usePermission/PermissionGuard wrap (class-level [Authorize] route guard sufficient). Q4 sidebar widen: fe-user `Layout.tsx:325` + fe-admin `Layout.tsx:218` `w-60 xl:w-72` (240/288px). PE Workspace 2-panel `[260px_1fr] xl:[320px_1fr]` (NOT 3-panel như memory `feedback_responsive_laptop_breakpoint` stale claim). After widen `w-72 xl:w-80` (288/320px) SAFE (sidebar 288 + main 992 → workspace 260+732 fit @ 1280px). `w-80 xl:w-96` THRESHOLD RISKY (sát 700px remaining). Q5 ApplicableType enum `ApprovalWorkflow.cs:45-50` {DuyetNcc=1, DuyetNccPhuongAn=2, Contract=3}. Surprises: (1) memory responsive breakpoint stale "3-panel" → cần update sau Plan AA. (2) Order strategy "Luồng duyệt" Order=2 first → shift existing leaves +1 → cần DbInitializer UPDATE Order existing (KHÔNG chỉ INSERT-if-not-exists). (3) Contract=3 chưa wire FE (chỉ DuyetNcc + DuyetNccPhuongAn). Recommendation: Proceed Plan AA — chỉ ADD param filter + 1 menu key + page mới + sidebar widen. Token cost ~32k.
- **2026-05-15 (S24 t1-t4 post-spawn, em main solo 4 polish chunks — Plan AA wrap):** 7 commits total `a1a910f..ee0902a`: BE+Layout (`ee776d5`) + FE Page (`c667802`) + Docs (`ac2c859`) + 4 polish iter UAT (`da218f1` px-2 + `4d60598` v1 panel-per-NV + `fbbd361` v2 table rowSpan + `ee0902a` sidebar label wrap). **Pattern reusable**: `inline-block icon + inline text + absolute ChevronDown` cho hanging-indent reverse wrap (label dài về đầu hàng). Mirror admin Designer style cho user view read-only. **Sidebar widen tradeoff**: `w-72 xl:w-80` + remove `truncate` FAIL fit 44+ chars label custom Mig 27 — cần combine với `text-[12px] + leading-snug` + restructure flex → block + inline. Sole `truncate` removal không đủ — phải full layout restructure NavLink. **Memory drift confirmed**: `feedback_responsive_laptop_breakpoint.md` claim "PE Workspace 3-panel" → S24 verify ACTUAL **2-panel** (260+1fr only, KHÔNG có panel thứ 3). Cross-ref update needed memory user-level (admin trigger curate sau). **Plan AA color palette success**: STEP_PALETTE 5 màu (blue/purple/emerald/amber/pink) + LEVEL_PALETTE 5 màu (violet/sky/teal/orange/rose) — **Tailwind JIT yêu cầu full class strings array, KHÔNG dynamic interpolation** (`bg-${color}-100` FAIL — class purged). Reusable cross-project cho menu hierarchy color coding (step parent + level child distinct palette). Final layout v2 table rowSpan: Step column merge per-Phòng + Level column rowSpan per-Cấp + NV column 1-row-per-approver, đẹp hơn v1 panel-per-NV stacked. Token cost iteration negligible (em main solo, no spawn).
- **2026-05-15 (S23 t8 spawn Plan R pre-flight cleanup audit):** Bro chốt cleanup destructive prod. 4 sqlcmd queries audit: 35 PE total (28 active + 7 soft) + 17 V2 (15 IsUserSelectable=false + 2 ghim) + 4 V1 (2 active + 2 inactive). FK gotcha catch: PE.ApprovalWorkflowId Restrict + ApprovalWorkflow extends `BaseEntity` NO soft-delete → hard-DELETE required; LevelOpinion → ApprovalWorkflowLevel Restrict cascade block. SQL Express limit: NO COMPRESSION + RESTORE VERIFYONLY require sysadmin. Filtered indexes (Mig 29+) require `SET QUOTED_IDENTIFIER ON`. Cascade child estimate: 446 PE children + ~140 V2 + ~37 V1 = ~620 rows. 3 Option compare → bro chốt A (Hard-DELETE PE + V2 unghim + V1 inactive, GIỮ V2 ghim + V1 active). Plan F precedent: KHÔNG drop V1 active (PE pin → BE crash). - **2026-05-15 (S23 t8 spawn Plan R pre-flight cleanup audit):** Bro chốt cleanup destructive prod. 4 sqlcmd queries audit: 35 PE total (28 active + 7 soft) + 17 V2 (15 IsUserSelectable=false + 2 ghim) + 4 V1 (2 active + 2 inactive). FK gotcha catch: PE.ApprovalWorkflowId Restrict + ApprovalWorkflow extends `BaseEntity` NO soft-delete → hard-DELETE required; LevelOpinion → ApprovalWorkflowLevel Restrict cascade block. SQL Express limit: NO COMPRESSION + RESTORE VERIFYONLY require sysadmin. Filtered indexes (Mig 29+) require `SET QUOTED_IDENTIFIER ON`. Cascade child estimate: 446 PE children + ~140 V2 + ~37 V1 = ~620 rows. 3 Option compare → bro chốt A (Hard-DELETE PE + V2 unghim + V1 inactive, GIỮ V2 ghim + V1 active). Plan F precedent: KHÔNG drop V1 active (PE pin → BE crash).
- **2026-05-15 (S23 t6 spawn Plan P FE wire audit — confirm BE-only scope):** Em main hypothesize Plan P scope BE Controller body record drop. Investigator audit FE × 2 confirm: `PeWorkflowPanel.tsx:113-124` `api.post(/transitions, body)` SEND ĐÚNG 7 fields (TargetPhase + Decision + Comment + ReturnMode + ReturnTargetUserId + SkipToFinal). No service file (untyped object literal). BE `PurchaseEvaluationsController.cs:267` `TransitionPeBody` record CHỈ 3 fields → ASP.NET silent DROP 3 missing fields. Verdict: Plan P BE Controller ONLY ~6 LOC + no test (Mig 28/31 Domain test cover handler). Saved em main blind fix cross-stack. - **2026-05-15 (S23 t6 spawn Plan P FE wire audit — confirm BE-only scope):** Em main hypothesize Plan P scope BE Controller body record drop. Investigator audit FE × 2 confirm: `PeWorkflowPanel.tsx:113-124` `api.post(/transitions, body)` SEND ĐÚNG 7 fields (TargetPhase + Decision + Comment + ReturnMode + ReturnTargetUserId + SkipToFinal). No service file (untyped object literal). BE `PurchaseEvaluationsController.cs:267` `TransitionPeBody` record CHỈ 3 fields → ASP.NET silent DROP 3 missing fields. Verdict: Plan P BE Controller ONLY ~6 LOC + no test (Mig 28/31 Domain test cover handler). Saved em main blind fix cross-stack.
- **2026-05-15 (S23 t3 spawn — UAT bug Allow* flags không hiện cho actor non-row1):** Bro UAT login `nv.test@solutions.com.vn` vào menu eoffice "Duyệt NCC → Duyệt" phiếu PE/2026/A/026 (Phase=ChoDuyet, WF=QT-DN-V2-001 v12, ở Bước 2 Cấp 1 4 NV: Trần Xuân Lưu/NV Test UAT V2/Hồ Thị Nữ Nguyên/Lê Văn Bính). Admin ĐÃ tick 7 Allow*=TRUE riêng cho slot NV Test UAT V2. Nhưng FE dialog Duyệt KHÔNG hiện checkbox SkipToFinal + Trả lại 4 mode + Edit. **Verdict: HYPOTHESIS B — BE handler picks wrong slot row.** Evidence: (1) `PurchaseEvaluationFeatures.cs:765` `var curLevel = curStep?.Levels.FirstOrDefault(l => l.Order == curLevelOrder);` — match FIRST row có `Level.Order == curLevelOrder`, NOT actor's row. Post-Mig 29 refactor, Level.Order trùng nhau cho mọi NV cùng Cấp (4 row có `Order=1` ở Step 2). EF returns Trần Xuân Lưu trước (PK order) → `FirstOrDefault` lấy row đó (all-false except Drafter=true). (2) API curl admin token + nv.test token return CÙNG `currentLevelOptions={ allowReturnOneLevel=false, OneStep=false, Assignee=false, Drafter=true, EditDetails=false, EditBudget=false, SkipToFinal=false }` — handler currentUser-agnostic confirm. (3) Workflow detail GET `/approval-workflows-v2?applicableType=1` `.types[0].active.steps[1].levels` enumerate 4 slot Bước 2 Cấp 1: NV Test (UAT V2) = ALL 7 TRUE; 3 NV còn lại = ALL FALSE (trừ Drafter=true mặc định). Admin Designer wire ĐÚNG (`fe-admin/src/pages/system/ApprovalWorkflowsV2Page.tsx:889-946` 7 checkbox per-slot). FE consumer wire ĐÚNG (`fe-user/src/components/pe/PeWorkflowPanel.tsx:51 levelOptions = evaluation.currentLevelOptions` + line 343/357/371/397 conditional render mode picker + line 425 SkipToFinal checkbox). **Root cause:** BE line 765 lookup semantic broken sau Mig 29 (S21 t5). Trước Mig 29, 1 Level row per Cấp + `ApproverUsers` join table → `FirstOrDefault(Order==X)` đúng. Sau Mig 29 split 1 Level row PER ApproverUser → `Order` field collide → cần match thêm `ApproverUserId == currentUser.UserId`. **Fix BE 1 dòng:** `var curLevel = curStep?.Levels.FirstOrDefault(l => l.Order == curLevelOrder && l.ApproverUserId == currentUser.UserId);` (admin bypass: fallback `?? curStep?.Levels.FirstOrDefault(l => l.Order == curLevelOrder)` để admin xem detail không lỗi). Edge case: Phase=DaDuyet/TraLai/TuChoi pointer null → existing guard line 760-762 skip block OK. **LOC ~2-3 LOC 1 file.** Surprise: bug PRESENT từ deploy Mig 29 (S21 t5 2026-05-13) — không phải regression S23. Lý do trước đây không bắt: UAT test users (default 13 cũ) đa số là row đầu của slot Cấp (Admin tick toàn FALSE → behavior giống nhau, không lộ); chỉ bộc lộ khi admin tick CHỌN LỌC per-NV (UAT V2 S22+2 thêm 20 user role-based + bro tick chỉ NV Test UAT V2). Cross-reference memory `feedback_per_nv_permission_scope.md` cumulative S21 t5 → S22+5 → S23 t1 — KHÔNG có entry nào nhắc bug lookup BE post-refactor. - **2026-05-15 (S23 t3 spawn — UAT bug Allow* flags không hiện cho actor non-row1):** Bro UAT login `nv.test@solutions.com.vn` vào menu eoffice "Duyệt NCC → Duyệt" phiếu PE/2026/A/026 (Phase=ChoDuyet, WF=QT-DN-V2-001 v12, ở Bước 2 Cấp 1 4 NV: Trần Xuân Lưu/NV Test UAT V2/Hồ Thị Nữ Nguyên/Lê Văn Bính). Admin ĐÃ tick 7 Allow*=TRUE riêng cho slot NV Test UAT V2. Nhưng FE dialog Duyệt KHÔNG hiện checkbox SkipToFinal + Trả lại 4 mode + Edit. **Verdict: HYPOTHESIS B — BE handler picks wrong slot row.** Evidence: (1) `PurchaseEvaluationFeatures.cs:765` `var curLevel = curStep?.Levels.FirstOrDefault(l => l.Order == curLevelOrder);` — match FIRST row có `Level.Order == curLevelOrder`, NOT actor's row. Post-Mig 29 refactor, Level.Order trùng nhau cho mọi NV cùng Cấp (4 row có `Order=1` ở Step 2). EF returns Trần Xuân Lưu trước (PK order) → `FirstOrDefault` lấy row đó (all-false except Drafter=true). (2) API curl admin token + nv.test token return CÙNG `currentLevelOptions={ allowReturnOneLevel=false, OneStep=false, Assignee=false, Drafter=true, EditDetails=false, EditBudget=false, SkipToFinal=false }` — handler currentUser-agnostic confirm. (3) Workflow detail GET `/approval-workflows-v2?applicableType=1` `.types[0].active.steps[1].levels` enumerate 4 slot Bước 2 Cấp 1: NV Test (UAT V2) = ALL 7 TRUE; 3 NV còn lại = ALL FALSE (trừ Drafter=true mặc định). Admin Designer wire ĐÚNG (`fe-admin/src/pages/system/ApprovalWorkflowsV2Page.tsx:889-946` 7 checkbox per-slot). FE consumer wire ĐÚNG (`fe-user/src/components/pe/PeWorkflowPanel.tsx:51 levelOptions = evaluation.currentLevelOptions` + line 343/357/371/397 conditional render mode picker + line 425 SkipToFinal checkbox). **Root cause:** BE line 765 lookup semantic broken sau Mig 29 (S21 t5). Trước Mig 29, 1 Level row per Cấp + `ApproverUsers` join table → `FirstOrDefault(Order==X)` đúng. Sau Mig 29 split 1 Level row PER ApproverUser → `Order` field collide → cần match thêm `ApproverUserId == currentUser.UserId`. **Fix BE 1 dòng:** `var curLevel = curStep?.Levels.FirstOrDefault(l => l.Order == curLevelOrder && l.ApproverUserId == currentUser.UserId);` (admin bypass: fallback `?? curStep?.Levels.FirstOrDefault(l => l.Order == curLevelOrder)` để admin xem detail không lỗi). Edge case: Phase=DaDuyet/TraLai/TuChoi pointer null → existing guard line 760-762 skip block OK. **LOC ~2-3 LOC 1 file.** Surprise: bug PRESENT từ deploy Mig 29 (S21 t5 2026-05-13) — không phải regression S23. Lý do trước đây không bắt: UAT test users (default 13 cũ) đa số là row đầu của slot Cấp (Admin tick toàn FALSE → behavior giống nhau, không lộ); chỉ bộc lộ khi admin tick CHỌN LỌC per-NV (UAT V2 S22+2 thêm 20 user role-based + bro tick chỉ NV Test UAT V2). Cross-reference memory `feedback_per_nv_permission_scope.md` cumulative S21 t5 → S22+5 → S23 t1 — KHÔNG có entry nào nhắc bug lookup BE post-refactor.

View File

@ -144,6 +144,7 @@ Flag commit nếu thấy `<PackageReference Include="MediatR" Version="14...` ho
## 📅 Recent activity (last 10 FIFO) ## 📅 Recent activity (last 10 FIFO)
- **2026-05-15 (S24 Plan AA post-wrap cumulative finalize, no re-spawn):** Post-Chunk C learning append — em main iterate **4 polish chunks back-to-back** (`da218f1` px-2 hotfix + `4d60598` redesign v1 panel-per-NV color + `fbbd361` redesign v2 table layout rowSpan + `ee0902a` wrap fix sidebar label) UAT visual feedback bro, cumulative ~1.5h, KHÔNG Reviewer spawn. **Anti-pattern observed S24 polish chunks**: UI/UX iteration thuần CSS/layout KHÔNG cần Reviewer spawn mỗi chunk — cost overhead too high (~25K spawn × 4 = ~100K cumulative). Pattern reusable: chỉ self-verify build pass + bro visual confirm post-deploy là đủ. **Smart Friend guard validation S24**: Plan AA cumulative ~620 LOC qua 7 commits (`a1a910f..ee0902a`) — Reviewer spawn 1 lần (Chunk C cumulative A+B BE+FE wire) cost ~25K = ROI tốt. Multi-spawn polish chunks 4× sẽ ~100K = ROI thấp. **Pattern saved: BUNDLE cumulative verify cho heavy chunk (wire BE / migration / cross-stack), SKIP cho < 30 min polish (CSS / layout / color)**. **Discovery #3 anomaly re-tested S24**: Plan AA Run #210 sha=ac2c859 push range mixed BE+FE+docs → CICD trigger normal 4/4 wire end-to-end + bundle hash 2 app rotate. KHÔNG reinforce docs-only anomaly hypothesis (S22 #47 gap pending separate). Defer Investigator follow-up. **Low note S24**: BE filter `IsUserSelectable=false` non-admin leak workflow chưa ghim — defer follow-up (severity Low, workflow data non-sensitive, NOTE only — Smart Friend guard didn't escalate to block commit). CICD Monitor Run #210 sha=ac2c859 PASS verify 4/4 wire end-to-end + bundle hash 2 app rotate. Cumulative state unchanged S24: 31 mig, 111 test, 47 gotcha.
- **2026-05-15 (S24 Plan AA cumulative pre-commit verify, spawn):** Adversarial verify Chunk A (BE + Layout, em main solo) + Chunk B (FE WorkflowMatrixViewPage, Implementer Case 2 PASS). Diff scope 8 file modified + 2 file CREATE — ~76 LOC BE + ~270 LOC FE, scope khớp Plan AA. **Verdict: PASS with 0 critical / 0 major / 0 minor issues — proceed commit OK.** Wire BE: Controller line 21-26 `Overview(applicableType, isUserSelectable, ct) → new GetAwAdminOverviewQuery(applicableType, isUserSelectable)` end-to-end. Handler line 114-117 `request.IsUserSelectable is bool ius → query.Where(d => d.IsUserSelectable == ius)` correct conditional. FE WorkflowMatrixViewPage line 29-33 actual `api.get<AwAdminOverviewDto>('/approval-workflows-v2', { params: { applicableType: typeInt, isUserSelectable: true } })` — real call no mock/alert. Route `/purchase-evaluations/workflow-matrix?type=N` wired App.tsx:38 + Layout.tsx resolvePath:81-86. Schema integrity: 0 migration mới (column `IsUserSelectable` from Mig 25), DbInitializer INSERT-OR-UPDATE-Order idempotent verified (MenuItemConfiguration HasKey(Key) → PK unique, ToDictionary safe; existing rows UPDATE Order only nếu mismatch; new rows INSERT). 7 Allow* flag count match BE DTO ↔ FE type. ApplicableType enum {1,2,3} — FE chỉ wire 2 type PE matrix view correct. Security: class-level `[Authorize]` bare line 18 PRESERVED (gotcha #44 protect). GET any authenticated → non-admin Drafter OK access. Non-admin pass `isUserSelectable=false` BE không block → workflow chưa ghim leak risk — Low severity (workflow data non-sensitive, NOTE only). Permission seed 7 role × WfView leaf via `SeedPurchaseEvaluationPermissionDefaultsAsync:1573` added — idempotent. Admin role qua `SeedAdminPermissionsAsync` chỉ cover `MenuKeys.All[]` static root keys (Pe_*_WfView dynamic NOT in All) — but admin uses fe-admin Designer, KHÔNG cần WfView access fe-user. Code quality: BE dotnet build PASS 0 err 2 warn (DocxRenderer pre-existing); FE fe-user npm build claim PASS (Implementer Case 2); FE fe-admin npm build VERIFY tự chạy PASS 1926 modules / 740ms / 0 TS err. Anti-fiddle 0% drift, scope khớp spec. Mirror 2 FE §3.9: Layout.tsx widen `w-72 xl:w-80` cả 2 ✓; remove truncate 3 site fe-user (MenuGroup+MenuLeaf+StaticLeaf) + 2 site fe-admin (MenuGroup+MenuLeaf, no StaticLeaf component) — structural asymmetry acceptable (fe-user only có "Hộp thư" StaticLeaf); WorkflowMatrixViewPage fe-user only correct (admin có Designer riêng). Test coverage: Phase 9 UAT exception accept — test-after default OK. Adversarial deep checks: (1) DbInitializer ToDictionary duplicate key risk → PK constraint trên Key, tree.Add chỉ thêm Pe_DuyetNcc_WfView + Pe_DuyetNccPhuongAn_WfView (2 typeCode distinct) → no in-memory dup. (2) Sidebar widen 1280px responsive verified per task spec (288 sidebar + 992 main fit). (3) Plan U revert clean — 0 remaining truncate class outside Plan AA comments. (4) Mig drift schema: column existed Mig 25, no new mig needed. 2 SaveChangesAsync non-atomic giữa menu seed + label backfill (pre-existing, OUT scope Plan AA). Comment quality: Plan AA marker rõ ràng 8+ sites, no TODO/FIXME zombie. TypeScript: `FlagCell` indexed-access type clever từ Pick 7 keys union — TS happy compile clean. Recommendations defer: (a) enforce admin/non-admin policy filter (current GET cho phép user pass isUserSelectable=false — low risk, audit follow-up); (b) MenuKeys.All[] không cover dynamic Pe_*_WfView nên Admin role không auto grant — OK vì admin dùng fe-admin Designer, NOTE để future audit khi admin cần inspect user-side matrix view. Cumulative state unchanged: 31 mig, 111 test, 47 gotcha. Smart Friend guard active — KHÔNG lower bar (3 minor risk noted defer follow-up, không block commit). - **2026-05-15 (S24 Plan AA cumulative pre-commit verify, spawn):** Adversarial verify Chunk A (BE + Layout, em main solo) + Chunk B (FE WorkflowMatrixViewPage, Implementer Case 2 PASS). Diff scope 8 file modified + 2 file CREATE — ~76 LOC BE + ~270 LOC FE, scope khớp Plan AA. **Verdict: PASS with 0 critical / 0 major / 0 minor issues — proceed commit OK.** Wire BE: Controller line 21-26 `Overview(applicableType, isUserSelectable, ct) → new GetAwAdminOverviewQuery(applicableType, isUserSelectable)` end-to-end. Handler line 114-117 `request.IsUserSelectable is bool ius → query.Where(d => d.IsUserSelectable == ius)` correct conditional. FE WorkflowMatrixViewPage line 29-33 actual `api.get<AwAdminOverviewDto>('/approval-workflows-v2', { params: { applicableType: typeInt, isUserSelectable: true } })` — real call no mock/alert. Route `/purchase-evaluations/workflow-matrix?type=N` wired App.tsx:38 + Layout.tsx resolvePath:81-86. Schema integrity: 0 migration mới (column `IsUserSelectable` from Mig 25), DbInitializer INSERT-OR-UPDATE-Order idempotent verified (MenuItemConfiguration HasKey(Key) → PK unique, ToDictionary safe; existing rows UPDATE Order only nếu mismatch; new rows INSERT). 7 Allow* flag count match BE DTO ↔ FE type. ApplicableType enum {1,2,3} — FE chỉ wire 2 type PE matrix view correct. Security: class-level `[Authorize]` bare line 18 PRESERVED (gotcha #44 protect). GET any authenticated → non-admin Drafter OK access. Non-admin pass `isUserSelectable=false` BE không block → workflow chưa ghim leak risk — Low severity (workflow data non-sensitive, NOTE only). Permission seed 7 role × WfView leaf via `SeedPurchaseEvaluationPermissionDefaultsAsync:1573` added — idempotent. Admin role qua `SeedAdminPermissionsAsync` chỉ cover `MenuKeys.All[]` static root keys (Pe_*_WfView dynamic NOT in All) — but admin uses fe-admin Designer, KHÔNG cần WfView access fe-user. Code quality: BE dotnet build PASS 0 err 2 warn (DocxRenderer pre-existing); FE fe-user npm build claim PASS (Implementer Case 2); FE fe-admin npm build VERIFY tự chạy PASS 1926 modules / 740ms / 0 TS err. Anti-fiddle 0% drift, scope khớp spec. Mirror 2 FE §3.9: Layout.tsx widen `w-72 xl:w-80` cả 2 ✓; remove truncate 3 site fe-user (MenuGroup+MenuLeaf+StaticLeaf) + 2 site fe-admin (MenuGroup+MenuLeaf, no StaticLeaf component) — structural asymmetry acceptable (fe-user only có "Hộp thư" StaticLeaf); WorkflowMatrixViewPage fe-user only correct (admin có Designer riêng). Test coverage: Phase 9 UAT exception accept — test-after default OK. Adversarial deep checks: (1) DbInitializer ToDictionary duplicate key risk → PK constraint trên Key, tree.Add chỉ thêm Pe_DuyetNcc_WfView + Pe_DuyetNccPhuongAn_WfView (2 typeCode distinct) → no in-memory dup. (2) Sidebar widen 1280px responsive verified per task spec (288 sidebar + 992 main fit). (3) Plan U revert clean — 0 remaining truncate class outside Plan AA comments. (4) Mig drift schema: column existed Mig 25, no new mig needed. 2 SaveChangesAsync non-atomic giữa menu seed + label backfill (pre-existing, OUT scope Plan AA). Comment quality: Plan AA marker rõ ràng 8+ sites, no TODO/FIXME zombie. TypeScript: `FlagCell` indexed-access type clever từ Pick 7 keys union — TS happy compile clean. Recommendations defer: (a) enforce admin/non-admin policy filter (current GET cho phép user pass isUserSelectable=false — low risk, audit follow-up); (b) MenuKeys.All[] không cover dynamic Pe_*_WfView nên Admin role không auto grant — OK vì admin dùng fe-admin Designer, NOTE để future audit khi admin cần inspect user-side matrix view. Cumulative state unchanged: 31 mig, 111 test, 47 gotcha. Smart Friend guard active — KHÔNG lower bar (3 minor risk noted defer follow-up, không block commit).
- **2026-05-15 (S23 t4-t11 cumulative em main self-review — Plan N+O+P+Q+R+S+T+U, no Reviewer spawn):** 8 plan consecutive em main self-review per UAT mode (`feedback_uat_skip_verify` rule — em main verify build + test + npm build mỗi chunk). Key validations cumulative: **Plan N** GetPe handler `PurchaseEvaluationFeatures.cs:765` per-NV `ApproverUserId` discriminator + admin fallback row đầu. **Plan O** 4 lookup sites cascade fix (`EnsureCanRejectV2Async:201` + `ApplyReturnModeAsync:248` + `EnsureEditableForDetailsAsync:72` + `AdjustBudgetCommandHandler:311`) — pattern uniform Plan N, +3 regression test `PurchaseEvaluationPerNvLookupRegressionTests.cs`. **Plan P** Controller `TransitionPeBody:267` record +3 fields mirror `TransitionPurchaseEvaluationCommand` schema — root cause 2 ngày prod bug F1+F2 wire fail. **Plan Q** FE banner mx-5 inset gap fix (CSS layout polish mirror 2 app). **Plan R+S+T5** destructive sqlcmd cleanup prod ~720 rows wiped cumulative + Plan F precedent avoid được (V1 active workflow giữ nguyên → BE healthy startup). **Plan T** DbInitializer `DemoSeed:Disabled` flag config — disable 5 demo seed methods (Workflow V1 + PE V1 + Demo Contracts + Demo PE + Sample V2). **Plan U** FE sidebar truncate + tooltip 2 app mirror — handle long DisplayLabel (Mig 27 admin custom). Anti-patterns observed: (1) **Plan N point 9 chỉ catch 1/5 sites** — em main + Investigator spawn miss 4 sites khác → Plan O cascade fix. Lesson: grep ENUMERATE TẤT CẢ lookup sites cùng pattern (KHÔNG fix theo bug report mỗi lần). (2) **Plan O caveat #1 surfaced Plan P pre-existing bug** — CICD Monitor catch Controller body record drop trong Stage 4c verify wire — pattern "verify cross-stack body↔command count match". (3) **DbInitializer auto re-seed** loop — Plan R+S clean → IIS recycle → re-seed loop. Plan T flag fix root cause. Pattern reusable cross-project: refactor schema 1-row-per-role MUST grep enum lookup sites + Controller body record MUST mirror Command record fields. Cumulative state: 111 test (+7 vs 104 baseline pre-Plan M), 31 mig (no new), 47 gotcha unchanged, `feedback_per_nv_permission_scope.md` reinforced 5 lookup sites enum + 9 wire surface points + Plan P caveat → 10 surface points. Smart Friend guard still active for future spawn. - **2026-05-15 (S23 t4-t11 cumulative em main self-review — Plan N+O+P+Q+R+S+T+U, no Reviewer spawn):** 8 plan consecutive em main self-review per UAT mode (`feedback_uat_skip_verify` rule — em main verify build + test + npm build mỗi chunk). Key validations cumulative: **Plan N** GetPe handler `PurchaseEvaluationFeatures.cs:765` per-NV `ApproverUserId` discriminator + admin fallback row đầu. **Plan O** 4 lookup sites cascade fix (`EnsureCanRejectV2Async:201` + `ApplyReturnModeAsync:248` + `EnsureEditableForDetailsAsync:72` + `AdjustBudgetCommandHandler:311`) — pattern uniform Plan N, +3 regression test `PurchaseEvaluationPerNvLookupRegressionTests.cs`. **Plan P** Controller `TransitionPeBody:267` record +3 fields mirror `TransitionPurchaseEvaluationCommand` schema — root cause 2 ngày prod bug F1+F2 wire fail. **Plan Q** FE banner mx-5 inset gap fix (CSS layout polish mirror 2 app). **Plan R+S+T5** destructive sqlcmd cleanup prod ~720 rows wiped cumulative + Plan F precedent avoid được (V1 active workflow giữ nguyên → BE healthy startup). **Plan T** DbInitializer `DemoSeed:Disabled` flag config — disable 5 demo seed methods (Workflow V1 + PE V1 + Demo Contracts + Demo PE + Sample V2). **Plan U** FE sidebar truncate + tooltip 2 app mirror — handle long DisplayLabel (Mig 27 admin custom). Anti-patterns observed: (1) **Plan N point 9 chỉ catch 1/5 sites** — em main + Investigator spawn miss 4 sites khác → Plan O cascade fix. Lesson: grep ENUMERATE TẤT CẢ lookup sites cùng pattern (KHÔNG fix theo bug report mỗi lần). (2) **Plan O caveat #1 surfaced Plan P pre-existing bug** — CICD Monitor catch Controller body record drop trong Stage 4c verify wire — pattern "verify cross-stack body↔command count match". (3) **DbInitializer auto re-seed** loop — Plan R+S clean → IIS recycle → re-seed loop. Plan T flag fix root cause. Pattern reusable cross-project: refactor schema 1-row-per-role MUST grep enum lookup sites + Controller body record MUST mirror Command record fields. Cumulative state: 111 test (+7 vs 104 baseline pre-Plan M), 31 mig (no new), 47 gotcha unchanged, `feedback_per_nv_permission_scope.md` reinforced 5 lookup sites enum + 9 wire surface points + Plan P caveat → 10 surface points. Smart Friend guard still active for future spawn.
- **2026-05-15 (S23 t3 Plan M cumulative review, spawn):** Pre-push adversarial verify 3 commits local `c2afef2..508b17a..4dd6f9c` Plan M F1 edge case Bước 1 + Phase=TraLai display rename. Diff cumulative: 26 LOC BE (Service.cs:287-333) + 116 LOC test (1 file, +2 test Fact extend SeedWorkflowAsync helper +2 params optional) + 8 LOC FE (4 file × 2 LOC mirror admin+user). **Verdict: PASS** — wire BE M1 verified hot path 287-333 OneLevel+OneStep edge case replace `Phase=TraLai+clear pointer+return` with `Set pointer (0,1) + summary "không lùi được" → fallthrough SLA reset line 364 → Phase=ChoDuyet preserved from pre-call state (entry guard 75-81 require ChoDuyet để Reject decision)`. ApplyReturnModeAsync caller line 94-100 truyền `evaluation.Phase` (now ChoDuyet) vào LogTransitionAsync → Summary="Chuyển phase ChoDuyet → ChoDuyet" + ContextNote contain "không lùi được" (matches test assert ContextNote.Contain). Drafter mode line 268-275 GIỮ Phase=TraLai semantic (unchanged). Assignee line 335-360 throw nếu không match unchanged. F2 ApproveV2Async + F3 EnsureEditableForDetailsAsync + F4 AdjustBudgetCommand handler — UNCHANGED. Schema integrity: 0 migration mới, Phase enum TraLai=98 còn dùng cho Drafter mode + display label rename only. Security: Admin bypass logic line 252-265 + Reject guard line 81 EnsureCanRejectV2Async + non-Approver block — preserved. Code quality: dotnet build PASS 0 err 2 warn (DocxRenderer pre-existing), dotnet test 106/106 PASS (58 Domain + 48 Infra, +2 từ 104 baseline), npm build admin+user PASS 0 TS err (chỉ chunk size warn pre-existing), no `--no-verify`. Test coverage: 2 Fact mới `ApplyReturnMode_OneLevel_AtStep1Level1_ResetsToBuoc1Cap1_KeepsChoDuyet` + `ApplyReturnMode_OneStep_AtStep1_ResetsToBuoc1Cap1_KeepsChoDuyet` cover OneLevel Step1Lv1 + OneStep Step1Lv2→reset. Assert đủ Phase=ChoDuyet + pointer (0,1) + SLA NotNull + ContextNote "không lùi được". Helper extend +2 params backward compat OK (default false). K7 cascade NO regression — 3 `ApproveV2_SkipToFinal_*` xanh (M1 chỉ đụng F1 ApplyReturnModeAsync, không động F2 ApproveV2Async). Mirror 2 FE app (§3.9): purchaseEvaluation.ts admin+user identical (98:'Cần chỉnh sửa lại' + PeDisplayStatus.TraLai:'Cần chỉnh sửa lại'), PeWorkflowPanel.tsx admin+user identical (2 inline literal "Phase → ..." + "Phiếu sẽ về ..." rename). Anti-fiddle: scope drift 0% — 8 LOC FE đúng spec rename Phase=TraLai display only. Anti-pattern guard: **(1) Stale narrative comment Service.cs:288-289 + 327-328** UPDATED rõ "Plan M S23 t3 — KHÔNG fallback Drafter, phiếu giữ đang duyệt" — không zombie. **(2) Audit log consistency** test+code match "không lùi được" exact. **(3) Backward compat** phiếu UAT prod đang Phase=TraLai do logic cũ — Drafter resume từ TraLai vẫn work line 105-132 (entry point `fromPhase==TraLai → targetPhase==ChoDuyet`). **Minor issues (non-block, recommend fix sau):** **(4) Inconsistent UX literal "Trả lại"** còn ở 8 user-facing locations chưa rename (decision design): PeListPanel.tsx:112 "Bản nháp + Trả lại" filter label, PeWorkflowPanel.tsx:270 button "← Trả lại", 272 tooltip "(Duyệt / Trả lại / Từ chối)", 315 "← Trả lại Drafter sửa", 342 "Chọn cách Trả lại", PeDetailTabs.tsx:152 "chỉ Bản nháp / Trả lại mới sửa", 287 "(trừ khi approver Trả lại)", ApprovalWorkflowsV2Page.tsx:639 "(Trả lại / Edit Section 2 / ...)" — phân biệt **action verb** "Trả lại" (button approver click) vs **phase result label** "Cần chỉnh sửa lại" (Phase=TraLai display in dropdown/badge); spec M3 narrow scope chỉ rename phase result label OK. Em main quyết: giữ action verb hay rename hết. **(5) Inconsistent across module** contracts.ts:29 + budget.ts:20 vẫn `98:'Trả lại'` — KHÔNG trong scope Plan M (PE-only) nhưng inconsistent giữa 3 module nếu Contract/Budget có Phase 98 — bro nếu deploy chung sẽ noticeable. Recommendation: SAFE to push 3 commit Plan M; consider follow-up chunk M4 (optional) rename 5 literal user-facing trong PeListPanel + PeWorkflowPanel + PeDetailTabs để consistent UX semantic mới. Smart Friend guard active. - **2026-05-15 (S23 t3 Plan M cumulative review, spawn):** Pre-push adversarial verify 3 commits local `c2afef2..508b17a..4dd6f9c` Plan M F1 edge case Bước 1 + Phase=TraLai display rename. Diff cumulative: 26 LOC BE (Service.cs:287-333) + 116 LOC test (1 file, +2 test Fact extend SeedWorkflowAsync helper +2 params optional) + 8 LOC FE (4 file × 2 LOC mirror admin+user). **Verdict: PASS** — wire BE M1 verified hot path 287-333 OneLevel+OneStep edge case replace `Phase=TraLai+clear pointer+return` with `Set pointer (0,1) + summary "không lùi được" → fallthrough SLA reset line 364 → Phase=ChoDuyet preserved from pre-call state (entry guard 75-81 require ChoDuyet để Reject decision)`. ApplyReturnModeAsync caller line 94-100 truyền `evaluation.Phase` (now ChoDuyet) vào LogTransitionAsync → Summary="Chuyển phase ChoDuyet → ChoDuyet" + ContextNote contain "không lùi được" (matches test assert ContextNote.Contain). Drafter mode line 268-275 GIỮ Phase=TraLai semantic (unchanged). Assignee line 335-360 throw nếu không match unchanged. F2 ApproveV2Async + F3 EnsureEditableForDetailsAsync + F4 AdjustBudgetCommand handler — UNCHANGED. Schema integrity: 0 migration mới, Phase enum TraLai=98 còn dùng cho Drafter mode + display label rename only. Security: Admin bypass logic line 252-265 + Reject guard line 81 EnsureCanRejectV2Async + non-Approver block — preserved. Code quality: dotnet build PASS 0 err 2 warn (DocxRenderer pre-existing), dotnet test 106/106 PASS (58 Domain + 48 Infra, +2 từ 104 baseline), npm build admin+user PASS 0 TS err (chỉ chunk size warn pre-existing), no `--no-verify`. Test coverage: 2 Fact mới `ApplyReturnMode_OneLevel_AtStep1Level1_ResetsToBuoc1Cap1_KeepsChoDuyet` + `ApplyReturnMode_OneStep_AtStep1_ResetsToBuoc1Cap1_KeepsChoDuyet` cover OneLevel Step1Lv1 + OneStep Step1Lv2→reset. Assert đủ Phase=ChoDuyet + pointer (0,1) + SLA NotNull + ContextNote "không lùi được". Helper extend +2 params backward compat OK (default false). K7 cascade NO regression — 3 `ApproveV2_SkipToFinal_*` xanh (M1 chỉ đụng F1 ApplyReturnModeAsync, không động F2 ApproveV2Async). Mirror 2 FE app (§3.9): purchaseEvaluation.ts admin+user identical (98:'Cần chỉnh sửa lại' + PeDisplayStatus.TraLai:'Cần chỉnh sửa lại'), PeWorkflowPanel.tsx admin+user identical (2 inline literal "Phase → ..." + "Phiếu sẽ về ..." rename). Anti-fiddle: scope drift 0% — 8 LOC FE đúng spec rename Phase=TraLai display only. Anti-pattern guard: **(1) Stale narrative comment Service.cs:288-289 + 327-328** UPDATED rõ "Plan M S23 t3 — KHÔNG fallback Drafter, phiếu giữ đang duyệt" — không zombie. **(2) Audit log consistency** test+code match "không lùi được" exact. **(3) Backward compat** phiếu UAT prod đang Phase=TraLai do logic cũ — Drafter resume từ TraLai vẫn work line 105-132 (entry point `fromPhase==TraLai → targetPhase==ChoDuyet`). **Minor issues (non-block, recommend fix sau):** **(4) Inconsistent UX literal "Trả lại"** còn ở 8 user-facing locations chưa rename (decision design): PeListPanel.tsx:112 "Bản nháp + Trả lại" filter label, PeWorkflowPanel.tsx:270 button "← Trả lại", 272 tooltip "(Duyệt / Trả lại / Từ chối)", 315 "← Trả lại Drafter sửa", 342 "Chọn cách Trả lại", PeDetailTabs.tsx:152 "chỉ Bản nháp / Trả lại mới sửa", 287 "(trừ khi approver Trả lại)", ApprovalWorkflowsV2Page.tsx:639 "(Trả lại / Edit Section 2 / ...)" — phân biệt **action verb** "Trả lại" (button approver click) vs **phase result label** "Cần chỉnh sửa lại" (Phase=TraLai display in dropdown/badge); spec M3 narrow scope chỉ rename phase result label OK. Em main quyết: giữ action verb hay rename hết. **(5) Inconsistent across module** contracts.ts:29 + budget.ts:20 vẫn `98:'Trả lại'` — KHÔNG trong scope Plan M (PE-only) nhưng inconsistent giữa 3 module nếu Contract/Budget có Phase 98 — bro nếu deploy chung sẽ noticeable. Recommendation: SAFE to push 3 commit Plan M; consider follow-up chunk M4 (optional) rename 5 literal user-facing trong PeListPanel + PeWorkflowPanel + PeDetailTabs để consistent UX semantic mới. Smart Friend guard active.

View File

@ -1,6 +1,6 @@
# HANDOFF — Brief 5 phút cho session tiếp theo # HANDOFF — Brief 5 phút cho session tiếp theo
**Last updated:** 2026-05-15 (Session 24 turn 1**🎯 Plan AA: User Workflow Matrix view + Sidebar widen — DONE 3 commits**. Bro UAT request 2 việc: (1) sidebar truncate Plan U S23 t11 → hiển thị đầy đủ, (2) thêm menu "Luồng duyệt" trên Danh sách hiển thị ma trận phân quyền workflow Designer ghim cho user xem (filter `IsUserSelectable=true` Mig 25). 4 sub-agent: 🟦 Investigator Pre-A audit 5Q (~32K, confirm gotcha #44 đã fixed permanent từ S18 + sidebar widen w-72 xl:w-80 SAFE + memory responsive 3-panel stale) + 🟨 Implementer Case 2 Chunk B FE (~14K, page + types + App.tsx route ~270 LOC) + 🟥 Reviewer cumulative pre-commit (~25K, PASS 0 critical/major/minor blocker + fe-admin build verify bonus 1926 modules 740ms). Em main Chunk A solo: BE `IsUserSelectable bool?` filter param + handler conditional + Controller pass-through + MenuKeys `PurchaseEvaluationWorkflowView` helper + DbInitializer tree.Add LuongDuyet + INSERT-OR-UPDATE-Order refactor (idempotent shift existing prod rows) + Permission seed 7 role + sidebar widen `w-72 xl:w-80` × 2 app mirror + revert Plan U truncate × 5 sites + Layout.tsx resolvePath `WfView` regex. Pattern reinforced: gotcha #44 class-level Authorize relax pattern PROVEN cumulative S18→S24 (Workflows endpoint reusable cho user read-only matrix view). 3 commits push `ee776d5..<docs>`. Stats: 31 mig · 59 tables · **~146 endpoints (+1 GET filter param)** · **35 FE pages (+1 WorkflowMatrixViewPage)** · 111 test · 47 gotcha · 21 memory · 6 skills · 4 sub-agents.) **Last updated:** 2026-05-15 (Session 24 chốt cuối**🎯 Plan AA cumulative 7 commits push `a1a910f..ee0902a`** — User Workflow Matrix view + Sidebar widen + 4 polish iteration UAT feedback. Phase 1 Plan AA core (3 commit `ee776d5..ac2c859`): 🟦 Investigator Pre-A 5Q audit (~32K) + 👤 Chủ trì Chunk A BE+Layout solo (gotcha #44 đã fix permanent từ S18 → chỉ ADD `IsUserSelectable bool?` filter + DbInitializer INSERT-OR-UPDATE-Order idempotent shift existing prod rows + MenuKeys `Pe_DuyetNcc_WfView` helper + sidebar widen `w-72 xl:w-80` × 2 app + revert Plan U truncate × 5 sites) + 🟨 Implementer Case 2 Chunk B FE (~14K, WorkflowMatrixViewPage + types + App.tsx route ~270 LOC) + 🟥 Reviewer cumulative pre-commit (~25K, PASS 0 blocker + fe-admin build bonus 1926 modules) + 🟩 CICD Monitor Run #210 verify (4/4 wire end-to-end: filter live + menu Order shift + bundle hash rotate 2 app + Mig 31 unchanged). Phase 2 polish iteration UAT feedback (4 commit `da218f1..ee0902a`): 👤 Chủ trì Solo 4× CSS/UX polish — (1) `da218f1` hotfix container px-6→px-2 (content sát sidebar) + (2) `4d60598` redesign v1 panel-per-NV mirror admin Designer color coding (drop table 11 cột symbol khó hiểu) + (3) `fbbd361` redesign v2 HTML table rowSpan tận dụng full width (4 cột: Bước/Cấp/NV/Quyền duyệt grid 2-col 7 label) + (4) `ee0902a` wrap fix label dài về đầu hàng pattern hanging-indent reverse CSS (flex→block + inline-block icon + inline text + absolute ChevronDown) + text smaller text-[12px] leading-snug. Patterns reusable cross-project: (a) gotcha #44 relax pattern PROVEN cross-stack reuse, (b) DbInitializer INSERT-OR-UPDATE-Order idempotent re-deploy, (c) Tailwind JIT palette array (STEP_PALETTE 5 màu + LEVEL_PALETTE 5 màu cycle), (d) HTML table rowSpan flat row builder helper, (e) hanging-indent reverse via inline-block icon. Stats: 31 mig · 59 tables · **~146 endpoints (+1 GET filter param)** · **35 FE pages (+1 WorkflowMatrixViewPage)** · **111 test** (no change, baseline confirmed post-Plan AA) · 47 gotcha · 21 memory · 6 skills · 4 sub-agents. Multi-agent ROI S24: ~175K total (Inv 32K + Imp 14K + Rev 25K + CICD 12K + 3 flush agents ~12K + em main ~80K) = ~28% solo equiv. CICD verify Run #210 PASS. **Implementer MEMORY ~31.5KB > 25KB threshold** → recommend curate next session archive S20-S22 old entries.)
**Last updated S23 t12:** 2026-05-15 (Session 23 turn 12 chốt cuối — **🎯 S23 cumulative 11 plan + 32 commits**. Plan K (Mig 31 F2 refactor 9c) → L (UAT bug 5c) → M (F1 edge case 4c) → N (per-NV lookup 1 site 2c) → O (4 sites cascade 2c) → P (Controller body record 1c) → Q (FE banner 1c) → R (cleanup phiếu/wf 1c) → S (wipe ALL wf 1c) → T (DemoSeed flag 2c) → U (sidebar truncate 1c). 4 sub-agents: Investigator 5 spawn + Implementer 5 spawn + Reviewer 2 spawn + CICD Monitor 10 verify runs PASS. Memory +1 NEW `feedback_demo_seed_flag_disable.md` + `feedback_per_nv_permission_scope.md` reinforced 10 wire surface points (point 9 lookup discrimination + point 10 Controller body record mirror). Cleanup cumulative R+S+T5 ~720 rows wiped + DbInitializer flag persist. Stats: 31 mig · 59 tables · ~145 endpoints · **111 test** · 47 gotcha · **21 memory** (+1) · 6 skills · **0 PE + 0 demo workflow + flag persist** UAT permanent clean slate. 32 commits push `eb106f2..86d8806`. Plan B Contract V2 wire HIGH next.) **Last updated S23 t12:** 2026-05-15 (Session 23 turn 12 chốt cuối — **🎯 S23 cumulative 11 plan + 32 commits**. Plan K (Mig 31 F2 refactor 9c) → L (UAT bug 5c) → M (F1 edge case 4c) → N (per-NV lookup 1 site 2c) → O (4 sites cascade 2c) → P (Controller body record 1c) → Q (FE banner 1c) → R (cleanup phiếu/wf 1c) → S (wipe ALL wf 1c) → T (DemoSeed flag 2c) → U (sidebar truncate 1c). 4 sub-agents: Investigator 5 spawn + Implementer 5 spawn + Reviewer 2 spawn + CICD Monitor 10 verify runs PASS. Memory +1 NEW `feedback_demo_seed_flag_disable.md` + `feedback_per_nv_permission_scope.md` reinforced 10 wire surface points (point 9 lookup discrimination + point 10 Controller body record mirror). Cleanup cumulative R+S+T5 ~720 rows wiped + DbInitializer flag persist. Stats: 31 mig · 59 tables · ~145 endpoints · **111 test** · 47 gotcha · **21 memory** (+1) · 6 skills · **0 PE + 0 demo workflow + flag persist** UAT permanent clean slate. 32 commits push `eb106f2..86d8806`. Plan B Contract V2 wire HIGH next.)

View File

@ -80,6 +80,7 @@
| Ngày | Ai | Task | Commit | | Ngày | Ai | Task | Commit |
|---|---|---|---| |---|---|---|---|
| 2026-05-15 | Claude | **🎯 SESSION 24 chốt cuối — Plan AA cumulative 7 commits (3 core + 4 polish UAT iteration)** — Plan AA Phase 1 core 3 commit (Chunk A BE+Layout + Chunk B FE matrix page + Chunk C Docs initial). Phase 2 polish 4 commit liên tục UAT feedback bro: `da218f1` hotfix px-6→px-2 (content sát sidebar) + `4d60598` redesign v1 panel-per-NV mirror admin Designer color coding (drop table symbol khó hiểu) + `fbbd361` redesign v2 HTML table rowSpan tận dụng full width (Bước/Cấp/NV/Quyền duyệt grid 2-col 7 label tiếng Việt nguyên văn) + `ee0902a` wrap fix sidebar label dài về đầu hàng (hanging-indent reverse CSS: flex→block + inline-block icon + inline text + absolute ChevronDown + text-[12px] leading-snug × 5 sites mirror 2 app). Patterns reusable saved: (1) Tailwind JIT palette array (5-color cycle Step + Cấp), (2) HTML table rowSpan flat row builder helper, (3) hanging-indent reverse CSS pattern. Multi-agent ROI: ~175K total (Investigator 32K Pre-A + Implementer 14K Chunk B + Reviewer 25K cumulative + CICD 12K Run #210 + 3 agent flush ~12K + em main ~80K) ≈ 28% solo equiv. **CICD Run #210 PASS 4/4 wire end-to-end**: IsUserSelectable filter live (admin no-filter / admin ghim / nv.test ghim all HTTP 200) + menu Pe_DuyetNcc_WfView present + Order shift idempotent 1-10 contiguous + non-admin permission Read OK + bundle hash rotate 2 app + Mig 31 unchanged. Pattern reinforced cumulative: gotcha #44 class-level Authorize relax PROVEN cross-stack reuse S18→S24 (Workflows endpoint từ admin-only sang any-auth read accessible). Test 111/111 PASS unchanged post-Plan AA (BE filter param + DbInitializer refactor no regression). Stats: 31 mig · 59 tables · **~146 endpoints (+1)** · **35 FE pages (+1 WorkflowMatrixViewPage)** · 111 test · 47 gotcha · 21 memory · 6 skills. **Implementer agent MEMORY ~31.5KB > 25KB threshold** → recommend curate next session archive S20-S22 old entries. | `ee776d5` (A BE+Layout) · `c667802` (B FE page) · `ac2c859` (C Docs init) · `da218f1` (px-2 hotfix) · `4d60598` (redesign v1 panel) · `fbbd361` (redesign v2 table rowSpan) · `ee0902a` (wrap fix label) · this Docs final |
| 2026-05-15 | Claude | **🎯 SESSION 24 turn 1 — Plan AA User Workflow Matrix view + Sidebar widen revert Plan U truncate (3 commit)** — Bro UAT request: (1) sidebar Plan U S23 t11 truncate "..." → hiển thị đầy đủ label custom Mig 27, (2) thêm menu "Luồng duyệt" trên Danh sách hiển thị ma trận phân quyền workflow Designer ghim cho user xem (filter `IsUserSelectable=true` Mig 25). Q&A clarify 2 lượt: Q1 Permission strategy "Relax class-level [Authorize]" (đã fix gotcha #44 permanent từ S18 → CHỈ cần add filter param), Q2 Matrix layout "Table 2D full 7 Allow* cột". Plan 4 chunk: Pre-A (🟦 Investigator audit ~32K, confirm gotcha #44 + sidebar `w-72 xl:w-80` SAFE + Order strategy shift existing) + Chunk A (👤 Chủ trì Solo BE + Layout: MenuKeys `PurchaseEvaluationWorkflowView` helper + DbInitializer tree.Add LuongDuyet Order=2 + INSERT-OR-UPDATE-Order refactor idempotent + Permission seed 7 role + Handler `IsUserSelectable bool?` filter + Controller pass-through + sidebar `w-60 xl:w-72``w-72 xl:w-80` × 2 app mirror + revert Plan U truncate × 5 sites; commit `ee776d5` 6 files +73/-24) + Chunk B (🟨 Implementer Case 2 ~14K: WorkflowMatrixViewPage.tsx ~215 LOC + types/approvalWorkflowV2.ts ~55 LOC + App.tsx +route 2 LOC; commit `c667802` 3 files +305) + Chunk C (🟥 Reviewer cumulative ~25K: PASS 0 critical/major/minor blocker + Smart Friend guard active + fe-admin build verify bonus 1926 modules 740ms). Pattern reinforced: (1) gotcha #44 relax pattern PROVEN cross-stack reuse — Workflows endpoint từ admin-only sang any-auth read accessible. (2) DbInitializer INSERT-only → INSERT-OR-UPDATE-Order safe shift existing prod rows (idempotent re-deploy). (3) Plan U truncate revert pattern: widen sidebar + drop truncate, keep `min-w-0 flex-1` + `shrink-0` + `title` tooltip (no harm). **Surprise:** PE Workspace là **2-panel** không phải 3-panel — memory `feedback_responsive_laptop_breakpoint.md` stale claim → defer update memory. **3 commits push pending** (`ee776d5..<this>`). Stats: 31 mig · 59 tables · ~146 endpoints (+1 query filter param) · **35 FE pages (+1)** · 111 test (unchanged UAT mode) · 47 gotcha · 21 memory · 6 skills · 4 sub-agents (3 spawn S24 t1). | `ee776d5` (A BE+Layout) · `c667802` (B FE page) · (this Docs C) | | 2026-05-15 | Claude | **🎯 SESSION 24 turn 1 — Plan AA User Workflow Matrix view + Sidebar widen revert Plan U truncate (3 commit)** — Bro UAT request: (1) sidebar Plan U S23 t11 truncate "..." → hiển thị đầy đủ label custom Mig 27, (2) thêm menu "Luồng duyệt" trên Danh sách hiển thị ma trận phân quyền workflow Designer ghim cho user xem (filter `IsUserSelectable=true` Mig 25). Q&A clarify 2 lượt: Q1 Permission strategy "Relax class-level [Authorize]" (đã fix gotcha #44 permanent từ S18 → CHỈ cần add filter param), Q2 Matrix layout "Table 2D full 7 Allow* cột". Plan 4 chunk: Pre-A (🟦 Investigator audit ~32K, confirm gotcha #44 + sidebar `w-72 xl:w-80` SAFE + Order strategy shift existing) + Chunk A (👤 Chủ trì Solo BE + Layout: MenuKeys `PurchaseEvaluationWorkflowView` helper + DbInitializer tree.Add LuongDuyet Order=2 + INSERT-OR-UPDATE-Order refactor idempotent + Permission seed 7 role + Handler `IsUserSelectable bool?` filter + Controller pass-through + sidebar `w-60 xl:w-72``w-72 xl:w-80` × 2 app mirror + revert Plan U truncate × 5 sites; commit `ee776d5` 6 files +73/-24) + Chunk B (🟨 Implementer Case 2 ~14K: WorkflowMatrixViewPage.tsx ~215 LOC + types/approvalWorkflowV2.ts ~55 LOC + App.tsx +route 2 LOC; commit `c667802` 3 files +305) + Chunk C (🟥 Reviewer cumulative ~25K: PASS 0 critical/major/minor blocker + Smart Friend guard active + fe-admin build verify bonus 1926 modules 740ms). Pattern reinforced: (1) gotcha #44 relax pattern PROVEN cross-stack reuse — Workflows endpoint từ admin-only sang any-auth read accessible. (2) DbInitializer INSERT-only → INSERT-OR-UPDATE-Order safe shift existing prod rows (idempotent re-deploy). (3) Plan U truncate revert pattern: widen sidebar + drop truncate, keep `min-w-0 flex-1` + `shrink-0` + `title` tooltip (no harm). **Surprise:** PE Workspace là **2-panel** không phải 3-panel — memory `feedback_responsive_laptop_breakpoint.md` stale claim → defer update memory. **3 commits push pending** (`ee776d5..<this>`). Stats: 31 mig · 59 tables · ~146 endpoints (+1 query filter param) · **35 FE pages (+1)** · 111 test (unchanged UAT mode) · 47 gotcha · 21 memory · 6 skills · 4 sub-agents (3 spawn S24 t1). | `ee776d5` (A BE+Layout) · `c667802` (B FE page) · (this Docs C) |
| 2026-05-12 | Claude | **🎯 SESSION 21 turn 2 — RAG Hybrid setup planning + Cách A validation deep dive (2 commit `1f8e9af` plan save + this chốt)** — Sau S21 turn 1 chốt cicd-monitor, user clarify 5 dự án future > 1M MD tokens → cuộc thảo luận deep ~15 turn về RAG infrastructure. **Em main solo** (no SOLUTION_ERP sub-agent spawn), delegate **claude-code-guide × 2** spawn agent research Anthropic + community practice. **Q&A deep dive 10 topics**: (1) RAG fundamentals + Vector DB Qdrant role, (2) Embedding "AI nhúng" + Voyage AI cost mechanics ($0.18/M tokens), (3) Multi-project shared architecture (5 projects → single Qdrant + per-collection), (4) Audit procedure 3-tier (weekly auto + monthly deep + quarterly major), (5) UI/UX Streamlit dashboard 7 pages design (overview + drill-down + compare + audit + cost + change + admin), (6) Cách A defensive (giữ blanket 120K) vs Cách B aggressive (cắt 60-70%), (7) Reasoning depth comparison lazy 60% → A 90% → B 75-80%, (8) Industry validation Anthropic + Cursor + Continue + Cline + Aider all hybrid, (9) Multi-agent cost reality 8-10× multiplier ~520K cumulative blanket 5 entities, (10) 3-layer hybrid pattern Anthropic Contextual Retrieval Sept 2024. **Quyết định chốt Cách A** (defensive hybrid: giữ blanket 120K em main + RAG retrieve supplement, sub-agent spawn baseline ~100K each, 4 agents = ~400K cumulative, heavy session billed ~560K saving -20% vs lazy 700K, quality recall ~85%) over **Cách B bỏ** (aggressive cut 60-70% vi phạm priority em main control flow strong + reasoning fragmented + UX latency +1-2s/state Q + risk severe RAG fail). **Why Cách A** (bro priority chốt): em main control flow strong preserve, decision quality 90% multi-source cohesive, wall-clock -20% (12 phút vs 16), risk-averse graceful fallback, multi-agent leverage cache 70-90%, industry-validated 9 sources. **3-layer hybrid Phase rollout**: P1 (W1-4) vector only Voyage-3-large recall ~70% $1.50/mo · P2 (M2) +BM25 bm25s free recall ~78% $1.50/mo · P3 (M3) +Voyage rerank-2 + Contextual prefix recall ~92% $4-5/mo. **Stack validated** cross-industry: Voyage AI embedding (Anthropic partner, multilingual 26 lang, $0.36 initial), Qdrant local (Rust 50MB, agent-native 2026 leader, ~3GB disk 5 project), FastMCP Python (official SDK, ~100 LOC), SQLite event log (5 tables + audit history), Streamlit 7 pages. **Plan I NEW deferred** — trigger bro confirm 5 dự án path + stack + pilot + Voyage API key + disk cleanup → dedicated session 10-14h weekend (per `feedback_drastic_refactor_scope` rule). **Deliverables**: `docs/rag-setup-plan.md` 1223 LOC commit `1f8e9af` + extend S21 t2 ~300 LOC = ~1500 LOC final, memory `feedback_rag_hybrid_pattern.md` cross-project reusable, session log this chốt, MEMORY.md index +1 entry. **CI skipped** path filter (`.md`). **4 sub-agents vẫn seeds-only** (KHÔNG spawn S21 turn 2 nên KHÔNG flush MEMORY.md per §6.5 KHÔNG add noise). Tests baseline 81 unchanged. | `1f8e9af` (plan save) · this chốt (commit final) | | 2026-05-12 | Claude | **🎯 SESSION 21 turn 2 — RAG Hybrid setup planning + Cách A validation deep dive (2 commit `1f8e9af` plan save + this chốt)** — Sau S21 turn 1 chốt cicd-monitor, user clarify 5 dự án future > 1M MD tokens → cuộc thảo luận deep ~15 turn về RAG infrastructure. **Em main solo** (no SOLUTION_ERP sub-agent spawn), delegate **claude-code-guide × 2** spawn agent research Anthropic + community practice. **Q&A deep dive 10 topics**: (1) RAG fundamentals + Vector DB Qdrant role, (2) Embedding "AI nhúng" + Voyage AI cost mechanics ($0.18/M tokens), (3) Multi-project shared architecture (5 projects → single Qdrant + per-collection), (4) Audit procedure 3-tier (weekly auto + monthly deep + quarterly major), (5) UI/UX Streamlit dashboard 7 pages design (overview + drill-down + compare + audit + cost + change + admin), (6) Cách A defensive (giữ blanket 120K) vs Cách B aggressive (cắt 60-70%), (7) Reasoning depth comparison lazy 60% → A 90% → B 75-80%, (8) Industry validation Anthropic + Cursor + Continue + Cline + Aider all hybrid, (9) Multi-agent cost reality 8-10× multiplier ~520K cumulative blanket 5 entities, (10) 3-layer hybrid pattern Anthropic Contextual Retrieval Sept 2024. **Quyết định chốt Cách A** (defensive hybrid: giữ blanket 120K em main + RAG retrieve supplement, sub-agent spawn baseline ~100K each, 4 agents = ~400K cumulative, heavy session billed ~560K saving -20% vs lazy 700K, quality recall ~85%) over **Cách B bỏ** (aggressive cut 60-70% vi phạm priority em main control flow strong + reasoning fragmented + UX latency +1-2s/state Q + risk severe RAG fail). **Why Cách A** (bro priority chốt): em main control flow strong preserve, decision quality 90% multi-source cohesive, wall-clock -20% (12 phút vs 16), risk-averse graceful fallback, multi-agent leverage cache 70-90%, industry-validated 9 sources. **3-layer hybrid Phase rollout**: P1 (W1-4) vector only Voyage-3-large recall ~70% $1.50/mo · P2 (M2) +BM25 bm25s free recall ~78% $1.50/mo · P3 (M3) +Voyage rerank-2 + Contextual prefix recall ~92% $4-5/mo. **Stack validated** cross-industry: Voyage AI embedding (Anthropic partner, multilingual 26 lang, $0.36 initial), Qdrant local (Rust 50MB, agent-native 2026 leader, ~3GB disk 5 project), FastMCP Python (official SDK, ~100 LOC), SQLite event log (5 tables + audit history), Streamlit 7 pages. **Plan I NEW deferred** — trigger bro confirm 5 dự án path + stack + pilot + Voyage API key + disk cleanup → dedicated session 10-14h weekend (per `feedback_drastic_refactor_scope` rule). **Deliverables**: `docs/rag-setup-plan.md` 1223 LOC commit `1f8e9af` + extend S21 t2 ~300 LOC = ~1500 LOC final, memory `feedback_rag_hybrid_pattern.md` cross-project reusable, session log this chốt, MEMORY.md index +1 entry. **CI skipped** path filter (`.md`). **4 sub-agents vẫn seeds-only** (KHÔNG spawn S21 turn 2 nên KHÔNG flush MEMORY.md per §6.5 KHÔNG add noise). Tests baseline 81 unchanged. | `1f8e9af` (plan save) · this chốt (commit final) |
| 2026-05-12 | Claude | **🎯 SESSION 21 turn 1 — Add con thứ 4 cicd-monitor (Path A — post-deploy verifier green READ tier, 1 commit `f1c61c9`)** — User chốt Path A sau pre-flight Plan G Trial Week 1: thêm sub-agent thứ 4 chuyên post-deploy verify (Gitea Actions poll + bundle hash 2 app verify + sqlcmd mig prod = repo latest + endpoint smoke). Trade-off: +~150K spawn extra mỗi run, đổi lại catch deploy ship fail tự động — recurring blind spot pattern em main solo S20 quên verify ~30% push. **2 file mới**: `.claude/agents/cicd-monitor.md` (~7KB) — system prompt + 8-step workflow (verify push → poll Gitea API → fail log grep → live curl smoke → bundle hash × 2 app + verify changed → sqlcmd mig prod = repo latest → report PASS/FAIL/PARTIAL/TIMEOUT/SKIPPED-DOCS) + 5-stage report table + gotcha #25/#39/#40/#41/#44 cross-ref + skill `iis-deploy-runbook`/`dependency-audit-erp`/`ef-core-migration` preload + Anti-pattern 9 rules. `.claude/agent-memory/cicd-monitor/MEMORY.md` (~5KB seed) — recurring CI bug patterns + 5-stage checklist + baseline build/bundle metrics + bearer test pattern admin/nv.test. **1 file update repo**: `.claude/agents/README.md` — 4-agent architecture diagram (green slot mới) + decision tree (after push code + prod issue diagnose branches) + memory routine 4 SendMessage + skills preload 4 agents + cost reality table 564K → 750K spawn / 1.2M → 1.35M heavy / 600K → 700K optimized + trial workflow Week 1-3 CI/CD Monitor spawn integrated + pass criteria + catch ≥1 deploy ship fail. **Memory user-level update**: `feedback_multi_agent_setup.md` — title 3 → 4 sub-agents, decision tree +CI/CD Monitor invocation branches (after push + user prod issue), skills preload list +CI/CD Monitor (iis-deploy-runbook + dependency-audit-erp + ef-core-migration), cost table update + trade-off rationale (recurring blind spot ~30% push S20). **CI skipped**: all 3 file changed `.md` → match `paths-ignore: '**/*.md'` per gotcha #41 → no Gitea Actions run → no IIS deploy (expected — agent infra là local Claude Code, không cần present trên prod). Push success `36e21c8..f1c61c9 main -> main`. **3 (now 4) sub-agents vẫn seeds-only**: chưa spawn work nào — em main solo via context paste + Write file. KHÔNG flush 3 agent MEMORY.md (chưa spawn work = không findings, per §6.5 KHÔNG add noise entry). cicd-monitor MEMORY.md có entry "setup 2026-05-12" trong seed. Trial Week 1 kick-off ở Session 21 turn 2+ với Plan B Contract V2 wire Mig 28+29 candidate (mirror PE pattern S17-S19 proven 1×). Tests baseline 81 unchanged (no test added — docs-only commit). | `f1c61c9` (Setup cicd-monitor + README 4-agent + memory update) | | 2026-05-12 | Claude | **🎯 SESSION 21 turn 1 — Add con thứ 4 cicd-monitor (Path A — post-deploy verifier green READ tier, 1 commit `f1c61c9`)** — User chốt Path A sau pre-flight Plan G Trial Week 1: thêm sub-agent thứ 4 chuyên post-deploy verify (Gitea Actions poll + bundle hash 2 app verify + sqlcmd mig prod = repo latest + endpoint smoke). Trade-off: +~150K spawn extra mỗi run, đổi lại catch deploy ship fail tự động — recurring blind spot pattern em main solo S20 quên verify ~30% push. **2 file mới**: `.claude/agents/cicd-monitor.md` (~7KB) — system prompt + 8-step workflow (verify push → poll Gitea API → fail log grep → live curl smoke → bundle hash × 2 app + verify changed → sqlcmd mig prod = repo latest → report PASS/FAIL/PARTIAL/TIMEOUT/SKIPPED-DOCS) + 5-stage report table + gotcha #25/#39/#40/#41/#44 cross-ref + skill `iis-deploy-runbook`/`dependency-audit-erp`/`ef-core-migration` preload + Anti-pattern 9 rules. `.claude/agent-memory/cicd-monitor/MEMORY.md` (~5KB seed) — recurring CI bug patterns + 5-stage checklist + baseline build/bundle metrics + bearer test pattern admin/nv.test. **1 file update repo**: `.claude/agents/README.md` — 4-agent architecture diagram (green slot mới) + decision tree (after push code + prod issue diagnose branches) + memory routine 4 SendMessage + skills preload 4 agents + cost reality table 564K → 750K spawn / 1.2M → 1.35M heavy / 600K → 700K optimized + trial workflow Week 1-3 CI/CD Monitor spawn integrated + pass criteria + catch ≥1 deploy ship fail. **Memory user-level update**: `feedback_multi_agent_setup.md` — title 3 → 4 sub-agents, decision tree +CI/CD Monitor invocation branches (after push + user prod issue), skills preload list +CI/CD Monitor (iis-deploy-runbook + dependency-audit-erp + ef-core-migration), cost table update + trade-off rationale (recurring blind spot ~30% push S20). **CI skipped**: all 3 file changed `.md` → match `paths-ignore: '**/*.md'` per gotcha #41 → no Gitea Actions run → no IIS deploy (expected — agent infra là local Claude Code, không cần present trên prod). Push success `36e21c8..f1c61c9 main -> main`. **3 (now 4) sub-agents vẫn seeds-only**: chưa spawn work nào — em main solo via context paste + Write file. KHÔNG flush 3 agent MEMORY.md (chưa spawn work = không findings, per §6.5 KHÔNG add noise entry). cicd-monitor MEMORY.md có entry "setup 2026-05-12" trong seed. Trial Week 1 kick-off ở Session 21 turn 2+ với Plan B Contract V2 wire Mig 28+29 candidate (mirror PE pattern S17-S19 proven 1×). Tests baseline 81 unchanged (no test added — docs-only commit). | `f1c61c9` (Setup cicd-monitor + README 4-agent + memory update) |

View File

@ -235,3 +235,161 @@ import { WorkflowMatrixViewPage } from '@/pages/pe/WorkflowMatrixViewPage'
- Rules: §3.9 mirror 2 FE app, §6.5 KEEP narrative, §7 test timing - Rules: §3.9 mirror 2 FE app, §6.5 KEEP narrative, §7 test timing
- Cross-ref skill `permission-matrix` (menu structure) + `contract-workflow` (workflow V2) - Cross-ref skill `permission-matrix` (menu structure) + `contract-workflow` (workflow V2)
- Memory cross-ref `feedback_per_nv_permission_scope.md` (7 Allow* per-Level slot) + `feedback_uat_skip_verify.md` (Phase 9 test-after) - Memory cross-ref `feedback_per_nv_permission_scope.md` (7 Allow* per-Level slot) + `feedback_uat_skip_verify.md` (Phase 9 test-after)
---
## 🔁 Phase 2 — Polish iteration UAT feedback (4 commit post Plan AA core)
Sau Run #210 deploy Plan AA core (3 commit `ee776d5..ac2c859`), bro UAT iterate 4 polish chunks back-to-back theo visual feedback. Em main solo 4× CSS/UX polish (KHÔNG spawn agent — criteria #6 < 30 min trivial + criteria #2 UX decision).
### Polish 1 — Hotfix container px-2 (`da218f1`)
**Trigger:** Bro UAT: "cho dịch hết sang bên trái nhé"
Container `space-y-4 px-6 py-5` `space-y-4 px-2 py-5` (24px 8px). PageHeader + WorkflowCard + Table cùng shift left -16px sát sidebar border.
Verify: `npm run build` fe-user PASS 486ms, bundle 1282.59 KB unchanged.
### Polish 2 — Redesign v1 panel-per-NV color (`4d60598`)
**Trigger:** Bro UAT screenshot admin Designer: "cho hiển thị ràng các thông tin như thế này luôn. Giữa các cấp duyệt khác nhau cho màu sắc khác nhau, Giữa các phòng ban khác nhau cho màu sắc khác nhau."
Drop table 11 cột symbol khó hiểu (↶/✎/⏩) panel-per-NV mirror admin Designer line 853-949:
- Step (Phòng) container unique color cycle 5 màu (`STEP_PALETTE`: blue/purple/emerald/amber/pink)
- Cấp badge ring unique color cycle 5 màu (`LEVEL_PALETTE`: violet/sky/teal/orange/rose)
- "QUYỀN DUYỆT {NV name} {email}" header amber-700 uppercase
- 7 checkbox label tiếng Việt nguyên văn (read-only disabled + accent-emerald)
- Grid `grid-cols-1 sm:grid-cols-2` cho 4 return mode + col-span-2 cho 3 long label
**Tailwind JIT discipline:** Palette arrays với full class strings (KHÔNG dynamic interpolation `bg-${color}-100` JIT purge):
```ts
const STEP_PALETTE = [
{ bg: 'bg-blue-50/40', border: 'border-blue-200', headerBg: 'bg-blue-100', headerText: 'text-blue-800' },
// ... 4 more
] as const
```
Verify: `npm run build` fe-user PASS 423ms, bundle 1282.91 KB (+0.32 KB).
### Polish 3 — Redesign v2 HTML table rowSpan tận dụng full width (`fbbd361`)
**Trigger:** Bro UAT: "Đúng rồi hiển thị như vậy nhưng dạng table cho đẹp ràng, tận dụng hết toàn bộ layout rộng"
Refactor panel-per-NV HTML `<table>` 4 cột với rowSpan:
```
┌────────────────┬──────┬──────────────┬─────────────────────────────────────┐
│ Bước (Phòng) │ Cấp │ NV duyệt │ Quyền duyệt (grid 2-col 7 checkbox) │
├────────────────┴──────┴──────────────┴─────────────────────────────────────┤
│ Bước 1 (Phòng Cung ứng) - Step bg blue - rowSpan 5 │
│ ├ Cấp 1 - rowSpan 4 OR-of-4 ├ NV 1 ├ 7 checkbox │
│ ├ NV 2 ├ 7 checkbox │
│ ├ NV 3 ├ 7 checkbox │
│ ├ NV 4 ├ 7 checkbox │
│ ├ Cấp 2 - rowSpan 1 ├ NV 5 ├ 7 checkbox │
│ Bước 2 (Phòng Kiểm soát) - Step bg purple - rowSpan N │
│ ... │
└────────────────────────────────────────────────────────────────────────────┘
```
Helper `buildStepRows(step)` build flat `Row[]` với metadata: `(isFirstInStep, isFirstInCap, rowSpanStep, rowSpanCap)`. Render flat `<tr>` với conditional `<td rowSpan={}>`.
`colgroup` width hint: 160px / 100px / 240px / 1fr (rest). Tại 1280-1366px viewport: Quyền duyệt cell ~400-500px grid `md:grid-cols-2` fit 7 label OK.
Color preserved 2 layer (Step bg + Cấp badge cycle). NV + Quyền duyệt cell `bg-white/80` lighten Step tone.
Verify: `npm run build` fe-user PASS 522ms, bundle 1284.22 KB (+1.31 KB).
### Polish 4 — Wrap fix sidebar label về đầu hàng (`ee0902a`)
**Trigger:** Bro UAT screenshot sidebar: "1. Duyệt Nhà Cung Cấp - Thầu phụ" wrap 2 dòng với dòng 2 "(NCC -TP)" indent sau icon thay về đầu hàng. "Cho về đầu hàng nhé, thu nhỏ lại cũng đc."
**Root cause:** Flex container `items-center` + inner-flex `[icon][text]` 2nd line wraps within INNER SPAN (indent past icon area).
**Fix pattern (5 sites: 3 fe-user + 2 fe-admin mirror §3.9):**
- Restructure flex block + inline-block icon + inline text + absolute ChevronDown right
- `inline-block` icon + `inline` text share single line box wrap continuation text về left edge container
- ChevronDown absolute để KHÔNG bị đẩy xuống khi label wrap multi-line
```diff
- <span className="flex min-w-0 flex-1 items-center gap-2">
- <Icon className="h-4 w-4 shrink-0" />
- <span title={label}>{label}</span>
- </span>
- <ChevronDown className="h-3.5 w-3.5 shrink-0 ..." />
+ <Icon className="mr-1.5 -mt-0.5 inline-block h-4 w-4 align-middle" />
+ <span className="align-middle" title={label}>{label}</span>
+ <ChevronDown className="absolute right-2 top-2 ..." />
```
**Smaller text scale:**
- MenuGroup non-top button: `text-[13px]` `text-[12px] leading-snug`
- MenuLeaf top level: `text-sm` `text-[12px] leading-snug`
- MenuLeaf deep: `text-[12px]` `text-[11px] leading-snug`
- StaticLeaf: `text-sm` `text-[12px] leading-snug`
Verify: `npm run build` fe-user PASS 432ms + fe-admin PASS 494ms.
---
## 📊 Stats S24 chốt cuối cumulative
| Metric | S23 t12 chốt | S24 chốt | Δ |
|---|---|---|---|
| Migrations | 31 | 31 | 0 (Plan AA no Mig mới) |
| DB tables | 59 | 59 | 0 |
| Endpoints | ~145 | **~146** | +1 (GET filter param `isUserSelectable`) |
| FE pages | 34 | **35** | +1 (WorkflowMatrixViewPage) |
| Unit tests | 111 | 111 | 0 (UAT mode skip, baseline confirmed post-Plan AA) |
| Gotchas | 47 | 47 | 0 |
| Memory user-level | 21 | 21 | 0 (no new pattern captured trong agent MEMORY) |
| Skills | 6 | 6 | 0 |
| Sub-agents | 4 | 4 (4 spawn S24) | |
| **Commits S24** | | **7** | `ee776d5..ee0902a` push remote |
---
## 🎯 Multi-agent ROI S24 cumulative
| Owner | Cost | Verdict | Value catch |
|---|---|---|---|
| 🟦 Investigator Pre-A | ~32K | | 5Q audit + 3 surprises (PE 2-panel correction + Order shift strategy + Contract enum unwired). Saved em main 4 blind code assumptions. |
| 🟨 Implementer Chunk B | ~14K | | 3 files +305 LOC mirror Designer read-only. shadcn no Card/Badge fallback inline div pattern. |
| 🟥 Reviewer Chunk C | ~25K | | 0 blocker. Bonus catch fe-admin build verify mirror app PASS. |
| 🟩 CICD Monitor Run #210 | ~12K | | 4/4 wire verify + bundle rotate + Order shift idempotent confirm prod. |
| 🟦🟨🟥 3 agent S24 wrap flush | ~12K | | Cumulative MEMORY drift patches (Implementer +3 patterns 13/14/15, Reviewer +4 anti-patterns, Investigator +1 entry). |
| 👤 Chủ trì Solo Chunk A + 4 polish + coordinate | ~80K | | BE 4 file + Layout 2 file + 4 polish iteration UAT feedback ~250 LOC cumulative. |
**Total cost cumulative S24:** ~175K (~28% solo equiv). Cache leverage 70-90% per session.
---
## 📋 Patterns reinforced (cross-project reusable)
1. **Gotcha #44 relax class-level [Authorize] PROVEN cross-stack reuse** Workflows endpoint từ admin-only sang any-auth read accessible (cumulative S18 S24). Pattern reusable cho future user view của admin config.
2. **DbInitializer INSERT-OR-UPDATE-Order idempotent pattern** Shift existing prod rows Order qua re-deploy without migration. Add `existingItems = ToDictionaryAsync(m => m.Key)` + UPDATE if mismatch logic. Cross-project reusable cho menu re-order / label rename / icon change.
3. **Tailwind JIT palette array pattern** Full class strings (KHÔNG dynamic interpolation `bg-${color}-100`). `const PALETTE = [{bg: 'bg-blue-50/40', ...}, ...] as const` cycle theo `idx % length`. Cross-project reusable cho menu hierarchy color coding, status badge, category tone.
4. **HTML table rowSpan flat row builder helper** Build `Row[]` với metadata `(isFirstInStep + isFirstInCap + rowSpanStep + rowSpanCap)`. Cleaner than nested loop. Cross-project reusable cho hierarchical data table (org chart, BOM, schedule).
5. **Hanging-indent reverse CSS fix** Sidebar label dài wrap về đầu hàng (under icon) via `inline-block` icon + `inline` text + absolute right ChevronDown. Drop flex container wrapper. Cross-project reusable cho long-label nav menu / breadcrumb / list item.
6. **Read-only admin Designer mirror page** Implementer Case 2 pattern: drop edit mutations + reuse types + filter via query param. Cross-project reusable cho future user view của admin config (Role permission view, Workflow template view).
7. **UI/UX polish iteration discipline** UAT visual feedback iteration KHÔNG cần Reviewer spawn mỗi chunk (cost overhead ROI thấp). BUNDLE cumulative verify cho heavy chunk, SKIP < 30 min polish (criteria #6 + #2 REFUSE). S24 validated: ~25K bundle vs ~100K multi-spawn polish.
---
## ⏭ Pending S25+
- 🟢 Bro UAT verify Plan AA polish iteration cumulative qua 4 deploy Run #211-#214
- 🟡 **Plan B Contract V2 wire** (Mig 32+33) HIGH priority next (pre-allocated 5-6 chunk in HANDOFF S23)
- 📝 **Implementer agent MEMORY curate** ~31.5KB > 25KB threshold, archive S20-S22 old entries → `archive/2026-05-S20-S22.md`. Defer next session spawn.
- 📝 **CICD Monitor agent MEMORY curate** — ~43KB also over threshold, archive Run #186-#200 old entries.
- 🔍 Discovery #3 anomaly CI trigger docs-only (3× reinforced S23) — defer Investigator follow-up
- 🔍 Discovery #4 ASP.NET enum body deserialization (LOW polish)
- 🔧 Gotcha #47 paths-ignore agent-memory (pending bro chốt)
- ⚠️ Security follow-up Low note: BE enforce `isUserSelectable=true` mandatory non-admin (Reviewer Low note) — defer